babylon.d.ts 1.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562
  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<T>(sourceAssets, targetAssets, keepAssets);
  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(evt);
  1535. private _createUbo();
  1536. private _createAlternateUbo();
  1537. private _pickSpriteButKeepRay(originalPointerInfo, x, y, predicate?, fastCheck?, camera?);
  1538. private _setRayOnPointerInfo(pointerInfo);
  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(pickResult, evt);
  1548. private _checkPrePointerObservable(pickResult, evt, type);
  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(pickResult, evt);
  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(pickResult, evt, clickInfo);
  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(func);
  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(holder);
  1728. private _processLateAnimationBindingsForQuaternions(holder);
  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(subMesh, mesh);
  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(sourceMesh, mesh);
  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(camera, rigParent?);
  2219. private _processSubCameras(camera);
  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(rayFunction, predicate?, fastCheck?);
  2351. private _internalMultiPick(rayFunction, predicate?);
  2352. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  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(list, tagsQuery, forEach?);
  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: () => 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: () => 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 Vectpr2 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. * Gets the first frame
  4174. */
  4175. readonly from: number;
  4176. /**
  4177. * Gets the last frame
  4178. */
  4179. readonly to: number;
  4180. /**
  4181. * Define if the animations are started
  4182. */
  4183. readonly isStarted: boolean;
  4184. /**
  4185. * Gets or sets the speed ratio to use for all animations
  4186. */
  4187. /**
  4188. * Gets or sets the speed ratio to use for all animations
  4189. */
  4190. speedRatio: number;
  4191. /**
  4192. * Gets the targeted animations for this animation group
  4193. */
  4194. readonly targetedAnimations: Array<TargetedAnimation>;
  4195. /**
  4196. * returning the list of animatables controlled by this animation group.
  4197. */
  4198. readonly animatables: Array<Animatable>;
  4199. constructor(name: string, scene?: Nullable<Scene>);
  4200. /**
  4201. * Add an animation (with its target) in the group
  4202. * @param animation defines the animation we want to add
  4203. * @param target defines the target of the animation
  4204. * @returns the {BABYLON.TargetedAnimation} object
  4205. */
  4206. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4207. /**
  4208. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4209. * It can add constant keys at begin or end
  4210. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4211. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4212. */
  4213. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4214. /**
  4215. * Start all animations on given targets
  4216. * @param loop defines if animations must loop
  4217. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4218. * @param from defines the from key (optional)
  4219. * @param to defines the to key (optional)
  4220. * @returns the current animation group
  4221. */
  4222. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4223. /**
  4224. * Pause all animations
  4225. */
  4226. pause(): AnimationGroup;
  4227. /**
  4228. * Play all animations to initial state
  4229. * This function will start() the animations if they were not started or will restart() them if they were paused
  4230. * @param loop defines if animations must loop
  4231. */
  4232. play(loop?: boolean): AnimationGroup;
  4233. /**
  4234. * Reset all animations to initial state
  4235. */
  4236. reset(): AnimationGroup;
  4237. /**
  4238. * Restart animations from key 0
  4239. */
  4240. restart(): AnimationGroup;
  4241. /**
  4242. * Stop all animations
  4243. */
  4244. stop(): AnimationGroup;
  4245. /**
  4246. * Set animation weight for all animatables
  4247. * @param weight defines the weight to use
  4248. * @return the animationGroup
  4249. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4250. */
  4251. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4252. /**
  4253. * Synchronize and normalize all animatables with a source animatable
  4254. * @param root defines the root animatable to synchronize with
  4255. * @return the animationGroup
  4256. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4257. */
  4258. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4259. /**
  4260. * Goes to a specific frame in this animation group
  4261. * @param frame the frame number to go to
  4262. * @return the animationGroup
  4263. */
  4264. goToFrame(frame: number): AnimationGroup;
  4265. /**
  4266. * Dispose all associated resources
  4267. */
  4268. dispose(): void;
  4269. private _checkAnimationGroupEnded(animatable);
  4270. }
  4271. }
  4272. declare module BABYLON {
  4273. /**
  4274. * Class used to override all child animations of a given target
  4275. */
  4276. class AnimationPropertiesOverride {
  4277. /**
  4278. * Gets or sets a value indicating if animation blending must be used
  4279. */
  4280. enableBlending: boolean;
  4281. /**
  4282. * Gets or sets the blending speed to use when enableBlending is true
  4283. */
  4284. blendingSpeed: number;
  4285. /**
  4286. * Gets or sets the default loop mode to use
  4287. */
  4288. loopMode: number;
  4289. }
  4290. }
  4291. declare module BABYLON {
  4292. interface IEasingFunction {
  4293. ease(gradient: number): number;
  4294. }
  4295. class EasingFunction implements IEasingFunction {
  4296. private static _EASINGMODE_EASEIN;
  4297. private static _EASINGMODE_EASEOUT;
  4298. private static _EASINGMODE_EASEINOUT;
  4299. static readonly EASINGMODE_EASEIN: number;
  4300. static readonly EASINGMODE_EASEOUT: number;
  4301. static readonly EASINGMODE_EASEINOUT: number;
  4302. private _easingMode;
  4303. setEasingMode(easingMode: number): void;
  4304. getEasingMode(): number;
  4305. easeInCore(gradient: number): number;
  4306. ease(gradient: number): number;
  4307. }
  4308. class CircleEase extends EasingFunction implements IEasingFunction {
  4309. easeInCore(gradient: number): number;
  4310. }
  4311. class BackEase extends EasingFunction implements IEasingFunction {
  4312. amplitude: number;
  4313. constructor(amplitude?: number);
  4314. easeInCore(gradient: number): number;
  4315. }
  4316. class BounceEase extends EasingFunction implements IEasingFunction {
  4317. bounces: number;
  4318. bounciness: number;
  4319. constructor(bounces?: number, bounciness?: number);
  4320. easeInCore(gradient: number): number;
  4321. }
  4322. class CubicEase extends EasingFunction implements IEasingFunction {
  4323. easeInCore(gradient: number): number;
  4324. }
  4325. class ElasticEase extends EasingFunction implements IEasingFunction {
  4326. oscillations: number;
  4327. springiness: number;
  4328. constructor(oscillations?: number, springiness?: number);
  4329. easeInCore(gradient: number): number;
  4330. }
  4331. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4332. exponent: number;
  4333. constructor(exponent?: number);
  4334. easeInCore(gradient: number): number;
  4335. }
  4336. class PowerEase extends EasingFunction implements IEasingFunction {
  4337. power: number;
  4338. constructor(power?: number);
  4339. easeInCore(gradient: number): number;
  4340. }
  4341. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4342. easeInCore(gradient: number): number;
  4343. }
  4344. class QuarticEase extends EasingFunction implements IEasingFunction {
  4345. easeInCore(gradient: number): number;
  4346. }
  4347. class QuinticEase extends EasingFunction implements IEasingFunction {
  4348. easeInCore(gradient: number): number;
  4349. }
  4350. class SineEase extends EasingFunction implements IEasingFunction {
  4351. easeInCore(gradient: number): number;
  4352. }
  4353. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4354. x1: number;
  4355. y1: number;
  4356. x2: number;
  4357. y2: number;
  4358. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4359. easeInCore(gradient: number): number;
  4360. }
  4361. }
  4362. declare module BABYLON {
  4363. /**
  4364. * Defines a runtime animation
  4365. */
  4366. class RuntimeAnimation {
  4367. private _events;
  4368. /**
  4369. * The current frame of the runtime animation
  4370. */
  4371. private _currentFrame;
  4372. /**
  4373. * The animation used by the runtime animation
  4374. */
  4375. private _animation;
  4376. /**
  4377. * The target of the runtime animation
  4378. */
  4379. private _target;
  4380. /**
  4381. * The initiating animatable
  4382. */
  4383. private _host;
  4384. /**
  4385. * The original value of the runtime animation
  4386. */
  4387. private _originalValue;
  4388. /**
  4389. * The original blend value of the runtime animation
  4390. */
  4391. private _originalBlendValue;
  4392. /**
  4393. * The offsets cache of the runtime animation
  4394. */
  4395. private _offsetsCache;
  4396. /**
  4397. * The high limits cache of the runtime animation
  4398. */
  4399. private _highLimitsCache;
  4400. /**
  4401. * Specifies if the runtime animation has been stopped
  4402. */
  4403. private _stopped;
  4404. /**
  4405. * The blending factor of the runtime animation
  4406. */
  4407. private _blendingFactor;
  4408. /**
  4409. * The BabylonJS scene
  4410. */
  4411. private _scene;
  4412. /**
  4413. * The current value of the runtime animation
  4414. */
  4415. private _currentValue;
  4416. /** @hidden */
  4417. _workValue: any;
  4418. /**
  4419. * The active target of the runtime animation
  4420. */
  4421. private _activeTarget;
  4422. /**
  4423. * The target path of the runtime animation
  4424. */
  4425. private _targetPath;
  4426. /**
  4427. * The weight of the runtime animation
  4428. */
  4429. private _weight;
  4430. /**
  4431. * The ratio offset of the runtime animation
  4432. */
  4433. private _ratioOffset;
  4434. /**
  4435. * The previous delay of the runtime animation
  4436. */
  4437. private _previousDelay;
  4438. /**
  4439. * The previous ratio of the runtime animation
  4440. */
  4441. private _previousRatio;
  4442. /**
  4443. * Gets the current frame of the runtime animation
  4444. */
  4445. readonly currentFrame: number;
  4446. /**
  4447. * Gets the weight of the runtime animation
  4448. */
  4449. readonly weight: number;
  4450. /**
  4451. * Gets the current value of the runtime animation
  4452. */
  4453. readonly currentValue: any;
  4454. /**
  4455. * Gets the target path of the runtime animation
  4456. */
  4457. readonly targetPath: string;
  4458. /**
  4459. * Gets the actual target of the runtime animation
  4460. */
  4461. readonly target: any;
  4462. /**
  4463. * Create a new RuntimeAnimation object
  4464. * @param target defines the target of the animation
  4465. * @param animation defines the source animation object
  4466. * @param scene defines the hosting scene
  4467. * @param host defines the initiating Animatable
  4468. */
  4469. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4470. /**
  4471. * Gets the animation from the runtime animation
  4472. */
  4473. readonly animation: Animation;
  4474. /**
  4475. * Resets the runtime animation to the beginning
  4476. * @param restoreOriginal defines whether to restore the target property to the original value
  4477. */
  4478. reset(restoreOriginal?: boolean): void;
  4479. /**
  4480. * Specifies if the runtime animation is stopped
  4481. * @returns Boolean specifying if the runtime animation is stopped
  4482. */
  4483. isStopped(): boolean;
  4484. /**
  4485. * Disposes of the runtime animation
  4486. */
  4487. dispose(): void;
  4488. /**
  4489. * Interpolates the animation from the current frame
  4490. * @param currentFrame The frame to interpolate the animation to
  4491. * @param repeatCount The number of times that the animation should loop
  4492. * @param loopMode The type of looping mode to use
  4493. * @param offsetValue Animation offset value
  4494. * @param highLimitValue The high limit value
  4495. * @returns The interpolated value
  4496. */
  4497. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4498. /**
  4499. * Apply the interpolated value to the target
  4500. * @param currentValue defines the value computed by the animation
  4501. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4502. */
  4503. setValue(currentValue: any, weight?: number): void;
  4504. private _setValue(target, currentValue, weight, targetIndex?);
  4505. /**
  4506. * Gets the loop pmode of the runtime animation
  4507. * @returns Loop Mode
  4508. */
  4509. private _getCorrectLoopMode();
  4510. /**
  4511. * Move the current animation to a given frame
  4512. * @param frame defines the frame to move to
  4513. */
  4514. goToFrame(frame: number): void;
  4515. /**
  4516. * @hidden Internal use only
  4517. */
  4518. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4519. /**
  4520. * Execute the current animation
  4521. * @param delay defines the delay to add to the current frame
  4522. * @param from defines the lower bound of the animation range
  4523. * @param to defines the upper bound of the animation range
  4524. * @param loop defines if the current animation must loop
  4525. * @param speedRatio defines the current speed ratio
  4526. * @param weight defines the weight of the animation (default is -1 so no weight)
  4527. * @returns a boolean indicating if the animation is running
  4528. */
  4529. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4530. }
  4531. }
  4532. declare module BABYLON {
  4533. /**
  4534. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4535. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4536. */
  4537. class Analyser {
  4538. /**
  4539. * Gets or sets the smoothing
  4540. * @ignorenaming
  4541. */
  4542. SMOOTHING: number;
  4543. /**
  4544. * Gets or sets the FFT table size
  4545. * @ignorenaming
  4546. */
  4547. FFT_SIZE: number;
  4548. /**
  4549. * Gets or sets the bar graph amplitude
  4550. * @ignorenaming
  4551. */
  4552. BARGRAPHAMPLITUDE: number;
  4553. /**
  4554. * Gets or sets the position of the debug canvas
  4555. * @ignorenaming
  4556. */
  4557. DEBUGCANVASPOS: {
  4558. x: number;
  4559. y: number;
  4560. };
  4561. /**
  4562. * Gets or sets the debug canvas size
  4563. * @ignorenaming
  4564. */
  4565. DEBUGCANVASSIZE: {
  4566. width: number;
  4567. height: number;
  4568. };
  4569. private _byteFreqs;
  4570. private _byteTime;
  4571. private _floatFreqs;
  4572. private _webAudioAnalyser;
  4573. private _debugCanvas;
  4574. private _debugCanvasContext;
  4575. private _scene;
  4576. private _registerFunc;
  4577. private _audioEngine;
  4578. /**
  4579. * Creates a new analyser
  4580. * @param scene defines hosting scene
  4581. */
  4582. constructor(scene: Scene);
  4583. /**
  4584. * Get the number of data values you will have to play with for the visualization
  4585. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4586. * @returns a number
  4587. */
  4588. getFrequencyBinCount(): number;
  4589. /**
  4590. * Gets the current frequency data as a byte array
  4591. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4592. * @returns a Uint8Array
  4593. */
  4594. getByteFrequencyData(): Uint8Array;
  4595. /**
  4596. * Gets the current waveform as a byte array
  4597. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4598. * @returns a Uint8Array
  4599. */
  4600. getByteTimeDomainData(): Uint8Array;
  4601. /**
  4602. * Gets the current frequency data as a float array
  4603. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4604. * @returns a Float32Array
  4605. */
  4606. getFloatFrequencyData(): Float32Array;
  4607. /**
  4608. * Renders the debug canvas
  4609. */
  4610. drawDebugCanvas(): void;
  4611. /**
  4612. * Stops rendering the debug canvas and removes it
  4613. */
  4614. stopDebugCanvas(): void;
  4615. /**
  4616. * Connects two audio nodes
  4617. * @param inputAudioNode defines first node to connect
  4618. * @param outputAudioNode defines second node to connect
  4619. */
  4620. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4621. /**
  4622. * Releases all associated resources
  4623. */
  4624. dispose(): void;
  4625. }
  4626. }
  4627. declare module BABYLON {
  4628. class AudioEngine {
  4629. private _audioContext;
  4630. private _audioContextInitialized;
  4631. canUseWebAudio: boolean;
  4632. masterGain: GainNode;
  4633. private _connectedAnalyser;
  4634. WarnedWebAudioUnsupported: boolean;
  4635. unlocked: boolean;
  4636. onAudioUnlocked: () => any;
  4637. isMP3supported: boolean;
  4638. isOGGsupported: boolean;
  4639. readonly audioContext: Nullable<AudioContext>;
  4640. constructor();
  4641. private _unlockiOSaudio();
  4642. private _initializeAudioContext();
  4643. dispose(): void;
  4644. getGlobalVolume(): number;
  4645. setGlobalVolume(newVolume: number): void;
  4646. connectToAnalyser(analyser: Analyser): void;
  4647. }
  4648. }
  4649. declare module BABYLON {
  4650. class Sound {
  4651. name: string;
  4652. autoplay: boolean;
  4653. loop: boolean;
  4654. useCustomAttenuation: boolean;
  4655. soundTrackId: number;
  4656. spatialSound: boolean;
  4657. refDistance: number;
  4658. rolloffFactor: number;
  4659. maxDistance: number;
  4660. distanceModel: string;
  4661. private _panningModel;
  4662. onended: () => any;
  4663. private _playbackRate;
  4664. private _streaming;
  4665. private _startTime;
  4666. private _startOffset;
  4667. private _position;
  4668. private _localDirection;
  4669. private _volume;
  4670. private _isReadyToPlay;
  4671. isPlaying: boolean;
  4672. isPaused: boolean;
  4673. private _isDirectional;
  4674. private _readyToPlayCallback;
  4675. private _audioBuffer;
  4676. private _soundSource;
  4677. private _streamingSource;
  4678. private _soundPanner;
  4679. private _soundGain;
  4680. private _inputAudioNode;
  4681. private _ouputAudioNode;
  4682. private _coneInnerAngle;
  4683. private _coneOuterAngle;
  4684. private _coneOuterGain;
  4685. private _scene;
  4686. private _connectedMesh;
  4687. private _customAttenuationFunction;
  4688. private _registerFunc;
  4689. private _isOutputConnected;
  4690. private _htmlAudioElement;
  4691. private _urlType;
  4692. /**
  4693. * Create a sound and attach it to a scene
  4694. * @param name Name of your sound
  4695. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4696. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4697. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4698. */
  4699. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4700. dispose(): void;
  4701. isReady(): boolean;
  4702. private _soundLoaded(audioData);
  4703. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4704. updateOptions(options: any): void;
  4705. private _createSpatialParameters();
  4706. private _updateSpatialParameters();
  4707. switchPanningModelToHRTF(): void;
  4708. switchPanningModelToEqualPower(): void;
  4709. private _switchPanningModel();
  4710. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4711. /**
  4712. * Transform this sound into a directional source
  4713. * @param coneInnerAngle Size of the inner cone in degree
  4714. * @param coneOuterAngle Size of the outer cone in degree
  4715. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4716. */
  4717. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4718. setPosition(newPosition: Vector3): void;
  4719. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4720. private _updateDirection();
  4721. updateDistanceFromListener(): void;
  4722. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4723. /**
  4724. * Play the sound
  4725. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4726. * @param offset (optional) Start the sound setting it at a specific time
  4727. */
  4728. play(time?: number, offset?: number): void;
  4729. private _onended();
  4730. /**
  4731. * Stop the sound
  4732. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4733. */
  4734. stop(time?: number): void;
  4735. pause(): void;
  4736. setVolume(newVolume: number, time?: number): void;
  4737. setPlaybackRate(newPlaybackRate: number): void;
  4738. getVolume(): number;
  4739. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4740. detachFromMesh(): void;
  4741. private _onRegisterAfterWorldMatrixUpdate(node);
  4742. clone(): Nullable<Sound>;
  4743. getAudioBuffer(): AudioBuffer | null;
  4744. serialize(): any;
  4745. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4746. }
  4747. }
  4748. declare module BABYLON {
  4749. class SoundTrack {
  4750. private _outputAudioNode;
  4751. private _scene;
  4752. id: number;
  4753. soundCollection: Array<Sound>;
  4754. private _isMainTrack;
  4755. private _connectedAnalyser;
  4756. private _options;
  4757. private _isInitialized;
  4758. constructor(scene: Scene, options?: any);
  4759. private _initializeSoundTrackAudioGraph();
  4760. dispose(): void;
  4761. AddSound(sound: Sound): void;
  4762. RemoveSound(sound: Sound): void;
  4763. setVolume(newVolume: number): void;
  4764. switchPanningModelToHRTF(): void;
  4765. switchPanningModelToEqualPower(): void;
  4766. connectToAnalyser(analyser: Analyser): void;
  4767. }
  4768. }
  4769. declare module BABYLON {
  4770. /**
  4771. * Interface used to define a behavior
  4772. */
  4773. interface Behavior<T> {
  4774. /** gets or sets behavior's name */
  4775. name: string;
  4776. /**
  4777. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4778. */
  4779. init(): void;
  4780. /**
  4781. * Called when the behavior is attached to a target
  4782. * @param target defines the target where the behavior is attached to
  4783. */
  4784. attach(target: T): void;
  4785. /**
  4786. * Called when the behavior is detached from its target
  4787. */
  4788. detach(): void;
  4789. }
  4790. /**
  4791. * Interface implemented by classes supporting behaviors
  4792. */
  4793. interface IBehaviorAware<T> {
  4794. /**
  4795. * Attach a behavior
  4796. * @param behavior defines the behavior to attach
  4797. * @returns the current host
  4798. */
  4799. addBehavior(behavior: Behavior<T>): T;
  4800. /**
  4801. * Remove a behavior from the current object
  4802. * @param behavior defines the behavior to detach
  4803. * @returns the current host
  4804. */
  4805. removeBehavior(behavior: Behavior<T>): T;
  4806. /**
  4807. * Gets a behavior using its name to search
  4808. * @param name defines the name to search
  4809. * @returns the behavior or null if not found
  4810. */
  4811. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4812. }
  4813. }
  4814. declare module BABYLON {
  4815. /**
  4816. * Class used to store bone information
  4817. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4818. */
  4819. class Bone extends Node {
  4820. /**
  4821. * defines the bone name
  4822. */
  4823. name: string;
  4824. private static _tmpVecs;
  4825. private static _tmpQuat;
  4826. private static _tmpMats;
  4827. /**
  4828. * Gets the list of child bones
  4829. */
  4830. children: Bone[];
  4831. /** Gets the animations associated with this bone */
  4832. animations: Animation[];
  4833. /**
  4834. * Gets or sets bone length
  4835. */
  4836. length: number;
  4837. /**
  4838. * @hidden Internal only
  4839. * Set this value to map this bone to a different index in the transform matrices
  4840. * Set this value to -1 to exclude the bone from the transform matrices
  4841. */
  4842. _index: Nullable<number>;
  4843. private _skeleton;
  4844. private _localMatrix;
  4845. private _restPose;
  4846. private _baseMatrix;
  4847. private _absoluteTransform;
  4848. private _invertedAbsoluteTransform;
  4849. private _parent;
  4850. private _scalingDeterminant;
  4851. private _worldTransform;
  4852. private _localScaling;
  4853. private _localRotation;
  4854. private _localPosition;
  4855. private _needToDecompose;
  4856. private _needToCompose;
  4857. /** @hidden */
  4858. /** @hidden */
  4859. _matrix: Matrix;
  4860. /**
  4861. * Create a new bone
  4862. * @param name defines the bone name
  4863. * @param skeleton defines the parent skeleton
  4864. * @param parentBone defines the parent (can be null if the bone is the root)
  4865. * @param localMatrix defines the local matrix
  4866. * @param restPose defines the rest pose matrix
  4867. * @param baseMatrix defines the base matrix
  4868. * @param index defines index of the bone in the hiearchy
  4869. */
  4870. constructor(
  4871. /**
  4872. * defines the bone name
  4873. */
  4874. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4875. /**
  4876. * Gets the parent skeleton
  4877. * @returns a skeleton
  4878. */
  4879. getSkeleton(): Skeleton;
  4880. /**
  4881. * Gets parent bone
  4882. * @returns a bone or null if the bone is the root of the bone hierarchy
  4883. */
  4884. getParent(): Nullable<Bone>;
  4885. /**
  4886. * Sets the parent bone
  4887. * @param parent defines the parent (can be null if the bone is the root)
  4888. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4889. */
  4890. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4891. /**
  4892. * Gets the local matrix
  4893. * @returns a matrix
  4894. */
  4895. getLocalMatrix(): Matrix;
  4896. /**
  4897. * Gets the base matrix (initial matrix which remains unchanged)
  4898. * @returns a matrix
  4899. */
  4900. getBaseMatrix(): Matrix;
  4901. /**
  4902. * Gets the rest pose matrix
  4903. * @returns a matrix
  4904. */
  4905. getRestPose(): Matrix;
  4906. /**
  4907. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4908. */
  4909. getWorldMatrix(): Matrix;
  4910. /**
  4911. * Sets the local matrix to rest pose matrix
  4912. */
  4913. returnToRest(): void;
  4914. /**
  4915. * Gets the inverse of the absolute transform matrix.
  4916. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4917. * @returns a matrix
  4918. */
  4919. getInvertedAbsoluteTransform(): Matrix;
  4920. /**
  4921. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4922. * @returns a matrix
  4923. */
  4924. getAbsoluteTransform(): Matrix;
  4925. /** Gets or sets current position (in local space) */
  4926. position: Vector3;
  4927. /** Gets or sets current rotation (in local space) */
  4928. rotation: Vector3;
  4929. /** Gets or sets current rotation quaternion (in local space) */
  4930. rotationQuaternion: Quaternion;
  4931. /** Gets or sets current scaling (in local space) */
  4932. scaling: Vector3;
  4933. /**
  4934. * Gets the animation properties override
  4935. */
  4936. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4937. private _decompose();
  4938. private _compose();
  4939. /**
  4940. * Update the base and local matrices
  4941. * @param matrix defines the new base or local matrix
  4942. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4943. * @param updateLocalMatrix defines if the local matrix should be updated
  4944. */
  4945. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4946. /** @hidden */
  4947. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  4948. /**
  4949. * Flag the bone as dirty (Forcing it to update everything)
  4950. */
  4951. markAsDirty(): void;
  4952. private _markAsDirtyAndCompose();
  4953. private _markAsDirtyAndDecompose();
  4954. /**
  4955. * Copy an animation range from another bone
  4956. * @param source defines the source bone
  4957. * @param rangeName defines the range name to copy
  4958. * @param frameOffset defines the frame offset
  4959. * @param rescaleAsRequired defines if rescaling must be applied if required
  4960. * @param skelDimensionsRatio defines the scaling ratio
  4961. * @returns true if operation was successful
  4962. */
  4963. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4964. /**
  4965. * Translate the bone in local or world space
  4966. * @param vec The amount to translate the bone
  4967. * @param space The space that the translation is in
  4968. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4969. */
  4970. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4971. /**
  4972. * Set the postion of the bone in local or world space
  4973. * @param position The position to set the bone
  4974. * @param space The space that the position is in
  4975. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4976. */
  4977. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4978. /**
  4979. * Set the absolute position of the bone (world space)
  4980. * @param position The position to set the bone
  4981. * @param mesh The mesh that this bone is attached to
  4982. */
  4983. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4984. /**
  4985. * Scale the bone on the x, y and z axes (in local space)
  4986. * @param x The amount to scale the bone on the x axis
  4987. * @param y The amount to scale the bone on the y axis
  4988. * @param z The amount to scale the bone on the z axis
  4989. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4990. */
  4991. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4992. /**
  4993. * Set the bone scaling in local space
  4994. * @param scale defines the scaling vector
  4995. */
  4996. setScale(scale: Vector3): void;
  4997. /**
  4998. * Gets the current scaling in local space
  4999. * @returns the current scaling vector
  5000. */
  5001. getScale(): Vector3;
  5002. /**
  5003. * Gets the current scaling in local space and stores it in a target vector
  5004. * @param result defines the target vector
  5005. */
  5006. getScaleToRef(result: Vector3): void;
  5007. /**
  5008. * Set the yaw, pitch, and roll of the bone in local or world space
  5009. * @param yaw The rotation of the bone on the y axis
  5010. * @param pitch The rotation of the bone on the x axis
  5011. * @param roll The rotation of the bone on the z axis
  5012. * @param space The space that the axes of rotation are in
  5013. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5014. */
  5015. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  5016. /**
  5017. * Add a rotation to the bone on an axis in local or world space
  5018. * @param axis The axis to rotate the bone on
  5019. * @param amount The amount to rotate the bone
  5020. * @param space The space that the axis is in
  5021. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5022. */
  5023. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  5024. /**
  5025. * Set the rotation of the bone to a particular axis angle in local or world space
  5026. * @param axis The axis to rotate the bone on
  5027. * @param angle The angle that the bone should be rotated to
  5028. * @param space The space that the axis is in
  5029. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5030. */
  5031. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  5032. /**
  5033. * Set the euler rotation of the bone in local of world space
  5034. * @param rotation The euler rotation that the bone should be set to
  5035. * @param space The space that the rotation is in
  5036. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5037. */
  5038. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5039. /**
  5040. * Set the quaternion rotation of the bone in local of world space
  5041. * @param quat The quaternion rotation that the bone should be set to
  5042. * @param space The space that the rotation is in
  5043. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5044. */
  5045. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  5046. /**
  5047. * Set the rotation matrix of the bone in local of world space
  5048. * @param rotMat The rotation matrix that the bone should be set to
  5049. * @param space The space that the rotation is in
  5050. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5051. */
  5052. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  5053. private _rotateWithMatrix(rmat, space?, mesh?);
  5054. private _getNegativeRotationToRef(rotMatInv, mesh?);
  5055. /**
  5056. * Get the position of the bone in local or world space
  5057. * @param space The space that the returned position is in
  5058. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5059. * @returns The position of the bone
  5060. */
  5061. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5062. /**
  5063. * Copy the position of the bone to a vector3 in local or world space
  5064. * @param space The space that the returned position is in
  5065. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5066. * @param result The vector3 to copy the position to
  5067. */
  5068. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  5069. /**
  5070. * Get the absolute position of the bone (world space)
  5071. * @param mesh The mesh that this bone is attached to
  5072. * @returns The absolute position of the bone
  5073. */
  5074. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  5075. /**
  5076. * Copy the absolute position of the bone (world space) to the result param
  5077. * @param mesh The mesh that this bone is attached to
  5078. * @param result The vector3 to copy the absolute position to
  5079. */
  5080. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  5081. /**
  5082. * Compute the absolute transforms of this bone and its children
  5083. */
  5084. computeAbsoluteTransforms(): void;
  5085. /**
  5086. * Get the world direction from an axis that is in the local space of the bone
  5087. * @param localAxis The local direction that is used to compute the world direction
  5088. * @param mesh The mesh that this bone is attached to
  5089. * @returns The world direction
  5090. */
  5091. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5092. /**
  5093. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  5094. * @param localAxis The local direction that is used to compute the world direction
  5095. * @param mesh The mesh that this bone is attached to
  5096. * @param result The vector3 that the world direction will be copied to
  5097. */
  5098. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5099. /**
  5100. * Get the euler rotation of the bone in local or world space
  5101. * @param space The space that the rotation should be in
  5102. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5103. * @returns The euler rotation
  5104. */
  5105. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  5106. /**
  5107. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  5108. * @param space The space that the rotation should be in
  5109. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5110. * @param result The vector3 that the rotation should be copied to
  5111. */
  5112. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5113. /**
  5114. * Get the quaternion rotation of the bone in either local or world space
  5115. * @param space The space that the rotation should be in
  5116. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5117. * @returns The quaternion rotation
  5118. */
  5119. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  5120. /**
  5121. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  5122. * @param space The space that the rotation should be in
  5123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5124. * @param result The quaternion that the rotation should be copied to
  5125. */
  5126. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  5127. /**
  5128. * Get the rotation matrix of the bone in local or world space
  5129. * @param space The space that the rotation should be in
  5130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5131. * @returns The rotation matrix
  5132. */
  5133. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  5134. /**
  5135. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  5136. * @param space The space that the rotation should be in
  5137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5138. * @param result The quaternion that the rotation should be copied to
  5139. */
  5140. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  5141. /**
  5142. * Get the world position of a point that is in the local space of the bone
  5143. * @param position The local position
  5144. * @param mesh The mesh that this bone is attached to
  5145. * @returns The world position
  5146. */
  5147. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5148. /**
  5149. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  5150. * @param position The local position
  5151. * @param mesh The mesh that this bone is attached to
  5152. * @param result The vector3 that the world position should be copied to
  5153. */
  5154. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5155. /**
  5156. * Get the local position of a point that is in world space
  5157. * @param position The world position
  5158. * @param mesh The mesh that this bone is attached to
  5159. * @returns The local position
  5160. */
  5161. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5162. /**
  5163. * Get the local position of a point that is in world space and copy it to the result param
  5164. * @param position The world position
  5165. * @param mesh The mesh that this bone is attached to
  5166. * @param result The vector3 that the local position should be copied to
  5167. */
  5168. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5169. }
  5170. }
  5171. declare module BABYLON {
  5172. /**
  5173. * Class used to apply inverse kinematics to bones
  5174. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5175. */
  5176. class BoneIKController {
  5177. private static _tmpVecs;
  5178. private static _tmpQuat;
  5179. private static _tmpMats;
  5180. /**
  5181. * Gets or sets the target mesh
  5182. */
  5183. targetMesh: AbstractMesh;
  5184. /** Gets or sets the mesh used as pole */
  5185. poleTargetMesh: AbstractMesh;
  5186. /**
  5187. * Gets or sets the bone used as pole
  5188. */
  5189. poleTargetBone: Nullable<Bone>;
  5190. /**
  5191. * Gets or sets the target position
  5192. */
  5193. targetPosition: Vector3;
  5194. /**
  5195. * Gets or sets the pole target position
  5196. */
  5197. poleTargetPosition: Vector3;
  5198. /**
  5199. * Gets or sets the pole target local offset
  5200. */
  5201. poleTargetLocalOffset: Vector3;
  5202. /**
  5203. * Gets or sets the pole angle
  5204. */
  5205. poleAngle: number;
  5206. /**
  5207. * Gets or sets the mesh associated with the controller
  5208. */
  5209. mesh: AbstractMesh;
  5210. /**
  5211. * 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)
  5212. */
  5213. slerpAmount: number;
  5214. private _bone1Quat;
  5215. private _bone1Mat;
  5216. private _bone2Ang;
  5217. private _bone1;
  5218. private _bone2;
  5219. private _bone1Length;
  5220. private _bone2Length;
  5221. private _maxAngle;
  5222. private _maxReach;
  5223. private _rightHandedSystem;
  5224. private _bendAxis;
  5225. private _slerping;
  5226. private _adjustRoll;
  5227. /**
  5228. * Gets or sets maximum allowed angle
  5229. */
  5230. maxAngle: number;
  5231. /**
  5232. * Creates a new BoneIKController
  5233. * @param mesh defines the mesh to control
  5234. * @param bone defines the bone to control
  5235. * @param options defines options to set up the controller
  5236. */
  5237. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5238. targetMesh?: AbstractMesh;
  5239. poleTargetMesh?: AbstractMesh;
  5240. poleTargetBone?: Bone;
  5241. poleTargetLocalOffset?: Vector3;
  5242. poleAngle?: number;
  5243. bendAxis?: Vector3;
  5244. maxAngle?: number;
  5245. slerpAmount?: number;
  5246. });
  5247. private _setMaxAngle(ang);
  5248. /**
  5249. * Force the controller to update the bones
  5250. */
  5251. update(): void;
  5252. }
  5253. }
  5254. declare module BABYLON {
  5255. /**
  5256. * Class used to make a bone look toward a point in space
  5257. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5258. */
  5259. class BoneLookController {
  5260. private static _tmpVecs;
  5261. private static _tmpQuat;
  5262. private static _tmpMats;
  5263. /**
  5264. * The target Vector3 that the bone will look at
  5265. */
  5266. target: Vector3;
  5267. /**
  5268. * The mesh that the bone is attached to
  5269. */
  5270. mesh: AbstractMesh;
  5271. /**
  5272. * The bone that will be looking to the target
  5273. */
  5274. bone: Bone;
  5275. /**
  5276. * The up axis of the coordinate system that is used when the bone is rotated
  5277. */
  5278. upAxis: Vector3;
  5279. /**
  5280. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5281. */
  5282. upAxisSpace: Space;
  5283. /**
  5284. * Used to make an adjustment to the yaw of the bone
  5285. */
  5286. adjustYaw: number;
  5287. /**
  5288. * Used to make an adjustment to the pitch of the bone
  5289. */
  5290. adjustPitch: number;
  5291. /**
  5292. * Used to make an adjustment to the roll of the bone
  5293. */
  5294. adjustRoll: number;
  5295. /**
  5296. * 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)
  5297. */
  5298. slerpAmount: number;
  5299. private _minYaw;
  5300. private _maxYaw;
  5301. private _minPitch;
  5302. private _maxPitch;
  5303. private _minYawSin;
  5304. private _minYawCos;
  5305. private _maxYawSin;
  5306. private _maxYawCos;
  5307. private _midYawConstraint;
  5308. private _minPitchTan;
  5309. private _maxPitchTan;
  5310. private _boneQuat;
  5311. private _slerping;
  5312. private _transformYawPitch;
  5313. private _transformYawPitchInv;
  5314. private _firstFrameSkipped;
  5315. private _yawRange;
  5316. private _fowardAxis;
  5317. /**
  5318. * Gets or sets the minimum yaw angle that the bone can look to
  5319. */
  5320. minYaw: number;
  5321. /**
  5322. * Gets or sets the maximum yaw angle that the bone can look to
  5323. */
  5324. maxYaw: number;
  5325. /**
  5326. * Gets or sets the minimum pitch angle that the bone can look to
  5327. */
  5328. minPitch: number;
  5329. /**
  5330. * Gets or sets the maximum pitch angle that the bone can look to
  5331. */
  5332. maxPitch: number;
  5333. /**
  5334. * Create a BoneLookController
  5335. * @param mesh the mesh that the bone belongs to
  5336. * @param bone the bone that will be looking to the target
  5337. * @param target the target Vector3 to look at
  5338. * @param settings optional settings:
  5339. * * maxYaw: the maximum angle the bone will yaw to
  5340. * * minYaw: the minimum angle the bone will yaw to
  5341. * * maxPitch: the maximum angle the bone will pitch to
  5342. * * minPitch: the minimum angle the bone will yaw to
  5343. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5344. * * upAxis: the up axis of the coordinate system
  5345. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5346. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5347. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5348. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5349. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5350. * * adjustRoll: used to make an adjustment to the roll of the bone
  5351. **/
  5352. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5353. maxYaw?: number;
  5354. minYaw?: number;
  5355. maxPitch?: number;
  5356. minPitch?: number;
  5357. slerpAmount?: number;
  5358. upAxis?: Vector3;
  5359. upAxisSpace?: Space;
  5360. yawAxis?: Vector3;
  5361. pitchAxis?: Vector3;
  5362. adjustYaw?: number;
  5363. adjustPitch?: number;
  5364. adjustRoll?: number;
  5365. });
  5366. /**
  5367. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5368. */
  5369. update(): void;
  5370. private _getAngleDiff(ang1, ang2);
  5371. private _getAngleBetween(ang1, ang2);
  5372. private _isAngleBetween(ang, ang1, ang2);
  5373. }
  5374. }
  5375. declare module BABYLON {
  5376. /**
  5377. * Class used to handle skinning animations
  5378. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5379. */
  5380. class Skeleton implements IAnimatable {
  5381. /** defines the skeleton name */
  5382. name: string;
  5383. /** defines the skeleton Id */
  5384. id: string;
  5385. /**
  5386. * Gets the list of child bones
  5387. */
  5388. bones: Bone[];
  5389. /**
  5390. * Gets an estimate of the dimension of the skeleton at rest
  5391. */
  5392. dimensionsAtRest: Vector3;
  5393. /**
  5394. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5395. */
  5396. needInitialSkinMatrix: boolean;
  5397. /**
  5398. * Gets the list of animations attached to this skeleton
  5399. */
  5400. animations: Array<Animation>;
  5401. private _scene;
  5402. private _isDirty;
  5403. private _transformMatrices;
  5404. private _meshesWithPoseMatrix;
  5405. private _animatables;
  5406. private _identity;
  5407. private _synchronizedWithMesh;
  5408. private _ranges;
  5409. private _lastAbsoluteTransformsUpdateId;
  5410. /**
  5411. * Specifies if the skeleton should be serialized
  5412. */
  5413. doNotSerialize: boolean;
  5414. private _animationPropertiesOverride;
  5415. /**
  5416. * Gets or sets the animation properties override
  5417. */
  5418. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5419. /**
  5420. * An observable triggered before computing the skeleton's matrices
  5421. */
  5422. onBeforeComputeObservable: Observable<Skeleton>;
  5423. /**
  5424. * Creates a new skeleton
  5425. * @param name defines the skeleton name
  5426. * @param id defines the skeleton Id
  5427. * @param scene defines the hosting scene
  5428. */
  5429. constructor(
  5430. /** defines the skeleton name */
  5431. name: string,
  5432. /** defines the skeleton Id */
  5433. id: string, scene: Scene);
  5434. /**
  5435. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5436. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5437. * @returns a Float32Array containing matrices data
  5438. */
  5439. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5440. /**
  5441. * Gets the current hosting scene
  5442. * @returns a scene object
  5443. */
  5444. getScene(): Scene;
  5445. /**
  5446. * Gets a string representing the current skeleton data
  5447. * @param fullDetails defines a boolean indicating if we want a verbose version
  5448. * @returns a string representing the current skeleton data
  5449. */
  5450. toString(fullDetails?: boolean): string;
  5451. /**
  5452. * Get bone's index searching by name
  5453. * @param name defines bone's name to search for
  5454. * @return the indice of the bone. Returns -1 if not found
  5455. */
  5456. getBoneIndexByName(name: string): number;
  5457. /**
  5458. * Creater a new animation range
  5459. * @param name defines the name of the range
  5460. * @param from defines the start key
  5461. * @param to defines the end key
  5462. */
  5463. createAnimationRange(name: string, from: number, to: number): void;
  5464. /**
  5465. * Delete a specific animation range
  5466. * @param name defines the name of the range
  5467. * @param deleteFrames defines if frames must be removed as well
  5468. */
  5469. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5470. /**
  5471. * Gets a specific animation range
  5472. * @param name defines the name of the range to look for
  5473. * @returns the requested animation range or null if not found
  5474. */
  5475. getAnimationRange(name: string): Nullable<AnimationRange>;
  5476. /**
  5477. * Gets the list of all animation ranges defined on this skeleton
  5478. * @returns an array
  5479. */
  5480. getAnimationRanges(): Nullable<AnimationRange>[];
  5481. /**
  5482. * Copy animation range from a source skeleton.
  5483. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5484. * @param source defines the source skeleton
  5485. * @param name defines the name of the range to copy
  5486. * @param rescaleAsRequired defines if rescaling must be applied if required
  5487. * @returns true if operation was successful
  5488. */
  5489. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5490. /**
  5491. * Forces the skeleton to go to rest pose
  5492. */
  5493. returnToRest(): void;
  5494. private _getHighestAnimationFrame();
  5495. /**
  5496. * Begin a specific animation range
  5497. * @param name defines the name of the range to start
  5498. * @param loop defines if looping must be turned on (false by default)
  5499. * @param speedRatio defines the speed ratio to apply (1 by default)
  5500. * @param onAnimationEnd defines a callback which will be called when animation will end
  5501. * @returns a new animatable
  5502. */
  5503. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5504. /** @hidden */
  5505. _markAsDirty(): void;
  5506. /** @hidden */
  5507. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5508. /** @hidden */
  5509. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5510. /** @hidden */
  5511. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5512. /**
  5513. * Build all resources required to render a skeleton
  5514. */
  5515. prepare(): void;
  5516. /**
  5517. * Gets the list of animatables currently running for this skeleton
  5518. * @returns an array of animatables
  5519. */
  5520. getAnimatables(): IAnimatable[];
  5521. /**
  5522. * Clone the current skeleton
  5523. * @param name defines the name of the new skeleton
  5524. * @param id defines the id of the enw skeleton
  5525. * @returns the new skeleton
  5526. */
  5527. clone(name: string, id: string): Skeleton;
  5528. /**
  5529. * Enable animation blending for this skeleton
  5530. * @param blendingSpeed defines the blending speed to apply
  5531. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5532. */
  5533. enableBlending(blendingSpeed?: number): void;
  5534. /**
  5535. * Releases all resources associated with the current skeleton
  5536. */
  5537. dispose(): void;
  5538. /**
  5539. * Serialize the skeleton in a JSON object
  5540. * @returns a JSON object
  5541. */
  5542. serialize(): any;
  5543. /**
  5544. * Creates a new skeleton from serialized data
  5545. * @param parsedSkeleton defines the serialized data
  5546. * @param scene defines the hosting scene
  5547. * @returns a new skeleton
  5548. */
  5549. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5550. /**
  5551. * Compute all node absolute transforms
  5552. * @param forceUpdate defines if computation must be done even if cache is up to date
  5553. */
  5554. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5555. /**
  5556. * Gets the root pose matrix
  5557. * @returns a matrix
  5558. */
  5559. getPoseMatrix(): Nullable<Matrix>;
  5560. /**
  5561. * Sorts bones per internal index
  5562. */
  5563. sortBones(): void;
  5564. private _sortBones(index, bones, visited);
  5565. }
  5566. }
  5567. declare module BABYLON {
  5568. class BoundingBox implements ICullable {
  5569. vectors: Vector3[];
  5570. center: Vector3;
  5571. centerWorld: Vector3;
  5572. extendSize: Vector3;
  5573. extendSizeWorld: Vector3;
  5574. directions: Vector3[];
  5575. vectorsWorld: Vector3[];
  5576. minimumWorld: Vector3;
  5577. maximumWorld: Vector3;
  5578. minimum: Vector3;
  5579. maximum: Vector3;
  5580. private _worldMatrix;
  5581. /**
  5582. * Creates a new bounding box
  5583. * @param min defines the minimum vector (in local space)
  5584. * @param max defines the maximum vector (in local space)
  5585. */
  5586. constructor(min: Vector3, max: Vector3);
  5587. /**
  5588. * Recreates the entire bounding box from scratch
  5589. * @param min defines the new minimum vector (in local space)
  5590. * @param max defines the new maximum vector (in local space)
  5591. */
  5592. reConstruct(min: Vector3, max: Vector3): void;
  5593. /**
  5594. * Scale the current bounding box by applying a scale factor
  5595. * @param factor defines the scale factor to apply
  5596. * @returns the current bounding box
  5597. */
  5598. scale(factor: number): BoundingBox;
  5599. getWorldMatrix(): Matrix;
  5600. setWorldMatrix(matrix: Matrix): BoundingBox;
  5601. _update(world: Matrix): void;
  5602. isInFrustum(frustumPlanes: Plane[]): boolean;
  5603. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5604. intersectsPoint(point: Vector3): boolean;
  5605. intersectsSphere(sphere: BoundingSphere): boolean;
  5606. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  5607. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  5608. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  5609. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5610. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5611. }
  5612. }
  5613. declare module BABYLON {
  5614. interface ICullable {
  5615. isInFrustum(frustumPlanes: Plane[]): boolean;
  5616. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5617. }
  5618. class BoundingInfo implements ICullable {
  5619. minimum: Vector3;
  5620. maximum: Vector3;
  5621. boundingBox: BoundingBox;
  5622. boundingSphere: BoundingSphere;
  5623. private _isLocked;
  5624. constructor(minimum: Vector3, maximum: Vector3);
  5625. isLocked: boolean;
  5626. update(world: Matrix): void;
  5627. /**
  5628. * Recreate the bounding info to be centered around a specific point given a specific extend.
  5629. * @param center New center of the bounding info
  5630. * @param extend New extend of the bounding info
  5631. */
  5632. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  5633. /**
  5634. * Scale the current bounding info by applying a scale factor
  5635. * @param factor defines the scale factor to apply
  5636. * @returns the current bounding info
  5637. */
  5638. scale(factor: number): BoundingInfo;
  5639. isInFrustum(frustumPlanes: Plane[]): boolean;
  5640. /**
  5641. * Gets the world distance between the min and max points of the bounding box
  5642. */
  5643. readonly diagonalLength: number;
  5644. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5645. _checkCollision(collider: Collider): boolean;
  5646. intersectsPoint(point: Vector3): boolean;
  5647. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  5648. }
  5649. }
  5650. declare module BABYLON {
  5651. class BoundingSphere {
  5652. center: Vector3;
  5653. radius: number;
  5654. centerWorld: Vector3;
  5655. radiusWorld: number;
  5656. minimum: Vector3;
  5657. maximum: Vector3;
  5658. private _tempRadiusVector;
  5659. /**
  5660. * Creates a new bounding sphere
  5661. * @param min defines the minimum vector (in local space)
  5662. * @param max defines the maximum vector (in local space)
  5663. */
  5664. constructor(min: Vector3, max: Vector3);
  5665. /**
  5666. * Recreates the entire bounding sphere from scratch
  5667. * @param min defines the new minimum vector (in local space)
  5668. * @param max defines the new maximum vector (in local space)
  5669. */
  5670. reConstruct(min: Vector3, max: Vector3): void;
  5671. /**
  5672. * Scale the current bounding sphere by applying a scale factor
  5673. * @param factor defines the scale factor to apply
  5674. * @returns the current bounding box
  5675. */
  5676. scale(factor: number): BoundingSphere;
  5677. _update(world: Matrix): void;
  5678. isInFrustum(frustumPlanes: Plane[]): boolean;
  5679. intersectsPoint(point: Vector3): boolean;
  5680. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  5681. }
  5682. }
  5683. declare module BABYLON {
  5684. class Ray {
  5685. origin: Vector3;
  5686. direction: Vector3;
  5687. length: number;
  5688. private _edge1;
  5689. private _edge2;
  5690. private _pvec;
  5691. private _tvec;
  5692. private _qvec;
  5693. private _tmpRay;
  5694. constructor(origin: Vector3, direction: Vector3, length?: number);
  5695. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  5696. intersectsBox(box: BoundingBox): boolean;
  5697. intersectsSphere(sphere: BoundingSphere): boolean;
  5698. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  5699. intersectsPlane(plane: Plane): Nullable<number>;
  5700. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  5701. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  5702. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  5703. private static smallnum;
  5704. private static rayl;
  5705. /**
  5706. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  5707. * @param sega the first point of the segment to test the intersection against
  5708. * @param segb the second point of the segment to test the intersection against
  5709. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  5710. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  5711. */
  5712. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  5713. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5714. static Zero(): Ray;
  5715. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5716. /**
  5717. * 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
  5718. * transformed to the given world matrix.
  5719. * @param origin The origin point
  5720. * @param end The end point
  5721. * @param world a matrix to transform the ray to. Default is the identity matrix.
  5722. */
  5723. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  5724. static Transform(ray: Ray, matrix: Matrix): Ray;
  5725. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  5726. }
  5727. }
  5728. declare module BABYLON {
  5729. class ArcRotateCamera extends TargetCamera {
  5730. alpha: number;
  5731. beta: number;
  5732. radius: number;
  5733. protected _target: Vector3;
  5734. protected _targetHost: Nullable<AbstractMesh>;
  5735. target: Vector3;
  5736. inertialAlphaOffset: number;
  5737. inertialBetaOffset: number;
  5738. inertialRadiusOffset: number;
  5739. lowerAlphaLimit: Nullable<number>;
  5740. upperAlphaLimit: Nullable<number>;
  5741. lowerBetaLimit: number;
  5742. upperBetaLimit: number;
  5743. lowerRadiusLimit: Nullable<number>;
  5744. upperRadiusLimit: Nullable<number>;
  5745. inertialPanningX: number;
  5746. inertialPanningY: number;
  5747. pinchToPanMaxDistance: number;
  5748. panningDistanceLimit: Nullable<number>;
  5749. panningOriginTarget: Vector3;
  5750. panningInertia: number;
  5751. angularSensibilityX: number;
  5752. angularSensibilityY: number;
  5753. pinchPrecision: number;
  5754. pinchDeltaPercentage: number;
  5755. panningSensibility: number;
  5756. keysUp: number[];
  5757. keysDown: number[];
  5758. keysLeft: number[];
  5759. keysRight: number[];
  5760. wheelPrecision: number;
  5761. wheelDeltaPercentage: number;
  5762. zoomOnFactor: number;
  5763. targetScreenOffset: Vector2;
  5764. allowUpsideDown: boolean;
  5765. _viewMatrix: Matrix;
  5766. _useCtrlForPanning: boolean;
  5767. _panningMouseButton: number;
  5768. inputs: ArcRotateCameraInputsManager;
  5769. _reset: () => void;
  5770. panningAxis: Vector3;
  5771. protected _localDirection: Vector3;
  5772. protected _transformedDirection: Vector3;
  5773. private _bouncingBehavior;
  5774. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5775. useBouncingBehavior: boolean;
  5776. private _framingBehavior;
  5777. readonly framingBehavior: Nullable<FramingBehavior>;
  5778. useFramingBehavior: boolean;
  5779. private _autoRotationBehavior;
  5780. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5781. useAutoRotationBehavior: boolean;
  5782. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5783. onCollide: (collidedMesh: AbstractMesh) => void;
  5784. checkCollisions: boolean;
  5785. collisionRadius: Vector3;
  5786. protected _collider: Collider;
  5787. protected _previousPosition: Vector3;
  5788. protected _collisionVelocity: Vector3;
  5789. protected _newPosition: Vector3;
  5790. protected _previousAlpha: number;
  5791. protected _previousBeta: number;
  5792. protected _previousRadius: number;
  5793. protected _collisionTriggered: boolean;
  5794. protected _targetBoundingCenter: Nullable<Vector3>;
  5795. private _computationVector;
  5796. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5797. _initCache(): void;
  5798. _updateCache(ignoreParentClass?: boolean): void;
  5799. protected _getTargetPosition(): Vector3;
  5800. /**
  5801. * Store current camera state (fov, position, etc..)
  5802. */
  5803. private _storedAlpha;
  5804. private _storedBeta;
  5805. private _storedRadius;
  5806. private _storedTarget;
  5807. storeState(): Camera;
  5808. /**
  5809. * Restored camera state. You must call storeState() first
  5810. */
  5811. _restoreStateValues(): boolean;
  5812. _isSynchronizedViewMatrix(): boolean;
  5813. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5814. detachControl(element: HTMLElement): void;
  5815. _checkInputs(): void;
  5816. protected _checkLimits(): void;
  5817. rebuildAnglesAndRadius(): void;
  5818. setPosition(position: Vector3): void;
  5819. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5820. _getViewMatrix(): Matrix;
  5821. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5822. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5823. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5824. min: Vector3;
  5825. max: Vector3;
  5826. distance: number;
  5827. }, doNotUpdateMaxZ?: boolean): void;
  5828. /**
  5829. * @override
  5830. * Override Camera.createRigCamera
  5831. */
  5832. createRigCamera(name: string, cameraIndex: number): Camera;
  5833. /**
  5834. * @override
  5835. * Override Camera._updateRigCameras
  5836. */
  5837. _updateRigCameras(): void;
  5838. dispose(): void;
  5839. getClassName(): string;
  5840. }
  5841. }
  5842. declare module BABYLON {
  5843. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5844. constructor(camera: ArcRotateCamera);
  5845. addMouseWheel(): ArcRotateCameraInputsManager;
  5846. addPointers(): ArcRotateCameraInputsManager;
  5847. addKeyboard(): ArcRotateCameraInputsManager;
  5848. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5849. }
  5850. }
  5851. declare module BABYLON {
  5852. class Camera extends Node {
  5853. inputs: CameraInputsManager<Camera>;
  5854. private static _PERSPECTIVE_CAMERA;
  5855. private static _ORTHOGRAPHIC_CAMERA;
  5856. private static _FOVMODE_VERTICAL_FIXED;
  5857. private static _FOVMODE_HORIZONTAL_FIXED;
  5858. private static _RIG_MODE_NONE;
  5859. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5860. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5861. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5862. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5863. private static _RIG_MODE_VR;
  5864. private static _RIG_MODE_WEBVR;
  5865. static readonly PERSPECTIVE_CAMERA: number;
  5866. static readonly ORTHOGRAPHIC_CAMERA: number;
  5867. /**
  5868. * This is the default FOV mode for perspective cameras.
  5869. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5870. *
  5871. */
  5872. static readonly FOVMODE_VERTICAL_FIXED: number;
  5873. /**
  5874. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5875. *
  5876. */
  5877. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5878. static readonly RIG_MODE_NONE: number;
  5879. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5880. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5881. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5882. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5883. static readonly RIG_MODE_VR: number;
  5884. static readonly RIG_MODE_WEBVR: number;
  5885. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5886. static UseAlternateWebVRRendering: boolean;
  5887. position: Vector3;
  5888. /**
  5889. * The vector the camera should consider as up.
  5890. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5891. */
  5892. upVector: Vector3;
  5893. orthoLeft: Nullable<number>;
  5894. orthoRight: Nullable<number>;
  5895. orthoBottom: Nullable<number>;
  5896. orthoTop: Nullable<number>;
  5897. /**
  5898. * FOV is set in Radians. (default is 0.8)
  5899. */
  5900. fov: number;
  5901. minZ: number;
  5902. maxZ: number;
  5903. inertia: number;
  5904. mode: number;
  5905. isIntermediate: boolean;
  5906. viewport: Viewport;
  5907. /**
  5908. * Restricts the camera to viewing objects with the same layerMask.
  5909. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5910. */
  5911. layerMask: number;
  5912. /**
  5913. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5914. */
  5915. fovMode: number;
  5916. cameraRigMode: number;
  5917. interaxialDistance: number;
  5918. isStereoscopicSideBySide: boolean;
  5919. _cameraRigParams: any;
  5920. _rigCameras: Camera[];
  5921. _rigPostProcess: Nullable<PostProcess>;
  5922. protected _webvrViewMatrix: Matrix;
  5923. _skipRendering: boolean;
  5924. _alternateCamera: Camera;
  5925. customRenderTargets: RenderTargetTexture[];
  5926. onViewMatrixChangedObservable: Observable<Camera>;
  5927. onProjectionMatrixChangedObservable: Observable<Camera>;
  5928. onAfterCheckInputsObservable: Observable<Camera>;
  5929. onRestoreStateObservable: Observable<Camera>;
  5930. private _computedViewMatrix;
  5931. _projectionMatrix: Matrix;
  5932. private _doNotComputeProjectionMatrix;
  5933. private _worldMatrix;
  5934. _postProcesses: Nullable<PostProcess>[];
  5935. private _transformMatrix;
  5936. _activeMeshes: SmartArray<AbstractMesh>;
  5937. protected _globalPosition: Vector3;
  5938. private _frustumPlanes;
  5939. private _refreshFrustumPlanes;
  5940. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5941. private _storedFov;
  5942. private _stateStored;
  5943. /**
  5944. * Store current camera state (fov, position, etc..)
  5945. */
  5946. storeState(): Camera;
  5947. /**
  5948. * Restores the camera state values if it has been stored. You must call storeState() first
  5949. */
  5950. protected _restoreStateValues(): boolean;
  5951. /**
  5952. * Restored camera state. You must call storeState() first
  5953. */
  5954. restoreState(): boolean;
  5955. getClassName(): string;
  5956. /**
  5957. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5958. */
  5959. toString(fullDetails?: boolean): string;
  5960. readonly globalPosition: Vector3;
  5961. getActiveMeshes(): SmartArray<AbstractMesh>;
  5962. isActiveMesh(mesh: Mesh): boolean;
  5963. /**
  5964. * Is this camera ready to be used/rendered
  5965. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  5966. * @return true if the camera is ready
  5967. */
  5968. isReady(completeCheck?: boolean): boolean;
  5969. _initCache(): void;
  5970. _updateCache(ignoreParentClass?: boolean): void;
  5971. _isSynchronized(): boolean;
  5972. _isSynchronizedViewMatrix(): boolean;
  5973. _isSynchronizedProjectionMatrix(): boolean;
  5974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5975. detachControl(element: HTMLElement): void;
  5976. update(): void;
  5977. _checkInputs(): void;
  5978. readonly rigCameras: Camera[];
  5979. readonly rigPostProcess: Nullable<PostProcess>;
  5980. /**
  5981. * Internal, gets the first post proces.
  5982. * @returns the first post process to be run on this camera.
  5983. */
  5984. _getFirstPostProcess(): Nullable<PostProcess>;
  5985. private _cascadePostProcessesToRigCams();
  5986. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  5987. detachPostProcess(postProcess: PostProcess): void;
  5988. getWorldMatrix(): Matrix;
  5989. _getViewMatrix(): Matrix;
  5990. getViewMatrix(force?: boolean): Matrix;
  5991. freezeProjectionMatrix(projection?: Matrix): void;
  5992. unfreezeProjectionMatrix(): void;
  5993. getProjectionMatrix(force?: boolean): Matrix;
  5994. /**
  5995. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  5996. * @returns a Matrix
  5997. */
  5998. getTransformationMatrix(): Matrix;
  5999. private updateFrustumPlanes();
  6000. isInFrustum(target: ICullable): boolean;
  6001. isCompletelyInFrustum(target: ICullable): boolean;
  6002. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  6003. /**
  6004. * Releases resources associated with this node.
  6005. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  6006. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  6007. */
  6008. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  6009. readonly leftCamera: Nullable<FreeCamera>;
  6010. readonly rightCamera: Nullable<FreeCamera>;
  6011. getLeftTarget(): Nullable<Vector3>;
  6012. getRightTarget(): Nullable<Vector3>;
  6013. setCameraRigMode(mode: number, rigParams: any): void;
  6014. private _getVRProjectionMatrix();
  6015. protected _updateCameraRotationMatrix(): void;
  6016. protected _updateWebVRCameraRotationMatrix(): void;
  6017. /**
  6018. * This function MUST be overwritten by the different WebVR cameras available.
  6019. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6020. */
  6021. protected _getWebVRProjectionMatrix(): Matrix;
  6022. /**
  6023. * This function MUST be overwritten by the different WebVR cameras available.
  6024. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6025. */
  6026. protected _getWebVRViewMatrix(): Matrix;
  6027. setCameraRigParameter(name: string, value: any): void;
  6028. /**
  6029. * needs to be overridden by children so sub has required properties to be copied
  6030. */
  6031. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6032. /**
  6033. * May need to be overridden by children
  6034. */
  6035. _updateRigCameras(): void;
  6036. _setupInputs(): void;
  6037. serialize(): any;
  6038. clone(name: string): Camera;
  6039. getDirection(localAxis: Vector3): Vector3;
  6040. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  6041. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  6042. computeWorldMatrix(): Matrix;
  6043. static Parse(parsedCamera: any, scene: Scene): Camera;
  6044. }
  6045. }
  6046. declare module BABYLON {
  6047. var CameraInputTypes: {};
  6048. interface ICameraInput<TCamera extends Camera> {
  6049. camera: Nullable<TCamera>;
  6050. getClassName(): string;
  6051. getSimpleName(): string;
  6052. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  6053. detachControl: (element: Nullable<HTMLElement>) => void;
  6054. checkInputs?: () => void;
  6055. }
  6056. interface CameraInputsMap<TCamera extends Camera> {
  6057. [name: string]: ICameraInput<TCamera>;
  6058. [idx: number]: ICameraInput<TCamera>;
  6059. }
  6060. class CameraInputsManager<TCamera extends Camera> {
  6061. attached: CameraInputsMap<TCamera>;
  6062. attachedElement: Nullable<HTMLElement>;
  6063. noPreventDefault: boolean;
  6064. camera: TCamera;
  6065. checkInputs: () => void;
  6066. constructor(camera: TCamera);
  6067. /**
  6068. * Add an input method to a camera
  6069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6070. * @param input camera input method
  6071. */
  6072. add(input: ICameraInput<TCamera>): void;
  6073. /**
  6074. * Remove a specific input method from a camera
  6075. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6076. * @param inputToRemove camera input method
  6077. */
  6078. remove(inputToRemove: ICameraInput<TCamera>): void;
  6079. removeByType(inputType: string): void;
  6080. private _addCheckInputs(fn);
  6081. attachInput(input: ICameraInput<TCamera>): void;
  6082. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6083. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6084. rebuildInputCheck(): void;
  6085. /**
  6086. * Remove all attached input methods from a camera
  6087. */
  6088. clear(): void;
  6089. serialize(serializedCamera: any): void;
  6090. parse(parsedCamera: any): void;
  6091. }
  6092. }
  6093. declare module BABYLON {
  6094. /**
  6095. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  6096. * being tilted forward or back and left or right.
  6097. */
  6098. class DeviceOrientationCamera extends FreeCamera {
  6099. private _initialQuaternion;
  6100. private _quaternionCache;
  6101. /**
  6102. * Creates a new device orientation camera
  6103. * @param name The name of the camera
  6104. * @param position The start position camera
  6105. * @param scene The scene the camera belongs to
  6106. */
  6107. constructor(name: string, position: Vector3, scene: Scene);
  6108. /**
  6109. * Gets the current instance class name ("DeviceOrientationCamera").
  6110. * This helps avoiding instanceof at run time.
  6111. * @returns the class name
  6112. */
  6113. getClassName(): string;
  6114. /**
  6115. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6116. */
  6117. _checkInputs(): void;
  6118. /**
  6119. * Reset the camera to its default orientation on the specified axis only.
  6120. * @param axis The axis to reset
  6121. */
  6122. resetToCurrentRotation(axis?: Axis): void;
  6123. }
  6124. }
  6125. declare module BABYLON {
  6126. class FollowCamera extends TargetCamera {
  6127. radius: number;
  6128. rotationOffset: number;
  6129. heightOffset: number;
  6130. cameraAcceleration: number;
  6131. maxCameraSpeed: number;
  6132. lockedTarget: Nullable<AbstractMesh>;
  6133. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6134. private getRadians(degrees);
  6135. private follow(cameraTarget);
  6136. _checkInputs(): void;
  6137. getClassName(): string;
  6138. }
  6139. class ArcFollowCamera extends TargetCamera {
  6140. alpha: number;
  6141. beta: number;
  6142. radius: number;
  6143. target: Nullable<AbstractMesh>;
  6144. private _cartesianCoordinates;
  6145. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6146. private follow();
  6147. _checkInputs(): void;
  6148. getClassName(): string;
  6149. }
  6150. }
  6151. declare module BABYLON {
  6152. class FreeCamera extends TargetCamera {
  6153. ellipsoid: Vector3;
  6154. ellipsoidOffset: Vector3;
  6155. checkCollisions: boolean;
  6156. applyGravity: boolean;
  6157. inputs: FreeCameraInputsManager;
  6158. /**
  6159. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6160. * Higher values reduce sensitivity.
  6161. */
  6162. /**
  6163. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6164. * Higher values reduce sensitivity.
  6165. */
  6166. angularSensibility: number;
  6167. keysUp: number[];
  6168. keysDown: number[];
  6169. keysLeft: number[];
  6170. keysRight: number[];
  6171. onCollide: (collidedMesh: AbstractMesh) => void;
  6172. private _collider;
  6173. private _needMoveForGravity;
  6174. private _oldPosition;
  6175. private _diffPosition;
  6176. private _newPosition;
  6177. _localDirection: Vector3;
  6178. _transformedDirection: Vector3;
  6179. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6181. detachControl(element: HTMLElement): void;
  6182. private _collisionMask;
  6183. collisionMask: number;
  6184. _collideWithWorld(displacement: Vector3): void;
  6185. private _onCollisionPositionChange;
  6186. _checkInputs(): void;
  6187. _decideIfNeedsToMove(): boolean;
  6188. _updatePosition(): void;
  6189. dispose(): void;
  6190. getClassName(): string;
  6191. }
  6192. }
  6193. declare module BABYLON {
  6194. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6195. constructor(camera: FreeCamera);
  6196. addKeyboard(): FreeCameraInputsManager;
  6197. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6198. addDeviceOrientation(): FreeCameraInputsManager;
  6199. addTouch(): FreeCameraInputsManager;
  6200. addVirtualJoystick(): FreeCameraInputsManager;
  6201. }
  6202. }
  6203. declare module BABYLON {
  6204. class GamepadCamera extends UniversalCamera {
  6205. gamepadAngularSensibility: number;
  6206. gamepadMoveSensibility: number;
  6207. constructor(name: string, position: Vector3, scene: Scene);
  6208. getClassName(): string;
  6209. }
  6210. }
  6211. declare module BABYLON {
  6212. class TargetCamera extends Camera {
  6213. cameraDirection: Vector3;
  6214. cameraRotation: Vector2;
  6215. rotation: Vector3;
  6216. rotationQuaternion: Quaternion;
  6217. speed: number;
  6218. noRotationConstraint: boolean;
  6219. lockedTarget: any;
  6220. _currentTarget: Vector3;
  6221. _viewMatrix: Matrix;
  6222. _camMatrix: Matrix;
  6223. _cameraTransformMatrix: Matrix;
  6224. _cameraRotationMatrix: Matrix;
  6225. private _rigCamTransformMatrix;
  6226. _referencePoint: Vector3;
  6227. private _currentUpVector;
  6228. _transformedReferencePoint: Vector3;
  6229. protected _globalCurrentTarget: Vector3;
  6230. protected _globalCurrentUpVector: Vector3;
  6231. _reset: () => void;
  6232. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6233. getFrontPosition(distance: number): Vector3;
  6234. _getLockedTargetPosition(): Nullable<Vector3>;
  6235. /**
  6236. * Store current camera state (fov, position, etc..)
  6237. */
  6238. private _storedPosition;
  6239. private _storedRotation;
  6240. private _storedRotationQuaternion;
  6241. storeState(): Camera;
  6242. /**
  6243. * Restored camera state. You must call storeState() first
  6244. */
  6245. _restoreStateValues(): boolean;
  6246. _initCache(): void;
  6247. _updateCache(ignoreParentClass?: boolean): void;
  6248. _isSynchronizedViewMatrix(): boolean;
  6249. _computeLocalCameraSpeed(): number;
  6250. setTarget(target: Vector3): void;
  6251. /**
  6252. * Return the current target position of the camera. This value is expressed in local space.
  6253. */
  6254. getTarget(): Vector3;
  6255. _decideIfNeedsToMove(): boolean;
  6256. _updatePosition(): void;
  6257. _checkInputs(): void;
  6258. protected _updateCameraRotationMatrix(): void;
  6259. _getViewMatrix(): Matrix;
  6260. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6261. /**
  6262. * @override
  6263. * Override Camera.createRigCamera
  6264. */
  6265. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6266. /**
  6267. * @override
  6268. * Override Camera._updateRigCameras
  6269. */
  6270. _updateRigCameras(): void;
  6271. private _getRigCamPosition(halfSpace, result);
  6272. getClassName(): string;
  6273. }
  6274. }
  6275. declare module BABYLON {
  6276. class TouchCamera extends FreeCamera {
  6277. touchAngularSensibility: number;
  6278. touchMoveSensibility: number;
  6279. constructor(name: string, position: Vector3, scene: Scene);
  6280. getClassName(): string;
  6281. _setupInputs(): void;
  6282. }
  6283. }
  6284. declare module BABYLON {
  6285. class UniversalCamera extends TouchCamera {
  6286. gamepadAngularSensibility: number;
  6287. gamepadMoveSensibility: number;
  6288. constructor(name: string, position: Vector3, scene: Scene);
  6289. getClassName(): string;
  6290. }
  6291. }
  6292. declare module BABYLON {
  6293. class VirtualJoysticksCamera extends FreeCamera {
  6294. constructor(name: string, position: Vector3, scene: Scene);
  6295. getClassName(): string;
  6296. }
  6297. }
  6298. interface VRDisplay extends EventTarget {
  6299. /**
  6300. * Dictionary of capabilities describing the VRDisplay.
  6301. */
  6302. readonly capabilities: VRDisplayCapabilities;
  6303. /**
  6304. * z-depth defining the far plane of the eye view frustum
  6305. * enables mapping of values in the render target depth
  6306. * attachment to scene coordinates. Initially set to 10000.0.
  6307. */
  6308. depthFar: number;
  6309. /**
  6310. * z-depth defining the near plane of the eye view frustum
  6311. * enables mapping of values in the render target depth
  6312. * attachment to scene coordinates. Initially set to 0.01.
  6313. */
  6314. depthNear: number;
  6315. /**
  6316. * An identifier for this distinct VRDisplay. Used as an
  6317. * association point in the Gamepad API.
  6318. */
  6319. readonly displayId: number;
  6320. /**
  6321. * A display name, a user-readable name identifying it.
  6322. */
  6323. readonly displayName: string;
  6324. readonly isConnected: boolean;
  6325. readonly isPresenting: boolean;
  6326. /**
  6327. * If this VRDisplay supports room-scale experiences, the optional
  6328. * stage attribute contains details on the room-scale parameters.
  6329. */
  6330. readonly stageParameters: VRStageParameters | null;
  6331. /**
  6332. * Passing the value returned by `requestAnimationFrame` to
  6333. * `cancelAnimationFrame` will unregister the callback.
  6334. */
  6335. cancelAnimationFrame(handle: number): void;
  6336. /**
  6337. * Stops presenting to the VRDisplay.
  6338. */
  6339. exitPresent(): Promise<void>;
  6340. getEyeParameters(whichEye: string): VREyeParameters;
  6341. /**
  6342. * Populates the passed VRFrameData with the information required to render
  6343. * the current frame.
  6344. */
  6345. getFrameData(frameData: VRFrameData): boolean;
  6346. /**
  6347. * Get the layers currently being presented.
  6348. */
  6349. getLayers(): VRLayer[];
  6350. /**
  6351. * Return a VRPose containing the future predicted pose of the VRDisplay
  6352. * when the current frame will be presented. The value returned will not
  6353. * change until JavaScript has returned control to the browser.
  6354. *
  6355. * The VRPose will contain the position, orientation, velocity,
  6356. * and acceleration of each of these properties.
  6357. */
  6358. getPose(): VRPose;
  6359. /**
  6360. * Return the current instantaneous pose of the VRDisplay, with no
  6361. * prediction applied.
  6362. */
  6363. getImmediatePose(): VRPose;
  6364. /**
  6365. * The callback passed to `requestAnimationFrame` will be called
  6366. * any time a new frame should be rendered. When the VRDisplay is
  6367. * presenting the callback will be called at the native refresh
  6368. * rate of the HMD. When not presenting this function acts
  6369. * identically to how window.requestAnimationFrame acts. Content should
  6370. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6371. * asynchronously from other displays and at differing refresh rates.
  6372. */
  6373. requestAnimationFrame(callback: FrameRequestCallback): number;
  6374. /**
  6375. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6376. * Repeat calls while already presenting will update the VRLayers being displayed.
  6377. */
  6378. requestPresent(layers: VRLayer[]): Promise<void>;
  6379. /**
  6380. * Reset the pose for this display, treating its current position and
  6381. * orientation as the "origin/zero" values. VRPose.position,
  6382. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6383. * updated when calling resetPose(). This should be called in only
  6384. * sitting-space experiences.
  6385. */
  6386. resetPose(): void;
  6387. /**
  6388. * The VRLayer provided to the VRDisplay will be captured and presented
  6389. * in the HMD. Calling this function has the same effect on the source
  6390. * canvas as any other operation that uses its source image, and canvases
  6391. * created without preserveDrawingBuffer set to true will be cleared.
  6392. */
  6393. submitFrame(pose?: VRPose): void;
  6394. }
  6395. declare var VRDisplay: {
  6396. prototype: VRDisplay;
  6397. new (): VRDisplay;
  6398. };
  6399. interface VRLayer {
  6400. leftBounds?: number[] | null;
  6401. rightBounds?: number[] | null;
  6402. source?: HTMLCanvasElement | null;
  6403. }
  6404. interface VRDisplayCapabilities {
  6405. readonly canPresent: boolean;
  6406. readonly hasExternalDisplay: boolean;
  6407. readonly hasOrientation: boolean;
  6408. readonly hasPosition: boolean;
  6409. readonly maxLayers: number;
  6410. }
  6411. interface VREyeParameters {
  6412. /** @deprecated */
  6413. readonly fieldOfView: VRFieldOfView;
  6414. readonly offset: Float32Array;
  6415. readonly renderHeight: number;
  6416. readonly renderWidth: number;
  6417. }
  6418. interface VRFieldOfView {
  6419. readonly downDegrees: number;
  6420. readonly leftDegrees: number;
  6421. readonly rightDegrees: number;
  6422. readonly upDegrees: number;
  6423. }
  6424. interface VRFrameData {
  6425. readonly leftProjectionMatrix: Float32Array;
  6426. readonly leftViewMatrix: Float32Array;
  6427. readonly pose: VRPose;
  6428. readonly rightProjectionMatrix: Float32Array;
  6429. readonly rightViewMatrix: Float32Array;
  6430. readonly timestamp: number;
  6431. }
  6432. interface VRPose {
  6433. readonly angularAcceleration: Float32Array | null;
  6434. readonly angularVelocity: Float32Array | null;
  6435. readonly linearAcceleration: Float32Array | null;
  6436. readonly linearVelocity: Float32Array | null;
  6437. readonly orientation: Float32Array | null;
  6438. readonly position: Float32Array | null;
  6439. readonly timestamp: number;
  6440. }
  6441. interface VRStageParameters {
  6442. sittingToStandingTransform?: Float32Array;
  6443. sizeX?: number;
  6444. sizeY?: number;
  6445. }
  6446. interface Navigator {
  6447. getVRDisplays(): Promise<VRDisplay[]>;
  6448. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6449. }
  6450. interface Window {
  6451. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6452. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6453. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6454. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6455. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6456. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6457. }
  6458. interface Gamepad {
  6459. readonly displayId: number;
  6460. }
  6461. /**
  6462. * Module Debug contains the (visual) components to debug a scene correctly
  6463. */
  6464. declare module BABYLON.Debug {
  6465. /**
  6466. * The Axes viewer will show 3 axes in a specific point in space
  6467. */
  6468. class AxesViewer {
  6469. private _xline;
  6470. private _yline;
  6471. private _zline;
  6472. private _xmesh;
  6473. private _ymesh;
  6474. private _zmesh;
  6475. /**
  6476. * Gets the hosting scene
  6477. */
  6478. scene: Nullable<Scene>;
  6479. /**
  6480. * Gets or sets a number used to scale line length
  6481. */
  6482. scaleLines: number;
  6483. /**
  6484. * Creates a new AxesViewer
  6485. * @param scene defines the hosting scene
  6486. * @param scaleLines defines a number used to scale line length (1 by default)
  6487. */
  6488. constructor(scene: Scene, scaleLines?: number);
  6489. /**
  6490. * Force the viewer to update
  6491. * @param position defines the position of the viewer
  6492. * @param xaxis defines the x axis of the viewer
  6493. * @param yaxis defines the y axis of the viewer
  6494. * @param zaxis defines the z axis of the viewer
  6495. */
  6496. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  6497. /** Releases resources */
  6498. dispose(): void;
  6499. }
  6500. }
  6501. declare module BABYLON.Debug {
  6502. /**
  6503. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  6504. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  6505. */
  6506. class BoneAxesViewer extends AxesViewer {
  6507. /**
  6508. * Gets or sets the target mesh where to display the axes viewer
  6509. */
  6510. mesh: Nullable<Mesh>;
  6511. /**
  6512. * Gets or sets the target bone where to display the axes viewer
  6513. */
  6514. bone: Nullable<Bone>;
  6515. /** Gets current position */
  6516. pos: Vector3;
  6517. /** Gets direction of X axis */
  6518. xaxis: Vector3;
  6519. /** Gets direction of Y axis */
  6520. yaxis: Vector3;
  6521. /** Gets direction of Z axis */
  6522. zaxis: Vector3;
  6523. /**
  6524. * Creates a new BoneAxesViewer
  6525. * @param scene defines the hosting scene
  6526. * @param bone defines the target bone
  6527. * @param mesh defines the target mesh
  6528. * @param scaleLines defines a scaling factor for line length (1 by default)
  6529. */
  6530. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  6531. /**
  6532. * Force the viewer to update
  6533. */
  6534. update(): void;
  6535. /** Releases resources */
  6536. dispose(): void;
  6537. }
  6538. }
  6539. declare module BABYLON {
  6540. class DebugLayer {
  6541. private _scene;
  6542. static InspectorURL: string;
  6543. private _inspector;
  6544. private BJSINSPECTOR;
  6545. onPropertyChangedObservable: Observable<{
  6546. object: any;
  6547. property: string;
  6548. value: any;
  6549. initialValue: any;
  6550. }>;
  6551. constructor(scene: Scene);
  6552. /** Creates the inspector window. */
  6553. private _createInspector(config?);
  6554. isVisible(): boolean;
  6555. hide(): void;
  6556. /**
  6557. *
  6558. * Launch the debugLayer.
  6559. *
  6560. * initialTab:
  6561. * | Value | Tab Name |
  6562. * | --- | --- |
  6563. * | 0 | Scene |
  6564. * | 1 | Console |
  6565. * | 2 | Stats |
  6566. * | 3 | Textures |
  6567. * | 4 | Mesh |
  6568. * | 5 | Light |
  6569. * | 6 | Material |
  6570. * | 7 | GLTF |
  6571. * | 8 | GUI |
  6572. * | 9 | Physics |
  6573. * | 10 | Camera |
  6574. * | 11 | Audio |
  6575. *
  6576. */
  6577. show(config?: {
  6578. popup?: boolean;
  6579. initialTab?: number;
  6580. parentElement?: HTMLElement;
  6581. newColors?: {
  6582. backgroundColor?: string;
  6583. backgroundColorLighter?: string;
  6584. backgroundColorLighter2?: string;
  6585. backgroundColorLighter3?: string;
  6586. color?: string;
  6587. colorTop?: string;
  6588. colorBot?: string;
  6589. };
  6590. }): void;
  6591. /**
  6592. * Gets the active tab
  6593. * @return the index of the active tab or -1 if the inspector is hidden
  6594. */
  6595. getActiveTab(): number;
  6596. }
  6597. }
  6598. declare module BABYLON.Debug {
  6599. /**
  6600. * Used to show the physics impostor around the specific mesh
  6601. */
  6602. class PhysicsViewer {
  6603. /** @hidden */
  6604. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  6605. /** @hidden */
  6606. protected _meshes: Array<Nullable<AbstractMesh>>;
  6607. /** @hidden */
  6608. protected _scene: Nullable<Scene>;
  6609. /** @hidden */
  6610. protected _numMeshes: number;
  6611. /** @hidden */
  6612. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  6613. private _renderFunction;
  6614. private _debugBoxMesh;
  6615. private _debugSphereMesh;
  6616. private _debugMaterial;
  6617. /**
  6618. * Creates a new PhysicsViewer
  6619. * @param scene defines the hosting scene
  6620. */
  6621. constructor(scene: Scene);
  6622. /** @hidden */
  6623. protected _updateDebugMeshes(): void;
  6624. /**
  6625. * Renders a specified physic impostor
  6626. * @param impostor defines the impostor to render
  6627. */
  6628. showImpostor(impostor: PhysicsImpostor): void;
  6629. /**
  6630. * Hides a specified physic impostor
  6631. * @param impostor defines the impostor to hide
  6632. */
  6633. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  6634. private _getDebugMaterial(scene);
  6635. private _getDebugBoxMesh(scene);
  6636. private _getDebugSphereMesh(scene);
  6637. private _getDebugMesh(impostor, scene);
  6638. /** Releases all resources */
  6639. dispose(): void;
  6640. }
  6641. }
  6642. declare module BABYLON {
  6643. class RayHelper {
  6644. ray: Nullable<Ray>;
  6645. private _renderPoints;
  6646. private _renderLine;
  6647. private _renderFunction;
  6648. private _scene;
  6649. private _updateToMeshFunction;
  6650. private _attachedToMesh;
  6651. private _meshSpaceDirection;
  6652. private _meshSpaceOrigin;
  6653. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  6654. constructor(ray: Ray);
  6655. show(scene: Scene, color?: Color3): void;
  6656. hide(): void;
  6657. private _render();
  6658. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  6659. detachFromMesh(): void;
  6660. private _updateToMesh();
  6661. dispose(): void;
  6662. }
  6663. }
  6664. declare module BABYLON.Debug {
  6665. /**
  6666. * Class used to render a debug view of a given skeleton
  6667. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  6668. */
  6669. class SkeletonViewer {
  6670. /** defines the skeleton to render */
  6671. skeleton: Skeleton;
  6672. /** defines the mesh attached to the skeleton */
  6673. mesh: AbstractMesh;
  6674. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  6675. autoUpdateBonesMatrices: boolean;
  6676. /** defines the rendering group id to use with the viewer */
  6677. renderingGroupId: number;
  6678. /** Gets or sets the color used to render the skeleton */
  6679. color: Color3;
  6680. private _scene;
  6681. private _debugLines;
  6682. private _debugMesh;
  6683. private _isEnabled;
  6684. private _renderFunction;
  6685. /**
  6686. * Creates a new SkeletonViewer
  6687. * @param skeleton defines the skeleton to render
  6688. * @param mesh defines the mesh attached to the skeleton
  6689. * @param scene defines the hosting scene
  6690. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  6691. * @param renderingGroupId defines the rendering group id to use with the viewer
  6692. */
  6693. constructor(
  6694. /** defines the skeleton to render */
  6695. skeleton: Skeleton,
  6696. /** defines the mesh attached to the skeleton */
  6697. mesh: AbstractMesh, scene: Scene,
  6698. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  6699. autoUpdateBonesMatrices?: boolean,
  6700. /** defines the rendering group id to use with the viewer */
  6701. renderingGroupId?: number);
  6702. /** Gets or sets a boolean indicating if the viewer is enabled */
  6703. isEnabled: boolean;
  6704. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  6705. private _getLinesForBonesWithLength(bones, meshMat);
  6706. private _getLinesForBonesNoLength(bones, meshMat);
  6707. /** Update the viewer to sync with current skeleton state */
  6708. update(): void;
  6709. /** Release associated resources */
  6710. dispose(): void;
  6711. }
  6712. }
  6713. declare module BABYLON {
  6714. /**
  6715. * Interface for attribute information associated with buffer instanciation
  6716. */
  6717. class InstancingAttributeInfo {
  6718. /**
  6719. * Index/offset of the attribute in the vertex shader
  6720. */
  6721. index: number;
  6722. /**
  6723. * size of the attribute, 1, 2, 3 or 4
  6724. */
  6725. attributeSize: number;
  6726. /**
  6727. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  6728. * default is FLOAT
  6729. */
  6730. attribyteType: number;
  6731. /**
  6732. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  6733. */
  6734. normalized: boolean;
  6735. /**
  6736. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  6737. */
  6738. offset: number;
  6739. /**
  6740. * Name of the GLSL attribute, for debugging purpose only
  6741. */
  6742. attributeName: string;
  6743. }
  6744. /**
  6745. * Define options used to create a render target texture
  6746. */
  6747. class RenderTargetCreationOptions {
  6748. /**
  6749. * Specifies is mipmaps must be generated
  6750. */
  6751. generateMipMaps?: boolean;
  6752. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6753. generateDepthBuffer?: boolean;
  6754. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6755. generateStencilBuffer?: boolean;
  6756. /** Defines texture type (int by default) */
  6757. type?: number;
  6758. /** Defines sampling mode (trilinear by default) */
  6759. samplingMode?: number;
  6760. /** Defines format (RGBA by default) */
  6761. format?: number;
  6762. }
  6763. /**
  6764. * Define options used to create a depth texture
  6765. */
  6766. class DepthTextureCreationOptions {
  6767. /** Specifies whether or not a stencil should be allocated in the texture */
  6768. generateStencil?: boolean;
  6769. /** Specifies whether or not bilinear filtering is enable on the texture */
  6770. bilinearFiltering?: boolean;
  6771. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  6772. comparisonFunction?: number;
  6773. /** Specifies if the created texture is a cube texture */
  6774. isCube?: boolean;
  6775. }
  6776. /**
  6777. * Class used to describe the capabilities of the engine relatively to the current browser
  6778. */
  6779. class EngineCapabilities {
  6780. /** Maximum textures units per fragment shader */
  6781. maxTexturesImageUnits: number;
  6782. /** Maximum texture units per vertex shader */
  6783. maxVertexTextureImageUnits: number;
  6784. /** Maximum textures units in the entire pipeline */
  6785. maxCombinedTexturesImageUnits: number;
  6786. /** Maximum texture size */
  6787. maxTextureSize: number;
  6788. /** Maximum cube texture size */
  6789. maxCubemapTextureSize: number;
  6790. /** Maximum render texture size */
  6791. maxRenderTextureSize: number;
  6792. /** Maximum number of vertex attributes */
  6793. maxVertexAttribs: number;
  6794. /** Maximum number of varyings */
  6795. maxVaryingVectors: number;
  6796. /** Maximum number of uniforms per vertex shader */
  6797. maxVertexUniformVectors: number;
  6798. /** Maximum number of uniforms per fragment shader */
  6799. maxFragmentUniformVectors: number;
  6800. /** Defines if standard derivates (dx/dy) are supported */
  6801. standardDerivatives: boolean;
  6802. /** Defines if s3tc texture compression is supported */
  6803. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  6804. /** Defines if pvrtc texture compression is supported */
  6805. pvrtc: any;
  6806. /** Defines if etc1 texture compression is supported */
  6807. etc1: any;
  6808. /** Defines if etc2 texture compression is supported */
  6809. etc2: any;
  6810. /** Defines if astc texture compression is supported */
  6811. astc: any;
  6812. /** Defines if float textures are supported */
  6813. textureFloat: boolean;
  6814. /** Defines if vertex array objects are supported */
  6815. vertexArrayObject: boolean;
  6816. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  6817. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  6818. /** Gets the maximum level of anisotropy supported */
  6819. maxAnisotropy: number;
  6820. /** Defines if instancing is supported */
  6821. instancedArrays: boolean;
  6822. /** Defines if 32 bits indices are supported */
  6823. uintIndices: boolean;
  6824. /** Defines if high precision shaders are supported */
  6825. highPrecisionShaderSupported: boolean;
  6826. /** Defines if depth reading in the fragment shader is supported */
  6827. fragmentDepthSupported: boolean;
  6828. /** Defines if float texture linear filtering is supported*/
  6829. textureFloatLinearFiltering: boolean;
  6830. /** Defines if rendering to float textures is supported */
  6831. textureFloatRender: boolean;
  6832. /** Defines if half float textures are supported*/
  6833. textureHalfFloat: boolean;
  6834. /** Defines if half float texture linear filtering is supported*/
  6835. textureHalfFloatLinearFiltering: boolean;
  6836. /** Defines if rendering to half float textures is supported */
  6837. textureHalfFloatRender: boolean;
  6838. /** Defines if textureLOD shader command is supported */
  6839. textureLOD: boolean;
  6840. /** Defines if draw buffers extension is supported */
  6841. drawBuffersExtension: boolean;
  6842. /** Defines if depth textures are supported */
  6843. depthTextureExtension: boolean;
  6844. /** Defines if float color buffer are supported */
  6845. colorBufferFloat: boolean;
  6846. /** Gets disjoint timer query extension (null if not supported) */
  6847. timerQuery: EXT_disjoint_timer_query;
  6848. /** Defines if timestamp can be used with timer query */
  6849. canUseTimestampForTimerQuery: boolean;
  6850. }
  6851. /** Interface defining initialization parameters for Engine class */
  6852. interface EngineOptions extends WebGLContextAttributes {
  6853. /**
  6854. * Defines if the engine should no exceed a specified device ratio
  6855. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  6856. */
  6857. limitDeviceRatio?: number;
  6858. /**
  6859. * Defines if webvr should be enabled automatically
  6860. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6861. */
  6862. autoEnableWebVR?: boolean;
  6863. /**
  6864. * Defines if webgl2 should be turned off even if supported
  6865. * @see http://doc.babylonjs.com/features/webgl2
  6866. */
  6867. disableWebGL2Support?: boolean;
  6868. /**
  6869. * Defines if webaudio should be initialized as well
  6870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6871. */
  6872. audioEngine?: boolean;
  6873. /**
  6874. * Defines if animations should run using a deterministic lock step
  6875. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6876. */
  6877. deterministicLockstep?: boolean;
  6878. /** Defines the maximum steps to use with deterministic lock step mode */
  6879. lockstepMaxSteps?: number;
  6880. /**
  6881. * Defines that engine should ignore context lost events
  6882. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  6883. */
  6884. doNotHandleContextLost?: boolean;
  6885. }
  6886. /**
  6887. * Defines the interface used by display changed events
  6888. */
  6889. interface IDisplayChangedEventArgs {
  6890. /** Gets the vrDisplay object (if any) */
  6891. vrDisplay: Nullable<any>;
  6892. /** Gets a boolean indicating if webVR is supported */
  6893. vrSupported: boolean;
  6894. }
  6895. /**
  6896. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  6897. */
  6898. class Engine {
  6899. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  6900. static ExceptionList: ({
  6901. key: string;
  6902. capture: string;
  6903. captureConstraint: number;
  6904. targets: string[];
  6905. } | {
  6906. key: string;
  6907. capture: null;
  6908. captureConstraint: null;
  6909. targets: string[];
  6910. })[];
  6911. /** Gets the list of created engines */
  6912. static Instances: Engine[];
  6913. /**
  6914. * Gets the latest created engine
  6915. */
  6916. static readonly LastCreatedEngine: Nullable<Engine>;
  6917. /**
  6918. * Gets the latest created scene
  6919. */
  6920. static readonly LastCreatedScene: Nullable<Scene>;
  6921. /**
  6922. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  6923. * @param flag defines which part of the materials must be marked as dirty
  6924. * @param predicate defines a predicate used to filter which materials should be affected
  6925. */
  6926. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  6927. /**
  6928. * Hidden
  6929. */
  6930. static _TextureLoaders: IInternalTextureLoader[];
  6931. /** Defines that alpha blending is disabled */
  6932. static readonly ALPHA_DISABLE: number;
  6933. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  6934. static readonly ALPHA_ADD: number;
  6935. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  6936. static readonly ALPHA_COMBINE: number;
  6937. /** Defines that alpha blending to DEST - SRC * DEST */
  6938. static readonly ALPHA_SUBTRACT: number;
  6939. /** Defines that alpha blending to SRC * DEST */
  6940. static readonly ALPHA_MULTIPLY: number;
  6941. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  6942. static readonly ALPHA_MAXIMIZED: number;
  6943. /** Defines that alpha blending to SRC + DEST */
  6944. static readonly ALPHA_ONEONE: number;
  6945. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  6946. static readonly ALPHA_PREMULTIPLIED: number;
  6947. /**
  6948. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  6949. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  6950. */
  6951. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  6952. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  6953. static readonly ALPHA_INTERPOLATE: number;
  6954. /**
  6955. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  6956. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  6957. */
  6958. static readonly ALPHA_SCREENMODE: number;
  6959. /** Defines that the ressource is not delayed*/
  6960. static readonly DELAYLOADSTATE_NONE: number;
  6961. /** Defines that the ressource was successfully delay loaded */
  6962. static readonly DELAYLOADSTATE_LOADED: number;
  6963. /** Defines that the ressource is currently delay loading */
  6964. static readonly DELAYLOADSTATE_LOADING: number;
  6965. /** Defines that the ressource is delayed and has not started loading */
  6966. static readonly DELAYLOADSTATE_NOTLOADED: number;
  6967. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  6968. static readonly NEVER: number;
  6969. /** 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 */
  6970. static readonly ALWAYS: number;
  6971. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  6972. static readonly LESS: number;
  6973. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  6974. static readonly EQUAL: number;
  6975. /** 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 */
  6976. static readonly LEQUAL: number;
  6977. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  6978. static readonly GREATER: number;
  6979. /** 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 */
  6980. static readonly GEQUAL: number;
  6981. /** 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 */
  6982. static readonly NOTEQUAL: number;
  6983. /** Passed to stencilOperation to specify that stencil value must be kept */
  6984. static readonly KEEP: number;
  6985. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6986. static readonly REPLACE: number;
  6987. /** Passed to stencilOperation to specify that stencil value must be incremented */
  6988. static readonly INCR: number;
  6989. /** Passed to stencilOperation to specify that stencil value must be decremented */
  6990. static readonly DECR: number;
  6991. /** Passed to stencilOperation to specify that stencil value must be inverted */
  6992. static readonly INVERT: number;
  6993. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  6994. static readonly INCR_WRAP: number;
  6995. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  6996. static readonly DECR_WRAP: number;
  6997. /** Texture is not repeating outside of 0..1 UVs */
  6998. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  6999. /** Texture is repeating outside of 0..1 UVs */
  7000. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  7001. /** Texture is repeating and mirrored */
  7002. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  7003. /** ALPHA */
  7004. static readonly TEXTUREFORMAT_ALPHA: number;
  7005. /** LUMINANCE */
  7006. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7007. /** LUMINANCE_ALPHA */
  7008. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7009. /** RGB */
  7010. static readonly TEXTUREFORMAT_RGB: number;
  7011. /** RGBA */
  7012. static readonly TEXTUREFORMAT_RGBA: number;
  7013. /** R */
  7014. static readonly TEXTUREFORMAT_R: number;
  7015. /** RG */
  7016. static readonly TEXTUREFORMAT_RG: number;
  7017. /** UNSIGNED_INT */
  7018. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7019. /** FLOAT */
  7020. static readonly TEXTURETYPE_FLOAT: number;
  7021. /** HALF_FLOAT */
  7022. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7023. /** nearest is mag = nearest and min = nearest and mip = linear */
  7024. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  7025. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7026. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  7027. /** Trilinear is mag = linear and min = linear and mip = linear */
  7028. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  7029. /** nearest is mag = nearest and min = nearest and mip = linear */
  7030. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  7031. /** Bilinear is mag = linear and min = linear and mip = nearest */
  7032. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  7033. /** Trilinear is mag = linear and min = linear and mip = linear */
  7034. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  7035. /** mag = nearest and min = nearest and mip = nearest */
  7036. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  7037. /** mag = nearest and min = linear and mip = nearest */
  7038. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  7039. /** mag = nearest and min = linear and mip = linear */
  7040. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  7041. /** mag = nearest and min = linear and mip = none */
  7042. static readonly TEXTURE_NEAREST_LINEAR: number;
  7043. /** mag = nearest and min = nearest and mip = none */
  7044. static readonly TEXTURE_NEAREST_NEAREST: number;
  7045. /** mag = linear and min = nearest and mip = nearest */
  7046. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  7047. /** mag = linear and min = nearest and mip = linear */
  7048. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  7049. /** mag = linear and min = linear and mip = none */
  7050. static readonly TEXTURE_LINEAR_LINEAR: number;
  7051. /** mag = linear and min = nearest and mip = none */
  7052. static readonly TEXTURE_LINEAR_NEAREST: number;
  7053. /** Explicit coordinates mode */
  7054. static readonly TEXTURE_EXPLICIT_MODE: number;
  7055. /** Spherical coordinates mode */
  7056. static readonly TEXTURE_SPHERICAL_MODE: number;
  7057. /** Planar coordinates mode */
  7058. static readonly TEXTURE_PLANAR_MODE: number;
  7059. /** Cubic coordinates mode */
  7060. static readonly TEXTURE_CUBIC_MODE: number;
  7061. /** Projection coordinates mode */
  7062. static readonly TEXTURE_PROJECTION_MODE: number;
  7063. /** Skybox coordinates mode */
  7064. static readonly TEXTURE_SKYBOX_MODE: number;
  7065. /** Inverse Cubic coordinates mode */
  7066. static readonly TEXTURE_INVCUBIC_MODE: number;
  7067. /** Equirectangular coordinates mode */
  7068. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  7069. /** Equirectangular Fixed coordinates mode */
  7070. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  7071. /** Equirectangular Fixed Mirrored coordinates mode */
  7072. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  7073. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7074. static readonly SCALEMODE_FLOOR: number;
  7075. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7076. static readonly SCALEMODE_NEAREST: number;
  7077. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7078. static readonly SCALEMODE_CEILING: number;
  7079. /**
  7080. * Returns the current version of the framework
  7081. */
  7082. static readonly Version: string;
  7083. /**
  7084. * Gets or sets the epsilon value used by collision engine
  7085. */
  7086. static CollisionsEpsilon: number;
  7087. /**
  7088. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7089. */
  7090. static CodeRepository: string;
  7091. /**
  7092. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7093. */
  7094. static ShadersRepository: string;
  7095. /**
  7096. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7097. */
  7098. forcePOTTextures: boolean;
  7099. /**
  7100. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7101. */
  7102. isFullscreen: boolean;
  7103. /**
  7104. * Gets a boolean indicating if the pointer is currently locked
  7105. */
  7106. isPointerLock: boolean;
  7107. /**
  7108. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7109. */
  7110. cullBackFaces: boolean;
  7111. /**
  7112. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7113. */
  7114. renderEvenInBackground: boolean;
  7115. /**
  7116. * Gets or sets a boolean indicating that cache can be kept between frames
  7117. */
  7118. preventCacheWipeBetweenFrames: boolean;
  7119. /**
  7120. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7121. **/
  7122. enableOfflineSupport: boolean;
  7123. /**
  7124. * 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)
  7125. **/
  7126. disableManifestCheck: boolean;
  7127. /**
  7128. * Gets the list of created scenes
  7129. */
  7130. scenes: Scene[];
  7131. /**
  7132. * Gets the list of created postprocesses
  7133. */
  7134. postProcesses: PostProcess[];
  7135. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  7136. validateShaderPrograms: boolean;
  7137. /**
  7138. * Observable event triggered each time the rendering canvas is resized
  7139. */
  7140. onResizeObservable: Observable<Engine>;
  7141. /**
  7142. * Observable event triggered each time the canvas loses focus
  7143. */
  7144. onCanvasBlurObservable: Observable<Engine>;
  7145. /**
  7146. * Observable event triggered each time the canvas gains focus
  7147. */
  7148. onCanvasFocusObservable: Observable<Engine>;
  7149. /**
  7150. * Observable event triggered each time the canvas receives pointerout event
  7151. */
  7152. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7153. /**
  7154. * Observable event triggered before each texture is initialized
  7155. */
  7156. onBeforeTextureInitObservable: Observable<Texture>;
  7157. private _vrDisplay;
  7158. private _vrSupported;
  7159. private _oldSize;
  7160. private _oldHardwareScaleFactor;
  7161. private _vrExclusivePointerMode;
  7162. private _webVRInitPromise;
  7163. /**
  7164. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7165. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7166. */
  7167. readonly isInVRExclusivePointerMode: boolean;
  7168. /**
  7169. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7170. */
  7171. disableUniformBuffers: boolean;
  7172. /** @hidden */
  7173. _uniformBuffers: UniformBuffer[];
  7174. /**
  7175. * Gets a boolean indicating that the engine supports uniform buffers
  7176. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7177. */
  7178. readonly supportsUniformBuffers: boolean;
  7179. /**
  7180. * Observable raised when the engine begins a new frame
  7181. */
  7182. onBeginFrameObservable: Observable<Engine>;
  7183. /**
  7184. * Observable raised when the engine ends the current frame
  7185. */
  7186. onEndFrameObservable: Observable<Engine>;
  7187. /**
  7188. * Observable raised when the engine is about to compile a shader
  7189. */
  7190. onBeforeShaderCompilationObservable: Observable<Engine>;
  7191. /**
  7192. * Observable raised when the engine has jsut compiled a shader
  7193. */
  7194. onAfterShaderCompilationObservable: Observable<Engine>;
  7195. /** @hidden */
  7196. _gl: WebGLRenderingContext;
  7197. private _renderingCanvas;
  7198. private _windowIsBackground;
  7199. private _webGLVersion;
  7200. /**
  7201. * Gets a boolean indicating that only power of 2 textures are supported
  7202. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7203. */
  7204. readonly needPOTTextures: boolean;
  7205. /** @hidden */
  7206. _badOS: boolean;
  7207. /** @hidden */
  7208. _badDesktopOS: boolean;
  7209. /**
  7210. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7211. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7212. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7213. */
  7214. disableTextureBindingOptimization: boolean;
  7215. /**
  7216. * Gets the audio engine
  7217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7218. * @ignorenaming
  7219. */
  7220. static audioEngine: AudioEngine;
  7221. private _onFocus;
  7222. private _onBlur;
  7223. private _onCanvasPointerOut;
  7224. private _onCanvasBlur;
  7225. private _onCanvasFocus;
  7226. private _onFullscreenChange;
  7227. private _onPointerLockChange;
  7228. private _onVRDisplayPointerRestricted;
  7229. private _onVRDisplayPointerUnrestricted;
  7230. private _onVrDisplayConnect;
  7231. private _onVrDisplayDisconnect;
  7232. private _onVrDisplayPresentChange;
  7233. /**
  7234. * Observable signaled when VR display mode changes
  7235. */
  7236. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7237. /**
  7238. * Observable signaled when VR request present is complete
  7239. */
  7240. onVRRequestPresentComplete: Observable<boolean>;
  7241. /**
  7242. * Observable signaled when VR request present starts
  7243. */
  7244. onVRRequestPresentStart: Observable<Engine>;
  7245. private _hardwareScalingLevel;
  7246. /** @hidden */
  7247. protected _caps: EngineCapabilities;
  7248. private _pointerLockRequested;
  7249. private _isStencilEnable;
  7250. private _colorWrite;
  7251. private _loadingScreen;
  7252. /** @hidden */
  7253. _drawCalls: PerfCounter;
  7254. /** @hidden */
  7255. _textureCollisions: PerfCounter;
  7256. private _glVersion;
  7257. private _glRenderer;
  7258. private _glVendor;
  7259. private _videoTextureSupported;
  7260. private _renderingQueueLaunched;
  7261. private _activeRenderLoops;
  7262. private _deterministicLockstep;
  7263. private _lockstepMaxSteps;
  7264. /**
  7265. * Observable signaled when a context lost event is raised
  7266. */
  7267. onContextLostObservable: Observable<Engine>;
  7268. /**
  7269. * Observable signaled when a context restored event is raised
  7270. */
  7271. onContextRestoredObservable: Observable<Engine>;
  7272. private _onContextLost;
  7273. private _onContextRestored;
  7274. private _contextWasLost;
  7275. private _doNotHandleContextLost;
  7276. /**
  7277. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7278. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7279. */
  7280. doNotHandleContextLost: boolean;
  7281. private _performanceMonitor;
  7282. private _fps;
  7283. private _deltaTime;
  7284. /**
  7285. * Turn this value on if you want to pause FPS computation when in background
  7286. */
  7287. disablePerformanceMonitorInBackground: boolean;
  7288. /**
  7289. * Gets the performance monitor attached to this engine
  7290. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7291. */
  7292. readonly performanceMonitor: PerformanceMonitor;
  7293. /** @hidden */
  7294. protected _depthCullingState: _DepthCullingState;
  7295. /** @hidden */
  7296. protected _stencilState: _StencilState;
  7297. /** @hidden */
  7298. protected _alphaState: _AlphaState;
  7299. /** @hidden */
  7300. protected _alphaMode: number;
  7301. protected _internalTexturesCache: InternalTexture[];
  7302. /** @hidden */
  7303. protected _activeChannel: number;
  7304. private _currentTextureChannel;
  7305. /** @hidden */
  7306. protected _boundTexturesCache: {
  7307. [key: string]: Nullable<InternalTexture>;
  7308. };
  7309. /** @hidden */
  7310. protected _currentEffect: Nullable<Effect>;
  7311. /** @hidden */
  7312. protected _currentProgram: Nullable<WebGLProgram>;
  7313. private _compiledEffects;
  7314. private _vertexAttribArraysEnabled;
  7315. /** @hidden */
  7316. protected _cachedViewport: Nullable<Viewport>;
  7317. private _cachedVertexArrayObject;
  7318. /** @hidden */
  7319. protected _cachedVertexBuffers: any;
  7320. /** @hidden */
  7321. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7322. /** @hidden */
  7323. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7324. /** @hidden */
  7325. protected _currentRenderTarget: Nullable<InternalTexture>;
  7326. private _uintIndicesCurrentlySet;
  7327. private _currentBoundBuffer;
  7328. /** @hidden */
  7329. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7330. private _currentBufferPointers;
  7331. private _currentInstanceLocations;
  7332. private _currentInstanceBuffers;
  7333. private _textureUnits;
  7334. private _firstBoundInternalTextureTracker;
  7335. private _lastBoundInternalTextureTracker;
  7336. private _workingCanvas;
  7337. private _workingContext;
  7338. private _rescalePostProcess;
  7339. private _dummyFramebuffer;
  7340. private _externalData;
  7341. private _bindedRenderFunction;
  7342. private _vaoRecordInProgress;
  7343. private _mustWipeVertexAttributes;
  7344. private _emptyTexture;
  7345. private _emptyCubeTexture;
  7346. private _emptyTexture3D;
  7347. private _frameHandler;
  7348. private _nextFreeTextureSlots;
  7349. private _maxSimultaneousTextures;
  7350. private _activeRequests;
  7351. private _texturesSupported;
  7352. private _textureFormatInUse;
  7353. /**
  7354. * Gets the list of texture formats supported
  7355. */
  7356. readonly texturesSupported: Array<string>;
  7357. /**
  7358. * Gets the list of texture formats in use
  7359. */
  7360. readonly textureFormatInUse: Nullable<string>;
  7361. /**
  7362. * Gets the current viewport
  7363. */
  7364. readonly currentViewport: Nullable<Viewport>;
  7365. /**
  7366. * Gets the default empty texture
  7367. */
  7368. readonly emptyTexture: InternalTexture;
  7369. /**
  7370. * Gets the default empty 3D texture
  7371. */
  7372. readonly emptyTexture3D: InternalTexture;
  7373. /**
  7374. * Gets the default empty cube texture
  7375. */
  7376. readonly emptyCubeTexture: InternalTexture;
  7377. /**
  7378. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  7379. */
  7380. readonly premultipliedAlpha: boolean;
  7381. /**
  7382. * Creates a new engine
  7383. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  7384. * @param antialias defines enable antialiasing (default: false)
  7385. * @param options defines further options to be sent to the getContext() function
  7386. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7387. */
  7388. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7389. private _rebuildInternalTextures();
  7390. private _rebuildEffects();
  7391. private _rebuildBuffers();
  7392. private _initGLContext();
  7393. /**
  7394. * Gets version of the current webGL context
  7395. */
  7396. readonly webGLVersion: number;
  7397. /**
  7398. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7399. */
  7400. readonly isStencilEnable: boolean;
  7401. private _prepareWorkingCanvas();
  7402. /**
  7403. * Reset the texture cache to empty state
  7404. */
  7405. resetTextureCache(): void;
  7406. /**
  7407. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7408. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7409. * @returns true if engine is in deterministic lock step mode
  7410. */
  7411. isDeterministicLockStep(): boolean;
  7412. /**
  7413. * Gets the max steps when engine is running in deterministic lock step
  7414. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7415. * @returns the max steps
  7416. */
  7417. getLockstepMaxSteps(): number;
  7418. /**
  7419. * Gets an object containing information about the current webGL context
  7420. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7421. */
  7422. getGlInfo(): {
  7423. vendor: string;
  7424. renderer: string;
  7425. version: string;
  7426. };
  7427. /**
  7428. * Gets current aspect ratio
  7429. * @param camera defines the camera to use to get the aspect ratio
  7430. * @param useScreen defines if screen size must be used (or the current render target if any)
  7431. * @returns a number defining the aspect ratio
  7432. */
  7433. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7434. /**
  7435. * Gets current screen aspect ratio
  7436. * @returns a number defining the aspect ratio
  7437. */
  7438. getScreenAspectRatio(): number;
  7439. /**
  7440. * Gets the current render width
  7441. * @param useScreen defines if screen size must be used (or the current render target if any)
  7442. * @returns a number defining the current render width
  7443. */
  7444. getRenderWidth(useScreen?: boolean): number;
  7445. /**
  7446. * Gets the current render height
  7447. * @param useScreen defines if screen size must be used (or the current render target if any)
  7448. * @returns a number defining the current render height
  7449. */
  7450. getRenderHeight(useScreen?: boolean): number;
  7451. /**
  7452. * Gets the HTML canvas attached with the current webGL context
  7453. * @returns a HTML canvas
  7454. */
  7455. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7456. /**
  7457. * Gets the client rect of the HTML canvas attached with the current webGL context
  7458. * @returns a client rectanglee
  7459. */
  7460. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7461. /**
  7462. * Defines the hardware scaling level.
  7463. * By default the hardware scaling level is computed from the window device ratio.
  7464. * 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.
  7465. * @param level defines the level to use
  7466. */
  7467. setHardwareScalingLevel(level: number): void;
  7468. /**
  7469. * Gets the current hardware scaling level.
  7470. * By default the hardware scaling level is computed from the window device ratio.
  7471. * 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.
  7472. * @returns a number indicating the current hardware scaling level
  7473. */
  7474. getHardwareScalingLevel(): number;
  7475. /**
  7476. * Gets the list of loaded textures
  7477. * @returns an array containing all loaded textures
  7478. */
  7479. getLoadedTexturesCache(): InternalTexture[];
  7480. /**
  7481. * Gets the object containing all engine capabilities
  7482. * @returns the EngineCapabilities object
  7483. */
  7484. getCaps(): EngineCapabilities;
  7485. /** @hidden */
  7486. readonly drawCalls: number;
  7487. /** @hidden */
  7488. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7489. /**
  7490. * Gets the current depth function
  7491. * @returns a number defining the depth function
  7492. */
  7493. getDepthFunction(): Nullable<number>;
  7494. /**
  7495. * Sets the current depth function
  7496. * @param depthFunc defines the function to use
  7497. */
  7498. setDepthFunction(depthFunc: number): void;
  7499. /**
  7500. * Sets the current depth function to GREATER
  7501. */
  7502. setDepthFunctionToGreater(): void;
  7503. /**
  7504. * Sets the current depth function to GEQUAL
  7505. */
  7506. setDepthFunctionToGreaterOrEqual(): void;
  7507. /**
  7508. * Sets the current depth function to LESS
  7509. */
  7510. setDepthFunctionToLess(): void;
  7511. /**
  7512. * Sets the current depth function to LEQUAL
  7513. */
  7514. setDepthFunctionToLessOrEqual(): void;
  7515. /**
  7516. * Gets a boolean indicating if stencil buffer is enabled
  7517. * @returns the current stencil buffer state
  7518. */
  7519. getStencilBuffer(): boolean;
  7520. /**
  7521. * Enable or disable the stencil buffer
  7522. * @param enable defines if the stencil buffer must be enabled or disabled
  7523. */
  7524. setStencilBuffer(enable: boolean): void;
  7525. /**
  7526. * Gets the current stencil mask
  7527. * @returns a number defining the new stencil mask to use
  7528. */
  7529. getStencilMask(): number;
  7530. /**
  7531. * Sets the current stencil mask
  7532. * @param mask defines the new stencil mask to use
  7533. */
  7534. setStencilMask(mask: number): void;
  7535. /**
  7536. * Gets the current stencil function
  7537. * @returns a number defining the stencil function to use
  7538. */
  7539. getStencilFunction(): number;
  7540. /**
  7541. * Gets the current stencil reference value
  7542. * @returns a number defining the stencil reference value to use
  7543. */
  7544. getStencilFunctionReference(): number;
  7545. /**
  7546. * Gets the current stencil mask
  7547. * @returns a number defining the stencil mask to use
  7548. */
  7549. getStencilFunctionMask(): number;
  7550. /**
  7551. * Sets the current stencil function
  7552. * @param stencilFunc defines the new stencil function to use
  7553. */
  7554. setStencilFunction(stencilFunc: number): void;
  7555. /**
  7556. * Sets the current stencil reference
  7557. * @param reference defines the new stencil reference to use
  7558. */
  7559. setStencilFunctionReference(reference: number): void;
  7560. /**
  7561. * Sets the current stencil mask
  7562. * @param mask defines the new stencil mask to use
  7563. */
  7564. setStencilFunctionMask(mask: number): void;
  7565. /**
  7566. * Gets the current stencil operation when stencil fails
  7567. * @returns a number defining stencil operation to use when stencil fails
  7568. */
  7569. getStencilOperationFail(): number;
  7570. /**
  7571. * Gets the current stencil operation when depth fails
  7572. * @returns a number defining stencil operation to use when depth fails
  7573. */
  7574. getStencilOperationDepthFail(): number;
  7575. /**
  7576. * Gets the current stencil operation when stencil passes
  7577. * @returns a number defining stencil operation to use when stencil passes
  7578. */
  7579. getStencilOperationPass(): number;
  7580. /**
  7581. * Sets the stencil operation to use when stencil fails
  7582. * @param operation defines the stencil operation to use when stencil fails
  7583. */
  7584. setStencilOperationFail(operation: number): void;
  7585. /**
  7586. * Sets the stencil operation to use when depth fails
  7587. * @param operation defines the stencil operation to use when depth fails
  7588. */
  7589. setStencilOperationDepthFail(operation: number): void;
  7590. /**
  7591. * Sets the stencil operation to use when stencil passes
  7592. * @param operation defines the stencil operation to use when stencil passes
  7593. */
  7594. setStencilOperationPass(operation: number): void;
  7595. /**
  7596. * Sets a boolean indicating if the dithering state is enabled or disabled
  7597. * @param value defines the dithering state
  7598. */
  7599. setDitheringState(value: boolean): void;
  7600. /**
  7601. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7602. * @param value defines the rasterizer state
  7603. */
  7604. setRasterizerState(value: boolean): void;
  7605. /**
  7606. * stop executing a render loop function and remove it from the execution array
  7607. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7608. */
  7609. stopRenderLoop(renderFunction?: () => void): void;
  7610. /** @hidden */
  7611. _renderLoop(): void;
  7612. /**
  7613. * Register and execute a render loop. The engine can have more than one render function
  7614. * @param renderFunction defines the function to continuously execute
  7615. */
  7616. runRenderLoop(renderFunction: () => void): void;
  7617. /**
  7618. * Toggle full screen mode
  7619. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7620. * @param options defines an option object to be sent to the requestFullscreen function
  7621. */
  7622. switchFullscreen(requestPointerLock: boolean): void;
  7623. /**
  7624. * Clear the current render buffer or the current render target (if any is set up)
  7625. * @param color defines the color to use
  7626. * @param backBuffer defines if the back buffer must be cleared
  7627. * @param depth defines if the depth buffer must be cleared
  7628. * @param stencil defines if the stencil buffer must be cleared
  7629. */
  7630. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7631. /**
  7632. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7633. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7634. * @param y defines the y-coordinate of the corner of the clear rectangle
  7635. * @param width defines the width of the clear rectangle
  7636. * @param height defines the height of the clear rectangle
  7637. * @param clearColor defines the clear color
  7638. */
  7639. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7640. private _viewportCached;
  7641. /** @hidden */
  7642. _viewport(x: number, y: number, width: number, height: number): void;
  7643. /**
  7644. * Set the WebGL's viewport
  7645. * @param viewport defines the viewport element to be used
  7646. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7647. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7648. */
  7649. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7650. /**
  7651. * Directly set the WebGL Viewport
  7652. * @param x defines the x coordinate of the viewport (in screen space)
  7653. * @param y defines the y coordinate of the viewport (in screen space)
  7654. * @param width defines the width of the viewport (in screen space)
  7655. * @param height defines the height of the viewport (in screen space)
  7656. * @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
  7657. */
  7658. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  7659. /**
  7660. * Begin a new frame
  7661. */
  7662. beginFrame(): void;
  7663. /**
  7664. * Enf the current frame
  7665. */
  7666. endFrame(): void;
  7667. /**
  7668. * Resize the view according to the canvas' size
  7669. */
  7670. resize(): void;
  7671. /**
  7672. * Force a specific size of the canvas
  7673. * @param width defines the new canvas' width
  7674. * @param height defines the new canvas' height
  7675. */
  7676. setSize(width: number, height: number): void;
  7677. /**
  7678. * Gets a boolean indicating if a webVR device was detected
  7679. * @returns true if a webVR device was detected
  7680. */
  7681. isVRDevicePresent(): boolean;
  7682. /**
  7683. * Gets the current webVR device
  7684. * @returns the current webVR device (or null)
  7685. */
  7686. getVRDevice(): any;
  7687. /**
  7688. * Initializes a webVR display and starts listening to display change events
  7689. * The onVRDisplayChangedObservable will be notified upon these changes
  7690. * @returns The onVRDisplayChangedObservable
  7691. */
  7692. initWebVR(): Observable<IDisplayChangedEventArgs>;
  7693. /**
  7694. * Initializes a webVR display and starts listening to display change events
  7695. * The onVRDisplayChangedObservable will be notified upon these changes
  7696. * @returns A promise containing a VRDisplay and if vr is supported
  7697. */
  7698. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  7699. /**
  7700. * Call this function to switch to webVR mode
  7701. * Will do nothing if webVR is not supported or if there is no webVR device
  7702. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7703. */
  7704. enableVR(): void;
  7705. /**
  7706. * Call this function to leave webVR mode
  7707. * Will do nothing if webVR is not supported or if there is no webVR device
  7708. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7709. */
  7710. disableVR(): void;
  7711. private _onVRFullScreenTriggered;
  7712. private _getVRDisplaysAsync();
  7713. /**
  7714. * Binds the frame buffer to the specified texture.
  7715. * @param texture The texture to render to or null for the default canvas
  7716. * @param faceIndex The face of the texture to render to in case of cube texture
  7717. * @param requiredWidth The width of the target to render to
  7718. * @param requiredHeight The height of the target to render to
  7719. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  7720. * @param depthStencilTexture The depth stencil texture to use to render
  7721. * @param lodLevel defines le lod level to bind to the frame buffer
  7722. */
  7723. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  7724. private bindUnboundFramebuffer(framebuffer);
  7725. /**
  7726. * Unbind the current render target texture from the webGL context
  7727. * @param texture defines the render target texture to unbind
  7728. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7729. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7730. */
  7731. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7732. /**
  7733. * Unbind a list of render target textures from the webGL context
  7734. * This is used only when drawBuffer extension or webGL2 are active
  7735. * @param textures defines the render target textures to unbind
  7736. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7737. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7738. */
  7739. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7740. /**
  7741. * Force the mipmap generation for the given render target texture
  7742. * @param texture defines the render target texture to use
  7743. */
  7744. generateMipMapsForCubemap(texture: InternalTexture): void;
  7745. /**
  7746. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  7747. */
  7748. flushFramebuffer(): void;
  7749. /**
  7750. * Unbind the current render target and bind the default framebuffer
  7751. */
  7752. restoreDefaultFramebuffer(): void;
  7753. /**
  7754. * Create an uniform buffer
  7755. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7756. * @param elements defines the content of the uniform buffer
  7757. * @returns the webGL uniform buffer
  7758. */
  7759. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  7760. /**
  7761. * Create a dynamic uniform buffer
  7762. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7763. * @param elements defines the content of the uniform buffer
  7764. * @returns the webGL uniform buffer
  7765. */
  7766. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  7767. /**
  7768. * Update an existing uniform buffer
  7769. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7770. * @param uniformBuffer defines the target uniform buffer
  7771. * @param elements defines the content to update
  7772. * @param offset defines the offset in the uniform buffer where update should start
  7773. * @param count defines the size of the data to update
  7774. */
  7775. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7776. private _resetVertexBufferBinding();
  7777. /**
  7778. * Creates a vertex buffer
  7779. * @param data the data for the vertex buffer
  7780. * @returns the new WebGL static buffer
  7781. */
  7782. createVertexBuffer(data: DataArray): WebGLBuffer;
  7783. /**
  7784. * Creates a dynamic vertex buffer
  7785. * @param data the data for the dynamic vertex buffer
  7786. * @returns the new WebGL dynamic buffer
  7787. */
  7788. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  7789. /**
  7790. * Update a dynamic index buffer
  7791. * @param indexBuffer defines the target index buffer
  7792. * @param indices defines the data to update
  7793. * @param offset defines the offset in the target index buffer where update should start
  7794. */
  7795. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7796. /**
  7797. * Updates a dynamic vertex buffer.
  7798. * @param vertexBuffer the vertex buffer to update
  7799. * @param data the data used to update the vertex buffer
  7800. * @param byteOffset the byte offset of the data
  7801. * @param byteLength the byte length of the data
  7802. */
  7803. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  7804. private _resetIndexBufferBinding();
  7805. /**
  7806. * Creates a new index buffer
  7807. * @param indices defines the content of the index buffer
  7808. * @param updatable defines if the index buffer must be updatable
  7809. * @returns a new webGL buffer
  7810. */
  7811. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  7812. /**
  7813. * Bind a webGL buffer to the webGL context
  7814. * @param buffer defines the buffer to bind
  7815. */
  7816. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  7817. /**
  7818. * Bind an uniform buffer to the current webGL context
  7819. * @param buffer defines the buffer to bind
  7820. */
  7821. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  7822. /**
  7823. * Bind a buffer to the current webGL context at a given location
  7824. * @param buffer defines the buffer to bind
  7825. * @param location defines the index where to bind the buffer
  7826. */
  7827. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  7828. /**
  7829. * Bind a specific block at a given index in a specific shader program
  7830. * @param shaderProgram defines the shader program
  7831. * @param blockName defines the block name
  7832. * @param index defines the index where to bind the block
  7833. */
  7834. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  7835. private bindIndexBuffer(buffer);
  7836. private bindBuffer(buffer, target);
  7837. /**
  7838. * update the bound buffer with the given data
  7839. * @param data defines the data to update
  7840. */
  7841. updateArrayBuffer(data: Float32Array): void;
  7842. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  7843. private _bindIndexBufferWithCache(indexBuffer);
  7844. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  7845. /**
  7846. * Records a vertex array object
  7847. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7848. * @param vertexBuffers defines the list of vertex buffers to store
  7849. * @param indexBuffer defines the index buffer to store
  7850. * @param effect defines the effect to store
  7851. * @returns the new vertex array object
  7852. */
  7853. recordVertexArrayObject(vertexBuffers: {
  7854. [key: string]: VertexBuffer;
  7855. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  7856. /**
  7857. * Bind a specific vertex array object
  7858. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7859. * @param vertexArrayObject defines the vertex array object to bind
  7860. * @param indexBuffer defines the index buffer to bind
  7861. */
  7862. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  7863. /**
  7864. * Bind webGl buffers directly to the webGL context
  7865. * @param vertexBuffer defines the vertex buffer to bind
  7866. * @param indexBuffer defines the index buffer to bind
  7867. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  7868. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  7869. * @param effect defines the effect associated with the vertex buffer
  7870. */
  7871. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  7872. private _unbindVertexArrayObject();
  7873. /**
  7874. * Bind a list of vertex buffers to the webGL context
  7875. * @param vertexBuffers defines the list of vertex buffers to bind
  7876. * @param indexBuffer defines the index buffer to bind
  7877. * @param effect defines the effect associated with the vertex buffers
  7878. */
  7879. bindBuffers(vertexBuffers: {
  7880. [key: string]: Nullable<VertexBuffer>;
  7881. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  7882. /**
  7883. * Unbind all instance attributes
  7884. */
  7885. unbindInstanceAttributes(): void;
  7886. /**
  7887. * Release and free the memory of a vertex array object
  7888. * @param vao defines the vertex array object to delete
  7889. */
  7890. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  7891. /** @hidden */
  7892. _releaseBuffer(buffer: WebGLBuffer): boolean;
  7893. /**
  7894. * Creates a webGL buffer to use with instanciation
  7895. * @param capacity defines the size of the buffer
  7896. * @returns the webGL buffer
  7897. */
  7898. createInstancesBuffer(capacity: number): WebGLBuffer;
  7899. /**
  7900. * Delete a webGL buffer used with instanciation
  7901. * @param buffer defines the webGL buffer to delete
  7902. */
  7903. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  7904. /**
  7905. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  7906. * @param instancesBuffer defines the webGL buffer to update and bind
  7907. * @param data defines the data to store in the buffer
  7908. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  7909. */
  7910. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  7911. /**
  7912. * Apply all cached states (depth, culling, stencil and alpha)
  7913. */
  7914. applyStates(): void;
  7915. /**
  7916. * Send a draw order
  7917. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7918. * @param indexStart defines the starting index
  7919. * @param indexCount defines the number of index to draw
  7920. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7921. */
  7922. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7923. /**
  7924. * Draw a list of points
  7925. * @param verticesStart defines the index of first vertex to draw
  7926. * @param verticesCount defines the count of vertices to draw
  7927. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7928. */
  7929. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7930. /**
  7931. * Draw a list of unindexed primitives
  7932. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7933. * @param verticesStart defines the index of first vertex to draw
  7934. * @param verticesCount defines the count of vertices to draw
  7935. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7936. */
  7937. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7938. /**
  7939. * Draw a list of indexed primitives
  7940. * @param fillMode defines the primitive to use
  7941. * @param indexStart defines the starting index
  7942. * @param indexCount defines the number of index to draw
  7943. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7944. */
  7945. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  7946. /**
  7947. * Draw a list of unindexed primitives
  7948. * @param fillMode defines the primitive to use
  7949. * @param verticesStart defines the index of first vertex to draw
  7950. * @param verticesCount defines the count of vertices to draw
  7951. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7952. */
  7953. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7954. private _drawMode(fillMode);
  7955. /** @hidden */
  7956. _releaseEffect(effect: Effect): void;
  7957. /** @hidden */
  7958. _deleteProgram(program: WebGLProgram): void;
  7959. /**
  7960. * Create a new effect (used to store vertex/fragment shaders)
  7961. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  7962. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  7963. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  7964. * @param samplers defines an array of string used to represent textures
  7965. * @param defines defines the string containing the defines to use to compile the shaders
  7966. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7967. * @param onCompiled defines a function to call when the effect creation is successful
  7968. * @param onError defines a function to call when the effect creation has failed
  7969. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  7970. * @returns the new Effect
  7971. */
  7972. 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;
  7973. private _compileShader(source, type, defines, shaderVersion);
  7974. private _compileRawShader(source, type);
  7975. /**
  7976. * Directly creates a webGL program
  7977. * @param vertexCode defines the vertex shader code to use
  7978. * @param fragmentCode defines the fragment shader code to use
  7979. * @param context defines the webGL context to use (if not set, the current one will be used)
  7980. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7981. * @returns the new webGL program
  7982. */
  7983. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7984. /**
  7985. * Creates a webGL program
  7986. * @param vertexCode defines the vertex shader code to use
  7987. * @param fragmentCode defines the fragment shader code to use
  7988. * @param defines defines the string containing the defines to use to compile the shaders
  7989. * @param context defines the webGL context to use (if not set, the current one will be used)
  7990. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7991. * @returns the new webGL program
  7992. */
  7993. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7994. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  7995. /**
  7996. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  7997. * @param shaderProgram defines the webGL program to use
  7998. * @param uniformsNames defines the list of uniform names
  7999. * @returns an array of webGL uniform locations
  8000. */
  8001. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8002. /**
  8003. * Gets the lsit of active attributes for a given webGL program
  8004. * @param shaderProgram defines the webGL program to use
  8005. * @param attributesNames defines the list of attribute names to get
  8006. * @returns an array of indices indicating the offset of each attribute
  8007. */
  8008. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8009. /**
  8010. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8011. * @param effect defines the effect to activate
  8012. */
  8013. enableEffect(effect: Nullable<Effect>): void;
  8014. /**
  8015. * Set the value of an uniform to an array of int32
  8016. * @param uniform defines the webGL uniform location where to store the value
  8017. * @param array defines the array of int32 to store
  8018. */
  8019. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8020. /**
  8021. * Set the value of an uniform to an array of int32 (stored as vec2)
  8022. * @param uniform defines the webGL uniform location where to store the value
  8023. * @param array defines the array of int32 to store
  8024. */
  8025. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8026. /**
  8027. * Set the value of an uniform to an array of int32 (stored as vec3)
  8028. * @param uniform defines the webGL uniform location where to store the value
  8029. * @param array defines the array of int32 to store
  8030. */
  8031. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8032. /**
  8033. * Set the value of an uniform to an array of int32 (stored as vec4)
  8034. * @param uniform defines the webGL uniform location where to store the value
  8035. * @param array defines the array of int32 to store
  8036. */
  8037. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8038. /**
  8039. * Set the value of an uniform to an array of float32
  8040. * @param uniform defines the webGL uniform location where to store the value
  8041. * @param array defines the array of float32 to store
  8042. */
  8043. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8044. /**
  8045. * Set the value of an uniform to an array of float32 (stored as vec2)
  8046. * @param uniform defines the webGL uniform location where to store the value
  8047. * @param array defines the array of float32 to store
  8048. */
  8049. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8050. /**
  8051. * Set the value of an uniform to an array of float32 (stored as vec3)
  8052. * @param uniform defines the webGL uniform location where to store the value
  8053. * @param array defines the array of float32 to store
  8054. */
  8055. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8056. /**
  8057. * Set the value of an uniform to an array of float32 (stored as vec4)
  8058. * @param uniform defines the webGL uniform location where to store the value
  8059. * @param array defines the array of float32 to store
  8060. */
  8061. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8062. /**
  8063. * Set the value of an uniform to an array of number
  8064. * @param uniform defines the webGL uniform location where to store the value
  8065. * @param array defines the array of number to store
  8066. */
  8067. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8068. /**
  8069. * Set the value of an uniform to an array of number (stored as vec2)
  8070. * @param uniform defines the webGL uniform location where to store the value
  8071. * @param array defines the array of number to store
  8072. */
  8073. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8074. /**
  8075. * Set the value of an uniform to an array of number (stored as vec3)
  8076. * @param uniform defines the webGL uniform location where to store the value
  8077. * @param array defines the array of number to store
  8078. */
  8079. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8080. /**
  8081. * Set the value of an uniform to an array of number (stored as vec4)
  8082. * @param uniform defines the webGL uniform location where to store the value
  8083. * @param array defines the array of number to store
  8084. */
  8085. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8086. /**
  8087. * Set the value of an uniform to an array of float32 (stored as matrices)
  8088. * @param uniform defines the webGL uniform location where to store the value
  8089. * @param matrices defines the array of float32 to store
  8090. */
  8091. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8092. /**
  8093. * Set the value of an uniform to a matrix
  8094. * @param uniform defines the webGL uniform location where to store the value
  8095. * @param matrix defines the matrix to store
  8096. */
  8097. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8098. /**
  8099. * Set the value of an uniform to a matrix (3x3)
  8100. * @param uniform defines the webGL uniform location where to store the value
  8101. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8102. */
  8103. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8104. /**
  8105. * Set the value of an uniform to a matrix (2x2)
  8106. * @param uniform defines the webGL uniform location where to store the value
  8107. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8108. */
  8109. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8110. /**
  8111. * Set the value of an uniform to a number (int)
  8112. * @param uniform defines the webGL uniform location where to store the value
  8113. * @param value defines the int number to store
  8114. */
  8115. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8116. /**
  8117. * Set the value of an uniform to a number (float)
  8118. * @param uniform defines the webGL uniform location where to store the value
  8119. * @param value defines the float number to store
  8120. */
  8121. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8122. /**
  8123. * Set the value of an uniform to a vec2
  8124. * @param uniform defines the webGL uniform location where to store the value
  8125. * @param x defines the 1st component of the value
  8126. * @param y defines the 2nd component of the value
  8127. */
  8128. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8129. /**
  8130. * Set the value of an uniform to a vec3
  8131. * @param uniform defines the webGL uniform location where to store the value
  8132. * @param x defines the 1st component of the value
  8133. * @param y defines the 2nd component of the value
  8134. * @param z defines the 3rd component of the value
  8135. */
  8136. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8137. /**
  8138. * Set the value of an uniform to a boolean
  8139. * @param uniform defines the webGL uniform location where to store the value
  8140. * @param bool defines the boolean to store
  8141. */
  8142. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8143. /**
  8144. * Set the value of an uniform to a vec4
  8145. * @param uniform defines the webGL uniform location where to store the value
  8146. * @param x defines the 1st component of the value
  8147. * @param y defines the 2nd component of the value
  8148. * @param z defines the 3rd component of the value
  8149. * @param w defines the 4th component of the value
  8150. */
  8151. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8152. /**
  8153. * Set the value of an uniform to a Color3
  8154. * @param uniform defines the webGL uniform location where to store the value
  8155. * @param color3 defines the color to store
  8156. */
  8157. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8158. /**
  8159. * Set the value of an uniform to a Color3 and an alpha value
  8160. * @param uniform defines the webGL uniform location where to store the value
  8161. * @param color3 defines the color to store
  8162. * @param alpha defines the alpha component to store
  8163. */
  8164. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8165. /**
  8166. * Sets a Color4 on a uniform variable
  8167. * @param uniform defines the uniform location
  8168. * @param color4 defines the value to be set
  8169. */
  8170. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8171. /**
  8172. * Set various states to the webGL context
  8173. * @param culling defines backface culling state
  8174. * @param zOffset defines the value to apply to zOffset (0 by default)
  8175. * @param force defines if states must be applied even if cache is up to date
  8176. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8177. */
  8178. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8179. /**
  8180. * Set the z offset to apply to current rendering
  8181. * @param value defines the offset to apply
  8182. */
  8183. setZOffset(value: number): void;
  8184. /**
  8185. * Gets the current value of the zOffset
  8186. * @returns the current zOffset state
  8187. */
  8188. getZOffset(): number;
  8189. /**
  8190. * Enable or disable depth buffering
  8191. * @param enable defines the state to set
  8192. */
  8193. setDepthBuffer(enable: boolean): void;
  8194. /**
  8195. * Gets a boolean indicating if depth writing is enabled
  8196. * @returns the current depth writing state
  8197. */
  8198. getDepthWrite(): boolean;
  8199. /**
  8200. * Enable or disable depth writing
  8201. * @param enable defines the state to set
  8202. */
  8203. setDepthWrite(enable: boolean): void;
  8204. /**
  8205. * Enable or disable color writing
  8206. * @param enable defines the state to set
  8207. */
  8208. setColorWrite(enable: boolean): void;
  8209. /**
  8210. * Gets a boolean indicating if color writing is enabled
  8211. * @returns the current color writing state
  8212. */
  8213. getColorWrite(): boolean;
  8214. /**
  8215. * Sets alpha constants used by some alpha blending modes
  8216. * @param r defines the red component
  8217. * @param g defines the green component
  8218. * @param b defines the blue component
  8219. * @param a defines the alpha component
  8220. */
  8221. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8222. /**
  8223. * Sets the current alpha mode
  8224. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8225. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8226. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8227. */
  8228. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8229. /**
  8230. * Gets the current alpha mode
  8231. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8232. * @returns the current alpha mode
  8233. */
  8234. getAlphaMode(): number;
  8235. /**
  8236. * Clears the list of texture accessible through engine.
  8237. * This can help preventing texture load conflict due to name collision.
  8238. */
  8239. clearInternalTexturesCache(): void;
  8240. /**
  8241. * Force the entire cache to be cleared
  8242. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8243. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8244. */
  8245. wipeCaches(bruteForce?: boolean): void;
  8246. /**
  8247. * Set the compressed texture format to use, based on the formats you have, and the formats
  8248. * supported by the hardware / browser.
  8249. *
  8250. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8251. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8252. * to API arguments needed to compressed textures. This puts the burden on the container
  8253. * generator to house the arcane code for determining these for current & future formats.
  8254. *
  8255. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8256. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8257. *
  8258. * Note: The result of this call is not taken into account when a texture is base64.
  8259. *
  8260. * @param formatsAvailable defines the list of those format families you have created
  8261. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8262. *
  8263. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8264. * @returns The extension selected.
  8265. */
  8266. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8267. private _getSamplingParameters(samplingMode, generateMipMaps);
  8268. private _partialLoadImg(url, index, loadedImages, scene, onfinish, onErrorCallBack?);
  8269. private _cascadeLoadImgs(rootUrl, scene, onfinish, files, onError?);
  8270. /** @hidden */
  8271. _createTexture(): WebGLTexture;
  8272. /**
  8273. * Usually called from BABYLON.Texture.ts.
  8274. * Passed information to create a WebGLTexture
  8275. * @param urlArg defines a value which contains one of the following:
  8276. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8277. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8278. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8279. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8280. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8281. * @param scene needed for loading to the correct scene
  8282. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8283. * @param onLoad optional callback to be called upon successful completion
  8284. * @param onError optional callback to be called upon failure
  8285. * @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
  8286. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8287. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8288. * @param forcedExtension defines the extension to use to pick the right loader
  8289. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8290. */
  8291. 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;
  8292. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  8293. /**
  8294. * Update a raw texture
  8295. * @param texture defines the texture to update
  8296. * @param data defines the data to store in the texture
  8297. * @param format defines the format of the data
  8298. * @param invertY defines if data must be stored with Y axis inverted
  8299. * @param compression defines the compression used (null by default)
  8300. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8301. */
  8302. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8303. /**
  8304. * Creates a raw texture
  8305. * @param data defines the data to store in the texture
  8306. * @param width defines the width of the texture
  8307. * @param height defines the height of the texture
  8308. * @param format defines the format of the data
  8309. * @param generateMipMaps defines if the engine should generate the mip levels
  8310. * @param invertY defines if data must be stored with Y axis inverted
  8311. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8312. * @param compression defines the compression used (null by default)
  8313. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8314. * @returns the raw texture inside an InternalTexture
  8315. */
  8316. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8317. private _unpackFlipYCached;
  8318. /** @hidden */
  8319. _unpackFlipY(value: boolean): void;
  8320. /** @hidden */
  8321. _getUnpackAlignement(): number;
  8322. /**
  8323. * Creates a dynamic texture
  8324. * @param width defines the width of the texture
  8325. * @param height defines the height of the texture
  8326. * @param generateMipMaps defines if the engine should generate the mip levels
  8327. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8328. * @returns the dynamic texture inside an InternalTexture
  8329. */
  8330. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8331. /**
  8332. * Update the sampling mode of a given texture
  8333. * @param samplingMode defines the required sampling mode
  8334. * @param texture defines the texture to update
  8335. */
  8336. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8337. /**
  8338. * Update the content of a dynamic texture
  8339. * @param texture defines the texture to update
  8340. * @param canvas defines the canvas containing the source
  8341. * @param invertY defines if data must be stored with Y axis inverted
  8342. * @param premulAlpha defines if alpha is stored as premultiplied
  8343. * @param format defines the format of the data
  8344. */
  8345. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8346. /**
  8347. * Update a video texture
  8348. * @param texture defines the texture to update
  8349. * @param video defines the video element to use
  8350. * @param invertY defines if data must be stored with Y axis inverted
  8351. */
  8352. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8353. /**
  8354. * Updates a depth texture Comparison Mode and Function.
  8355. * If the comparison Function is equal to 0, the mode will be set to none.
  8356. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8357. * @param texture The texture to set the comparison function for
  8358. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8359. */
  8360. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8361. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  8362. /**
  8363. * Creates a depth stencil texture.
  8364. * This is only available in WebGL 2 or with the depth texture extension available.
  8365. * @param size The size of face edge in the texture.
  8366. * @param options The options defining the texture.
  8367. * @returns The texture
  8368. */
  8369. createDepthStencilTexture(size: number | {
  8370. width: number;
  8371. height: number;
  8372. }, options: DepthTextureCreationOptions): InternalTexture;
  8373. /**
  8374. * Creates a depth stencil texture.
  8375. * This is only available in WebGL 2 or with the depth texture extension available.
  8376. * @param size The size of face edge in the texture.
  8377. * @param options The options defining the texture.
  8378. * @returns The texture
  8379. */
  8380. private _createDepthStencilTexture(size, options);
  8381. /**
  8382. * Creates a depth stencil cube texture.
  8383. * This is only available in WebGL 2.
  8384. * @param size The size of face edge in the cube texture.
  8385. * @param options The options defining the cube texture.
  8386. * @returns The cube texture
  8387. */
  8388. private _createDepthStencilCubeTexture(size, options);
  8389. /**
  8390. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8391. * @param renderTarget The render target to set the frame buffer for
  8392. */
  8393. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8394. /**
  8395. * Creates a new render target texture
  8396. * @param size defines the size of the texture
  8397. * @param options defines the options used to create the texture
  8398. * @returns a new render target texture stored in an InternalTexture
  8399. */
  8400. createRenderTargetTexture(size: number | {
  8401. width: number;
  8402. height: number;
  8403. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8404. /**
  8405. * Create a multi render target texture
  8406. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8407. * @param size defines the size of the texture
  8408. * @param options defines the creation options
  8409. * @returns the cube texture as an InternalTexture
  8410. */
  8411. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8412. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  8413. /**
  8414. * Updates the sample count of a render target texture
  8415. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8416. * @param texture defines the texture to update
  8417. * @param samples defines the sample count to set
  8418. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8419. */
  8420. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8421. /**
  8422. * Update the sample count for a given multiple render target texture
  8423. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8424. * @param textures defines the textures to update
  8425. * @param samples defines the sample count to set
  8426. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8427. */
  8428. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8429. /** @hidden */
  8430. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8431. /** @hidden */
  8432. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8433. /** @hidden */
  8434. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8435. /** @hidden */
  8436. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  8437. /**
  8438. * Creates a new render target cube texture
  8439. * @param size defines the size of the texture
  8440. * @param options defines the options used to create the texture
  8441. * @returns a new render target cube texture stored in an InternalTexture
  8442. */
  8443. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8444. /**
  8445. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8446. * @param rootUrl defines the url where the file to load is located
  8447. * @param scene defines the current scene
  8448. * @param lodScale defines scale to apply to the mip map selection
  8449. * @param lodOffset defines offset to apply to the mip map selection
  8450. * @param onLoad defines an optional callback raised when the texture is loaded
  8451. * @param onError defines an optional callback raised if there is an issue to load the texture
  8452. * @param format defines the format of the data
  8453. * @param forcedExtension defines the extension to use to pick the right loader
  8454. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8455. * @returns the cube texture as an InternalTexture
  8456. */
  8457. 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;
  8458. /**
  8459. * Creates a cube texture
  8460. * @param rootUrl defines the url where the files to load is located
  8461. * @param scene defines the current scene
  8462. * @param files defines the list of files to load (1 per face)
  8463. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8464. * @param onLoad defines an optional callback raised when the texture is loaded
  8465. * @param onError defines an optional callback raised if there is an issue to load the texture
  8466. * @param format defines the format of the data
  8467. * @param forcedExtension defines the extension to use to pick the right loader
  8468. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8469. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8470. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8471. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8472. * @returns the cube texture as an InternalTexture
  8473. */
  8474. 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;
  8475. /**
  8476. * @hidden
  8477. */
  8478. _setCubeMapTextureParams(loadMipmap: boolean): void;
  8479. /**
  8480. * Update a raw cube texture
  8481. * @param texture defines the texture to udpdate
  8482. * @param data defines the data to store
  8483. * @param format defines the data format
  8484. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8485. * @param invertY defines if data must be stored with Y axis inverted
  8486. * @param compression defines the compression used (null by default)
  8487. * @param level defines which level of the texture to update
  8488. */
  8489. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8490. /**
  8491. * Creates a new raw cube texture
  8492. * @param data defines the array of data to use to create each face
  8493. * @param size defines the size of the textures
  8494. * @param format defines the format of the data
  8495. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8496. * @param generateMipMaps defines if the engine should generate the mip levels
  8497. * @param invertY defines if data must be stored with Y axis inverted
  8498. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8499. * @param compression defines the compression used (null by default)
  8500. * @returns the cube texture as an InternalTexture
  8501. */
  8502. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8503. /**
  8504. * Creates a new raw cube texture from a specified url
  8505. * @param url defines the url where the data is located
  8506. * @param scene defines the current scene
  8507. * @param size defines the size of the textures
  8508. * @param format defines the format of the data
  8509. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8510. * @param noMipmap defines if the engine should avoid generating the mip levels
  8511. * @param callback defines a callback used to extract texture data from loaded data
  8512. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8513. * @param onLoad defines a callback called when texture is loaded
  8514. * @param onError defines a callback called if there is an error
  8515. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8516. * @param invertY defines if data must be stored with Y axis inverted
  8517. * @returns the cube texture as an InternalTexture
  8518. */
  8519. 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;
  8520. /**
  8521. * Update a raw 3D texture
  8522. * @param texture defines the texture to update
  8523. * @param data defines the data to store
  8524. * @param format defines the data format
  8525. * @param invertY defines if data must be stored with Y axis inverted
  8526. * @param compression defines the used compression (can be null)
  8527. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  8528. */
  8529. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  8530. /**
  8531. * Creates a new raw 3D texture
  8532. * @param data defines the data used to create the texture
  8533. * @param width defines the width of the texture
  8534. * @param height defines the height of the texture
  8535. * @param depth defines the depth of the texture
  8536. * @param format defines the format of the texture
  8537. * @param generateMipMaps defines if the engine must generate mip levels
  8538. * @param invertY defines if data must be stored with Y axis inverted
  8539. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8540. * @param compression defines the compressed used (can be null)
  8541. * @param textureType defines the compressed used (can be null)
  8542. * @returns a new raw 3D texture (stored in an InternalTexture)
  8543. */
  8544. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  8545. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  8546. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  8547. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  8548. /** @hidden */
  8549. _releaseFramebufferObjects(texture: InternalTexture): void;
  8550. /** @hidden */
  8551. _releaseTexture(texture: InternalTexture): void;
  8552. private setProgram(program);
  8553. private _boundUniforms;
  8554. /**
  8555. * Binds an effect to the webGL context
  8556. * @param effect defines the effect to bind
  8557. */
  8558. bindSamplers(effect: Effect): void;
  8559. private _moveBoundTextureOnTop(internalTexture);
  8560. private _getCorrectTextureChannel(channel, internalTexture);
  8561. private _linkTrackers(previous, next);
  8562. private _removeDesignatedSlot(internalTexture);
  8563. private _activateCurrentTexture();
  8564. /** @hidden */
  8565. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  8566. /** @hidden */
  8567. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  8568. /**
  8569. * Sets a texture to the webGL context from a postprocess
  8570. * @param channel defines the channel to use
  8571. * @param postProcess defines the source postprocess
  8572. */
  8573. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8574. /**
  8575. * Binds the output of the passed in post process to the texture channel specified
  8576. * @param channel The channel the texture should be bound to
  8577. * @param postProcess The post process which's output should be bound
  8578. */
  8579. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8580. /**
  8581. * Unbind all textures from the webGL context
  8582. */
  8583. unbindAllTextures(): void;
  8584. /**
  8585. * Sets a texture to the according uniform.
  8586. * @param channel The texture channel
  8587. * @param uniform The uniform to set
  8588. * @param texture The texture to apply
  8589. */
  8590. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8591. /**
  8592. * Sets a depth stencil texture from a render target to the according uniform.
  8593. * @param channel The texture channel
  8594. * @param uniform The uniform to set
  8595. * @param texture The render target texture containing the depth stencil texture to apply
  8596. */
  8597. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8598. private _bindSamplerUniformToChannel(sourceSlot, destination);
  8599. private _getTextureWrapMode(mode);
  8600. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  8601. /**
  8602. * Sets an array of texture to the webGL context
  8603. * @param channel defines the channel where the texture array must be set
  8604. * @param uniform defines the associated uniform location
  8605. * @param textures defines the array of textures to bind
  8606. */
  8607. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8608. /** @hidden */
  8609. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  8610. private _setTextureParameterFloat(target, parameter, value, texture);
  8611. private _setTextureParameterInteger(target, parameter, value, texture?);
  8612. /**
  8613. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8614. * @param x defines the x coordinate of the rectangle where pixels must be read
  8615. * @param y defines the y coordinate of the rectangle where pixels must be read
  8616. * @param width defines the width of the rectangle where pixels must be read
  8617. * @param height defines the height of the rectangle where pixels must be read
  8618. * @returns a Uint8Array containing RGBA colors
  8619. */
  8620. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8621. /**
  8622. * Add an externaly attached data from its key.
  8623. * This method call will fail and return false, if such key already exists.
  8624. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8625. * @param key the unique key that identifies the data
  8626. * @param data the data object to associate to the key for this Engine instance
  8627. * @return true if no such key were already present and the data was added successfully, false otherwise
  8628. */
  8629. addExternalData<T>(key: string, data: T): boolean;
  8630. /**
  8631. * Get an externaly attached data from its key
  8632. * @param key the unique key that identifies the data
  8633. * @return the associated data, if present (can be null), or undefined if not present
  8634. */
  8635. getExternalData<T>(key: string): T;
  8636. /**
  8637. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8638. * @param key the unique key that identifies the data
  8639. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8640. * @return the associated data, can be null if the factory returned null.
  8641. */
  8642. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8643. /**
  8644. * Remove an externaly attached data from the Engine instance
  8645. * @param key the unique key that identifies the data
  8646. * @return true if the data was successfully removed, false if it doesn't exist
  8647. */
  8648. removeExternalData(key: string): boolean;
  8649. /**
  8650. * Unbind all vertex attributes from the webGL context
  8651. */
  8652. unbindAllAttributes(): void;
  8653. /**
  8654. * 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
  8655. */
  8656. releaseEffects(): void;
  8657. /**
  8658. * Dispose and release all associated resources
  8659. */
  8660. dispose(): void;
  8661. /**
  8662. * Display the loading screen
  8663. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8664. */
  8665. displayLoadingUI(): void;
  8666. /**
  8667. * Hide the loading screen
  8668. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8669. */
  8670. hideLoadingUI(): void;
  8671. /**
  8672. * Gets the current loading screen object
  8673. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8674. */
  8675. /**
  8676. * Sets the current loading screen object
  8677. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8678. */
  8679. loadingScreen: ILoadingScreen;
  8680. /**
  8681. * Sets the current loading screen text
  8682. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8683. */
  8684. loadingUIText: string;
  8685. /**
  8686. * Sets the current loading screen background color
  8687. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8688. */
  8689. loadingUIBackgroundColor: string;
  8690. /**
  8691. * Attach a new callback raised when context lost event is fired
  8692. * @param callback defines the callback to call
  8693. */
  8694. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8695. /**
  8696. * Attach a new callback raised when context restored event is fired
  8697. * @param callback defines the callback to call
  8698. */
  8699. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8700. /**
  8701. * Gets the source code of the vertex shader associated with a specific webGL program
  8702. * @param program defines the program to use
  8703. * @returns a string containing the source code of the vertex shader associated with the program
  8704. */
  8705. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  8706. /**
  8707. * Gets the source code of the fragment shader associated with a specific webGL program
  8708. * @param program defines the program to use
  8709. * @returns a string containing the source code of the fragment shader associated with the program
  8710. */
  8711. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  8712. /**
  8713. * Get the current error code of the webGL context
  8714. * @returns the error code
  8715. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8716. */
  8717. getError(): number;
  8718. /**
  8719. * Gets the current framerate
  8720. * @returns a number representing the framerate
  8721. */
  8722. getFps(): number;
  8723. /**
  8724. * Gets the time spent between current and previous frame
  8725. * @returns a number representing the delta time in ms
  8726. */
  8727. getDeltaTime(): number;
  8728. private _measureFps();
  8729. /** @hidden */
  8730. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number): ArrayBufferView;
  8731. private _canRenderToFloatFramebuffer();
  8732. private _canRenderToHalfFloatFramebuffer();
  8733. private _canRenderToFramebuffer(type);
  8734. /** @hidden */
  8735. _getWebGLTextureType(type: number): number;
  8736. private _getInternalFormat(format);
  8737. /** @hidden */
  8738. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  8739. /** @hidden */
  8740. _getRGBAMultiSampleBufferFormat(type: number): number;
  8741. /** @hidden */
  8742. _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;
  8743. /** @hidden */
  8744. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  8745. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  8746. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  8747. /**
  8748. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  8749. * @returns true if the engine can be created
  8750. * @ignorenaming
  8751. */
  8752. static isSupported(): boolean;
  8753. }
  8754. }
  8755. declare module BABYLON {
  8756. class NullEngineOptions {
  8757. renderWidth: number;
  8758. renderHeight: number;
  8759. textureSize: number;
  8760. deterministicLockstep: boolean;
  8761. lockstepMaxSteps: number;
  8762. }
  8763. /**
  8764. * The null engine class provides support for headless version of babylon.js.
  8765. * This can be used in server side scenario or for testing purposes
  8766. */
  8767. class NullEngine extends Engine {
  8768. private _options;
  8769. isDeterministicLockStep(): boolean;
  8770. getLockstepMaxSteps(): number;
  8771. getHardwareScalingLevel(): number;
  8772. constructor(options?: NullEngineOptions);
  8773. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8774. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  8775. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8776. getRenderWidth(useScreen?: boolean): number;
  8777. getRenderHeight(useScreen?: boolean): number;
  8778. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8779. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  8780. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  8781. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8782. bindSamplers(effect: Effect): void;
  8783. enableEffect(effect: Effect): void;
  8784. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8785. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  8786. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  8787. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  8788. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  8789. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  8790. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  8791. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  8792. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  8793. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  8794. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  8795. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  8796. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  8797. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  8798. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  8799. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8800. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8801. setFloat(uniform: WebGLUniformLocation, value: number): void;
  8802. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  8803. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  8804. setBool(uniform: WebGLUniformLocation, bool: number): void;
  8805. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  8806. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  8807. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  8808. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8809. bindBuffers(vertexBuffers: {
  8810. [key: string]: VertexBuffer;
  8811. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  8812. wipeCaches(bruteForce?: boolean): void;
  8813. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8814. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8815. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8816. _createTexture(): WebGLTexture;
  8817. _releaseTexture(texture: InternalTexture): void;
  8818. 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;
  8819. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8820. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8821. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  8822. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8823. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8824. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8825. /**
  8826. * Get the current error code of the webGL context
  8827. * @returns the error code
  8828. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8829. */
  8830. getError(): number;
  8831. /** @hidden */
  8832. _getUnpackAlignement(): number;
  8833. /** @hidden */
  8834. _unpackFlipY(value: boolean): void;
  8835. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8836. /**
  8837. * Updates a dynamic vertex buffer.
  8838. * @param vertexBuffer the vertex buffer to update
  8839. * @param data the data used to update the vertex buffer
  8840. * @param byteOffset the byte offset of the data (optional)
  8841. * @param byteLength the byte length of the data (optional)
  8842. */
  8843. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  8844. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  8845. _bindTexture(channel: number, texture: InternalTexture): void;
  8846. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8847. releaseEffects(): void;
  8848. displayLoadingUI(): void;
  8849. hideLoadingUI(): void;
  8850. /** @hidden */
  8851. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8852. /** @hidden */
  8853. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8854. /** @hidden */
  8855. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  8856. /** @hidden */
  8857. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  8858. }
  8859. }
  8860. interface WebGLRenderingContext {
  8861. readonly RASTERIZER_DISCARD: number;
  8862. readonly DEPTH_COMPONENT24: number;
  8863. readonly TEXTURE_3D: number;
  8864. readonly TEXTURE_2D_ARRAY: number;
  8865. readonly TEXTURE_COMPARE_FUNC: number;
  8866. readonly TEXTURE_COMPARE_MODE: number;
  8867. readonly COMPARE_REF_TO_TEXTURE: number;
  8868. readonly TEXTURE_WRAP_R: number;
  8869. readonly HALF_FLOAT: number;
  8870. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  8871. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  8872. 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;
  8873. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  8874. readonly TRANSFORM_FEEDBACK: number;
  8875. readonly INTERLEAVED_ATTRIBS: number;
  8876. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  8877. createTransformFeedback(): WebGLTransformFeedback;
  8878. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  8879. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  8880. beginTransformFeedback(primitiveMode: number): void;
  8881. endTransformFeedback(): void;
  8882. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  8883. }
  8884. interface ImageBitmap {
  8885. readonly width: number;
  8886. readonly height: number;
  8887. close(): void;
  8888. }
  8889. interface WebGLQuery extends WebGLObject {
  8890. }
  8891. declare var WebGLQuery: {
  8892. prototype: WebGLQuery;
  8893. new (): WebGLQuery;
  8894. };
  8895. interface WebGLSampler extends WebGLObject {
  8896. }
  8897. declare var WebGLSampler: {
  8898. prototype: WebGLSampler;
  8899. new (): WebGLSampler;
  8900. };
  8901. interface WebGLSync extends WebGLObject {
  8902. }
  8903. declare var WebGLSync: {
  8904. prototype: WebGLSync;
  8905. new (): WebGLSync;
  8906. };
  8907. interface WebGLTransformFeedback extends WebGLObject {
  8908. }
  8909. declare var WebGLTransformFeedback: {
  8910. prototype: WebGLTransformFeedback;
  8911. new (): WebGLTransformFeedback;
  8912. };
  8913. interface WebGLVertexArrayObject extends WebGLObject {
  8914. }
  8915. declare var WebGLVertexArrayObject: {
  8916. prototype: WebGLVertexArrayObject;
  8917. new (): WebGLVertexArrayObject;
  8918. };
  8919. declare module BABYLON {
  8920. class Collider {
  8921. /** Define if a collision was found */
  8922. collisionFound: boolean;
  8923. /**
  8924. * Define last intersection point in local space
  8925. */
  8926. intersectionPoint: Vector3;
  8927. /**
  8928. * Define last collided mesh
  8929. */
  8930. collidedMesh: Nullable<AbstractMesh>;
  8931. private _collisionPoint;
  8932. private _planeIntersectionPoint;
  8933. private _tempVector;
  8934. private _tempVector2;
  8935. private _tempVector3;
  8936. private _tempVector4;
  8937. private _edge;
  8938. private _baseToVertex;
  8939. private _destinationPoint;
  8940. private _slidePlaneNormal;
  8941. private _displacementVector;
  8942. _radius: Vector3;
  8943. _retry: number;
  8944. private _velocity;
  8945. private _basePoint;
  8946. private _epsilon;
  8947. _velocityWorldLength: number;
  8948. _basePointWorld: Vector3;
  8949. private _velocityWorld;
  8950. private _normalizedVelocity;
  8951. _initialVelocity: Vector3;
  8952. _initialPosition: Vector3;
  8953. private _nearestDistance;
  8954. private _collisionMask;
  8955. collisionMask: number;
  8956. /**
  8957. * Gets the plane normal used to compute the sliding response (in local space)
  8958. */
  8959. readonly slidePlaneNormal: Vector3;
  8960. _initialize(source: Vector3, dir: Vector3, e: number): void;
  8961. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  8962. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  8963. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  8964. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  8965. _getResponse(pos: Vector3, vel: Vector3): void;
  8966. }
  8967. }
  8968. declare module BABYLON {
  8969. var CollisionWorker: string;
  8970. interface ICollisionCoordinator {
  8971. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  8972. init(scene: Scene): void;
  8973. destroy(): void;
  8974. onMeshAdded(mesh: AbstractMesh): void;
  8975. onMeshUpdated(mesh: AbstractMesh): void;
  8976. onMeshRemoved(mesh: AbstractMesh): void;
  8977. onGeometryAdded(geometry: Geometry): void;
  8978. onGeometryUpdated(geometry: Geometry): void;
  8979. onGeometryDeleted(geometry: Geometry): void;
  8980. }
  8981. interface SerializedMesh {
  8982. id: string;
  8983. name: string;
  8984. uniqueId: number;
  8985. geometryId: Nullable<string>;
  8986. sphereCenter: Array<number>;
  8987. sphereRadius: number;
  8988. boxMinimum: Array<number>;
  8989. boxMaximum: Array<number>;
  8990. worldMatrixFromCache: any;
  8991. subMeshes: Array<SerializedSubMesh>;
  8992. checkCollisions: boolean;
  8993. }
  8994. interface SerializedSubMesh {
  8995. position: number;
  8996. verticesStart: number;
  8997. verticesCount: number;
  8998. indexStart: number;
  8999. indexCount: number;
  9000. hasMaterial: boolean;
  9001. sphereCenter: Array<number>;
  9002. sphereRadius: number;
  9003. boxMinimum: Array<number>;
  9004. boxMaximum: Array<number>;
  9005. }
  9006. /**
  9007. * Interface describing the value associated with a geometry
  9008. */
  9009. interface SerializedGeometry {
  9010. /**
  9011. * Defines the unique ID of the geometry
  9012. */
  9013. id: string;
  9014. /**
  9015. * Defines the array containing the positions
  9016. */
  9017. positions: Float32Array;
  9018. /**
  9019. * Defines the array containing the indices
  9020. */
  9021. indices: Uint32Array;
  9022. /**
  9023. * Defines the array containing the normals
  9024. */
  9025. normals: Float32Array;
  9026. }
  9027. interface BabylonMessage {
  9028. taskType: WorkerTaskType;
  9029. payload: InitPayload | CollidePayload | UpdatePayload;
  9030. }
  9031. interface SerializedColliderToWorker {
  9032. position: Array<number>;
  9033. velocity: Array<number>;
  9034. radius: Array<number>;
  9035. }
  9036. /** Defines supported task for worker process */
  9037. enum WorkerTaskType {
  9038. /** Initialization */
  9039. INIT = 0,
  9040. /** Update of geometry */
  9041. UPDATE = 1,
  9042. /** Evaluate collision */
  9043. COLLIDE = 2,
  9044. }
  9045. interface WorkerReply {
  9046. error: WorkerReplyType;
  9047. taskType: WorkerTaskType;
  9048. payload?: any;
  9049. }
  9050. interface CollisionReplyPayload {
  9051. newPosition: Array<number>;
  9052. collisionId: number;
  9053. collidedMeshUniqueId: number;
  9054. }
  9055. interface InitPayload {
  9056. }
  9057. interface CollidePayload {
  9058. collisionId: number;
  9059. collider: SerializedColliderToWorker;
  9060. maximumRetry: number;
  9061. excludedMeshUniqueId: Nullable<number>;
  9062. }
  9063. interface UpdatePayload {
  9064. updatedMeshes: {
  9065. [n: number]: SerializedMesh;
  9066. };
  9067. updatedGeometries: {
  9068. [s: string]: SerializedGeometry;
  9069. };
  9070. removedMeshes: Array<number>;
  9071. removedGeometries: Array<string>;
  9072. }
  9073. /** Defines kind of replies returned by worker */
  9074. enum WorkerReplyType {
  9075. /** Success */
  9076. SUCCESS = 0,
  9077. /** Unkown error */
  9078. UNKNOWN_ERROR = 1,
  9079. }
  9080. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  9081. private _scene;
  9082. private _scaledPosition;
  9083. private _scaledVelocity;
  9084. private _collisionsCallbackArray;
  9085. private _init;
  9086. private _runningUpdated;
  9087. private _worker;
  9088. private _addUpdateMeshesList;
  9089. private _addUpdateGeometriesList;
  9090. private _toRemoveMeshesArray;
  9091. private _toRemoveGeometryArray;
  9092. constructor();
  9093. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  9094. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  9095. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9096. init(scene: Scene): void;
  9097. destroy(): void;
  9098. onMeshAdded(mesh: AbstractMesh): void;
  9099. onMeshUpdated: (transformNode: TransformNode) => void;
  9100. onMeshRemoved(mesh: AbstractMesh): void;
  9101. onGeometryAdded(geometry: Geometry): void;
  9102. onGeometryUpdated: (geometry: Geometry) => void;
  9103. onGeometryDeleted(geometry: Geometry): void;
  9104. private _afterRender;
  9105. private _onMessageFromWorker;
  9106. }
  9107. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  9108. private _scene;
  9109. private _scaledPosition;
  9110. private _scaledVelocity;
  9111. private _finalPosition;
  9112. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9113. init(scene: Scene): void;
  9114. destroy(): void;
  9115. onMeshAdded(mesh: AbstractMesh): void;
  9116. onMeshUpdated(mesh: AbstractMesh): void;
  9117. onMeshRemoved(mesh: AbstractMesh): void;
  9118. onGeometryAdded(geometry: Geometry): void;
  9119. onGeometryUpdated(geometry: Geometry): void;
  9120. onGeometryDeleted(geometry: Geometry): void;
  9121. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  9122. }
  9123. }
  9124. declare function importScripts(...urls: string[]): void;
  9125. declare const safePostMessage: any;
  9126. declare module BABYLON {
  9127. var WorkerIncluded: boolean;
  9128. class CollisionCache {
  9129. private _meshes;
  9130. private _geometries;
  9131. getMeshes(): {
  9132. [n: number]: SerializedMesh;
  9133. };
  9134. getGeometries(): {
  9135. [s: number]: SerializedGeometry;
  9136. };
  9137. getMesh(id: any): SerializedMesh;
  9138. addMesh(mesh: SerializedMesh): void;
  9139. removeMesh(uniqueId: number): void;
  9140. getGeometry(id: string): SerializedGeometry;
  9141. addGeometry(geometry: SerializedGeometry): void;
  9142. removeGeometry(id: string): void;
  9143. }
  9144. class CollideWorker {
  9145. collider: Collider;
  9146. private _collisionCache;
  9147. private finalPosition;
  9148. private collisionsScalingMatrix;
  9149. private collisionTranformationMatrix;
  9150. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  9151. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  9152. private checkCollision(mesh);
  9153. private processCollisionsForSubMeshes(transformMatrix, mesh);
  9154. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  9155. private checkSubmeshCollision(subMesh);
  9156. }
  9157. interface ICollisionDetector {
  9158. onInit(payload: InitPayload): void;
  9159. onUpdate(payload: UpdatePayload): void;
  9160. onCollision(payload: CollidePayload): void;
  9161. }
  9162. class CollisionDetectorTransferable implements ICollisionDetector {
  9163. private _collisionCache;
  9164. onInit(payload: InitPayload): void;
  9165. onUpdate(payload: UpdatePayload): void;
  9166. onCollision(payload: CollidePayload): void;
  9167. }
  9168. }
  9169. declare module BABYLON {
  9170. class IntersectionInfo {
  9171. bu: Nullable<number>;
  9172. bv: Nullable<number>;
  9173. distance: number;
  9174. faceId: number;
  9175. subMeshId: number;
  9176. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  9177. }
  9178. /**
  9179. * Information about the result of picking within a scene
  9180. * See https://doc.babylonjs.com/babylon101/picking_collisions
  9181. */
  9182. class PickingInfo {
  9183. /**
  9184. * If the pick collided with an object
  9185. */
  9186. hit: boolean;
  9187. /**
  9188. * Distance away where the pick collided
  9189. */
  9190. distance: number;
  9191. /**
  9192. * The location of pick collision
  9193. */
  9194. pickedPoint: Nullable<Vector3>;
  9195. /**
  9196. * The mesh corrisponding the the pick collision
  9197. */
  9198. pickedMesh: Nullable<AbstractMesh>;
  9199. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  9200. bu: number;
  9201. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  9202. bv: number;
  9203. /** The id of the face on the mesh that was picked */
  9204. faceId: number;
  9205. /** Id of the the submesh that was picked */
  9206. subMeshId: number;
  9207. /** If a sprite was picked, this will be the sprite the pick collided with */
  9208. pickedSprite: Nullable<Sprite>;
  9209. /**
  9210. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  9211. */
  9212. originMesh: Nullable<AbstractMesh>;
  9213. /**
  9214. * The ray that was used to perform the picking.
  9215. */
  9216. ray: Nullable<Ray>;
  9217. /**
  9218. * Gets the normal corrispodning to the face the pick collided with
  9219. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  9220. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  9221. * @returns The normal corrispodning to the face the pick collided with
  9222. */
  9223. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  9224. /**
  9225. * Gets the texture coordinates of where the pick occured
  9226. * @returns the vector containing the coordnates of the texture
  9227. */
  9228. getTextureCoordinates(): Nullable<Vector2>;
  9229. }
  9230. }
  9231. declare module BABYLON {
  9232. class KeyboardEventTypes {
  9233. static _KEYDOWN: number;
  9234. static _KEYUP: number;
  9235. static readonly KEYDOWN: number;
  9236. static readonly KEYUP: number;
  9237. }
  9238. class KeyboardInfo {
  9239. type: number;
  9240. event: KeyboardEvent;
  9241. constructor(type: number, event: KeyboardEvent);
  9242. }
  9243. /**
  9244. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9245. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9246. */
  9247. class KeyboardInfoPre extends KeyboardInfo {
  9248. constructor(type: number, event: KeyboardEvent);
  9249. skipOnPointerObservable: boolean;
  9250. }
  9251. }
  9252. declare module BABYLON {
  9253. class PointerEventTypes {
  9254. static _POINTERDOWN: number;
  9255. static _POINTERUP: number;
  9256. static _POINTERMOVE: number;
  9257. static _POINTERWHEEL: number;
  9258. static _POINTERPICK: number;
  9259. static _POINTERTAP: number;
  9260. static _POINTERDOUBLETAP: number;
  9261. static readonly POINTERDOWN: number;
  9262. static readonly POINTERUP: number;
  9263. static readonly POINTERMOVE: number;
  9264. static readonly POINTERWHEEL: number;
  9265. static readonly POINTERPICK: number;
  9266. static readonly POINTERTAP: number;
  9267. static readonly POINTERDOUBLETAP: number;
  9268. }
  9269. class PointerInfoBase {
  9270. type: number;
  9271. event: PointerEvent | MouseWheelEvent;
  9272. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9273. }
  9274. /**
  9275. * This class is used to store pointer related info for the onPrePointerObservable event.
  9276. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9277. */
  9278. class PointerInfoPre extends PointerInfoBase {
  9279. /**
  9280. * Ray from a pointer if availible (eg. 6dof controller)
  9281. */
  9282. ray: Nullable<Ray>;
  9283. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9284. localPosition: Vector2;
  9285. skipOnPointerObservable: boolean;
  9286. }
  9287. /**
  9288. * This type contains all the data related to a pointer event in Babylon.js.
  9289. * 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.
  9290. */
  9291. class PointerInfo extends PointerInfoBase {
  9292. pickInfo: Nullable<PickingInfo>;
  9293. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9294. }
  9295. }
  9296. declare module BABYLON {
  9297. class StickValues {
  9298. x: number;
  9299. y: number;
  9300. constructor(x: number, y: number);
  9301. }
  9302. interface GamepadButtonChanges {
  9303. changed: boolean;
  9304. pressChanged: boolean;
  9305. touchChanged: boolean;
  9306. valueChanged: boolean;
  9307. }
  9308. class Gamepad {
  9309. id: string;
  9310. index: number;
  9311. browserGamepad: any;
  9312. type: number;
  9313. private _leftStick;
  9314. private _rightStick;
  9315. _isConnected: boolean;
  9316. private _leftStickAxisX;
  9317. private _leftStickAxisY;
  9318. private _rightStickAxisX;
  9319. private _rightStickAxisY;
  9320. private _onleftstickchanged;
  9321. private _onrightstickchanged;
  9322. static GAMEPAD: number;
  9323. static GENERIC: number;
  9324. static XBOX: number;
  9325. static POSE_ENABLED: number;
  9326. protected _invertLeftStickY: boolean;
  9327. readonly isConnected: boolean;
  9328. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9329. onleftstickchanged(callback: (values: StickValues) => void): void;
  9330. onrightstickchanged(callback: (values: StickValues) => void): void;
  9331. leftStick: StickValues;
  9332. rightStick: StickValues;
  9333. update(): void;
  9334. dispose(): void;
  9335. }
  9336. class GenericPad extends Gamepad {
  9337. private _buttons;
  9338. private _onbuttondown;
  9339. private _onbuttonup;
  9340. onButtonDownObservable: Observable<number>;
  9341. onButtonUpObservable: Observable<number>;
  9342. onbuttondown(callback: (buttonPressed: number) => void): void;
  9343. onbuttonup(callback: (buttonReleased: number) => void): void;
  9344. constructor(id: string, index: number, browserGamepad: any);
  9345. private _setButtonValue(newValue, currentValue, buttonIndex);
  9346. update(): void;
  9347. dispose(): void;
  9348. }
  9349. }
  9350. declare module BABYLON {
  9351. class GamepadManager {
  9352. private _scene;
  9353. private _babylonGamepads;
  9354. private _oneGamepadConnected;
  9355. _isMonitoring: boolean;
  9356. private _gamepadEventSupported;
  9357. private _gamepadSupport;
  9358. onGamepadConnectedObservable: Observable<Gamepad>;
  9359. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9360. private _onGamepadConnectedEvent;
  9361. private _onGamepadDisconnectedEvent;
  9362. constructor(_scene?: Scene | undefined);
  9363. readonly gamepads: Gamepad[];
  9364. getGamepadByType(type?: number): Nullable<Gamepad>;
  9365. dispose(): void;
  9366. private _addNewGamepad(gamepad);
  9367. private _startMonitoringGamepads();
  9368. private _stopMonitoringGamepads();
  9369. _checkGamepadsStatus(): void;
  9370. private _updateGamepadObjects();
  9371. }
  9372. }
  9373. declare module BABYLON {
  9374. interface Scene {
  9375. /** @hidden */
  9376. _gamepadManager: Nullable<GamepadManager>;
  9377. /**
  9378. * Gets the gamepad manager associated with the scene
  9379. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  9380. */
  9381. gamepadManager: GamepadManager;
  9382. }
  9383. interface FreeCameraInputsManager {
  9384. addGamepad(): FreeCameraInputsManager;
  9385. }
  9386. interface ArcRotateCameraInputsManager {
  9387. addGamepad(): ArcRotateCameraInputsManager;
  9388. }
  9389. /**
  9390. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  9391. */
  9392. class GamepadSystemSceneComponent implements ISceneComponent {
  9393. /**
  9394. * The component name helpfull to identify the component in the list of scene components.
  9395. */
  9396. readonly name: string;
  9397. /**
  9398. * The scene the component belongs to.
  9399. */
  9400. scene: Scene;
  9401. /**
  9402. * Creates a new instance of the component for the given scene
  9403. * @param scene Defines the scene to register the component in
  9404. */
  9405. constructor(scene: Scene);
  9406. /**
  9407. * Registers the component in a given scene
  9408. */
  9409. register(): void;
  9410. /**
  9411. * Rebuilds the elements related to this component in case of
  9412. * context lost for instance.
  9413. */
  9414. rebuild(): void;
  9415. /**
  9416. * Disposes the component and the associated ressources
  9417. */
  9418. dispose(): void;
  9419. private _beforeCameraUpdate();
  9420. }
  9421. }
  9422. declare module BABYLON {
  9423. /**
  9424. * Defines supported buttons for XBox360 compatible gamepads
  9425. */
  9426. enum Xbox360Button {
  9427. /** A */
  9428. A = 0,
  9429. /** B */
  9430. B = 1,
  9431. /** X */
  9432. X = 2,
  9433. /** Y */
  9434. Y = 3,
  9435. /** Start */
  9436. Start = 4,
  9437. /** Back */
  9438. Back = 5,
  9439. /** Left button */
  9440. LB = 6,
  9441. /** Right button */
  9442. RB = 7,
  9443. /** Left stick */
  9444. LeftStick = 8,
  9445. /** Right stick */
  9446. RightStick = 9,
  9447. }
  9448. /** Defines values for XBox360 DPad */
  9449. enum Xbox360Dpad {
  9450. /** Up */
  9451. Up = 0,
  9452. /** Down */
  9453. Down = 1,
  9454. /** Left */
  9455. Left = 2,
  9456. /** Right */
  9457. Right = 3,
  9458. }
  9459. /**
  9460. * Defines a XBox360 gamepad
  9461. */
  9462. class Xbox360Pad extends Gamepad {
  9463. private _leftTrigger;
  9464. private _rightTrigger;
  9465. private _onlefttriggerchanged;
  9466. private _onrighttriggerchanged;
  9467. private _onbuttondown;
  9468. private _onbuttonup;
  9469. private _ondpaddown;
  9470. private _ondpadup;
  9471. /** Observable raised when a button is pressed */
  9472. onButtonDownObservable: Observable<Xbox360Button>;
  9473. /** Observable raised when a button is released */
  9474. onButtonUpObservable: Observable<Xbox360Button>;
  9475. /** Observable raised when a pad is pressed */
  9476. onPadDownObservable: Observable<Xbox360Dpad>;
  9477. /** Observable raised when a pad is released */
  9478. onPadUpObservable: Observable<Xbox360Dpad>;
  9479. private _buttonA;
  9480. private _buttonB;
  9481. private _buttonX;
  9482. private _buttonY;
  9483. private _buttonBack;
  9484. private _buttonStart;
  9485. private _buttonLB;
  9486. private _buttonRB;
  9487. private _buttonLeftStick;
  9488. private _buttonRightStick;
  9489. private _dPadUp;
  9490. private _dPadDown;
  9491. private _dPadLeft;
  9492. private _dPadRight;
  9493. private _isXboxOnePad;
  9494. /**
  9495. * Creates a new XBox360 gamepad object
  9496. * @param id defines the id of this gamepad
  9497. * @param index defines its index
  9498. * @param gamepad defines the internal HTML gamepad object
  9499. * @param xboxOne defines if it is a XBox One gamepad
  9500. */
  9501. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9502. /**
  9503. * Defines the callback to call when left trigger is pressed
  9504. * @param callback defines the callback to use
  9505. */
  9506. onlefttriggerchanged(callback: (value: number) => void): void;
  9507. /**
  9508. * Defines the callback to call when right trigger is pressed
  9509. * @param callback defines the callback to use
  9510. */
  9511. onrighttriggerchanged(callback: (value: number) => void): void;
  9512. /**
  9513. * Gets or sets left trigger value
  9514. */
  9515. leftTrigger: number;
  9516. /**
  9517. * Gets or sets right trigger value
  9518. */
  9519. rightTrigger: number;
  9520. /**
  9521. * Defines the callback to call when a button is pressed
  9522. * @param callback defines the callback to use
  9523. */
  9524. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9525. /**
  9526. * Defines the callback to call when a button is released
  9527. * @param callback defines the callback to use
  9528. */
  9529. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9530. /**
  9531. * Defines the callback to call when a pad is pressed
  9532. * @param callback defines the callback to use
  9533. */
  9534. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9535. /**
  9536. * Defines the callback to call when a pad is released
  9537. * @param callback defines the callback to use
  9538. */
  9539. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9540. private _setButtonValue(newValue, currentValue, buttonType);
  9541. private _setDPadValue(newValue, currentValue, buttonType);
  9542. /** Gets or sets value of A button */
  9543. buttonA: number;
  9544. /** Gets or sets value of B button */
  9545. buttonB: number;
  9546. /** Gets or sets value of X button */
  9547. buttonX: number;
  9548. /** Gets or sets value of Y button */
  9549. buttonY: number;
  9550. /** Gets or sets value of Start button */
  9551. buttonStart: number;
  9552. /** Gets or sets value of Back button */
  9553. buttonBack: number;
  9554. /** Gets or sets value of Left button */
  9555. buttonLB: number;
  9556. /** Gets or sets value of Right button */
  9557. buttonRB: number;
  9558. /** Gets or sets value of left stick */
  9559. buttonLeftStick: number;
  9560. /** Gets or sets value of right stick */
  9561. buttonRightStick: number;
  9562. /** Gets or sets value of DPad up */
  9563. dPadUp: number;
  9564. /** Gets or sets value of DPad down */
  9565. dPadDown: number;
  9566. /** Gets or sets value of DPad left */
  9567. dPadLeft: number;
  9568. /** Gets or sets value of DPad right */
  9569. dPadRight: number;
  9570. /**
  9571. * Force the gamepad to synchronize with device values
  9572. */
  9573. update(): void;
  9574. dispose(): void;
  9575. }
  9576. }
  9577. declare module BABYLON {
  9578. /**
  9579. * Single axis drag gizmo
  9580. */
  9581. class AxisDragGizmo extends Gizmo {
  9582. /**
  9583. * Drag behavior responsible for the gizmos dragging interactions
  9584. */
  9585. dragBehavior: PointerDragBehavior;
  9586. private _pointerObserver;
  9587. /**
  9588. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9589. */
  9590. snapDistance: number;
  9591. /**
  9592. * Event that fires each time the gizmo snaps to a new location.
  9593. * * snapDistance is the the change in distance
  9594. */
  9595. onSnapObservable: Observable<{
  9596. snapDistance: number;
  9597. }>;
  9598. /**
  9599. * Creates an AxisDragGizmo
  9600. * @param gizmoLayer The utility layer the gizmo will be added to
  9601. * @param dragAxis The axis which the gizmo will be able to drag on
  9602. * @param color The color of the gizmo
  9603. */
  9604. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9605. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9606. /**
  9607. * Disposes of the gizmo
  9608. */
  9609. dispose(): void;
  9610. }
  9611. }
  9612. declare module BABYLON {
  9613. /**
  9614. * Single axis scale gizmo
  9615. */
  9616. class AxisScaleGizmo extends Gizmo {
  9617. /**
  9618. * Drag behavior responsible for the gizmos dragging interactions
  9619. */
  9620. dragBehavior: PointerDragBehavior;
  9621. private _pointerObserver;
  9622. /**
  9623. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  9624. */
  9625. snapDistance: number;
  9626. /**
  9627. * Event that fires each time the gizmo snaps to a new location.
  9628. * * snapDistance is the the change in distance
  9629. */
  9630. onSnapObservable: Observable<{
  9631. snapDistance: number;
  9632. }>;
  9633. /**
  9634. * Creates an AxisScaleGizmo
  9635. * @param gizmoLayer The utility layer the gizmo will be added to
  9636. * @param dragAxis The axis which the gizmo will be able to scale on
  9637. * @param color The color of the gizmo
  9638. */
  9639. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9640. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9641. /**
  9642. * Disposes of the gizmo
  9643. */
  9644. dispose(): void;
  9645. }
  9646. }
  9647. declare module BABYLON {
  9648. /**
  9649. * Bounding box gizmo
  9650. */
  9651. class BoundingBoxGizmo extends Gizmo {
  9652. private _lineBoundingBox;
  9653. private _rotateSpheresParent;
  9654. private _scaleBoxesParent;
  9655. private _boundingDimensions;
  9656. private _renderObserver;
  9657. private _pointerObserver;
  9658. private _scaleDragSpeed;
  9659. private _tmpQuaternion;
  9660. private _tmpVector;
  9661. /**
  9662. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  9663. */
  9664. rotationSphereSize: number;
  9665. /**
  9666. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  9667. */
  9668. scaleBoxSize: number;
  9669. /**
  9670. * 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)
  9671. */
  9672. fixedDragMeshScreenSize: boolean;
  9673. /**
  9674. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  9675. */
  9676. fixedDragMeshScreenSizeDistanceFactor: number;
  9677. /**
  9678. * Fired when a rotation sphere or scale box is dragged
  9679. */
  9680. onDragStartObservable: Observable<{}>;
  9681. /**
  9682. * Fired when a rotation sphere or scale box drag is started
  9683. */
  9684. onDragObservable: Observable<{}>;
  9685. /**
  9686. * Fired when a rotation sphere or scale box drag is needed
  9687. */
  9688. onDragEndObservable: Observable<{}>;
  9689. private _anchorMesh;
  9690. private _existingMeshScale;
  9691. /**
  9692. * Creates an BoundingBoxGizmo
  9693. * @param gizmoLayer The utility layer the gizmo will be added to
  9694. * @param color The color of the gizmo
  9695. */
  9696. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9697. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9698. private _selectNode(selectedMesh);
  9699. private _recurseComputeWorld(mesh);
  9700. /**
  9701. * Updates the bounding box information for the Gizmo
  9702. */
  9703. updateBoundingBox(): void;
  9704. /**
  9705. * Enables rotation on the specified axis and disables rotation on the others
  9706. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  9707. */
  9708. setEnabledRotationAxis(axis: string): void;
  9709. /**
  9710. * Disposes of the gizmo
  9711. */
  9712. dispose(): void;
  9713. /**
  9714. * 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)
  9715. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  9716. * @returns the bounding box mesh with the passed in mesh as a child
  9717. */
  9718. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  9719. /**
  9720. * CustomMeshes are not supported by this gizmo
  9721. * @param mesh The mesh to replace the default mesh of the gizmo
  9722. */
  9723. setCustomMesh(mesh: Mesh): void;
  9724. }
  9725. }
  9726. declare module BABYLON {
  9727. /**
  9728. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  9729. */
  9730. class Gizmo implements IDisposable {
  9731. /** The utility layer the gizmo will be added to */
  9732. gizmoLayer: UtilityLayerRenderer;
  9733. /**
  9734. * The root mesh of the gizmo
  9735. */
  9736. protected _rootMesh: Mesh;
  9737. private _attachedMesh;
  9738. private _scaleFactor;
  9739. private _tmpMatrix;
  9740. /**
  9741. * If a custom mesh has been set (Default: false)
  9742. */
  9743. protected _customMeshSet: boolean;
  9744. /**
  9745. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  9746. * * When set, interactions will be enabled
  9747. */
  9748. attachedMesh: Nullable<AbstractMesh>;
  9749. /**
  9750. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  9751. * @param mesh The mesh to replace the default mesh of the gizmo
  9752. */
  9753. setCustomMesh(mesh: Mesh): void;
  9754. /**
  9755. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  9756. */
  9757. updateGizmoRotationToMatchAttachedMesh: boolean;
  9758. /**
  9759. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  9760. */
  9761. updateGizmoPositionToMatchAttachedMesh: boolean;
  9762. /**
  9763. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  9764. */
  9765. protected _updateScale: boolean;
  9766. protected _interactionsEnabled: boolean;
  9767. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9768. private _beforeRenderObserver;
  9769. /**
  9770. * Creates a gizmo
  9771. * @param gizmoLayer The utility layer the gizmo will be added to
  9772. */
  9773. constructor(
  9774. /** The utility layer the gizmo will be added to */
  9775. gizmoLayer?: UtilityLayerRenderer);
  9776. private _tempVector;
  9777. /**
  9778. * @hidden
  9779. * Updates the gizmo to match the attached mesh's position/rotation
  9780. */
  9781. protected _update(): void;
  9782. /**
  9783. * Disposes of the gizmo
  9784. */
  9785. dispose(): void;
  9786. }
  9787. }
  9788. declare module BABYLON {
  9789. /**
  9790. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  9791. */
  9792. class GizmoManager implements IDisposable {
  9793. private scene;
  9794. /**
  9795. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  9796. */
  9797. gizmos: {
  9798. positionGizmo: Nullable<PositionGizmo>;
  9799. rotationGizmo: Nullable<RotationGizmo>;
  9800. scaleGizmo: Nullable<ScaleGizmo>;
  9801. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  9802. };
  9803. private _gizmosEnabled;
  9804. private _gizmoLayer;
  9805. private _pointerObserver;
  9806. private _attachedMesh;
  9807. private _boundingBoxColor;
  9808. private _dragBehavior;
  9809. /**
  9810. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  9811. */
  9812. attachableMeshes: Nullable<Array<AbstractMesh>>;
  9813. /**
  9814. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  9815. */
  9816. usePointerToAttachGizmos: boolean;
  9817. /**
  9818. * Instatiates a gizmo manager
  9819. * @param scene the scene to overlay the gizmos on top of
  9820. */
  9821. constructor(scene: Scene);
  9822. /**
  9823. * Attaches a set of gizmos to the specified mesh
  9824. * @param mesh The mesh the gizmo's should be attached to
  9825. */
  9826. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  9827. /**
  9828. * If the position gizmo is enabled
  9829. */
  9830. positionGizmoEnabled: boolean;
  9831. /**
  9832. * If the rotation gizmo is enabled
  9833. */
  9834. rotationGizmoEnabled: boolean;
  9835. /**
  9836. * If the scale gizmo is enabled
  9837. */
  9838. scaleGizmoEnabled: boolean;
  9839. /**
  9840. * If the boundingBox gizmo is enabled
  9841. */
  9842. boundingBoxGizmoEnabled: boolean;
  9843. /**
  9844. * Disposes of the gizmo manager
  9845. */
  9846. dispose(): void;
  9847. }
  9848. }
  9849. declare module BABYLON {
  9850. /**
  9851. * Single plane rotation gizmo
  9852. */
  9853. class PlaneRotationGizmo extends Gizmo {
  9854. /**
  9855. * Drag behavior responsible for the gizmos dragging interactions
  9856. */
  9857. dragBehavior: PointerDragBehavior;
  9858. private _pointerObserver;
  9859. /**
  9860. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  9861. */
  9862. snapDistance: number;
  9863. /**
  9864. * Event that fires each time the gizmo snaps to a new location.
  9865. * * snapDistance is the the change in distance
  9866. */
  9867. onSnapObservable: Observable<{
  9868. snapDistance: number;
  9869. }>;
  9870. /**
  9871. * Creates a PlaneRotationGizmo
  9872. * @param gizmoLayer The utility layer the gizmo will be added to
  9873. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  9874. * @param color The color of the gizmo
  9875. */
  9876. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  9877. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  9878. /**
  9879. * Disposes of the gizmo
  9880. */
  9881. dispose(): void;
  9882. }
  9883. }
  9884. declare module BABYLON {
  9885. /**
  9886. * Gizmo that enables dragging a mesh along 3 axis
  9887. */
  9888. class PositionGizmo extends Gizmo {
  9889. /**
  9890. * Internal gizmo used for interactions on the x axis
  9891. */
  9892. xGizmo: AxisDragGizmo;
  9893. /**
  9894. * Internal gizmo used for interactions on the y axis
  9895. */
  9896. yGizmo: AxisDragGizmo;
  9897. /**
  9898. * Internal gizmo used for interactions on the z axis
  9899. */
  9900. zGizmo: AxisDragGizmo;
  9901. attachedMesh: Nullable<AbstractMesh>;
  9902. /**
  9903. * Creates a PositionGizmo
  9904. * @param gizmoLayer The utility layer the gizmo will be added to
  9905. */
  9906. constructor(gizmoLayer?: UtilityLayerRenderer);
  9907. updateGizmoRotationToMatchAttachedMesh: boolean;
  9908. /**
  9909. * Disposes of the gizmo
  9910. */
  9911. dispose(): void;
  9912. /**
  9913. * CustomMeshes are not supported by this gizmo
  9914. * @param mesh The mesh to replace the default mesh of the gizmo
  9915. */
  9916. setCustomMesh(mesh: Mesh): void;
  9917. }
  9918. }
  9919. declare module BABYLON {
  9920. /**
  9921. * Gizmo that enables rotating a mesh along 3 axis
  9922. */
  9923. class RotationGizmo extends Gizmo {
  9924. /**
  9925. * Internal gizmo used for interactions on the x axis
  9926. */
  9927. xGizmo: PlaneRotationGizmo;
  9928. /**
  9929. * Internal gizmo used for interactions on the y axis
  9930. */
  9931. yGizmo: PlaneRotationGizmo;
  9932. /**
  9933. * Internal gizmo used for interactions on the z axis
  9934. */
  9935. zGizmo: PlaneRotationGizmo;
  9936. attachedMesh: Nullable<AbstractMesh>;
  9937. /**
  9938. * Creates a RotationGizmo
  9939. * @param gizmoLayer The utility layer the gizmo will be added to
  9940. */
  9941. constructor(gizmoLayer?: UtilityLayerRenderer);
  9942. updateGizmoRotationToMatchAttachedMesh: boolean;
  9943. /**
  9944. * Disposes of the gizmo
  9945. */
  9946. dispose(): void;
  9947. /**
  9948. * CustomMeshes are not supported by this gizmo
  9949. * @param mesh The mesh to replace the default mesh of the gizmo
  9950. */
  9951. setCustomMesh(mesh: Mesh): void;
  9952. }
  9953. }
  9954. declare module BABYLON {
  9955. /**
  9956. * Gizmo that enables scaling a mesh along 3 axis
  9957. */
  9958. class ScaleGizmo extends Gizmo {
  9959. /**
  9960. * Internal gizmo used for interactions on the x axis
  9961. */
  9962. xGizmo: AxisScaleGizmo;
  9963. /**
  9964. * Internal gizmo used for interactions on the y axis
  9965. */
  9966. yGizmo: AxisScaleGizmo;
  9967. /**
  9968. * Internal gizmo used for interactions on the z axis
  9969. */
  9970. zGizmo: AxisScaleGizmo;
  9971. attachedMesh: Nullable<AbstractMesh>;
  9972. /**
  9973. * Creates a ScaleGizmo
  9974. * @param gizmoLayer The utility layer the gizmo will be added to
  9975. */
  9976. constructor(gizmoLayer?: UtilityLayerRenderer);
  9977. updateGizmoRotationToMatchAttachedMesh: boolean;
  9978. /**
  9979. * Disposes of the gizmo
  9980. */
  9981. dispose(): void;
  9982. }
  9983. }
  9984. declare module BABYLON {
  9985. /**
  9986. * This class can be used to get instrumentation data from a Babylon engine
  9987. */
  9988. class EngineInstrumentation implements IDisposable {
  9989. engine: Engine;
  9990. private _captureGPUFrameTime;
  9991. private _gpuFrameTimeToken;
  9992. private _gpuFrameTime;
  9993. private _captureShaderCompilationTime;
  9994. private _shaderCompilationTime;
  9995. private _onBeginFrameObserver;
  9996. private _onEndFrameObserver;
  9997. private _onBeforeShaderCompilationObserver;
  9998. private _onAfterShaderCompilationObserver;
  9999. /**
  10000. * Gets the perf counter used for GPU frame time
  10001. */
  10002. readonly gpuFrameTimeCounter: PerfCounter;
  10003. /**
  10004. * Gets the GPU frame time capture status
  10005. */
  10006. /**
  10007. * Enable or disable the GPU frame time capture
  10008. */
  10009. captureGPUFrameTime: boolean;
  10010. /**
  10011. * Gets the perf counter used for shader compilation time
  10012. */
  10013. readonly shaderCompilationTimeCounter: PerfCounter;
  10014. /**
  10015. * Gets the shader compilation time capture status
  10016. */
  10017. /**
  10018. * Enable or disable the shader compilation time capture
  10019. */
  10020. captureShaderCompilationTime: boolean;
  10021. constructor(engine: Engine);
  10022. dispose(): void;
  10023. }
  10024. }
  10025. declare module BABYLON {
  10026. /**
  10027. * This class can be used to get instrumentation data from a Babylon engine
  10028. */
  10029. class SceneInstrumentation implements IDisposable {
  10030. scene: Scene;
  10031. private _captureActiveMeshesEvaluationTime;
  10032. private _activeMeshesEvaluationTime;
  10033. private _captureRenderTargetsRenderTime;
  10034. private _renderTargetsRenderTime;
  10035. private _captureFrameTime;
  10036. private _frameTime;
  10037. private _captureRenderTime;
  10038. private _renderTime;
  10039. private _captureInterFrameTime;
  10040. private _interFrameTime;
  10041. private _captureParticlesRenderTime;
  10042. private _particlesRenderTime;
  10043. private _captureSpritesRenderTime;
  10044. private _spritesRenderTime;
  10045. private _capturePhysicsTime;
  10046. private _physicsTime;
  10047. private _captureAnimationsTime;
  10048. private _animationsTime;
  10049. private _captureCameraRenderTime;
  10050. private _cameraRenderTime;
  10051. private _onBeforeActiveMeshesEvaluationObserver;
  10052. private _onAfterActiveMeshesEvaluationObserver;
  10053. private _onBeforeRenderTargetsRenderObserver;
  10054. private _onAfterRenderTargetsRenderObserver;
  10055. private _onAfterRenderObserver;
  10056. private _onBeforeDrawPhaseObserver;
  10057. private _onAfterDrawPhaseObserver;
  10058. private _onBeforeAnimationsObserver;
  10059. private _onBeforeParticlesRenderingObserver;
  10060. private _onAfterParticlesRenderingObserver;
  10061. private _onBeforeSpritesRenderingObserver;
  10062. private _onAfterSpritesRenderingObserver;
  10063. private _onBeforePhysicsObserver;
  10064. private _onAfterPhysicsObserver;
  10065. private _onAfterAnimationsObserver;
  10066. private _onBeforeCameraRenderObserver;
  10067. private _onAfterCameraRenderObserver;
  10068. /**
  10069. * Gets the perf counter used for active meshes evaluation time
  10070. */
  10071. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10072. /**
  10073. * Gets the active meshes evaluation time capture status
  10074. */
  10075. /**
  10076. * Enable or disable the active meshes evaluation time capture
  10077. */
  10078. captureActiveMeshesEvaluationTime: boolean;
  10079. /**
  10080. * Gets the perf counter used for render targets render time
  10081. */
  10082. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10083. /**
  10084. * Gets the render targets render time capture status
  10085. */
  10086. /**
  10087. * Enable or disable the render targets render time capture
  10088. */
  10089. captureRenderTargetsRenderTime: boolean;
  10090. /**
  10091. * Gets the perf counter used for particles render time
  10092. */
  10093. readonly particlesRenderTimeCounter: PerfCounter;
  10094. /**
  10095. * Gets the particles render time capture status
  10096. */
  10097. /**
  10098. * Enable or disable the particles render time capture
  10099. */
  10100. captureParticlesRenderTime: boolean;
  10101. /**
  10102. * Gets the perf counter used for sprites render time
  10103. */
  10104. readonly spritesRenderTimeCounter: PerfCounter;
  10105. /**
  10106. * Gets the sprites render time capture status
  10107. */
  10108. /**
  10109. * Enable or disable the sprites render time capture
  10110. */
  10111. captureSpritesRenderTime: boolean;
  10112. /**
  10113. * Gets the perf counter used for physics time
  10114. */
  10115. readonly physicsTimeCounter: PerfCounter;
  10116. /**
  10117. * Gets the physics time capture status
  10118. */
  10119. /**
  10120. * Enable or disable the physics time capture
  10121. */
  10122. capturePhysicsTime: boolean;
  10123. /**
  10124. * Gets the perf counter used for animations time
  10125. */
  10126. readonly animationsTimeCounter: PerfCounter;
  10127. /**
  10128. * Gets the animations time capture status
  10129. */
  10130. /**
  10131. * Enable or disable the animations time capture
  10132. */
  10133. captureAnimationsTime: boolean;
  10134. /**
  10135. * Gets the perf counter used for frame time capture
  10136. */
  10137. readonly frameTimeCounter: PerfCounter;
  10138. /**
  10139. * Gets the frame time capture status
  10140. */
  10141. /**
  10142. * Enable or disable the frame time capture
  10143. */
  10144. captureFrameTime: boolean;
  10145. /**
  10146. * Gets the perf counter used for inter-frames time capture
  10147. */
  10148. readonly interFrameTimeCounter: PerfCounter;
  10149. /**
  10150. * Gets the inter-frames time capture status
  10151. */
  10152. /**
  10153. * Enable or disable the inter-frames time capture
  10154. */
  10155. captureInterFrameTime: boolean;
  10156. /**
  10157. * Gets the perf counter used for render time capture
  10158. */
  10159. readonly renderTimeCounter: PerfCounter;
  10160. /**
  10161. * Gets the render time capture status
  10162. */
  10163. /**
  10164. * Enable or disable the render time capture
  10165. */
  10166. captureRenderTime: boolean;
  10167. /**
  10168. * Gets the perf counter used for camera render time capture
  10169. */
  10170. readonly cameraRenderTimeCounter: PerfCounter;
  10171. /**
  10172. * Gets the camera render time capture status
  10173. */
  10174. /**
  10175. * Enable or disable the camera render time capture
  10176. */
  10177. captureCameraRenderTime: boolean;
  10178. /**
  10179. * Gets the perf counter used for draw calls
  10180. */
  10181. readonly drawCallsCounter: PerfCounter;
  10182. /**
  10183. * Gets the perf counter used for texture collisions
  10184. */
  10185. readonly textureCollisionsCounter: PerfCounter;
  10186. constructor(scene: Scene);
  10187. dispose(): void;
  10188. }
  10189. }
  10190. declare module BABYLON {
  10191. /**
  10192. * @hidden
  10193. **/
  10194. class _TimeToken {
  10195. _startTimeQuery: Nullable<WebGLQuery>;
  10196. _endTimeQuery: Nullable<WebGLQuery>;
  10197. _timeElapsedQuery: Nullable<WebGLQuery>;
  10198. _timeElapsedQueryEnded: boolean;
  10199. }
  10200. }
  10201. declare module BABYLON {
  10202. /**
  10203. * Represents the different options available during the creation of
  10204. * a Environment helper.
  10205. *
  10206. * This can control the default ground, skybox and image processing setup of your scene.
  10207. */
  10208. interface IEnvironmentHelperOptions {
  10209. /**
  10210. * Specifies wether or not to create a ground.
  10211. * True by default.
  10212. */
  10213. createGround: boolean;
  10214. /**
  10215. * Specifies the ground size.
  10216. * 15 by default.
  10217. */
  10218. groundSize: number;
  10219. /**
  10220. * The texture used on the ground for the main color.
  10221. * Comes from the BabylonJS CDN by default.
  10222. *
  10223. * Remarks: Can be either a texture or a url.
  10224. */
  10225. groundTexture: string | BaseTexture;
  10226. /**
  10227. * The color mixed in the ground texture by default.
  10228. * BabylonJS clearColor by default.
  10229. */
  10230. groundColor: Color3;
  10231. /**
  10232. * Specifies the ground opacity.
  10233. * 1 by default.
  10234. */
  10235. groundOpacity: number;
  10236. /**
  10237. * Enables the ground to receive shadows.
  10238. * True by default.
  10239. */
  10240. enableGroundShadow: boolean;
  10241. /**
  10242. * Helps preventing the shadow to be fully black on the ground.
  10243. * 0.5 by default.
  10244. */
  10245. groundShadowLevel: number;
  10246. /**
  10247. * Creates a mirror texture attach to the ground.
  10248. * false by default.
  10249. */
  10250. enableGroundMirror: boolean;
  10251. /**
  10252. * Specifies the ground mirror size ratio.
  10253. * 0.3 by default as the default kernel is 64.
  10254. */
  10255. groundMirrorSizeRatio: number;
  10256. /**
  10257. * Specifies the ground mirror blur kernel size.
  10258. * 64 by default.
  10259. */
  10260. groundMirrorBlurKernel: number;
  10261. /**
  10262. * Specifies the ground mirror visibility amount.
  10263. * 1 by default
  10264. */
  10265. groundMirrorAmount: number;
  10266. /**
  10267. * Specifies the ground mirror reflectance weight.
  10268. * This uses the standard weight of the background material to setup the fresnel effect
  10269. * of the mirror.
  10270. * 1 by default.
  10271. */
  10272. groundMirrorFresnelWeight: number;
  10273. /**
  10274. * Specifies the ground mirror Falloff distance.
  10275. * This can helps reducing the size of the reflection.
  10276. * 0 by Default.
  10277. */
  10278. groundMirrorFallOffDistance: number;
  10279. /**
  10280. * Specifies the ground mirror texture type.
  10281. * Unsigned Int by Default.
  10282. */
  10283. groundMirrorTextureType: number;
  10284. /**
  10285. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  10286. * the shown objects.
  10287. */
  10288. groundYBias: number;
  10289. /**
  10290. * Specifies wether or not to create a skybox.
  10291. * True by default.
  10292. */
  10293. createSkybox: boolean;
  10294. /**
  10295. * Specifies the skybox size.
  10296. * 20 by default.
  10297. */
  10298. skyboxSize: number;
  10299. /**
  10300. * The texture used on the skybox for the main color.
  10301. * Comes from the BabylonJS CDN by default.
  10302. *
  10303. * Remarks: Can be either a texture or a url.
  10304. */
  10305. skyboxTexture: string | BaseTexture;
  10306. /**
  10307. * The color mixed in the skybox texture by default.
  10308. * BabylonJS clearColor by default.
  10309. */
  10310. skyboxColor: Color3;
  10311. /**
  10312. * The background rotation around the Y axis of the scene.
  10313. * This helps aligning the key lights of your scene with the background.
  10314. * 0 by default.
  10315. */
  10316. backgroundYRotation: number;
  10317. /**
  10318. * Compute automatically the size of the elements to best fit with the scene.
  10319. */
  10320. sizeAuto: boolean;
  10321. /**
  10322. * Default position of the rootMesh if autoSize is not true.
  10323. */
  10324. rootPosition: Vector3;
  10325. /**
  10326. * Sets up the image processing in the scene.
  10327. * true by default.
  10328. */
  10329. setupImageProcessing: boolean;
  10330. /**
  10331. * The texture used as your environment texture in the scene.
  10332. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  10333. *
  10334. * Remarks: Can be either a texture or a url.
  10335. */
  10336. environmentTexture: string | BaseTexture;
  10337. /**
  10338. * The value of the exposure to apply to the scene.
  10339. * 0.6 by default if setupImageProcessing is true.
  10340. */
  10341. cameraExposure: number;
  10342. /**
  10343. * The value of the contrast to apply to the scene.
  10344. * 1.6 by default if setupImageProcessing is true.
  10345. */
  10346. cameraContrast: number;
  10347. /**
  10348. * Specifies wether or not tonemapping should be enabled in the scene.
  10349. * true by default if setupImageProcessing is true.
  10350. */
  10351. toneMappingEnabled: boolean;
  10352. }
  10353. /**
  10354. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  10355. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  10356. * It also helps with the default setup of your imageProcessing configuration.
  10357. */
  10358. class EnvironmentHelper {
  10359. /**
  10360. * Default ground texture URL.
  10361. */
  10362. private static _groundTextureCDNUrl;
  10363. /**
  10364. * Default skybox texture URL.
  10365. */
  10366. private static _skyboxTextureCDNUrl;
  10367. /**
  10368. * Default environment texture URL.
  10369. */
  10370. private static _environmentTextureCDNUrl;
  10371. /**
  10372. * Creates the default options for the helper.
  10373. */
  10374. private static _getDefaultOptions();
  10375. private _rootMesh;
  10376. /**
  10377. * Gets the root mesh created by the helper.
  10378. */
  10379. readonly rootMesh: Mesh;
  10380. private _skybox;
  10381. /**
  10382. * Gets the skybox created by the helper.
  10383. */
  10384. readonly skybox: Nullable<Mesh>;
  10385. private _skyboxTexture;
  10386. /**
  10387. * Gets the skybox texture created by the helper.
  10388. */
  10389. readonly skyboxTexture: Nullable<BaseTexture>;
  10390. private _skyboxMaterial;
  10391. /**
  10392. * Gets the skybox material created by the helper.
  10393. */
  10394. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  10395. private _ground;
  10396. /**
  10397. * Gets the ground mesh created by the helper.
  10398. */
  10399. readonly ground: Nullable<Mesh>;
  10400. private _groundTexture;
  10401. /**
  10402. * Gets the ground texture created by the helper.
  10403. */
  10404. readonly groundTexture: Nullable<BaseTexture>;
  10405. private _groundMirror;
  10406. /**
  10407. * Gets the ground mirror created by the helper.
  10408. */
  10409. readonly groundMirror: Nullable<MirrorTexture>;
  10410. /**
  10411. * Gets the ground mirror render list to helps pushing the meshes
  10412. * you wish in the ground reflection.
  10413. */
  10414. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  10415. private _groundMaterial;
  10416. /**
  10417. * Gets the ground material created by the helper.
  10418. */
  10419. readonly groundMaterial: Nullable<BackgroundMaterial>;
  10420. /**
  10421. * Stores the creation options.
  10422. */
  10423. private readonly _scene;
  10424. private _options;
  10425. /**
  10426. * This observable will be notified with any error during the creation of the environment,
  10427. * mainly texture creation errors.
  10428. */
  10429. onErrorObservable: Observable<{
  10430. message?: string;
  10431. exception?: any;
  10432. }>;
  10433. /**
  10434. * constructor
  10435. * @param options
  10436. * @param scene The scene to add the material to
  10437. */
  10438. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  10439. /**
  10440. * Updates the background according to the new options
  10441. * @param options
  10442. */
  10443. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  10444. /**
  10445. * Sets the primary color of all the available elements.
  10446. * @param color the main color to affect to the ground and the background
  10447. */
  10448. setMainColor(color: Color3): void;
  10449. /**
  10450. * Setup the image processing according to the specified options.
  10451. */
  10452. private _setupImageProcessing();
  10453. /**
  10454. * Setup the environment texture according to the specified options.
  10455. */
  10456. private _setupEnvironmentTexture();
  10457. /**
  10458. * Setup the background according to the specified options.
  10459. */
  10460. private _setupBackground();
  10461. /**
  10462. * Get the scene sizes according to the setup.
  10463. */
  10464. private _getSceneSize();
  10465. /**
  10466. * Setup the ground according to the specified options.
  10467. */
  10468. private _setupGround(sceneSize);
  10469. /**
  10470. * Setup the ground material according to the specified options.
  10471. */
  10472. private _setupGroundMaterial();
  10473. /**
  10474. * Setup the ground diffuse texture according to the specified options.
  10475. */
  10476. private _setupGroundDiffuseTexture();
  10477. /**
  10478. * Setup the ground mirror texture according to the specified options.
  10479. */
  10480. private _setupGroundMirrorTexture(sceneSize);
  10481. /**
  10482. * Setup the ground to receive the mirror texture.
  10483. */
  10484. private _setupMirrorInGroundMaterial();
  10485. /**
  10486. * Setup the skybox according to the specified options.
  10487. */
  10488. private _setupSkybox(sceneSize);
  10489. /**
  10490. * Setup the skybox material according to the specified options.
  10491. */
  10492. private _setupSkyboxMaterial();
  10493. /**
  10494. * Setup the skybox reflection texture according to the specified options.
  10495. */
  10496. private _setupSkyboxReflectionTexture();
  10497. private _errorHandler;
  10498. /**
  10499. * Dispose all the elements created by the Helper.
  10500. */
  10501. dispose(): void;
  10502. }
  10503. }
  10504. declare module BABYLON {
  10505. /**
  10506. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  10507. * As a subclass of Node, this allow parenting to the camera with different locations in the scene.
  10508. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  10509. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10510. */
  10511. class PhotoDome extends Node {
  10512. private _useDirectMapping;
  10513. /**
  10514. * The texture being displayed on the sphere
  10515. */
  10516. protected _photoTexture: Texture;
  10517. /**
  10518. * Gets or sets the texture being displayed on the sphere
  10519. */
  10520. photoTexture: Texture;
  10521. /**
  10522. * The skybox material
  10523. */
  10524. protected _material: BackgroundMaterial;
  10525. /**
  10526. * The surface used for the skybox
  10527. */
  10528. protected _mesh: Mesh;
  10529. /**
  10530. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10531. * Also see the options.resolution property.
  10532. */
  10533. fovMultiplier: number;
  10534. /**
  10535. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  10536. * @param name Element's name, child elements will append suffixes for their own names.
  10537. * @param urlsOfPhoto define the url of the photo to display
  10538. * @param options An object containing optional or exposed sub element properties
  10539. */
  10540. constructor(name: string, urlOfPhoto: string, options: {
  10541. resolution?: number;
  10542. size?: number;
  10543. useDirectMapping?: boolean;
  10544. }, scene: Scene);
  10545. /**
  10546. * Releases resources associated with this node.
  10547. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10548. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10549. */
  10550. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10551. }
  10552. }
  10553. declare module BABYLON {
  10554. /**
  10555. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  10556. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  10557. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  10558. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  10559. */
  10560. class VideoDome extends Node {
  10561. private _useDirectMapping;
  10562. /**
  10563. * The video texture being displayed on the sphere
  10564. */
  10565. protected _videoTexture: VideoTexture;
  10566. /**
  10567. * Gets the video texture being displayed on the sphere
  10568. */
  10569. readonly videoTexture: VideoTexture;
  10570. /**
  10571. * The skybox material
  10572. */
  10573. protected _material: BackgroundMaterial;
  10574. /**
  10575. * The surface used for the skybox
  10576. */
  10577. protected _mesh: Mesh;
  10578. /**
  10579. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  10580. * Also see the options.resolution property.
  10581. */
  10582. fovMultiplier: number;
  10583. /**
  10584. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  10585. * @param name Element's name, child elements will append suffixes for their own names.
  10586. * @param urlsOrVideo defines the url(s) or the video element to use
  10587. * @param options An object containing optional or exposed sub element properties
  10588. */
  10589. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10590. resolution?: number;
  10591. clickToPlay?: boolean;
  10592. autoPlay?: boolean;
  10593. loop?: boolean;
  10594. size?: number;
  10595. poster?: string;
  10596. useDirectMapping?: boolean;
  10597. }, scene: Scene);
  10598. /**
  10599. * Releases resources associated with this node.
  10600. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10601. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10602. */
  10603. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10604. }
  10605. }
  10606. declare module BABYLON {
  10607. /**
  10608. * Effect layer options. This helps customizing the behaviour
  10609. * of the effect layer.
  10610. */
  10611. interface IEffectLayerOptions {
  10612. /**
  10613. * Multiplication factor apply to the canvas size to compute the render target size
  10614. * used to generated the objects (the smaller the faster).
  10615. */
  10616. mainTextureRatio: number;
  10617. /**
  10618. * Enforces a fixed size texture to ensure effect stability across devices.
  10619. */
  10620. mainTextureFixedSize?: number;
  10621. /**
  10622. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10623. */
  10624. alphaBlendingMode: number;
  10625. /**
  10626. * The camera attached to the layer.
  10627. */
  10628. camera: Nullable<Camera>;
  10629. /**
  10630. * The rendering group to draw the layer in.
  10631. */
  10632. renderingGroupId: number;
  10633. }
  10634. /**
  10635. * The effect layer Helps adding post process effect blended with the main pass.
  10636. *
  10637. * This can be for instance use to generate glow or higlight effects on the scene.
  10638. *
  10639. * The effect layer class can not be used directly and is intented to inherited from to be
  10640. * customized per effects.
  10641. */
  10642. abstract class EffectLayer {
  10643. private _vertexBuffers;
  10644. private _indexBuffer;
  10645. private _cachedDefines;
  10646. private _effectLayerMapGenerationEffect;
  10647. private _effectLayerOptions;
  10648. private _mergeEffect;
  10649. protected _scene: Scene;
  10650. protected _engine: Engine;
  10651. protected _maxSize: number;
  10652. protected _mainTextureDesiredSize: ISize;
  10653. protected _mainTexture: RenderTargetTexture;
  10654. protected _shouldRender: boolean;
  10655. protected _postProcesses: PostProcess[];
  10656. protected _textures: BaseTexture[];
  10657. protected _emissiveTextureAndColor: {
  10658. texture: Nullable<BaseTexture>;
  10659. color: Color4;
  10660. };
  10661. /**
  10662. * The name of the layer
  10663. */
  10664. name: string;
  10665. /**
  10666. * The clear color of the texture used to generate the glow map.
  10667. */
  10668. neutralColor: Color4;
  10669. /**
  10670. * Specifies wether the highlight layer is enabled or not.
  10671. */
  10672. isEnabled: boolean;
  10673. /**
  10674. * Gets the camera attached to the layer.
  10675. */
  10676. readonly camera: Nullable<Camera>;
  10677. /**
  10678. * Gets the rendering group id the layer should render in.
  10679. */
  10680. readonly renderingGroupId: number;
  10681. /**
  10682. * An event triggered when the effect layer has been disposed.
  10683. */
  10684. onDisposeObservable: Observable<EffectLayer>;
  10685. /**
  10686. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  10687. */
  10688. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  10689. /**
  10690. * An event triggered when the generated texture is being merged in the scene.
  10691. */
  10692. onBeforeComposeObservable: Observable<EffectLayer>;
  10693. /**
  10694. * An event triggered when the generated texture has been merged in the scene.
  10695. */
  10696. onAfterComposeObservable: Observable<EffectLayer>;
  10697. /**
  10698. * An event triggered when the efffect layer changes its size.
  10699. */
  10700. onSizeChangedObservable: Observable<EffectLayer>;
  10701. /**
  10702. * Instantiates a new effect Layer and references it in the scene.
  10703. * @param name The name of the layer
  10704. * @param scene The scene to use the layer in
  10705. */
  10706. constructor(
  10707. /** The Friendly of the effect in the scene */
  10708. name: string, scene: Scene);
  10709. /**
  10710. * Get the effect name of the layer.
  10711. * @return The effect name
  10712. */
  10713. abstract getEffectName(): string;
  10714. /**
  10715. * Checks for the readiness of the element composing the layer.
  10716. * @param subMesh the mesh to check for
  10717. * @param useInstances specify wether or not to use instances to render the mesh
  10718. * @return true if ready otherwise, false
  10719. */
  10720. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10721. /**
  10722. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10723. * @returns true if the effect requires stencil during the main canvas render pass.
  10724. */
  10725. abstract needStencil(): boolean;
  10726. /**
  10727. * Create the merge effect. This is the shader use to blit the information back
  10728. * to the main canvas at the end of the scene rendering.
  10729. * @returns The effect containing the shader used to merge the effect on the main canvas
  10730. */
  10731. protected abstract _createMergeEffect(): Effect;
  10732. /**
  10733. * Creates the render target textures and post processes used in the effect layer.
  10734. */
  10735. protected abstract _createTextureAndPostProcesses(): void;
  10736. /**
  10737. * Implementation specific of rendering the generating effect on the main canvas.
  10738. * @param effect The effect used to render through
  10739. */
  10740. protected abstract _internalRender(effect: Effect): void;
  10741. /**
  10742. * Sets the required values for both the emissive texture and and the main color.
  10743. */
  10744. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10745. /**
  10746. * Free any resources and references associated to a mesh.
  10747. * Internal use
  10748. * @param mesh The mesh to free.
  10749. */
  10750. abstract _disposeMesh(mesh: Mesh): void;
  10751. /**
  10752. * Serializes this layer (Glow or Highlight for example)
  10753. * @returns a serialized layer object
  10754. */
  10755. abstract serialize?(): any;
  10756. /**
  10757. * Initializes the effect layer with the required options.
  10758. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10759. */
  10760. protected _init(options: Partial<IEffectLayerOptions>): void;
  10761. /**
  10762. * Generates the index buffer of the full screen quad blending to the main canvas.
  10763. */
  10764. private _generateIndexBuffer();
  10765. /**
  10766. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10767. */
  10768. private _genrateVertexBuffer();
  10769. /**
  10770. * Sets the main texture desired size which is the closest power of two
  10771. * of the engine canvas size.
  10772. */
  10773. private _setMainTextureSize();
  10774. /**
  10775. * Creates the main texture for the effect layer.
  10776. */
  10777. protected _createMainTexture(): void;
  10778. /**
  10779. * Checks for the readiness of the element composing the layer.
  10780. * @param subMesh the mesh to check for
  10781. * @param useInstances specify wether or not to use instances to render the mesh
  10782. * @param emissiveTexture the associated emissive texture used to generate the glow
  10783. * @return true if ready otherwise, false
  10784. */
  10785. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10786. /**
  10787. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10788. */
  10789. render(): void;
  10790. /**
  10791. * Determine if a given mesh will be used in the current effect.
  10792. * @param mesh mesh to test
  10793. * @returns true if the mesh will be used
  10794. */
  10795. hasMesh(mesh: AbstractMesh): boolean;
  10796. /**
  10797. * Returns true if the layer contains information to display, otherwise false.
  10798. * @returns true if the glow layer should be rendered
  10799. */
  10800. shouldRender(): boolean;
  10801. /**
  10802. * Returns true if the mesh should render, otherwise false.
  10803. * @param mesh The mesh to render
  10804. * @returns true if it should render otherwise false
  10805. */
  10806. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10807. /**
  10808. * Returns true if the mesh should render, otherwise false.
  10809. * @param mesh The mesh to render
  10810. * @returns true if it should render otherwise false
  10811. */
  10812. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10813. /**
  10814. * Renders the submesh passed in parameter to the generation map.
  10815. */
  10816. protected _renderSubMesh(subMesh: SubMesh): void;
  10817. /**
  10818. * Rebuild the required buffers.
  10819. * @hidden Internal use only.
  10820. */
  10821. _rebuild(): void;
  10822. /**
  10823. * Dispose only the render target textures and post process.
  10824. */
  10825. private _disposeTextureAndPostProcesses();
  10826. /**
  10827. * Dispose the highlight layer and free resources.
  10828. */
  10829. dispose(): void;
  10830. /**
  10831. * Gets the class name of the effect layer
  10832. * @returns the string with the class name of the effect layer
  10833. */
  10834. getClassName(): string;
  10835. /**
  10836. * Creates an effect layer from parsed effect layer data
  10837. * @param parsedEffectLayer defines effect layer data
  10838. * @param scene defines the current scene
  10839. * @param rootUrl defines the root URL containing the effect layer information
  10840. * @returns a parsed effect Layer
  10841. */
  10842. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10843. }
  10844. }
  10845. declare module BABYLON {
  10846. interface AbstractScene {
  10847. /**
  10848. * The list of effect layers (highlights/glow) added to the scene
  10849. * @see http://doc.babylonjs.com/how_to/highlight_layer
  10850. * @see http://doc.babylonjs.com/how_to/glow_layer
  10851. */
  10852. effectLayers: Array<EffectLayer>;
  10853. /**
  10854. * Removes the given effect layer from this scene.
  10855. * @param toRemove defines the effect layer to remove
  10856. * @returns the index of the removed effect layer
  10857. */
  10858. removeEffectLayer(toRemove: EffectLayer): number;
  10859. /**
  10860. * Adds the given effect layer to this scene
  10861. * @param newEffectLayer defines the effect layer to add
  10862. */
  10863. addEffectLayer(newEffectLayer: EffectLayer): void;
  10864. }
  10865. /**
  10866. * Defines the layer scene component responsible to manage any effect layers
  10867. * in a given scene.
  10868. */
  10869. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  10870. /**
  10871. * The component name helpfull to identify the component in the list of scene components.
  10872. */
  10873. readonly name: string;
  10874. /**
  10875. * The scene the component belongs to.
  10876. */
  10877. scene: Scene;
  10878. private _engine;
  10879. private _renderEffects;
  10880. private _needStencil;
  10881. private _previousStencilState;
  10882. /**
  10883. * Creates a new instance of the component for the given scene
  10884. * @param scene Defines the scene to register the component in
  10885. */
  10886. constructor(scene: Scene);
  10887. /**
  10888. * Registers the component in a given scene
  10889. */
  10890. register(): void;
  10891. /**
  10892. * Rebuilds the elements related to this component in case of
  10893. * context lost for instance.
  10894. */
  10895. rebuild(): void;
  10896. /**
  10897. * Serializes the component data to the specified json object
  10898. * @param serializationObject The object to serialize to
  10899. */
  10900. serialize(serializationObject: any): void;
  10901. /**
  10902. * Adds all the element from the container to the scene
  10903. * @param container the container holding the elements
  10904. */
  10905. addFromContainer(container: AbstractScene): void;
  10906. /**
  10907. * Removes all the elements in the container from the scene
  10908. * @param container contains the elements to remove
  10909. */
  10910. removeFromContainer(container: AbstractScene): void;
  10911. /**
  10912. * Disposes the component and the associated ressources.
  10913. */
  10914. dispose(): void;
  10915. private _isReadyForMesh(mesh, hardwareInstancedRendering);
  10916. private _renderMainTexture(camera);
  10917. private _setStencil(camera);
  10918. private _setStencilBack(camera);
  10919. private _draw(renderingGroupId);
  10920. private _drawCamera(camera);
  10921. private _drawRenderingGroup(index);
  10922. }
  10923. }
  10924. declare module BABYLON {
  10925. interface AbstractScene {
  10926. /**
  10927. * Return a the first highlight layer of the scene with a given name.
  10928. * @param name The name of the highlight layer to look for.
  10929. * @return The highlight layer if found otherwise null.
  10930. */
  10931. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  10932. }
  10933. /**
  10934. * Glow layer options. This helps customizing the behaviour
  10935. * of the glow layer.
  10936. */
  10937. interface IGlowLayerOptions {
  10938. /**
  10939. * Multiplication factor apply to the canvas size to compute the render target size
  10940. * used to generated the glowing objects (the smaller the faster).
  10941. */
  10942. mainTextureRatio: number;
  10943. /**
  10944. * Enforces a fixed size texture to ensure resize independant blur.
  10945. */
  10946. mainTextureFixedSize?: number;
  10947. /**
  10948. * How big is the kernel of the blur texture.
  10949. */
  10950. blurKernelSize: number;
  10951. /**
  10952. * The camera attached to the layer.
  10953. */
  10954. camera: Nullable<Camera>;
  10955. /**
  10956. * Enable MSAA by chosing the number of samples.
  10957. */
  10958. mainTextureSamples?: number;
  10959. /**
  10960. * The rendering group to draw the layer in.
  10961. */
  10962. renderingGroupId: number;
  10963. }
  10964. /**
  10965. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  10966. *
  10967. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10968. * glowy meshes to your scene.
  10969. *
  10970. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  10971. */
  10972. class GlowLayer extends EffectLayer {
  10973. /**
  10974. * Effect Name of the layer.
  10975. */
  10976. static readonly EffectName: string;
  10977. /**
  10978. * The default blur kernel size used for the glow.
  10979. */
  10980. static DefaultBlurKernelSize: number;
  10981. /**
  10982. * The default texture size ratio used for the glow.
  10983. */
  10984. static DefaultTextureRatio: number;
  10985. /**
  10986. * Gets the kernel size of the blur.
  10987. */
  10988. /**
  10989. * Sets the kernel size of the blur.
  10990. */
  10991. blurKernelSize: number;
  10992. /**
  10993. * Gets the glow intensity.
  10994. */
  10995. /**
  10996. * Sets the glow intensity.
  10997. */
  10998. intensity: number;
  10999. private _options;
  11000. private _intensity;
  11001. private _horizontalBlurPostprocess1;
  11002. private _verticalBlurPostprocess1;
  11003. private _horizontalBlurPostprocess2;
  11004. private _verticalBlurPostprocess2;
  11005. private _blurTexture1;
  11006. private _blurTexture2;
  11007. private _postProcesses1;
  11008. private _postProcesses2;
  11009. private _includedOnlyMeshes;
  11010. private _excludedMeshes;
  11011. /**
  11012. * Callback used to let the user override the color selection on a per mesh basis
  11013. */
  11014. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  11015. /**
  11016. * Callback used to let the user override the texture selection on a per mesh basis
  11017. */
  11018. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  11019. /**
  11020. * Instantiates a new glow Layer and references it to the scene.
  11021. * @param name The name of the layer
  11022. * @param scene The scene to use the layer in
  11023. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  11024. */
  11025. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  11026. /**
  11027. * Get the effect name of the layer.
  11028. * @return The effect name
  11029. */
  11030. getEffectName(): string;
  11031. /**
  11032. * Create the merge effect. This is the shader use to blit the information back
  11033. * to the main canvas at the end of the scene rendering.
  11034. */
  11035. protected _createMergeEffect(): Effect;
  11036. /**
  11037. * Creates the render target textures and post processes used in the glow layer.
  11038. */
  11039. protected _createTextureAndPostProcesses(): void;
  11040. /**
  11041. * Checks for the readiness of the element composing the layer.
  11042. * @param subMesh the mesh to check for
  11043. * @param useInstances specify wether or not to use instances to render the mesh
  11044. * @param emissiveTexture the associated emissive texture used to generate the glow
  11045. * @return true if ready otherwise, false
  11046. */
  11047. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11048. /**
  11049. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11050. */
  11051. needStencil(): boolean;
  11052. /**
  11053. * Implementation specific of rendering the generating effect on the main canvas.
  11054. * @param effect The effect used to render through
  11055. */
  11056. protected _internalRender(effect: Effect): void;
  11057. /**
  11058. * Sets the required values for both the emissive texture and and the main color.
  11059. */
  11060. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11061. /**
  11062. * Returns true if the mesh should render, otherwise false.
  11063. * @param mesh The mesh to render
  11064. * @returns true if it should render otherwise false
  11065. */
  11066. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11067. /**
  11068. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  11069. * @param mesh The mesh to exclude from the glow layer
  11070. */
  11071. addExcludedMesh(mesh: Mesh): void;
  11072. /**
  11073. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  11074. * @param mesh The mesh to remove
  11075. */
  11076. removeExcludedMesh(mesh: Mesh): void;
  11077. /**
  11078. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  11079. * @param mesh The mesh to include in the glow layer
  11080. */
  11081. addIncludedOnlyMesh(mesh: Mesh): void;
  11082. /**
  11083. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  11084. * @param mesh The mesh to remove
  11085. */
  11086. removeIncludedOnlyMesh(mesh: Mesh): void;
  11087. /**
  11088. * Determine if a given mesh will be used in the glow layer
  11089. * @param mesh The mesh to test
  11090. * @returns true if the mesh will be highlighted by the current glow layer
  11091. */
  11092. hasMesh(mesh: AbstractMesh): boolean;
  11093. /**
  11094. * Free any resources and references associated to a mesh.
  11095. * Internal use
  11096. * @param mesh The mesh to free.
  11097. */
  11098. _disposeMesh(mesh: Mesh): void;
  11099. /**
  11100. * Gets the class name of the effect layer
  11101. * @returns the string with the class name of the effect layer
  11102. */
  11103. getClassName(): string;
  11104. /**
  11105. * Serializes this glow layer
  11106. * @returns a serialized glow layer object
  11107. */
  11108. serialize(): any;
  11109. /**
  11110. * Creates a Glow Layer from parsed glow layer data
  11111. * @param parsedGlowLayer defines glow layer data
  11112. * @param scene defines the current scene
  11113. * @param rootUrl defines the root URL containing the glow layer information
  11114. * @returns a parsed Glow Layer
  11115. */
  11116. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11117. }
  11118. }
  11119. declare module BABYLON {
  11120. interface AbstractScene {
  11121. /**
  11122. * Return a the first highlight layer of the scene with a given name.
  11123. * @param name The name of the highlight layer to look for.
  11124. * @return The highlight layer if found otherwise null.
  11125. */
  11126. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  11127. }
  11128. /**
  11129. * Highlight layer options. This helps customizing the behaviour
  11130. * of the highlight layer.
  11131. */
  11132. interface IHighlightLayerOptions {
  11133. /**
  11134. * Multiplication factor apply to the canvas size to compute the render target size
  11135. * used to generated the glowing objects (the smaller the faster).
  11136. */
  11137. mainTextureRatio: number;
  11138. /**
  11139. * Enforces a fixed size texture to ensure resize independant blur.
  11140. */
  11141. mainTextureFixedSize?: number;
  11142. /**
  11143. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11144. * of the picture to blur (the smaller the faster).
  11145. */
  11146. blurTextureSizeRatio: number;
  11147. /**
  11148. * How big in texel of the blur texture is the vertical blur.
  11149. */
  11150. blurVerticalSize: number;
  11151. /**
  11152. * How big in texel of the blur texture is the horizontal blur.
  11153. */
  11154. blurHorizontalSize: number;
  11155. /**
  11156. * Alpha blending mode used to apply the blur. Default is combine.
  11157. */
  11158. alphaBlendingMode: number;
  11159. /**
  11160. * The camera attached to the layer.
  11161. */
  11162. camera: Nullable<Camera>;
  11163. /**
  11164. * Should we display highlight as a solid stroke?
  11165. */
  11166. isStroke?: boolean;
  11167. /**
  11168. * The rendering group to draw the layer in.
  11169. */
  11170. renderingGroupId: number;
  11171. }
  11172. /**
  11173. * The highlight layer Helps adding a glow effect around a mesh.
  11174. *
  11175. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11176. * glowy meshes to your scene.
  11177. *
  11178. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11179. */
  11180. class HighlightLayer extends EffectLayer {
  11181. name: string;
  11182. /**
  11183. * Effect Name of the highlight layer.
  11184. */
  11185. static readonly EffectName: string;
  11186. /**
  11187. * The neutral color used during the preparation of the glow effect.
  11188. * This is black by default as the blend operation is a blend operation.
  11189. */
  11190. static NeutralColor: Color4;
  11191. /**
  11192. * Stencil value used for glowing meshes.
  11193. */
  11194. static GlowingMeshStencilReference: number;
  11195. /**
  11196. * Stencil value used for the other meshes in the scene.
  11197. */
  11198. static NormalMeshStencilReference: number;
  11199. /**
  11200. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11201. */
  11202. innerGlow: boolean;
  11203. /**
  11204. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11205. */
  11206. outerGlow: boolean;
  11207. /**
  11208. * Gets the horizontal size of the blur.
  11209. */
  11210. /**
  11211. * Specifies the horizontal size of the blur.
  11212. */
  11213. blurHorizontalSize: number;
  11214. /**
  11215. * Gets the vertical size of the blur.
  11216. */
  11217. /**
  11218. * Specifies the vertical size of the blur.
  11219. */
  11220. blurVerticalSize: number;
  11221. /**
  11222. * An event triggered when the highlight layer is being blurred.
  11223. */
  11224. onBeforeBlurObservable: Observable<HighlightLayer>;
  11225. /**
  11226. * An event triggered when the highlight layer has been blurred.
  11227. */
  11228. onAfterBlurObservable: Observable<HighlightLayer>;
  11229. private _instanceGlowingMeshStencilReference;
  11230. private _options;
  11231. private _downSamplePostprocess;
  11232. private _horizontalBlurPostprocess;
  11233. private _verticalBlurPostprocess;
  11234. private _blurTexture;
  11235. private _meshes;
  11236. private _excludedMeshes;
  11237. /**
  11238. * Instantiates a new highlight Layer and references it to the scene..
  11239. * @param name The name of the layer
  11240. * @param scene The scene to use the layer in
  11241. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11242. */
  11243. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11244. /**
  11245. * Get the effect name of the layer.
  11246. * @return The effect name
  11247. */
  11248. getEffectName(): string;
  11249. /**
  11250. * Create the merge effect. This is the shader use to blit the information back
  11251. * to the main canvas at the end of the scene rendering.
  11252. */
  11253. protected _createMergeEffect(): Effect;
  11254. /**
  11255. * Creates the render target textures and post processes used in the highlight layer.
  11256. */
  11257. protected _createTextureAndPostProcesses(): void;
  11258. /**
  11259. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11260. */
  11261. needStencil(): boolean;
  11262. /**
  11263. * Checks for the readiness of the element composing the layer.
  11264. * @param subMesh the mesh to check for
  11265. * @param useInstances specify wether or not to use instances to render the mesh
  11266. * @param emissiveTexture the associated emissive texture used to generate the glow
  11267. * @return true if ready otherwise, false
  11268. */
  11269. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11270. /**
  11271. * Implementation specific of rendering the generating effect on the main canvas.
  11272. * @param effect The effect used to render through
  11273. */
  11274. protected _internalRender(effect: Effect): void;
  11275. /**
  11276. * Returns true if the layer contains information to display, otherwise false.
  11277. */
  11278. shouldRender(): boolean;
  11279. /**
  11280. * Returns true if the mesh should render, otherwise false.
  11281. * @param mesh The mesh to render
  11282. * @returns true if it should render otherwise false
  11283. */
  11284. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11285. /**
  11286. * Sets the required values for both the emissive texture and and the main color.
  11287. */
  11288. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11289. /**
  11290. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11291. * @param mesh The mesh to exclude from the highlight layer
  11292. */
  11293. addExcludedMesh(mesh: Mesh): void;
  11294. /**
  11295. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11296. * @param mesh The mesh to highlight
  11297. */
  11298. removeExcludedMesh(mesh: Mesh): void;
  11299. /**
  11300. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11301. * @param mesh mesh to test
  11302. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11303. */
  11304. hasMesh(mesh: AbstractMesh): boolean;
  11305. /**
  11306. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11307. * @param mesh The mesh to highlight
  11308. * @param color The color of the highlight
  11309. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11310. */
  11311. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11312. /**
  11313. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11314. * @param mesh The mesh to highlight
  11315. */
  11316. removeMesh(mesh: Mesh): void;
  11317. /**
  11318. * Force the stencil to the normal expected value for none glowing parts
  11319. */
  11320. private _defaultStencilReference(mesh);
  11321. /**
  11322. * Free any resources and references associated to a mesh.
  11323. * Internal use
  11324. * @param mesh The mesh to free.
  11325. */
  11326. _disposeMesh(mesh: Mesh): void;
  11327. /**
  11328. * Dispose the highlight layer and free resources.
  11329. */
  11330. dispose(): void;
  11331. /**
  11332. * Gets the class name of the effect layer
  11333. * @returns the string with the class name of the effect layer
  11334. */
  11335. getClassName(): string;
  11336. /**
  11337. * Serializes this Highlight layer
  11338. * @returns a serialized Highlight layer object
  11339. */
  11340. serialize(): any;
  11341. /**
  11342. * Creates a Highlight layer from parsed Highlight layer data
  11343. * @param parsedHightlightLayer defines the Highlight layer data
  11344. * @param scene defines the current scene
  11345. * @param rootUrl defines the root URL containing the Highlight layer information
  11346. * @returns a parsed Highlight layer
  11347. */
  11348. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11349. }
  11350. }
  11351. declare module BABYLON {
  11352. class Layer {
  11353. name: string;
  11354. texture: Nullable<Texture>;
  11355. isBackground: boolean;
  11356. color: Color4;
  11357. scale: Vector2;
  11358. offset: Vector2;
  11359. alphaBlendingMode: number;
  11360. alphaTest: boolean;
  11361. layerMask: number;
  11362. private _scene;
  11363. private _vertexBuffers;
  11364. private _indexBuffer;
  11365. private _effect;
  11366. private _alphaTestEffect;
  11367. /**
  11368. * An event triggered when the layer is disposed.
  11369. */
  11370. onDisposeObservable: Observable<Layer>;
  11371. private _onDisposeObserver;
  11372. onDispose: () => void;
  11373. /**
  11374. * An event triggered before rendering the scene
  11375. */
  11376. onBeforeRenderObservable: Observable<Layer>;
  11377. private _onBeforeRenderObserver;
  11378. onBeforeRender: () => void;
  11379. /**
  11380. * An event triggered after rendering the scene
  11381. */
  11382. onAfterRenderObservable: Observable<Layer>;
  11383. private _onAfterRenderObserver;
  11384. onAfterRender: () => void;
  11385. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11386. private _createIndexBuffer();
  11387. _rebuild(): void;
  11388. render(): void;
  11389. dispose(): void;
  11390. }
  11391. }
  11392. declare module BABYLON {
  11393. interface AbstractScene {
  11394. /**
  11395. * The list of layers (background and foreground) of the scene
  11396. */
  11397. layers: Array<Layer>;
  11398. }
  11399. /**
  11400. * Defines the layer scene component responsible to manage any layers
  11401. * in a given scene.
  11402. */
  11403. class LayerSceneComponent implements ISceneComponent {
  11404. /**
  11405. * The component name helpfull to identify the component in the list of scene components.
  11406. */
  11407. readonly name: string;
  11408. /**
  11409. * The scene the component belongs to.
  11410. */
  11411. scene: Scene;
  11412. private _engine;
  11413. /**
  11414. * Creates a new instance of the component for the given scene
  11415. * @param scene Defines the scene to register the component in
  11416. */
  11417. constructor(scene: Scene);
  11418. /**
  11419. * Registers the component in a given scene
  11420. */
  11421. register(): void;
  11422. /**
  11423. * Rebuilds the elements related to this component in case of
  11424. * context lost for instance.
  11425. */
  11426. rebuild(): void;
  11427. /**
  11428. * Disposes the component and the associated ressources.
  11429. */
  11430. dispose(): void;
  11431. private _draw(camera, isBackground);
  11432. private _drawBackground(camera);
  11433. private _drawForeground(camera);
  11434. }
  11435. }
  11436. declare module BABYLON {
  11437. class LensFlare {
  11438. size: number;
  11439. position: number;
  11440. color: Color3;
  11441. texture: Nullable<Texture>;
  11442. alphaMode: number;
  11443. private _system;
  11444. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  11445. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  11446. dispose(): void;
  11447. }
  11448. }
  11449. declare module BABYLON {
  11450. class LensFlareSystem {
  11451. name: string;
  11452. lensFlares: LensFlare[];
  11453. borderLimit: number;
  11454. viewportBorder: number;
  11455. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  11456. layerMask: number;
  11457. id: string;
  11458. private _scene;
  11459. private _emitter;
  11460. private _vertexBuffers;
  11461. private _indexBuffer;
  11462. private _effect;
  11463. private _positionX;
  11464. private _positionY;
  11465. private _isEnabled;
  11466. constructor(name: string, emitter: any, scene: Scene);
  11467. isEnabled: boolean;
  11468. getScene(): Scene;
  11469. getEmitter(): any;
  11470. setEmitter(newEmitter: any): void;
  11471. getEmitterPosition(): Vector3;
  11472. computeEffectivePosition(globalViewport: Viewport): boolean;
  11473. _isVisible(): boolean;
  11474. render(): boolean;
  11475. dispose(): void;
  11476. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  11477. serialize(): any;
  11478. }
  11479. }
  11480. declare module BABYLON {
  11481. interface AbstractScene {
  11482. /**
  11483. * The list of lens flare system added to the scene
  11484. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  11485. */
  11486. lensFlareSystems: Array<LensFlareSystem>;
  11487. /**
  11488. * Removes the given lens flare system from this scene.
  11489. * @param toRemove The lens flare system to remove
  11490. * @returns The index of the removed lens flare system
  11491. */
  11492. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  11493. /**
  11494. * Adds the given lens flare system to this scene
  11495. * @param newLensFlareSystem The lens flare system to add
  11496. */
  11497. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  11498. /**
  11499. * Gets a lens flare system using its name
  11500. * @param name defines the name to look for
  11501. * @returns the lens flare system or null if not found
  11502. */
  11503. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  11504. /**
  11505. * Gets a lens flare system using its id
  11506. * @param id defines the id to look for
  11507. * @returns the lens flare system or null if not found
  11508. */
  11509. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  11510. }
  11511. /**
  11512. * Defines the lens flare scene component responsible to manage any lens flares
  11513. * in a given scene.
  11514. */
  11515. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  11516. /**
  11517. * The component name helpfull to identify the component in the list of scene components.
  11518. */
  11519. readonly name: string;
  11520. /**
  11521. * The scene the component belongs to.
  11522. */
  11523. scene: Scene;
  11524. /**
  11525. * Creates a new instance of the component for the given scene
  11526. * @param scene Defines the scene to register the component in
  11527. */
  11528. constructor(scene: Scene);
  11529. /**
  11530. * Registers the component in a given scene
  11531. */
  11532. register(): void;
  11533. /**
  11534. * Rebuilds the elements related to this component in case of
  11535. * context lost for instance.
  11536. */
  11537. rebuild(): void;
  11538. /**
  11539. * Adds all the element from the container to the scene
  11540. * @param container the container holding the elements
  11541. */
  11542. addFromContainer(container: AbstractScene): void;
  11543. /**
  11544. * Removes all the elements in the container from the scene
  11545. * @param container contains the elements to remove
  11546. */
  11547. removeFromContainer(container: AbstractScene): void;
  11548. /**
  11549. * Serializes the component data to the specified json object
  11550. * @param serializationObject The object to serialize to
  11551. */
  11552. serialize(serializationObject: any): void;
  11553. /**
  11554. * Disposes the component and the associated ressources.
  11555. */
  11556. dispose(): void;
  11557. private _draw(camera);
  11558. }
  11559. }
  11560. declare module BABYLON {
  11561. /**
  11562. * A directional light is defined by a direction (what a surprise!).
  11563. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11564. * 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.
  11565. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11566. */
  11567. class DirectionalLight extends ShadowLight {
  11568. private _shadowFrustumSize;
  11569. /**
  11570. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  11571. */
  11572. /**
  11573. * Specifies a fix frustum size for the shadow generation.
  11574. */
  11575. shadowFrustumSize: number;
  11576. private _shadowOrthoScale;
  11577. /**
  11578. * Gets the shadow projection scale against the optimal computed one.
  11579. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11580. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11581. */
  11582. /**
  11583. * Sets the shadow projection scale against the optimal computed one.
  11584. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  11585. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  11586. */
  11587. shadowOrthoScale: number;
  11588. /**
  11589. * Automatically compute the projection matrix to best fit (including all the casters)
  11590. * on each frame.
  11591. */
  11592. autoUpdateExtends: boolean;
  11593. private _orthoLeft;
  11594. private _orthoRight;
  11595. private _orthoTop;
  11596. private _orthoBottom;
  11597. /**
  11598. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  11599. * The directional light is emitted from everywhere in the given direction.
  11600. * It can cast shawdows.
  11601. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11602. * @param name The friendly name of the light
  11603. * @param direction The direction of the light
  11604. * @param scene The scene the light belongs to
  11605. */
  11606. constructor(name: string, direction: Vector3, scene: Scene);
  11607. /**
  11608. * Returns the string "DirectionalLight".
  11609. * @return The class name
  11610. */
  11611. getClassName(): string;
  11612. /**
  11613. * Returns the integer 1.
  11614. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11615. */
  11616. getTypeID(): number;
  11617. /**
  11618. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  11619. * Returns the DirectionalLight Shadow projection matrix.
  11620. */
  11621. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11622. /**
  11623. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  11624. * Returns the DirectionalLight Shadow projection matrix.
  11625. */
  11626. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  11627. /**
  11628. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  11629. * Returns the DirectionalLight Shadow projection matrix.
  11630. */
  11631. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11632. protected _buildUniformLayout(): void;
  11633. /**
  11634. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11635. * @param effect The effect to update
  11636. * @param lightIndex The index of the light in the effect to update
  11637. * @returns The directional light
  11638. */
  11639. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  11640. /**
  11641. * Gets the minZ used for shadow according to both the scene and the light.
  11642. *
  11643. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11644. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11645. * @param activeCamera The camera we are returning the min for
  11646. * @returns the depth min z
  11647. */
  11648. getDepthMinZ(activeCamera: Camera): number;
  11649. /**
  11650. * Gets the maxZ used for shadow according to both the scene and the light.
  11651. *
  11652. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11653. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11654. * @param activeCamera The camera we are returning the max for
  11655. * @returns the depth max z
  11656. */
  11657. getDepthMaxZ(activeCamera: Camera): number;
  11658. /**
  11659. * Prepares the list of defines specific to the light type.
  11660. * @param defines the list of defines
  11661. * @param lightIndex defines the index of the light for the effect
  11662. */
  11663. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11664. }
  11665. }
  11666. declare module BABYLON {
  11667. /**
  11668. * The HemisphericLight simulates the ambient environment light,
  11669. * so the passed direction is the light reflection direction, not the incoming direction.
  11670. */
  11671. class HemisphericLight extends Light {
  11672. /**
  11673. * The groundColor is the light in the opposite direction to the one specified during creation.
  11674. * 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.
  11675. */
  11676. groundColor: Color3;
  11677. /**
  11678. * The light reflection direction, not the incoming direction.
  11679. */
  11680. direction: Vector3;
  11681. private _worldMatrix;
  11682. /**
  11683. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11684. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11685. * The HemisphericLight can't cast shadows.
  11686. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11687. * @param name The friendly name of the light
  11688. * @param direction The direction of the light reflection
  11689. * @param scene The scene the light belongs to
  11690. */
  11691. constructor(name: string, direction: Vector3, scene: Scene);
  11692. protected _buildUniformLayout(): void;
  11693. /**
  11694. * Returns the string "HemisphericLight".
  11695. * @return The class name
  11696. */
  11697. getClassName(): string;
  11698. /**
  11699. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11700. * Returns the updated direction.
  11701. * @param target The target the direction should point to
  11702. * @return The computed direction
  11703. */
  11704. setDirectionToTarget(target: Vector3): Vector3;
  11705. /**
  11706. * Returns the shadow generator associated to the light.
  11707. * @returns Always null for hemispheric lights because it does not support shadows.
  11708. */
  11709. getShadowGenerator(): Nullable<ShadowGenerator>;
  11710. /**
  11711. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11712. * @param effect The effect to update
  11713. * @param lightIndex The index of the light in the effect to update
  11714. * @returns The hemispheric light
  11715. */
  11716. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11717. /**
  11718. * @hidden internal use only.
  11719. */
  11720. _getWorldMatrix(): Matrix;
  11721. /**
  11722. * Returns the integer 3.
  11723. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11724. */
  11725. getTypeID(): number;
  11726. /**
  11727. * Prepares the list of defines specific to the light type.
  11728. * @param defines the list of defines
  11729. * @param lightIndex defines the index of the light for the effect
  11730. */
  11731. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11732. }
  11733. }
  11734. declare module BABYLON {
  11735. /**
  11736. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11737. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11738. * 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.
  11739. */
  11740. abstract class Light extends Node {
  11741. /**
  11742. * If every light affecting the material is in this lightmapMode,
  11743. * material.lightmapTexture adds or multiplies
  11744. * (depends on material.useLightmapAsShadowmap)
  11745. * after every other light calculations.
  11746. */
  11747. static readonly LIGHTMAP_DEFAULT: number;
  11748. /**
  11749. * material.lightmapTexture as only diffuse lighting from this light
  11750. * adds only specular lighting from this light
  11751. * adds dynamic shadows
  11752. */
  11753. static readonly LIGHTMAP_SPECULAR: number;
  11754. /**
  11755. * material.lightmapTexture as only lighting
  11756. * no light calculation from this light
  11757. * only adds dynamic shadows from this light
  11758. */
  11759. static readonly LIGHTMAP_SHADOWSONLY: number;
  11760. /**
  11761. * Each light type uses the default quantity according to its type:
  11762. * point/spot lights use luminous intensity
  11763. * directional lights use illuminance
  11764. */
  11765. static readonly INTENSITYMODE_AUTOMATIC: number;
  11766. /**
  11767. * lumen (lm)
  11768. */
  11769. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11770. /**
  11771. * candela (lm/sr)
  11772. */
  11773. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11774. /**
  11775. * lux (lm/m^2)
  11776. */
  11777. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11778. /**
  11779. * nit (cd/m^2)
  11780. */
  11781. static readonly INTENSITYMODE_LUMINANCE: number;
  11782. /**
  11783. * Light type const id of the point light.
  11784. */
  11785. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11786. /**
  11787. * Light type const id of the directional light.
  11788. */
  11789. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11790. /**
  11791. * Light type const id of the spot light.
  11792. */
  11793. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11794. /**
  11795. * Light type const id of the hemispheric light.
  11796. */
  11797. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11798. /**
  11799. * Diffuse gives the basic color to an object.
  11800. */
  11801. diffuse: Color3;
  11802. /**
  11803. * Specular produces a highlight color on an object.
  11804. * Note: This is note affecting PBR materials.
  11805. */
  11806. specular: Color3;
  11807. /**
  11808. * Strength of the light.
  11809. * Note: By default it is define in the framework own unit.
  11810. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11811. */
  11812. intensity: number;
  11813. /**
  11814. * Defines how far from the source the light is impacting in scene units.
  11815. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11816. */
  11817. range: number;
  11818. /**
  11819. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11820. * of light.
  11821. */
  11822. private _photometricScale;
  11823. private _intensityMode;
  11824. /**
  11825. * Gets the photometric scale used to interpret the intensity.
  11826. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11827. */
  11828. /**
  11829. * Sets the photometric scale used to interpret the intensity.
  11830. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11831. */
  11832. intensityMode: number;
  11833. private _radius;
  11834. /**
  11835. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11836. */
  11837. /**
  11838. * sets the light radius used by PBR Materials to simulate soft area lights.
  11839. */
  11840. radius: number;
  11841. private _renderPriority;
  11842. /**
  11843. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11844. * exceeding the number allowed of the materials.
  11845. */
  11846. renderPriority: number;
  11847. private _shadowEnabled;
  11848. /**
  11849. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11850. * the current shadow generator.
  11851. */
  11852. /**
  11853. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11854. * the current shadow generator.
  11855. */
  11856. shadowEnabled: boolean;
  11857. private _includedOnlyMeshes;
  11858. /**
  11859. * Gets the only meshes impacted by this light.
  11860. */
  11861. /**
  11862. * Sets the only meshes impacted by this light.
  11863. */
  11864. includedOnlyMeshes: AbstractMesh[];
  11865. private _excludedMeshes;
  11866. /**
  11867. * Gets the meshes not impacted by this light.
  11868. */
  11869. /**
  11870. * Sets the meshes not impacted by this light.
  11871. */
  11872. excludedMeshes: AbstractMesh[];
  11873. private _excludeWithLayerMask;
  11874. /**
  11875. * Gets the layer id use to find what meshes are not impacted by the light.
  11876. * Inactive if 0
  11877. */
  11878. /**
  11879. * Sets the layer id use to find what meshes are not impacted by the light.
  11880. * Inactive if 0
  11881. */
  11882. excludeWithLayerMask: number;
  11883. private _includeOnlyWithLayerMask;
  11884. /**
  11885. * Gets the layer id use to find what meshes are impacted by the light.
  11886. * Inactive if 0
  11887. */
  11888. /**
  11889. * Sets the layer id use to find what meshes are impacted by the light.
  11890. * Inactive if 0
  11891. */
  11892. includeOnlyWithLayerMask: number;
  11893. private _lightmapMode;
  11894. /**
  11895. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11896. */
  11897. /**
  11898. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11899. */
  11900. lightmapMode: number;
  11901. private _parentedWorldMatrix;
  11902. /**
  11903. * Shadow generator associted to the light.
  11904. * Internal use only.
  11905. */
  11906. _shadowGenerator: Nullable<IShadowGenerator>;
  11907. /**
  11908. * @hidden Internal use only.
  11909. */
  11910. _excludedMeshesIds: string[];
  11911. /**
  11912. * @hidden Internal use only.
  11913. */
  11914. _includedOnlyMeshesIds: string[];
  11915. /**
  11916. * The current light unifom buffer.
  11917. * @hidden Internal use only.
  11918. */
  11919. _uniformBuffer: UniformBuffer;
  11920. /**
  11921. * Creates a Light object in the scene.
  11922. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11923. * @param name The firendly name of the light
  11924. * @param scene The scene the light belongs too
  11925. */
  11926. constructor(name: string, scene: Scene);
  11927. protected abstract _buildUniformLayout(): void;
  11928. /**
  11929. * Sets the passed Effect "effect" with the Light information.
  11930. * @param effect The effect to update
  11931. * @param lightIndex The index of the light in the effect to update
  11932. * @returns The light
  11933. */
  11934. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11935. /**
  11936. * @hidden internal use only.
  11937. */
  11938. abstract _getWorldMatrix(): Matrix;
  11939. /**
  11940. * Returns the string "Light".
  11941. * @returns the class name
  11942. */
  11943. getClassName(): string;
  11944. /**
  11945. * Converts the light information to a readable string for debug purpose.
  11946. * @param fullDetails Supports for multiple levels of logging within scene loading
  11947. * @returns the human readable light info
  11948. */
  11949. toString(fullDetails?: boolean): string;
  11950. /**
  11951. * Set the enabled state of this node.
  11952. * @param value - the new enabled state
  11953. */
  11954. setEnabled(value: boolean): void;
  11955. /**
  11956. * Returns the Light associated shadow generator if any.
  11957. * @return the associated shadow generator.
  11958. */
  11959. getShadowGenerator(): Nullable<IShadowGenerator>;
  11960. /**
  11961. * Returns a Vector3, the absolute light position in the World.
  11962. * @returns the world space position of the light
  11963. */
  11964. getAbsolutePosition(): Vector3;
  11965. /**
  11966. * Specifies if the light will affect the passed mesh.
  11967. * @param mesh The mesh to test against the light
  11968. * @return true the mesh is affected otherwise, false.
  11969. */
  11970. canAffectMesh(mesh: AbstractMesh): boolean;
  11971. /**
  11972. * Computes and Returns the light World matrix.
  11973. * @returns the world matrix
  11974. */
  11975. getWorldMatrix(): Matrix;
  11976. /**
  11977. * Sort function to order lights for rendering.
  11978. * @param a First Light object to compare to second.
  11979. * @param b Second Light object to compare first.
  11980. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11981. */
  11982. static CompareLightsPriority(a: Light, b: Light): number;
  11983. /**
  11984. * Releases resources associated with this node.
  11985. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11986. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11987. */
  11988. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11989. /**
  11990. * Returns the light type ID (integer).
  11991. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11992. */
  11993. getTypeID(): number;
  11994. /**
  11995. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11996. * @returns the scaled intensity in intensity mode unit
  11997. */
  11998. getScaledIntensity(): number;
  11999. /**
  12000. * Returns a new Light object, named "name", from the current one.
  12001. * @param name The name of the cloned light
  12002. * @returns the new created light
  12003. */
  12004. clone(name: string): Nullable<Light>;
  12005. /**
  12006. * Serializes the current light into a Serialization object.
  12007. * @returns the serialized object.
  12008. */
  12009. serialize(): any;
  12010. /**
  12011. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12012. * This new light is named "name" and added to the passed scene.
  12013. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12014. * @param name The friendly name of the light
  12015. * @param scene The scene the new light will belong to
  12016. * @returns the constructor function
  12017. */
  12018. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12019. /**
  12020. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12021. * @param parsedLight The JSON representation of the light
  12022. * @param scene The scene to create the parsed light in
  12023. * @returns the created light after parsing
  12024. */
  12025. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12026. private _hookArrayForExcluded(array);
  12027. private _hookArrayForIncludedOnly(array);
  12028. private _resyncMeshes();
  12029. /**
  12030. * Forces the meshes to update their light related information in their rendering used effects
  12031. * @hidden Internal Use Only
  12032. */
  12033. _markMeshesAsLightDirty(): void;
  12034. /**
  12035. * Recomputes the cached photometric scale if needed.
  12036. */
  12037. private _computePhotometricScale();
  12038. /**
  12039. * Returns the Photometric Scale according to the light type and intensity mode.
  12040. */
  12041. private _getPhotometricScale();
  12042. /**
  12043. * Reorder the light in the scene according to their defined priority.
  12044. * @hidden Internal Use Only
  12045. */
  12046. _reorderLightsInScene(): void;
  12047. /**
  12048. * Prepares the list of defines specific to the light type.
  12049. * @param defines the list of defines
  12050. * @param lightIndex defines the index of the light for the effect
  12051. */
  12052. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12053. }
  12054. }
  12055. declare module BABYLON {
  12056. /**
  12057. * A point light is a light defined by an unique point in world space.
  12058. * The light is emitted in every direction from this point.
  12059. * A good example of a point light is a standard light bulb.
  12060. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12061. */
  12062. class PointLight extends ShadowLight {
  12063. private _shadowAngle;
  12064. /**
  12065. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12066. * This specifies what angle the shadow will use to be created.
  12067. *
  12068. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12069. */
  12070. /**
  12071. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12072. * This specifies what angle the shadow will use to be created.
  12073. *
  12074. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  12075. */
  12076. shadowAngle: number;
  12077. /**
  12078. * Gets the direction if it has been set.
  12079. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12080. */
  12081. /**
  12082. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  12083. */
  12084. direction: Vector3;
  12085. /**
  12086. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  12087. * A PointLight emits the light in every direction.
  12088. * It can cast shadows.
  12089. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  12090. * ```javascript
  12091. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  12092. * ```
  12093. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12094. * @param name The light friendly name
  12095. * @param position The position of the point light in the scene
  12096. * @param scene The scene the lights belongs to
  12097. */
  12098. constructor(name: string, position: Vector3, scene: Scene);
  12099. /**
  12100. * Returns the string "PointLight"
  12101. * @returns the class name
  12102. */
  12103. getClassName(): string;
  12104. /**
  12105. * Returns the integer 0.
  12106. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12107. */
  12108. getTypeID(): number;
  12109. /**
  12110. * Specifies wether or not the shadowmap should be a cube texture.
  12111. * @returns true if the shadowmap needs to be a cube texture.
  12112. */
  12113. needCube(): boolean;
  12114. /**
  12115. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  12116. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12117. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12118. */
  12119. getShadowDirection(faceIndex?: number): Vector3;
  12120. /**
  12121. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  12122. * - fov = PI / 2
  12123. * - aspect ratio : 1.0
  12124. * - z-near and far equal to the active camera minZ and maxZ.
  12125. * Returns the PointLight.
  12126. */
  12127. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12128. protected _buildUniformLayout(): void;
  12129. /**
  12130. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  12131. * @param effect The effect to update
  12132. * @param lightIndex The index of the light in the effect to update
  12133. * @returns The point light
  12134. */
  12135. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  12136. /**
  12137. * Prepares the list of defines specific to the light type.
  12138. * @param defines the list of defines
  12139. * @param lightIndex defines the index of the light for the effect
  12140. */
  12141. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12142. }
  12143. }
  12144. declare module BABYLON {
  12145. /**
  12146. * Interface describing all the common properties and methods a shadow light needs to implement.
  12147. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  12148. * as well as binding the different shadow properties to the effects.
  12149. */
  12150. interface IShadowLight extends Light {
  12151. /**
  12152. * The light id in the scene (used in scene.findLighById for instance)
  12153. */
  12154. id: string;
  12155. /**
  12156. * The position the shdow will be casted from.
  12157. */
  12158. position: Vector3;
  12159. /**
  12160. * In 2d mode (needCube being false), the direction used to cast the shadow.
  12161. */
  12162. direction: Vector3;
  12163. /**
  12164. * The transformed position. Position of the light in world space taking parenting in account.
  12165. */
  12166. transformedPosition: Vector3;
  12167. /**
  12168. * The transformed direction. Direction of the light in world space taking parenting in account.
  12169. */
  12170. transformedDirection: Vector3;
  12171. /**
  12172. * The friendly name of the light in the scene.
  12173. */
  12174. name: string;
  12175. /**
  12176. * Defines the shadow projection clipping minimum z value.
  12177. */
  12178. shadowMinZ: number;
  12179. /**
  12180. * Defines the shadow projection clipping maximum z value.
  12181. */
  12182. shadowMaxZ: number;
  12183. /**
  12184. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12185. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12186. */
  12187. computeTransformedInformation(): boolean;
  12188. /**
  12189. * Gets the scene the light belongs to.
  12190. * @returns The scene
  12191. */
  12192. getScene(): Scene;
  12193. /**
  12194. * Callback defining a custom Projection Matrix Builder.
  12195. * This can be used to override the default projection matrix computation.
  12196. */
  12197. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12198. /**
  12199. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12200. * @param matrix The materix to updated with the projection information
  12201. * @param viewMatrix The transform matrix of the light
  12202. * @param renderList The list of mesh to render in the map
  12203. * @returns The current light
  12204. */
  12205. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12206. /**
  12207. * Gets the current depth scale used in ESM.
  12208. * @returns The scale
  12209. */
  12210. getDepthScale(): number;
  12211. /**
  12212. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12213. * @returns true if a cube texture needs to be use
  12214. */
  12215. needCube(): boolean;
  12216. /**
  12217. * Detects if the projection matrix requires to be recomputed this frame.
  12218. * @returns true if it requires to be recomputed otherwise, false.
  12219. */
  12220. needProjectionMatrixCompute(): boolean;
  12221. /**
  12222. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12223. */
  12224. forceProjectionMatrixCompute(): void;
  12225. /**
  12226. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12227. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12228. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12229. */
  12230. getShadowDirection(faceIndex?: number): Vector3;
  12231. /**
  12232. * Gets the minZ used for shadow according to both the scene and the light.
  12233. * @param activeCamera The camera we are returning the min for
  12234. * @returns the depth min z
  12235. */
  12236. getDepthMinZ(activeCamera: Camera): number;
  12237. /**
  12238. * Gets the maxZ used for shadow according to both the scene and the light.
  12239. * @param activeCamera The camera we are returning the max for
  12240. * @returns the depth max z
  12241. */
  12242. getDepthMaxZ(activeCamera: Camera): number;
  12243. }
  12244. /**
  12245. * Base implementation IShadowLight
  12246. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  12247. */
  12248. abstract class ShadowLight extends Light implements IShadowLight {
  12249. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12250. protected _position: Vector3;
  12251. protected _setPosition(value: Vector3): void;
  12252. /**
  12253. * Sets the position the shadow will be casted from. Also use as the light position for both
  12254. * point and spot lights.
  12255. */
  12256. /**
  12257. * Sets the position the shadow will be casted from. Also use as the light position for both
  12258. * point and spot lights.
  12259. */
  12260. position: Vector3;
  12261. protected _direction: Vector3;
  12262. protected _setDirection(value: Vector3): void;
  12263. /**
  12264. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  12265. * Also use as the light direction on spot and directional lights.
  12266. */
  12267. /**
  12268. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  12269. * Also use as the light direction on spot and directional lights.
  12270. */
  12271. direction: Vector3;
  12272. private _shadowMinZ;
  12273. /**
  12274. * Gets the shadow projection clipping minimum z value.
  12275. */
  12276. /**
  12277. * Sets the shadow projection clipping minimum z value.
  12278. */
  12279. shadowMinZ: number;
  12280. private _shadowMaxZ;
  12281. /**
  12282. * Sets the shadow projection clipping maximum z value.
  12283. */
  12284. /**
  12285. * Gets the shadow projection clipping maximum z value.
  12286. */
  12287. shadowMaxZ: number;
  12288. /**
  12289. * Callback defining a custom Projection Matrix Builder.
  12290. * This can be used to override the default projection matrix computation.
  12291. */
  12292. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  12293. /**
  12294. * The transformed position. Position of the light in world space taking parenting in account.
  12295. */
  12296. transformedPosition: Vector3;
  12297. /**
  12298. * The transformed direction. Direction of the light in world space taking parenting in account.
  12299. */
  12300. transformedDirection: Vector3;
  12301. private _worldMatrix;
  12302. private _needProjectionMatrixCompute;
  12303. /**
  12304. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  12305. * @returns true if the information has been computed, false if it does not need to (no parenting)
  12306. */
  12307. computeTransformedInformation(): boolean;
  12308. /**
  12309. * Return the depth scale used for the shadow map.
  12310. * @returns the depth scale.
  12311. */
  12312. getDepthScale(): number;
  12313. /**
  12314. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  12315. * @param faceIndex The index of the face we are computed the direction to generate shadow
  12316. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  12317. */
  12318. getShadowDirection(faceIndex?: number): Vector3;
  12319. /**
  12320. * Returns the ShadowLight absolute position in the World.
  12321. * @returns the position vector in world space
  12322. */
  12323. getAbsolutePosition(): Vector3;
  12324. /**
  12325. * Sets the ShadowLight direction toward the passed target.
  12326. * @param target The point tot target in local space
  12327. * @returns the updated ShadowLight direction
  12328. */
  12329. setDirectionToTarget(target: Vector3): Vector3;
  12330. /**
  12331. * Returns the light rotation in euler definition.
  12332. * @returns the x y z rotation in local space.
  12333. */
  12334. getRotation(): Vector3;
  12335. /**
  12336. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  12337. * @returns true if a cube texture needs to be use
  12338. */
  12339. needCube(): boolean;
  12340. /**
  12341. * Detects if the projection matrix requires to be recomputed this frame.
  12342. * @returns true if it requires to be recomputed otherwise, false.
  12343. */
  12344. needProjectionMatrixCompute(): boolean;
  12345. /**
  12346. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  12347. */
  12348. forceProjectionMatrixCompute(): void;
  12349. /**
  12350. * Get the world matrix of the sahdow lights.
  12351. * @hidden Internal Use Only
  12352. */
  12353. _getWorldMatrix(): Matrix;
  12354. /**
  12355. * Gets the minZ used for shadow according to both the scene and the light.
  12356. * @param activeCamera The camera we are returning the min for
  12357. * @returns the depth min z
  12358. */
  12359. getDepthMinZ(activeCamera: Camera): number;
  12360. /**
  12361. * Gets the maxZ used for shadow according to both the scene and the light.
  12362. * @param activeCamera The camera we are returning the max for
  12363. * @returns the depth max z
  12364. */
  12365. getDepthMaxZ(activeCamera: Camera): number;
  12366. /**
  12367. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  12368. * @param matrix The materix to updated with the projection information
  12369. * @param viewMatrix The transform matrix of the light
  12370. * @param renderList The list of mesh to render in the map
  12371. * @returns The current light
  12372. */
  12373. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  12374. }
  12375. }
  12376. declare module BABYLON {
  12377. /**
  12378. * A spot light is defined by a position, a direction, an angle, and an exponent.
  12379. * These values define a cone of light starting from the position, emitting toward the direction.
  12380. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  12381. * and the exponent defines the speed of the decay of the light with distance (reach).
  12382. * Documentation: https://doc.babylonjs.com/babylon101/lights
  12383. */
  12384. class SpotLight extends ShadowLight {
  12385. private _angle;
  12386. /**
  12387. * Gets the cone angle of the spot light in Radians.
  12388. */
  12389. /**
  12390. * Sets the cone angle of the spot light in Radians.
  12391. */
  12392. angle: number;
  12393. private _shadowAngleScale;
  12394. /**
  12395. * Allows scaling the angle of the light for shadow generation only.
  12396. */
  12397. /**
  12398. * Allows scaling the angle of the light for shadow generation only.
  12399. */
  12400. shadowAngleScale: number;
  12401. /**
  12402. * The light decay speed with the distance from the emission spot.
  12403. */
  12404. exponent: number;
  12405. private _projectionTextureMatrix;
  12406. /**
  12407. * Allows reading the projecton texture
  12408. */
  12409. readonly projectionTextureMatrix: Matrix;
  12410. protected _projectionTextureLightNear: number;
  12411. /**
  12412. * Gets the near clip of the Spotlight for texture projection.
  12413. */
  12414. /**
  12415. * Sets the near clip of the Spotlight for texture projection.
  12416. */
  12417. projectionTextureLightNear: number;
  12418. protected _projectionTextureLightFar: number;
  12419. /**
  12420. * Gets the far clip of the Spotlight for texture projection.
  12421. */
  12422. /**
  12423. * Sets the far clip of the Spotlight for texture projection.
  12424. */
  12425. projectionTextureLightFar: number;
  12426. protected _projectionTextureUpDirection: Vector3;
  12427. /**
  12428. * Gets the Up vector of the Spotlight for texture projection.
  12429. */
  12430. /**
  12431. * Sets the Up vector of the Spotlight for texture projection.
  12432. */
  12433. projectionTextureUpDirection: Vector3;
  12434. private _projectionTexture;
  12435. /**
  12436. * Gets the projection texture of the light.
  12437. */
  12438. /**
  12439. * Sets the projection texture of the light.
  12440. */
  12441. projectionTexture: Nullable<BaseTexture>;
  12442. private _projectionTextureViewLightDirty;
  12443. private _projectionTextureProjectionLightDirty;
  12444. private _projectionTextureDirty;
  12445. private _projectionTextureViewTargetVector;
  12446. private _projectionTextureViewLightMatrix;
  12447. private _projectionTextureProjectionLightMatrix;
  12448. private _projectionTextureScalingMatrix;
  12449. /**
  12450. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  12451. * It can cast shadows.
  12452. * Documentation : http://doc.babylonjs.com/tutorials/lights
  12453. * @param name The light friendly name
  12454. * @param position The position of the spot light in the scene
  12455. * @param direction The direction of the light in the scene
  12456. * @param angle The cone angle of the light in Radians
  12457. * @param exponent The light decay speed with the distance from the emission spot
  12458. * @param scene The scene the lights belongs to
  12459. */
  12460. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  12461. /**
  12462. * Returns the string "SpotLight".
  12463. * @returns the class name
  12464. */
  12465. getClassName(): string;
  12466. /**
  12467. * Returns the integer 2.
  12468. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12469. */
  12470. getTypeID(): number;
  12471. /**
  12472. * Overrides the direction setter to recompute the projection texture view light Matrix.
  12473. */
  12474. protected _setDirection(value: Vector3): void;
  12475. /**
  12476. * Overrides the position setter to recompute the projection texture view light Matrix.
  12477. */
  12478. protected _setPosition(value: Vector3): void;
  12479. /**
  12480. * 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.
  12481. * Returns the SpotLight.
  12482. */
  12483. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  12484. protected _computeProjectionTextureViewLightMatrix(): void;
  12485. protected _computeProjectionTextureProjectionLightMatrix(): void;
  12486. /**
  12487. * Main function for light texture projection matrix computing.
  12488. */
  12489. protected _computeProjectionTextureMatrix(): void;
  12490. protected _buildUniformLayout(): void;
  12491. /**
  12492. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  12493. * @param effect The effect to update
  12494. * @param lightIndex The index of the light in the effect to update
  12495. * @returns The spot light
  12496. */
  12497. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  12498. /**
  12499. * Disposes the light and the associated resources.
  12500. */
  12501. dispose(): void;
  12502. /**
  12503. * Prepares the list of defines specific to the light type.
  12504. * @param defines the list of defines
  12505. * @param lightIndex defines the index of the light for the effect
  12506. */
  12507. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12508. }
  12509. }
  12510. declare module BABYLON {
  12511. interface ILoadingScreen {
  12512. displayLoadingUI: () => void;
  12513. hideLoadingUI: () => void;
  12514. loadingUIBackgroundColor: string;
  12515. loadingUIText: string;
  12516. }
  12517. class DefaultLoadingScreen implements ILoadingScreen {
  12518. private _renderingCanvas;
  12519. private _loadingText;
  12520. private _loadingDivBackgroundColor;
  12521. private _loadingDiv;
  12522. private _loadingTextDiv;
  12523. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  12524. displayLoadingUI(): void;
  12525. hideLoadingUI(): void;
  12526. loadingUIText: string;
  12527. loadingUIBackgroundColor: string;
  12528. private _resizeLoadingUI;
  12529. }
  12530. }
  12531. declare module BABYLON {
  12532. class SceneLoaderProgressEvent {
  12533. readonly lengthComputable: boolean;
  12534. readonly loaded: number;
  12535. readonly total: number;
  12536. constructor(lengthComputable: boolean, loaded: number, total: number);
  12537. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  12538. }
  12539. interface ISceneLoaderPluginExtensions {
  12540. [extension: string]: {
  12541. isBinary: boolean;
  12542. };
  12543. }
  12544. interface ISceneLoaderPluginFactory {
  12545. name: string;
  12546. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  12547. canDirectLoad?: (data: string) => boolean;
  12548. }
  12549. interface ISceneLoaderPlugin {
  12550. /**
  12551. * The friendly name of this plugin.
  12552. */
  12553. name: string;
  12554. /**
  12555. * The file extensions supported by this plugin.
  12556. */
  12557. extensions: string | ISceneLoaderPluginExtensions;
  12558. /**
  12559. * Import meshes into a scene.
  12560. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12561. * @param scene The scene to import into
  12562. * @param data The data to import
  12563. * @param rootUrl The root url for scene and resources
  12564. * @param meshes The meshes array to import into
  12565. * @param particleSystems The particle systems array to import into
  12566. * @param skeletons The skeletons array to import into
  12567. * @param onError The callback when import fails
  12568. * @returns True if successful or false otherwise
  12569. */
  12570. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  12571. /**
  12572. * Load into a scene.
  12573. * @param scene The scene to load into
  12574. * @param data The data to import
  12575. * @param rootUrl The root url for scene and resources
  12576. * @param onError The callback when import fails
  12577. * @returns true if successful or false otherwise
  12578. */
  12579. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  12580. /**
  12581. * The callback that returns true if the data can be directly loaded.
  12582. */
  12583. canDirectLoad?: (data: string) => boolean;
  12584. /**
  12585. * The callback that allows custom handling of the root url based on the response url.
  12586. */
  12587. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12588. /**
  12589. * Load into an asset container.
  12590. * @param scene The scene to load into
  12591. * @param data The data to import
  12592. * @param rootUrl The root url for scene and resources
  12593. * @param onError The callback when import fails
  12594. * @returns The loaded asset container
  12595. */
  12596. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  12597. }
  12598. interface ISceneLoaderPluginAsync {
  12599. /**
  12600. * The friendly name of this plugin.
  12601. */
  12602. name: string;
  12603. /**
  12604. * The file extensions supported by this plugin.
  12605. */
  12606. extensions: string | ISceneLoaderPluginExtensions;
  12607. /**
  12608. * Import meshes into a scene.
  12609. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12610. * @param scene The scene to import into
  12611. * @param data The data to import
  12612. * @param rootUrl The root url for scene and resources
  12613. * @param onProgress The callback when the load progresses
  12614. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  12615. */
  12616. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  12617. meshes: AbstractMesh[];
  12618. particleSystems: IParticleSystem[];
  12619. skeletons: Skeleton[];
  12620. animationGroups: AnimationGroup[];
  12621. }>;
  12622. /**
  12623. * Load into a scene.
  12624. * @param scene The scene to load into
  12625. * @param data The data to import
  12626. * @param rootUrl The root url for scene and resources
  12627. * @param onProgress The callback when the load progresses
  12628. * @returns Nothing
  12629. */
  12630. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  12631. /**
  12632. * The callback that returns true if the data can be directly loaded.
  12633. */
  12634. canDirectLoad?: (data: string) => boolean;
  12635. /**
  12636. * The callback that allows custom handling of the root url based on the response url.
  12637. */
  12638. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12639. /**
  12640. * Load into an asset container.
  12641. * @param scene The scene to load into
  12642. * @param data The data to import
  12643. * @param rootUrl The root url for scene and resources
  12644. * @param onProgress The callback when the load progresses
  12645. * @returns The loaded asset container
  12646. */
  12647. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  12648. }
  12649. class SceneLoader {
  12650. private static _ForceFullSceneLoadingForIncremental;
  12651. private static _ShowLoadingScreen;
  12652. private static _CleanBoneMatrixWeights;
  12653. static readonly NO_LOGGING: number;
  12654. static readonly MINIMAL_LOGGING: number;
  12655. static readonly SUMMARY_LOGGING: number;
  12656. static readonly DETAILED_LOGGING: number;
  12657. private static _loggingLevel;
  12658. static ForceFullSceneLoadingForIncremental: boolean;
  12659. static ShowLoadingScreen: boolean;
  12660. static loggingLevel: number;
  12661. static CleanBoneMatrixWeights: boolean;
  12662. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12663. private static _registeredPlugins;
  12664. private static _getDefaultPlugin();
  12665. private static _getPluginForExtension(extension);
  12666. private static _getPluginForDirectLoad(data);
  12667. private static _getPluginForFilename(sceneFilename);
  12668. private static _getDirectLoad(sceneFilename);
  12669. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  12670. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  12671. static IsPluginForExtensionAvailable(extension: string): boolean;
  12672. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  12673. /**
  12674. * Import meshes into a scene
  12675. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12676. * @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)
  12677. * @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)
  12678. * @param scene the instance of BABYLON.Scene to append to
  12679. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  12680. * @param onProgress a callback with a progress event for each file being loaded
  12681. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12682. * @param pluginExtension the extension used to determine the plugin
  12683. * @returns The loaded plugin
  12684. */
  12685. 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>;
  12686. /**
  12687. * Import meshes into a scene
  12688. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12689. * @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)
  12690. * @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)
  12691. * @param scene the instance of BABYLON.Scene to append to
  12692. * @param onProgress a callback with a progress event for each file being loaded
  12693. * @param pluginExtension the extension used to determine the plugin
  12694. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  12695. */
  12696. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  12697. meshes: AbstractMesh[];
  12698. particleSystems: IParticleSystem[];
  12699. skeletons: Skeleton[];
  12700. animationGroups: AnimationGroup[];
  12701. }>;
  12702. /**
  12703. * Load a scene
  12704. * @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)
  12705. * @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)
  12706. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12707. * @param onSuccess a callback with the scene when import succeeds
  12708. * @param onProgress a callback with a progress event for each file being loaded
  12709. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12710. * @param pluginExtension the extension used to determine the plugin
  12711. * @returns The loaded plugin
  12712. */
  12713. 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>;
  12714. /**
  12715. * Load a scene
  12716. * @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)
  12717. * @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)
  12718. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12719. * @param onProgress a callback with a progress event for each file being loaded
  12720. * @param pluginExtension the extension used to determine the plugin
  12721. * @returns The loaded scene
  12722. */
  12723. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12724. /**
  12725. * Append a scene
  12726. * @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)
  12727. * @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)
  12728. * @param scene is the instance of BABYLON.Scene to append to
  12729. * @param onSuccess a callback with the scene when import succeeds
  12730. * @param onProgress a callback with a progress event for each file being loaded
  12731. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12732. * @param pluginExtension the extension used to determine the plugin
  12733. * @returns The loaded plugin
  12734. */
  12735. 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>;
  12736. /**
  12737. * Append a scene
  12738. * @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)
  12739. * @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)
  12740. * @param scene is the instance of BABYLON.Scene to append to
  12741. * @param onProgress a callback with a progress event for each file being loaded
  12742. * @param pluginExtension the extension used to determine the plugin
  12743. * @returns The given scene
  12744. */
  12745. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12746. /**
  12747. * Load a scene into an asset container
  12748. * @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)
  12749. * @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)
  12750. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  12751. * @param onSuccess a callback with the scene when import succeeds
  12752. * @param onProgress a callback with a progress event for each file being loaded
  12753. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12754. * @param pluginExtension the extension used to determine the plugin
  12755. * @returns The loaded plugin
  12756. */
  12757. 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>;
  12758. /**
  12759. * Load a scene into an asset container
  12760. * @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)
  12761. * @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)
  12762. * @param scene is the instance of BABYLON.Scene to append to
  12763. * @param onProgress a callback with a progress event for each file being loaded
  12764. * @param pluginExtension the extension used to determine the plugin
  12765. * @returns The loaded asset container
  12766. */
  12767. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  12768. }
  12769. }
  12770. declare module BABYLON {
  12771. /**
  12772. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  12773. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  12774. * 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;
  12775. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  12776. */
  12777. class ColorCurves {
  12778. private _dirty;
  12779. private _tempColor;
  12780. private _globalCurve;
  12781. private _highlightsCurve;
  12782. private _midtonesCurve;
  12783. private _shadowsCurve;
  12784. private _positiveCurve;
  12785. private _negativeCurve;
  12786. private _globalHue;
  12787. private _globalDensity;
  12788. private _globalSaturation;
  12789. private _globalExposure;
  12790. /**
  12791. * Gets the global Hue value.
  12792. * 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).
  12793. */
  12794. /**
  12795. * Sets the global Hue value.
  12796. * 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).
  12797. */
  12798. globalHue: number;
  12799. /**
  12800. * Gets the global Density value.
  12801. * 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.
  12802. * Values less than zero provide a filter of opposite hue.
  12803. */
  12804. /**
  12805. * Sets the global Density value.
  12806. * 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.
  12807. * Values less than zero provide a filter of opposite hue.
  12808. */
  12809. globalDensity: number;
  12810. /**
  12811. * Gets the global Saturation value.
  12812. * 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.
  12813. */
  12814. /**
  12815. * Sets the global Saturation value.
  12816. * 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.
  12817. */
  12818. globalSaturation: number;
  12819. /**
  12820. * Gets the global Exposure value.
  12821. * 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.
  12822. */
  12823. /**
  12824. * Sets the global Exposure value.
  12825. * 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.
  12826. */
  12827. globalExposure: number;
  12828. private _highlightsHue;
  12829. private _highlightsDensity;
  12830. private _highlightsSaturation;
  12831. private _highlightsExposure;
  12832. /**
  12833. * Gets the highlights Hue value.
  12834. * 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).
  12835. */
  12836. /**
  12837. * Sets the highlights Hue value.
  12838. * 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).
  12839. */
  12840. highlightsHue: number;
  12841. /**
  12842. * Gets the highlights Density value.
  12843. * 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.
  12844. * Values less than zero provide a filter of opposite hue.
  12845. */
  12846. /**
  12847. * Sets the highlights Density value.
  12848. * 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.
  12849. * Values less than zero provide a filter of opposite hue.
  12850. */
  12851. highlightsDensity: number;
  12852. /**
  12853. * Gets the highlights Saturation value.
  12854. * 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.
  12855. */
  12856. /**
  12857. * Sets the highlights Saturation value.
  12858. * 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.
  12859. */
  12860. highlightsSaturation: number;
  12861. /**
  12862. * Gets the highlights Exposure value.
  12863. * 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.
  12864. */
  12865. /**
  12866. * Sets the highlights Exposure value.
  12867. * 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.
  12868. */
  12869. highlightsExposure: number;
  12870. private _midtonesHue;
  12871. private _midtonesDensity;
  12872. private _midtonesSaturation;
  12873. private _midtonesExposure;
  12874. /**
  12875. * Gets the midtones Hue value.
  12876. * 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).
  12877. */
  12878. /**
  12879. * Sets the midtones Hue value.
  12880. * 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).
  12881. */
  12882. midtonesHue: number;
  12883. /**
  12884. * Gets the midtones Density value.
  12885. * 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.
  12886. * Values less than zero provide a filter of opposite hue.
  12887. */
  12888. /**
  12889. * Sets the midtones Density value.
  12890. * 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.
  12891. * Values less than zero provide a filter of opposite hue.
  12892. */
  12893. midtonesDensity: number;
  12894. /**
  12895. * Gets the midtones Saturation value.
  12896. * 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.
  12897. */
  12898. /**
  12899. * Sets the midtones Saturation value.
  12900. * 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.
  12901. */
  12902. midtonesSaturation: number;
  12903. /**
  12904. * Gets the midtones Exposure value.
  12905. * 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.
  12906. */
  12907. /**
  12908. * Sets the midtones Exposure value.
  12909. * 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.
  12910. */
  12911. midtonesExposure: number;
  12912. private _shadowsHue;
  12913. private _shadowsDensity;
  12914. private _shadowsSaturation;
  12915. private _shadowsExposure;
  12916. /**
  12917. * Gets the shadows Hue value.
  12918. * 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).
  12919. */
  12920. /**
  12921. * Sets the shadows Hue value.
  12922. * 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).
  12923. */
  12924. shadowsHue: number;
  12925. /**
  12926. * Gets the shadows Density value.
  12927. * 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.
  12928. * Values less than zero provide a filter of opposite hue.
  12929. */
  12930. /**
  12931. * Sets the shadows Density value.
  12932. * 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.
  12933. * Values less than zero provide a filter of opposite hue.
  12934. */
  12935. shadowsDensity: number;
  12936. /**
  12937. * Gets the shadows Saturation value.
  12938. * 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.
  12939. */
  12940. /**
  12941. * Sets the shadows Saturation value.
  12942. * 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.
  12943. */
  12944. shadowsSaturation: number;
  12945. /**
  12946. * Gets the shadows Exposure value.
  12947. * 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.
  12948. */
  12949. /**
  12950. * Sets the shadows Exposure value.
  12951. * 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.
  12952. */
  12953. shadowsExposure: number;
  12954. getClassName(): string;
  12955. /**
  12956. * Binds the color curves to the shader.
  12957. * @param colorCurves The color curve to bind
  12958. * @param effect The effect to bind to
  12959. */
  12960. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  12961. /**
  12962. * Prepare the list of uniforms associated with the ColorCurves effects.
  12963. * @param uniformsList The list of uniforms used in the effect
  12964. */
  12965. static PrepareUniforms(uniformsList: string[]): void;
  12966. /**
  12967. * Returns color grading data based on a hue, density, saturation and exposure value.
  12968. * @param filterHue The hue of the color filter.
  12969. * @param filterDensity The density of the color filter.
  12970. * @param saturation The saturation.
  12971. * @param exposure The exposure.
  12972. * @param result The result data container.
  12973. */
  12974. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  12975. /**
  12976. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  12977. * @param value The input slider value in range [-100,100].
  12978. * @returns Adjusted value.
  12979. */
  12980. private static applyColorGradingSliderNonlinear(value);
  12981. /**
  12982. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  12983. * @param hue The hue (H) input.
  12984. * @param saturation The saturation (S) input.
  12985. * @param brightness The brightness (B) input.
  12986. * @result An RGBA color represented as Vector4.
  12987. */
  12988. private static fromHSBToRef(hue, saturation, brightness, result);
  12989. /**
  12990. * Returns a value clamped between min and max
  12991. * @param value The value to clamp
  12992. * @param min The minimum of value
  12993. * @param max The maximum of value
  12994. * @returns The clamped value.
  12995. */
  12996. private static clamp(value, min, max);
  12997. /**
  12998. * Clones the current color curve instance.
  12999. * @return The cloned curves
  13000. */
  13001. clone(): ColorCurves;
  13002. /**
  13003. * Serializes the current color curve instance to a json representation.
  13004. * @return a JSON representation
  13005. */
  13006. serialize(): any;
  13007. /**
  13008. * Parses the color curve from a json representation.
  13009. * @param source the JSON source to parse
  13010. * @return The parsed curves
  13011. */
  13012. static Parse(source: any): ColorCurves;
  13013. }
  13014. }
  13015. declare module BABYLON {
  13016. /**
  13017. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13018. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13019. */
  13020. class EffectFallbacks {
  13021. private _defines;
  13022. private _currentRank;
  13023. private _maxRank;
  13024. private _mesh;
  13025. /**
  13026. * Removes the fallback from the bound mesh.
  13027. */
  13028. unBindMesh(): void;
  13029. /**
  13030. * Adds a fallback on the specified property.
  13031. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13032. * @param define The name of the define in the shader
  13033. */
  13034. addFallback(rank: number, define: string): void;
  13035. /**
  13036. * Sets the mesh to use CPU skinning when needing to fallback.
  13037. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13038. * @param mesh The mesh to use the fallbacks.
  13039. */
  13040. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13041. /**
  13042. * Checks to see if more fallbacks are still availible.
  13043. */
  13044. readonly isMoreFallbacks: boolean;
  13045. /**
  13046. * Removes the defines that shoould be removed when falling back.
  13047. * @param currentDefines defines the current define statements for the shader.
  13048. * @param effect defines the current effect we try to compile
  13049. * @returns The resulting defines with defines of the current rank removed.
  13050. */
  13051. reduce(currentDefines: string, effect: Effect): string;
  13052. }
  13053. /**
  13054. * Options to be used when creating an effect.
  13055. */
  13056. class EffectCreationOptions {
  13057. /**
  13058. * Atrributes that will be used in the shader.
  13059. */
  13060. attributes: string[];
  13061. /**
  13062. * Uniform varible names that will be set in the shader.
  13063. */
  13064. uniformsNames: string[];
  13065. /**
  13066. * Uniform buffer varible names that will be set in the shader.
  13067. */
  13068. uniformBuffersNames: string[];
  13069. /**
  13070. * Sampler texture variable names that will be set in the shader.
  13071. */
  13072. samplers: string[];
  13073. /**
  13074. * Define statements that will be set in the shader.
  13075. */
  13076. defines: any;
  13077. /**
  13078. * Possible fallbacks for this effect to improve performance when needed.
  13079. */
  13080. fallbacks: Nullable<EffectFallbacks>;
  13081. /**
  13082. * Callback that will be called when the shader is compiled.
  13083. */
  13084. onCompiled: Nullable<(effect: Effect) => void>;
  13085. /**
  13086. * Callback that will be called if an error occurs during shader compilation.
  13087. */
  13088. onError: Nullable<(effect: Effect, errors: string) => void>;
  13089. /**
  13090. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13091. */
  13092. indexParameters: any;
  13093. /**
  13094. * Max number of lights that can be used in the shader.
  13095. */
  13096. maxSimultaneousLights: number;
  13097. /**
  13098. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  13099. */
  13100. transformFeedbackVaryings: Nullable<string[]>;
  13101. }
  13102. /**
  13103. * Effect containing vertex and fragment shader that can be executed on an object.
  13104. */
  13105. class Effect {
  13106. /**
  13107. * Name of the effect.
  13108. */
  13109. name: any;
  13110. /**
  13111. * String container all the define statements that should be set on the shader.
  13112. */
  13113. defines: string;
  13114. /**
  13115. * Callback that will be called when the shader is compiled.
  13116. */
  13117. onCompiled: Nullable<(effect: Effect) => void>;
  13118. /**
  13119. * Callback that will be called if an error occurs during shader compilation.
  13120. */
  13121. onError: Nullable<(effect: Effect, errors: string) => void>;
  13122. /**
  13123. * Callback that will be called when effect is bound.
  13124. */
  13125. onBind: Nullable<(effect: Effect) => void>;
  13126. /**
  13127. * Unique ID of the effect.
  13128. */
  13129. uniqueId: number;
  13130. /**
  13131. * Observable that will be called when the shader is compiled.
  13132. */
  13133. onCompileObservable: Observable<Effect>;
  13134. /**
  13135. * Observable that will be called if an error occurs during shader compilation.
  13136. */
  13137. onErrorObservable: Observable<Effect>;
  13138. /** @hidden */
  13139. _onBindObservable: Nullable<Observable<Effect>>;
  13140. /**
  13141. * Observable that will be called when effect is bound.
  13142. */
  13143. readonly onBindObservable: Observable<Effect>;
  13144. /** @hidden */
  13145. _bonesComputationForcedToCPU: boolean;
  13146. private static _uniqueIdSeed;
  13147. private _engine;
  13148. private _uniformBuffersNames;
  13149. private _uniformsNames;
  13150. private _samplers;
  13151. private _isReady;
  13152. private _compilationError;
  13153. private _attributesNames;
  13154. private _attributes;
  13155. private _uniforms;
  13156. /**
  13157. * Key for the effect.
  13158. */
  13159. _key: string;
  13160. private _indexParameters;
  13161. private _fallbacks;
  13162. private _vertexSourceCode;
  13163. private _fragmentSourceCode;
  13164. private _vertexSourceCodeOverride;
  13165. private _fragmentSourceCodeOverride;
  13166. private _transformFeedbackVaryings;
  13167. /**
  13168. * Compiled shader to webGL program.
  13169. */
  13170. _program: WebGLProgram;
  13171. private _valueCache;
  13172. private static _baseCache;
  13173. /**
  13174. * Instantiates an effect.
  13175. * An effect can be used to create/manage/execute vertex and fragment shaders.
  13176. * @param baseName Name of the effect.
  13177. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  13178. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  13179. * @param samplers List of sampler variables that will be passed to the shader.
  13180. * @param engine Engine to be used to render the effect
  13181. * @param defines Define statements to be added to the shader.
  13182. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  13183. * @param onCompiled Callback that will be called when the shader is compiled.
  13184. * @param onError Callback that will be called if an error occurs during shader compilation.
  13185. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  13186. */
  13187. 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);
  13188. /**
  13189. * Unique key for this effect
  13190. */
  13191. readonly key: string;
  13192. /**
  13193. * If the effect has been compiled and prepared.
  13194. * @returns if the effect is compiled and prepared.
  13195. */
  13196. isReady(): boolean;
  13197. /**
  13198. * The engine the effect was initialized with.
  13199. * @returns the engine.
  13200. */
  13201. getEngine(): Engine;
  13202. /**
  13203. * The compiled webGL program for the effect
  13204. * @returns the webGL program.
  13205. */
  13206. getProgram(): WebGLProgram;
  13207. /**
  13208. * The set of names of attribute variables for the shader.
  13209. * @returns An array of attribute names.
  13210. */
  13211. getAttributesNames(): string[];
  13212. /**
  13213. * Returns the attribute at the given index.
  13214. * @param index The index of the attribute.
  13215. * @returns The location of the attribute.
  13216. */
  13217. getAttributeLocation(index: number): number;
  13218. /**
  13219. * Returns the attribute based on the name of the variable.
  13220. * @param name of the attribute to look up.
  13221. * @returns the attribute location.
  13222. */
  13223. getAttributeLocationByName(name: string): number;
  13224. /**
  13225. * The number of attributes.
  13226. * @returns the numnber of attributes.
  13227. */
  13228. getAttributesCount(): number;
  13229. /**
  13230. * Gets the index of a uniform variable.
  13231. * @param uniformName of the uniform to look up.
  13232. * @returns the index.
  13233. */
  13234. getUniformIndex(uniformName: string): number;
  13235. /**
  13236. * Returns the attribute based on the name of the variable.
  13237. * @param uniformName of the uniform to look up.
  13238. * @returns the location of the uniform.
  13239. */
  13240. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  13241. /**
  13242. * Returns an array of sampler variable names
  13243. * @returns The array of sampler variable neames.
  13244. */
  13245. getSamplers(): string[];
  13246. /**
  13247. * The error from the last compilation.
  13248. * @returns the error string.
  13249. */
  13250. getCompilationError(): string;
  13251. /**
  13252. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  13253. * @param func The callback to be used.
  13254. */
  13255. executeWhenCompiled(func: (effect: Effect) => void): void;
  13256. /** @hidden */
  13257. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  13258. /** @hidden */
  13259. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  13260. /** @hidden */
  13261. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  13262. private _processShaderConversion(sourceCode, isFragment, callback);
  13263. private _processIncludes(sourceCode, callback);
  13264. private _processPrecision(source);
  13265. /**
  13266. * Recompiles the webGL program
  13267. * @param vertexSourceCode The source code for the vertex shader.
  13268. * @param fragmentSourceCode The source code for the fragment shader.
  13269. * @param onCompiled Callback called when completed.
  13270. * @param onError Callback called on error.
  13271. */
  13272. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  13273. /**
  13274. * Gets the uniform locations of the the specified variable names
  13275. * @param names THe names of the variables to lookup.
  13276. * @returns Array of locations in the same order as variable names.
  13277. */
  13278. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  13279. /**
  13280. * Prepares the effect
  13281. */
  13282. _prepareEffect(): void;
  13283. /**
  13284. * Checks if the effect is supported. (Must be called after compilation)
  13285. */
  13286. readonly isSupported: boolean;
  13287. /**
  13288. * Binds a texture to the engine to be used as output of the shader.
  13289. * @param channel Name of the output variable.
  13290. * @param texture Texture to bind.
  13291. */
  13292. _bindTexture(channel: string, texture: InternalTexture): void;
  13293. /**
  13294. * Sets a texture on the engine to be used in the shader.
  13295. * @param channel Name of the sampler variable.
  13296. * @param texture Texture to set.
  13297. */
  13298. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  13299. /**
  13300. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  13301. * @param channel Name of the sampler variable.
  13302. * @param texture Texture to set.
  13303. */
  13304. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  13305. /**
  13306. * Sets an array of textures on the engine to be used in the shader.
  13307. * @param channel Name of the variable.
  13308. * @param textures Textures to set.
  13309. */
  13310. setTextureArray(channel: string, textures: BaseTexture[]): void;
  13311. /**
  13312. * 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)
  13313. * @param channel Name of the sampler variable.
  13314. * @param postProcess Post process to get the input texture from.
  13315. */
  13316. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  13317. /**
  13318. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  13319. * 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)
  13320. * @param channel Name of the sampler variable.
  13321. * @param postProcess Post process to get the output texture from.
  13322. */
  13323. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  13324. /** @hidden */
  13325. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  13326. /** @hidden */
  13327. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  13328. /** @hidden */
  13329. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  13330. /** @hidden */
  13331. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  13332. /**
  13333. * Binds a buffer to a uniform.
  13334. * @param buffer Buffer to bind.
  13335. * @param name Name of the uniform variable to bind to.
  13336. */
  13337. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  13338. /**
  13339. * Binds block to a uniform.
  13340. * @param blockName Name of the block to bind.
  13341. * @param index Index to bind.
  13342. */
  13343. bindUniformBlock(blockName: string, index: number): void;
  13344. /**
  13345. * Sets an interger value on a uniform variable.
  13346. * @param uniformName Name of the variable.
  13347. * @param value Value to be set.
  13348. * @returns this effect.
  13349. */
  13350. setInt(uniformName: string, value: number): Effect;
  13351. /**
  13352. * Sets an int array on a uniform variable.
  13353. * @param uniformName Name of the variable.
  13354. * @param array array to be set.
  13355. * @returns this effect.
  13356. */
  13357. setIntArray(uniformName: string, array: Int32Array): Effect;
  13358. /**
  13359. * 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)
  13360. * @param uniformName Name of the variable.
  13361. * @param array array to be set.
  13362. * @returns this effect.
  13363. */
  13364. setIntArray2(uniformName: string, array: Int32Array): Effect;
  13365. /**
  13366. * 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)
  13367. * @param uniformName Name of the variable.
  13368. * @param array array to be set.
  13369. * @returns this effect.
  13370. */
  13371. setIntArray3(uniformName: string, array: Int32Array): Effect;
  13372. /**
  13373. * 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)
  13374. * @param uniformName Name of the variable.
  13375. * @param array array to be set.
  13376. * @returns this effect.
  13377. */
  13378. setIntArray4(uniformName: string, array: Int32Array): Effect;
  13379. /**
  13380. * Sets an float array on a uniform variable.
  13381. * @param uniformName Name of the variable.
  13382. * @param array array to be set.
  13383. * @returns this effect.
  13384. */
  13385. setFloatArray(uniformName: string, array: Float32Array): Effect;
  13386. /**
  13387. * 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)
  13388. * @param uniformName Name of the variable.
  13389. * @param array array to be set.
  13390. * @returns this effect.
  13391. */
  13392. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  13393. /**
  13394. * 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)
  13395. * @param uniformName Name of the variable.
  13396. * @param array array to be set.
  13397. * @returns this effect.
  13398. */
  13399. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  13400. /**
  13401. * 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)
  13402. * @param uniformName Name of the variable.
  13403. * @param array array to be set.
  13404. * @returns this effect.
  13405. */
  13406. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  13407. /**
  13408. * Sets an array on a uniform variable.
  13409. * @param uniformName Name of the variable.
  13410. * @param array array to be set.
  13411. * @returns this effect.
  13412. */
  13413. setArray(uniformName: string, array: number[]): Effect;
  13414. /**
  13415. * 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)
  13416. * @param uniformName Name of the variable.
  13417. * @param array array to be set.
  13418. * @returns this effect.
  13419. */
  13420. setArray2(uniformName: string, array: number[]): Effect;
  13421. /**
  13422. * 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)
  13423. * @param uniformName Name of the variable.
  13424. * @param array array to be set.
  13425. * @returns this effect.
  13426. */
  13427. setArray3(uniformName: string, array: number[]): Effect;
  13428. /**
  13429. * 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)
  13430. * @param uniformName Name of the variable.
  13431. * @param array array to be set.
  13432. * @returns this effect.
  13433. */
  13434. setArray4(uniformName: string, array: number[]): Effect;
  13435. /**
  13436. * Sets matrices on a uniform variable.
  13437. * @param uniformName Name of the variable.
  13438. * @param matrices matrices to be set.
  13439. * @returns this effect.
  13440. */
  13441. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  13442. /**
  13443. * Sets matrix on a uniform variable.
  13444. * @param uniformName Name of the variable.
  13445. * @param matrix matrix to be set.
  13446. * @returns this effect.
  13447. */
  13448. setMatrix(uniformName: string, matrix: Matrix): Effect;
  13449. /**
  13450. * 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)
  13451. * @param uniformName Name of the variable.
  13452. * @param matrix matrix to be set.
  13453. * @returns this effect.
  13454. */
  13455. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  13456. /**
  13457. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  13458. * @param uniformName Name of the variable.
  13459. * @param matrix matrix to be set.
  13460. * @returns this effect.
  13461. */
  13462. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  13463. /**
  13464. * Sets a float on a uniform variable.
  13465. * @param uniformName Name of the variable.
  13466. * @param value value to be set.
  13467. * @returns this effect.
  13468. */
  13469. setFloat(uniformName: string, value: number): Effect;
  13470. /**
  13471. * Sets a boolean on a uniform variable.
  13472. * @param uniformName Name of the variable.
  13473. * @param bool value to be set.
  13474. * @returns this effect.
  13475. */
  13476. setBool(uniformName: string, bool: boolean): Effect;
  13477. /**
  13478. * Sets a Vector2 on a uniform variable.
  13479. * @param uniformName Name of the variable.
  13480. * @param vector2 vector2 to be set.
  13481. * @returns this effect.
  13482. */
  13483. setVector2(uniformName: string, vector2: Vector2): Effect;
  13484. /**
  13485. * Sets a float2 on a uniform variable.
  13486. * @param uniformName Name of the variable.
  13487. * @param x First float in float2.
  13488. * @param y Second float in float2.
  13489. * @returns this effect.
  13490. */
  13491. setFloat2(uniformName: string, x: number, y: number): Effect;
  13492. /**
  13493. * Sets a Vector3 on a uniform variable.
  13494. * @param uniformName Name of the variable.
  13495. * @param vector3 Value to be set.
  13496. * @returns this effect.
  13497. */
  13498. setVector3(uniformName: string, vector3: Vector3): Effect;
  13499. /**
  13500. * Sets a float3 on a uniform variable.
  13501. * @param uniformName Name of the variable.
  13502. * @param x First float in float3.
  13503. * @param y Second float in float3.
  13504. * @param z Third float in float3.
  13505. * @returns this effect.
  13506. */
  13507. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  13508. /**
  13509. * Sets a Vector4 on a uniform variable.
  13510. * @param uniformName Name of the variable.
  13511. * @param vector4 Value to be set.
  13512. * @returns this effect.
  13513. */
  13514. setVector4(uniformName: string, vector4: Vector4): Effect;
  13515. /**
  13516. * Sets a float4 on a uniform variable.
  13517. * @param uniformName Name of the variable.
  13518. * @param x First float in float4.
  13519. * @param y Second float in float4.
  13520. * @param z Third float in float4.
  13521. * @param w Fourth float in float4.
  13522. * @returns this effect.
  13523. */
  13524. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  13525. /**
  13526. * Sets a Color3 on a uniform variable.
  13527. * @param uniformName Name of the variable.
  13528. * @param color3 Value to be set.
  13529. * @returns this effect.
  13530. */
  13531. setColor3(uniformName: string, color3: Color3): Effect;
  13532. /**
  13533. * Sets a Color4 on a uniform variable.
  13534. * @param uniformName Name of the variable.
  13535. * @param color3 Value to be set.
  13536. * @param alpha Alpha value to be set.
  13537. * @returns this effect.
  13538. */
  13539. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  13540. /**
  13541. * Sets a Color4 on a uniform variable
  13542. * @param uniformName defines the name of the variable
  13543. * @param color4 defines the value to be set
  13544. * @returns this effect.
  13545. */
  13546. setDirectColor4(uniformName: string, color4: Color4): Effect;
  13547. /**
  13548. * This function will add a new shader to the shader store
  13549. * @param name the name of the shader
  13550. * @param pixelShader optional pixel shader content
  13551. * @param vertexShader optional vertex shader content
  13552. */
  13553. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  13554. /**
  13555. * Store of each shader (The can be looked up using effect.key)
  13556. */
  13557. static ShadersStore: {
  13558. [key: string]: string;
  13559. };
  13560. /**
  13561. * Store of each included file for a shader (The can be looked up using effect.key)
  13562. */
  13563. static IncludesShadersStore: {
  13564. [key: string]: string;
  13565. };
  13566. /**
  13567. * Resets the cache of effects.
  13568. */
  13569. static ResetCache(): void;
  13570. }
  13571. }
  13572. declare module BABYLON {
  13573. class FresnelParameters {
  13574. private _isEnabled;
  13575. isEnabled: boolean;
  13576. leftColor: Color3;
  13577. rightColor: Color3;
  13578. bias: number;
  13579. power: number;
  13580. clone(): FresnelParameters;
  13581. serialize(): any;
  13582. static Parse(parsedFresnelParameters: any): FresnelParameters;
  13583. }
  13584. }
  13585. declare module BABYLON {
  13586. /**
  13587. * Interface to follow in your material defines to integrate easily the
  13588. * Image proccessing functions.
  13589. * @hidden
  13590. */
  13591. interface IImageProcessingConfigurationDefines {
  13592. IMAGEPROCESSING: boolean;
  13593. VIGNETTE: boolean;
  13594. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13595. VIGNETTEBLENDMODEOPAQUE: boolean;
  13596. TONEMAPPING: boolean;
  13597. CONTRAST: boolean;
  13598. EXPOSURE: boolean;
  13599. COLORCURVES: boolean;
  13600. COLORGRADING: boolean;
  13601. COLORGRADING3D: boolean;
  13602. SAMPLER3DGREENDEPTH: boolean;
  13603. SAMPLER3DBGRMAP: boolean;
  13604. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13605. }
  13606. /**
  13607. * This groups together the common properties used for image processing either in direct forward pass
  13608. * or through post processing effect depending on the use of the image processing pipeline in your scene
  13609. * or not.
  13610. */
  13611. class ImageProcessingConfiguration {
  13612. /**
  13613. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  13614. */
  13615. colorCurves: Nullable<ColorCurves>;
  13616. private _colorCurvesEnabled;
  13617. /**
  13618. * Gets wether the color curves effect is enabled.
  13619. */
  13620. /**
  13621. * Sets wether the color curves effect is enabled.
  13622. */
  13623. colorCurvesEnabled: boolean;
  13624. /**
  13625. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  13626. */
  13627. colorGradingTexture: Nullable<BaseTexture>;
  13628. private _colorGradingEnabled;
  13629. /**
  13630. * Gets wether the color grading effect is enabled.
  13631. */
  13632. /**
  13633. * Sets wether the color grading effect is enabled.
  13634. */
  13635. colorGradingEnabled: boolean;
  13636. private _colorGradingWithGreenDepth;
  13637. /**
  13638. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  13639. */
  13640. /**
  13641. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  13642. */
  13643. colorGradingWithGreenDepth: boolean;
  13644. private _colorGradingBGR;
  13645. /**
  13646. * Gets wether the color grading texture contains BGR values.
  13647. */
  13648. /**
  13649. * Sets wether the color grading texture contains BGR values.
  13650. */
  13651. colorGradingBGR: boolean;
  13652. _exposure: number;
  13653. /**
  13654. * Gets the Exposure used in the effect.
  13655. */
  13656. /**
  13657. * Sets the Exposure used in the effect.
  13658. */
  13659. exposure: number;
  13660. private _toneMappingEnabled;
  13661. /**
  13662. * Gets wether the tone mapping effect is enabled.
  13663. */
  13664. /**
  13665. * Sets wether the tone mapping effect is enabled.
  13666. */
  13667. toneMappingEnabled: boolean;
  13668. protected _contrast: number;
  13669. /**
  13670. * Gets the contrast used in the effect.
  13671. */
  13672. /**
  13673. * Sets the contrast used in the effect.
  13674. */
  13675. contrast: number;
  13676. /**
  13677. * Vignette stretch size.
  13678. */
  13679. vignetteStretch: number;
  13680. /**
  13681. * Vignette centre X Offset.
  13682. */
  13683. vignetteCentreX: number;
  13684. /**
  13685. * Vignette centre Y Offset.
  13686. */
  13687. vignetteCentreY: number;
  13688. /**
  13689. * Vignette weight or intensity of the vignette effect.
  13690. */
  13691. vignetteWeight: number;
  13692. /**
  13693. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  13694. * if vignetteEnabled is set to true.
  13695. */
  13696. vignetteColor: Color4;
  13697. /**
  13698. * Camera field of view used by the Vignette effect.
  13699. */
  13700. vignetteCameraFov: number;
  13701. private _vignetteBlendMode;
  13702. /**
  13703. * Gets the vignette blend mode allowing different kind of effect.
  13704. */
  13705. /**
  13706. * Sets the vignette blend mode allowing different kind of effect.
  13707. */
  13708. vignetteBlendMode: number;
  13709. private _vignetteEnabled;
  13710. /**
  13711. * Gets wether the vignette effect is enabled.
  13712. */
  13713. /**
  13714. * Sets wether the vignette effect is enabled.
  13715. */
  13716. vignetteEnabled: boolean;
  13717. private _applyByPostProcess;
  13718. /**
  13719. * Gets wether the image processing is applied through a post process or not.
  13720. */
  13721. /**
  13722. * Sets wether the image processing is applied through a post process or not.
  13723. */
  13724. applyByPostProcess: boolean;
  13725. private _isEnabled;
  13726. /**
  13727. * Gets wether the image processing is enabled or not.
  13728. */
  13729. /**
  13730. * Sets wether the image processing is enabled or not.
  13731. */
  13732. isEnabled: boolean;
  13733. /**
  13734. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  13735. */
  13736. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  13737. /**
  13738. * Method called each time the image processing information changes requires to recompile the effect.
  13739. */
  13740. protected _updateParameters(): void;
  13741. getClassName(): string;
  13742. /**
  13743. * Prepare the list of uniforms associated with the Image Processing effects.
  13744. * @param uniformsList The list of uniforms used in the effect
  13745. * @param defines the list of defines currently in use
  13746. */
  13747. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  13748. /**
  13749. * Prepare the list of samplers associated with the Image Processing effects.
  13750. * @param uniformsList The list of uniforms used in the effect
  13751. * @param defines the list of defines currently in use
  13752. */
  13753. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  13754. /**
  13755. * Prepare the list of defines associated to the shader.
  13756. * @param defines the list of defines to complete
  13757. */
  13758. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  13759. /**
  13760. * Returns true if all the image processing information are ready.
  13761. */
  13762. isReady(): boolean;
  13763. /**
  13764. * Binds the image processing to the shader.
  13765. * @param effect The effect to bind to
  13766. */
  13767. bind(effect: Effect, aspectRatio?: number): void;
  13768. /**
  13769. * Clones the current image processing instance.
  13770. * @return The cloned image processing
  13771. */
  13772. clone(): ImageProcessingConfiguration;
  13773. /**
  13774. * Serializes the current image processing instance to a json representation.
  13775. * @return a JSON representation
  13776. */
  13777. serialize(): any;
  13778. /**
  13779. * Parses the image processing from a json representation.
  13780. * @param source the JSON source to parse
  13781. * @return The parsed image processing
  13782. */
  13783. static Parse(source: any): ImageProcessingConfiguration;
  13784. private static _VIGNETTEMODE_MULTIPLY;
  13785. private static _VIGNETTEMODE_OPAQUE;
  13786. /**
  13787. * Used to apply the vignette as a mix with the pixel color.
  13788. */
  13789. static readonly VIGNETTEMODE_MULTIPLY: number;
  13790. /**
  13791. * Used to apply the vignette as a replacement of the pixel color.
  13792. */
  13793. static readonly VIGNETTEMODE_OPAQUE: number;
  13794. }
  13795. }
  13796. declare module BABYLON {
  13797. /**
  13798. * Manages the defines for the Material
  13799. */
  13800. class MaterialDefines {
  13801. private _keys;
  13802. private _isDirty;
  13803. /** @hidden */
  13804. _renderId: number;
  13805. /** @hidden */
  13806. _areLightsDirty: boolean;
  13807. /** @hidden */
  13808. _areAttributesDirty: boolean;
  13809. /** @hidden */
  13810. _areTexturesDirty: boolean;
  13811. /** @hidden */
  13812. _areFresnelDirty: boolean;
  13813. /** @hidden */
  13814. _areMiscDirty: boolean;
  13815. /** @hidden */
  13816. _areImageProcessingDirty: boolean;
  13817. /** @hidden */
  13818. _normals: boolean;
  13819. /** @hidden */
  13820. _uvs: boolean;
  13821. /** @hidden */
  13822. _needNormals: boolean;
  13823. /** @hidden */
  13824. _needUVs: boolean;
  13825. /**
  13826. * Specifies if the material needs to be re-calculated
  13827. */
  13828. readonly isDirty: boolean;
  13829. /**
  13830. * Marks the material to indicate that it has been re-calculated
  13831. */
  13832. markAsProcessed(): void;
  13833. /**
  13834. * Marks the material to indicate that it needs to be re-calculated
  13835. */
  13836. markAsUnprocessed(): void;
  13837. /**
  13838. * Marks the material to indicate all of its defines need to be re-calculated
  13839. */
  13840. markAllAsDirty(): void;
  13841. /**
  13842. * Marks the material to indicate that image processing needs to be re-calculated
  13843. */
  13844. markAsImageProcessingDirty(): void;
  13845. /**
  13846. * Marks the material to indicate the lights need to be re-calculated
  13847. */
  13848. markAsLightDirty(): void;
  13849. /**
  13850. * Marks the attribute state as changed
  13851. */
  13852. markAsAttributesDirty(): void;
  13853. /**
  13854. * Marks the texture state as changed
  13855. */
  13856. markAsTexturesDirty(): void;
  13857. /**
  13858. * Marks the fresnel state as changed
  13859. */
  13860. markAsFresnelDirty(): void;
  13861. /**
  13862. * Marks the misc state as changed
  13863. */
  13864. markAsMiscDirty(): void;
  13865. /**
  13866. * Rebuilds the material defines
  13867. */
  13868. rebuild(): void;
  13869. /**
  13870. * Specifies if two material defines are equal
  13871. * @param other - A material define instance to compare to
  13872. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  13873. */
  13874. isEqual(other: MaterialDefines): boolean;
  13875. /**
  13876. * Clones this instance's defines to another instance
  13877. * @param other - material defines to clone values to
  13878. */
  13879. cloneTo(other: MaterialDefines): void;
  13880. /**
  13881. * Resets the material define values
  13882. */
  13883. reset(): void;
  13884. /**
  13885. * Converts the material define values to a string
  13886. * @returns - String of material define information
  13887. */
  13888. toString(): string;
  13889. }
  13890. /**
  13891. * Base class for the main features of a material in Babylon.js
  13892. */
  13893. class Material implements IAnimatable {
  13894. private static _TriangleFillMode;
  13895. private static _WireFrameFillMode;
  13896. private static _PointFillMode;
  13897. private static _PointListDrawMode;
  13898. private static _LineListDrawMode;
  13899. private static _LineLoopDrawMode;
  13900. private static _LineStripDrawMode;
  13901. private static _TriangleStripDrawMode;
  13902. private static _TriangleFanDrawMode;
  13903. /**
  13904. * Returns the triangle fill mode
  13905. */
  13906. static readonly TriangleFillMode: number;
  13907. /**
  13908. * Returns the wireframe mode
  13909. */
  13910. static readonly WireFrameFillMode: number;
  13911. /**
  13912. * Returns the point fill mode
  13913. */
  13914. static readonly PointFillMode: number;
  13915. /**
  13916. * Returns the point list draw mode
  13917. */
  13918. static readonly PointListDrawMode: number;
  13919. /**
  13920. * Returns the line list draw mode
  13921. */
  13922. static readonly LineListDrawMode: number;
  13923. /**
  13924. * Returns the line loop draw mode
  13925. */
  13926. static readonly LineLoopDrawMode: number;
  13927. /**
  13928. * Returns the line strip draw mode
  13929. */
  13930. static readonly LineStripDrawMode: number;
  13931. /**
  13932. * Returns the triangle strip draw mode
  13933. */
  13934. static readonly TriangleStripDrawMode: number;
  13935. /**
  13936. * Returns the triangle fan draw mode
  13937. */
  13938. static readonly TriangleFanDrawMode: number;
  13939. /**
  13940. * Stores the clock-wise side orientation
  13941. */
  13942. private static _ClockWiseSideOrientation;
  13943. /**
  13944. * Stores the counter clock-wise side orientation
  13945. */
  13946. private static _CounterClockWiseSideOrientation;
  13947. /**
  13948. * Returns the clock-wise side orientation
  13949. */
  13950. static readonly ClockWiseSideOrientation: number;
  13951. /**
  13952. * Returns the counter clock-wise side orientation
  13953. */
  13954. static readonly CounterClockWiseSideOrientation: number;
  13955. /**
  13956. * The dirty texture flag value
  13957. */
  13958. private static _TextureDirtyFlag;
  13959. /**
  13960. * The dirty light flag value
  13961. */
  13962. private static _LightDirtyFlag;
  13963. /**
  13964. * The dirty fresnel flag value
  13965. */
  13966. private static _FresnelDirtyFlag;
  13967. /**
  13968. * The dirty attribute flag value
  13969. */
  13970. private static _AttributesDirtyFlag;
  13971. /**
  13972. * The dirty misc flag value
  13973. */
  13974. private static _MiscDirtyFlag;
  13975. /**
  13976. * Returns the dirty texture flag value
  13977. */
  13978. static readonly TextureDirtyFlag: number;
  13979. /**
  13980. * Returns the dirty light flag value
  13981. */
  13982. static readonly LightDirtyFlag: number;
  13983. /**
  13984. * Returns the dirty fresnel flag value
  13985. */
  13986. static readonly FresnelDirtyFlag: number;
  13987. /**
  13988. * Returns the dirty attributes flag value
  13989. */
  13990. static readonly AttributesDirtyFlag: number;
  13991. /**
  13992. * Returns the dirty misc flag value
  13993. */
  13994. static readonly MiscDirtyFlag: number;
  13995. /**
  13996. * The ID of the material
  13997. */
  13998. id: string;
  13999. /**
  14000. * Gets or sets the unique id of the material
  14001. */
  14002. uniqueId: number;
  14003. /**
  14004. * The name of the material
  14005. */
  14006. name: string;
  14007. /**
  14008. * Specifies if the ready state should be checked on each call
  14009. */
  14010. checkReadyOnEveryCall: boolean;
  14011. /**
  14012. * Specifies if the ready state should be checked once
  14013. */
  14014. checkReadyOnlyOnce: boolean;
  14015. /**
  14016. * The state of the material
  14017. */
  14018. state: string;
  14019. /**
  14020. * The alpha value of the material
  14021. */
  14022. protected _alpha: number;
  14023. /**
  14024. * Gets the alpha value of the material
  14025. */
  14026. /**
  14027. * Sets the alpha value of the material
  14028. */
  14029. alpha: number;
  14030. /**
  14031. * Specifies if back face culling is enabled
  14032. */
  14033. protected _backFaceCulling: boolean;
  14034. /**
  14035. * Gets the back-face culling state
  14036. */
  14037. /**
  14038. * Sets the back-face culling state
  14039. */
  14040. backFaceCulling: boolean;
  14041. /**
  14042. * Stores the value for side orientation
  14043. */
  14044. sideOrientation: number;
  14045. /**
  14046. * Callback triggered when the material is compiled
  14047. */
  14048. onCompiled: (effect: Effect) => void;
  14049. /**
  14050. * Callback triggered when an error occurs
  14051. */
  14052. onError: (effect: Effect, errors: string) => void;
  14053. /**
  14054. * Callback triggered to get the render target textures
  14055. */
  14056. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  14057. /**
  14058. * Specifies if the material should be serialized
  14059. */
  14060. doNotSerialize: boolean;
  14061. /**
  14062. * Specifies if the effect should be stored on sub meshes
  14063. */
  14064. storeEffectOnSubMeshes: boolean;
  14065. /**
  14066. * Stores the animations for the material
  14067. */
  14068. animations: Array<Animation>;
  14069. /**
  14070. * An event triggered when the material is disposed
  14071. */
  14072. onDisposeObservable: Observable<Material>;
  14073. /**
  14074. * An observer which watches for dispose events
  14075. */
  14076. private _onDisposeObserver;
  14077. private _onUnBindObservable;
  14078. /**
  14079. * Called during a dispose event
  14080. */
  14081. onDispose: () => void;
  14082. private _onBindObservable;
  14083. /**
  14084. * An event triggered when the material is bound
  14085. */
  14086. readonly onBindObservable: Observable<AbstractMesh>;
  14087. /**
  14088. * An observer which watches for bind events
  14089. */
  14090. private _onBindObserver;
  14091. /**
  14092. * Called during a bind event
  14093. */
  14094. onBind: (Mesh: AbstractMesh) => void;
  14095. /**
  14096. * An event triggered when the material is unbound
  14097. */
  14098. readonly onUnBindObservable: Observable<Material>;
  14099. /**
  14100. * Stores the value of the alpha mode
  14101. */
  14102. private _alphaMode;
  14103. /**
  14104. * Gets the value of the alpha mode
  14105. */
  14106. /**
  14107. * Sets the value of the alpha mode.
  14108. *
  14109. * | Value | Type | Description |
  14110. * | --- | --- | --- |
  14111. * | 0 | ALPHA_DISABLE | |
  14112. * | 1 | ALPHA_ADD | |
  14113. * | 2 | ALPHA_COMBINE | |
  14114. * | 3 | ALPHA_SUBTRACT | |
  14115. * | 4 | ALPHA_MULTIPLY | |
  14116. * | 5 | ALPHA_MAXIMIZED | |
  14117. * | 6 | ALPHA_ONEONE | |
  14118. * | 7 | ALPHA_PREMULTIPLIED | |
  14119. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  14120. * | 9 | ALPHA_INTERPOLATE | |
  14121. * | 10 | ALPHA_SCREENMODE | |
  14122. *
  14123. */
  14124. alphaMode: number;
  14125. /**
  14126. * Stores the state of the need depth pre-pass value
  14127. */
  14128. private _needDepthPrePass;
  14129. /**
  14130. * Gets the depth pre-pass value
  14131. */
  14132. /**
  14133. * Sets the need depth pre-pass value
  14134. */
  14135. needDepthPrePass: boolean;
  14136. /**
  14137. * Specifies if depth writing should be disabled
  14138. */
  14139. disableDepthWrite: boolean;
  14140. /**
  14141. * Specifies if depth writing should be forced
  14142. */
  14143. forceDepthWrite: boolean;
  14144. /**
  14145. * Specifies if there should be a separate pass for culling
  14146. */
  14147. separateCullingPass: boolean;
  14148. /**
  14149. * Stores the state specifing if fog should be enabled
  14150. */
  14151. private _fogEnabled;
  14152. /**
  14153. * Gets the value of the fog enabled state
  14154. */
  14155. /**
  14156. * Sets the state for enabling fog
  14157. */
  14158. fogEnabled: boolean;
  14159. /**
  14160. * Stores the size of points
  14161. */
  14162. pointSize: number;
  14163. /**
  14164. * Stores the z offset value
  14165. */
  14166. zOffset: number;
  14167. /**
  14168. * Gets a value specifying if wireframe mode is enabled
  14169. */
  14170. /**
  14171. * Sets the state of wireframe mode
  14172. */
  14173. wireframe: boolean;
  14174. /**
  14175. * Gets the value specifying if point clouds are enabled
  14176. */
  14177. /**
  14178. * Sets the state of point cloud mode
  14179. */
  14180. pointsCloud: boolean;
  14181. /**
  14182. * Gets the material fill mode
  14183. */
  14184. /**
  14185. * Sets the material fill mode
  14186. */
  14187. fillMode: number;
  14188. /**
  14189. * Stores the effects for the material
  14190. */
  14191. _effect: Nullable<Effect>;
  14192. /**
  14193. * Specifies if the material was previously ready
  14194. */
  14195. _wasPreviouslyReady: boolean;
  14196. /**
  14197. * Specifies if uniform buffers should be used
  14198. */
  14199. private _useUBO;
  14200. /**
  14201. * Stores a reference to the scene
  14202. */
  14203. private _scene;
  14204. /**
  14205. * Stores the fill mode state
  14206. */
  14207. private _fillMode;
  14208. /**
  14209. * Specifies if the depth write state should be cached
  14210. */
  14211. private _cachedDepthWriteState;
  14212. /**
  14213. * Stores the uniform buffer
  14214. */
  14215. protected _uniformBuffer: UniformBuffer;
  14216. /**
  14217. * Creates a material instance
  14218. * @param name defines the name of the material
  14219. * @param scene defines the scene to reference
  14220. * @param doNotAdd specifies if the material should be added to the scene
  14221. */
  14222. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  14223. /**
  14224. * Returns a string representation of the current material
  14225. * @param fullDetails defines a boolean indicating which levels of logging is desired
  14226. * @returns a string with material information
  14227. */
  14228. toString(fullDetails?: boolean): string;
  14229. /**
  14230. * Gets the class name of the material
  14231. * @returns a string with the class name of the material
  14232. */
  14233. getClassName(): string;
  14234. /**
  14235. * Specifies if updates for the material been locked
  14236. */
  14237. readonly isFrozen: boolean;
  14238. /**
  14239. * Locks updates for the material
  14240. */
  14241. freeze(): void;
  14242. /**
  14243. * Unlocks updates for the material
  14244. */
  14245. unfreeze(): void;
  14246. /**
  14247. * Specifies if the material is ready to be used
  14248. * @param mesh defines the mesh to check
  14249. * @param useInstances specifies if instances should be used
  14250. * @returns a boolean indicating if the material is ready to be used
  14251. */
  14252. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14253. /**
  14254. * Specifies that the submesh is ready to be used
  14255. * @param mesh defines the mesh to check
  14256. * @param subMesh defines which submesh to check
  14257. * @param useInstances specifies that instances should be used
  14258. * @returns a boolean indicating that the submesh is ready or not
  14259. */
  14260. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14261. /**
  14262. * Returns the material effect
  14263. * @returns the effect associated with the material
  14264. */
  14265. getEffect(): Nullable<Effect>;
  14266. /**
  14267. * Returns the current scene
  14268. * @returns a Scene
  14269. */
  14270. getScene(): Scene;
  14271. /**
  14272. * Specifies if the material will require alpha blending
  14273. * @returns a boolean specifying if alpha blending is needed
  14274. */
  14275. needAlphaBlending(): boolean;
  14276. /**
  14277. * Specifies if the mesh will require alpha blending
  14278. * @param mesh defines the mesh to check
  14279. * @returns a boolean specifying if alpha blending is needed for the mesh
  14280. */
  14281. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  14282. /**
  14283. * Specifies if this material should be rendered in alpha test mode
  14284. * @returns a boolean specifying if an alpha test is needed.
  14285. */
  14286. needAlphaTesting(): boolean;
  14287. /**
  14288. * Gets the texture used for the alpha test
  14289. * @returns the texture to use for alpha testing
  14290. */
  14291. getAlphaTestTexture(): Nullable<BaseTexture>;
  14292. /**
  14293. * Marks the material to indicate that it needs to be re-calculated
  14294. */
  14295. markDirty(): void;
  14296. /** @hidden */
  14297. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  14298. /**
  14299. * Binds the material to the mesh
  14300. * @param world defines the world transformation matrix
  14301. * @param mesh defines the mesh to bind the material to
  14302. */
  14303. bind(world: Matrix, mesh?: Mesh): void;
  14304. /**
  14305. * Binds the submesh to the material
  14306. * @param world defines the world transformation matrix
  14307. * @param mesh defines the mesh containing the submesh
  14308. * @param subMesh defines the submesh to bind the material to
  14309. */
  14310. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14311. /**
  14312. * Binds the world matrix to the material
  14313. * @param world defines the world transformation matrix
  14314. */
  14315. bindOnlyWorldMatrix(world: Matrix): void;
  14316. /**
  14317. * Binds the scene's uniform buffer to the effect.
  14318. * @param effect defines the effect to bind to the scene uniform buffer
  14319. * @param sceneUbo defines the uniform buffer storing scene data
  14320. */
  14321. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  14322. /**
  14323. * Binds the view matrix to the effect
  14324. * @param effect defines the effect to bind the view matrix to
  14325. */
  14326. bindView(effect: Effect): void;
  14327. /**
  14328. * Binds the view projection matrix to the effect
  14329. * @param effect defines the effect to bind the view projection matrix to
  14330. */
  14331. bindViewProjection(effect: Effect): void;
  14332. /**
  14333. * Specifies if material alpha testing should be turned on for the mesh
  14334. * @param mesh defines the mesh to check
  14335. */
  14336. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  14337. /**
  14338. * Processes to execute after binding the material to a mesh
  14339. * @param mesh defines the rendered mesh
  14340. */
  14341. protected _afterBind(mesh?: Mesh): void;
  14342. /**
  14343. * Unbinds the material from the mesh
  14344. */
  14345. unbind(): void;
  14346. /**
  14347. * Gets the active textures from the material
  14348. * @returns an array of textures
  14349. */
  14350. getActiveTextures(): BaseTexture[];
  14351. /**
  14352. * Specifies if the material uses a texture
  14353. * @param texture defines the texture to check against the material
  14354. * @returns a boolean specifying if the material uses the texture
  14355. */
  14356. hasTexture(texture: BaseTexture): boolean;
  14357. /**
  14358. * Makes a duplicate of the material, and gives it a new name
  14359. * @param name defines the new name for the duplicated material
  14360. * @returns the cloned material
  14361. */
  14362. clone(name: string): Nullable<Material>;
  14363. /**
  14364. * Gets the meshes bound to the material
  14365. * @returns an array of meshes bound to the material
  14366. */
  14367. getBindedMeshes(): AbstractMesh[];
  14368. /**
  14369. * Force shader compilation
  14370. * @param mesh defines the mesh associated with this material
  14371. * @param onCompiled defines a function to execute once the material is compiled
  14372. * @param options defines the options to configure the compilation
  14373. */
  14374. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  14375. clipPlane: boolean;
  14376. }>): void;
  14377. /**
  14378. * Force shader compilation
  14379. * @param mesh defines the mesh that will use this material
  14380. * @param options defines additional options for compiling the shaders
  14381. * @returns a promise that resolves when the compilation completes
  14382. */
  14383. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  14384. clipPlane: boolean;
  14385. }>): Promise<void>;
  14386. /**
  14387. * Marks a define in the material to indicate that it needs to be re-computed
  14388. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  14389. */
  14390. markAsDirty(flag: number): void;
  14391. /**
  14392. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  14393. * @param func defines a function which checks material defines against the submeshes
  14394. */
  14395. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  14396. /**
  14397. * Indicates that image processing needs to be re-calculated for all submeshes
  14398. */
  14399. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  14400. /**
  14401. * Indicates that textures need to be re-calculated for all submeshes
  14402. */
  14403. protected _markAllSubMeshesAsTexturesDirty(): void;
  14404. /**
  14405. * Indicates that fresnel needs to be re-calculated for all submeshes
  14406. */
  14407. protected _markAllSubMeshesAsFresnelDirty(): void;
  14408. /**
  14409. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  14410. */
  14411. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  14412. /**
  14413. * Indicates that lights need to be re-calculated for all submeshes
  14414. */
  14415. protected _markAllSubMeshesAsLightsDirty(): void;
  14416. /**
  14417. * Indicates that attributes need to be re-calculated for all submeshes
  14418. */
  14419. protected _markAllSubMeshesAsAttributesDirty(): void;
  14420. /**
  14421. * Indicates that misc needs to be re-calculated for all submeshes
  14422. */
  14423. protected _markAllSubMeshesAsMiscDirty(): void;
  14424. /**
  14425. * Indicates that textures and misc need to be re-calculated for all submeshes
  14426. */
  14427. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  14428. /**
  14429. * Disposes the material
  14430. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  14431. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  14432. */
  14433. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14434. /**
  14435. * Serializes this material
  14436. * @returns the serialized material object
  14437. */
  14438. serialize(): any;
  14439. /**
  14440. * Creates a MultiMaterial from parsed MultiMaterial data.
  14441. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  14442. * @param scene defines the hosting scene
  14443. * @returns a new MultiMaterial
  14444. */
  14445. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  14446. /**
  14447. * Creates a material from parsed material data
  14448. * @param parsedMaterial defines parsed material data
  14449. * @param scene defines the hosting scene
  14450. * @param rootUrl defines the root URL to use to load textures
  14451. * @returns a new material
  14452. */
  14453. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  14454. }
  14455. }
  14456. declare module BABYLON {
  14457. /**
  14458. * "Static Class" containing the most commonly used helper while dealing with material for
  14459. * rendering purpose.
  14460. *
  14461. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  14462. *
  14463. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14464. */
  14465. class MaterialHelper {
  14466. /**
  14467. * Bind the current view position to an effect.
  14468. * @param effect The effect to be bound
  14469. * @param scene The scene the eyes position is used from
  14470. */
  14471. static BindEyePosition(effect: Effect, scene: Scene): void;
  14472. /**
  14473. * Helps preparing the defines values about the UVs in used in the effect.
  14474. * UVs are shared as much as we can accross chanels in the shaders.
  14475. * @param texture The texture we are preparing the UVs for
  14476. * @param defines The defines to update
  14477. * @param key The chanel key "diffuse", "specular"... used in the shader
  14478. */
  14479. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  14480. /**
  14481. * Binds a texture matrix value to its corrsponding uniform
  14482. * @param texture The texture to bind the matrix for
  14483. * @param uniformBuffer The uniform buffer receivin the data
  14484. * @param key The chanel key "diffuse", "specular"... used in the shader
  14485. */
  14486. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  14487. /**
  14488. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  14489. * @param mesh defines the current mesh
  14490. * @param scene defines the current scene
  14491. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  14492. * @param pointsCloud defines if point cloud rendering has to be turned on
  14493. * @param fogEnabled defines if fog has to be turned on
  14494. * @param alphaTest defines if alpha testing has to be turned on
  14495. * @param defines defines the current list of defines
  14496. */
  14497. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  14498. /**
  14499. * Helper used to prepare the list of defines associated with frame values for shader compilation
  14500. * @param scene defines the current scene
  14501. * @param engine defines the current engine
  14502. * @param defines specifies the list of active defines
  14503. * @param useInstances defines if instances have to be turned on
  14504. * @param useClipPlane defines if clip plane have to be turned on
  14505. */
  14506. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  14507. /**
  14508. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  14509. * @param mesh The mesh containing the geometry data we will draw
  14510. * @param defines The defines to update
  14511. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  14512. * @param useBones Precise whether bones should be used or not (override mesh info)
  14513. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  14514. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  14515. * @returns false if defines are considered not dirty and have not been checked
  14516. */
  14517. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  14518. /**
  14519. * Prepares the defines related to the light information passed in parameter
  14520. * @param scene The scene we are intending to draw
  14521. * @param mesh The mesh the effect is compiling for
  14522. * @param defines The defines to update
  14523. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  14524. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  14525. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  14526. * @returns true if normals will be required for the rest of the effect
  14527. */
  14528. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  14529. /**
  14530. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  14531. * that won t be acctive due to defines being turned off.
  14532. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  14533. * @param samplersList The samplers list
  14534. * @param defines The defines helping in the list generation
  14535. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  14536. */
  14537. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  14538. /**
  14539. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  14540. * @param defines The defines to update while falling back
  14541. * @param fallbacks The authorized effect fallbacks
  14542. * @param maxSimultaneousLights The maximum number of lights allowed
  14543. * @param rank the current rank of the Effect
  14544. * @returns The newly affected rank
  14545. */
  14546. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  14547. /**
  14548. * Prepares the list of attributes required for morph targets according to the effect defines.
  14549. * @param attribs The current list of supported attribs
  14550. * @param mesh The mesh to prepare the morph targets attributes for
  14551. * @param defines The current Defines of the effect
  14552. */
  14553. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  14554. /**
  14555. * Prepares the list of attributes required for bones according to the effect defines.
  14556. * @param attribs The current list of supported attribs
  14557. * @param mesh The mesh to prepare the bones attributes for
  14558. * @param defines The current Defines of the effect
  14559. * @param fallbacks The current efffect fallback strategy
  14560. */
  14561. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  14562. /**
  14563. * Prepares the list of attributes required for instances according to the effect defines.
  14564. * @param attribs The current list of supported attribs
  14565. * @param defines The current Defines of the effect
  14566. */
  14567. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  14568. /**
  14569. * Binds the light shadow information to the effect for the given mesh.
  14570. * @param light The light containing the generator
  14571. * @param scene The scene the lights belongs to
  14572. * @param mesh The mesh we are binding the information to render
  14573. * @param lightIndex The light index in the effect used to render the mesh
  14574. * @param effect The effect we are binding the data to
  14575. */
  14576. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  14577. /**
  14578. * Binds the light information to the effect.
  14579. * @param light The light containing the generator
  14580. * @param effect The effect we are binding the data to
  14581. * @param lightIndex The light index in the effect used to render
  14582. */
  14583. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  14584. /**
  14585. * Binds the lights information from the scene to the effect for the given mesh.
  14586. * @param scene The scene the lights belongs to
  14587. * @param mesh The mesh we are binding the information to render
  14588. * @param effect The effect we are binding the data to
  14589. * @param defines The generated defines for the effect
  14590. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  14591. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  14592. */
  14593. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  14594. /**
  14595. * Binds the fog information from the scene to the effect for the given mesh.
  14596. * @param scene The scene the lights belongs to
  14597. * @param mesh The mesh we are binding the information to render
  14598. * @param effect The effect we are binding the data to
  14599. */
  14600. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  14601. /**
  14602. * Binds the bones information from the mesh to the effect.
  14603. * @param mesh The mesh we are binding the information to render
  14604. * @param effect The effect we are binding the data to
  14605. */
  14606. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  14607. /**
  14608. * Binds the morph targets information from the mesh to the effect.
  14609. * @param abstractMesh The mesh we are binding the information to render
  14610. * @param effect The effect we are binding the data to
  14611. */
  14612. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  14613. /**
  14614. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  14615. * @param defines The generated defines used in the effect
  14616. * @param effect The effect we are binding the data to
  14617. * @param scene The scene we are willing to render with logarithmic scale for
  14618. */
  14619. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  14620. /**
  14621. * Binds the clip plane information from the scene to the effect.
  14622. * @param scene The scene the clip plane information are extracted from
  14623. * @param effect The effect we are binding the data to
  14624. */
  14625. static BindClipPlane(effect: Effect, scene: Scene): void;
  14626. }
  14627. }
  14628. declare module BABYLON {
  14629. class MultiMaterial extends Material {
  14630. private _subMaterials;
  14631. subMaterials: Nullable<Material>[];
  14632. constructor(name: string, scene: Scene);
  14633. private _hookArray(array);
  14634. getSubMaterial(index: number): Nullable<Material>;
  14635. getActiveTextures(): BaseTexture[];
  14636. getClassName(): string;
  14637. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  14638. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  14639. serialize(): any;
  14640. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14641. }
  14642. }
  14643. declare module BABYLON {
  14644. class PushMaterial extends Material {
  14645. protected _activeEffect: Effect;
  14646. protected _normalMatrix: Matrix;
  14647. constructor(name: string, scene: Scene);
  14648. getEffect(): Effect;
  14649. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14650. /**
  14651. * Binds the given world matrix to the active effect
  14652. *
  14653. * @param world the matrix to bind
  14654. */
  14655. bindOnlyWorldMatrix(world: Matrix): void;
  14656. /**
  14657. * Binds the given normal matrix to the active effect
  14658. *
  14659. * @param normalMatrix the matrix to bind
  14660. */
  14661. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14662. bind(world: Matrix, mesh?: Mesh): void;
  14663. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14664. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14665. }
  14666. }
  14667. declare module BABYLON {
  14668. class ShaderMaterial extends Material {
  14669. private _shaderPath;
  14670. private _options;
  14671. private _textures;
  14672. private _textureArrays;
  14673. private _floats;
  14674. private _ints;
  14675. private _floatsArrays;
  14676. private _colors3;
  14677. private _colors3Arrays;
  14678. private _colors4;
  14679. private _vectors2;
  14680. private _vectors3;
  14681. private _vectors4;
  14682. private _matrices;
  14683. private _matrices3x3;
  14684. private _matrices2x2;
  14685. private _vectors2Arrays;
  14686. private _vectors3Arrays;
  14687. private _cachedWorldViewMatrix;
  14688. private _renderId;
  14689. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  14690. getClassName(): string;
  14691. needAlphaBlending(): boolean;
  14692. needAlphaTesting(): boolean;
  14693. private _checkUniform(uniformName);
  14694. setTexture(name: string, texture: Texture): ShaderMaterial;
  14695. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  14696. setFloat(name: string, value: number): ShaderMaterial;
  14697. setInt(name: string, value: number): ShaderMaterial;
  14698. setFloats(name: string, value: number[]): ShaderMaterial;
  14699. setColor3(name: string, value: Color3): ShaderMaterial;
  14700. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  14701. setColor4(name: string, value: Color4): ShaderMaterial;
  14702. setVector2(name: string, value: Vector2): ShaderMaterial;
  14703. setVector3(name: string, value: Vector3): ShaderMaterial;
  14704. setVector4(name: string, value: Vector4): ShaderMaterial;
  14705. setMatrix(name: string, value: Matrix): ShaderMaterial;
  14706. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  14707. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  14708. setArray2(name: string, value: number[]): ShaderMaterial;
  14709. setArray3(name: string, value: number[]): ShaderMaterial;
  14710. private _checkCache(scene, mesh?, useInstances?);
  14711. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14712. bindOnlyWorldMatrix(world: Matrix): void;
  14713. bind(world: Matrix, mesh?: Mesh): void;
  14714. getActiveTextures(): BaseTexture[];
  14715. hasTexture(texture: BaseTexture): boolean;
  14716. clone(name: string): ShaderMaterial;
  14717. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14718. serialize(): any;
  14719. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  14720. }
  14721. }
  14722. declare module BABYLON {
  14723. /** @hidden */
  14724. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  14725. MAINUV1: boolean;
  14726. MAINUV2: boolean;
  14727. DIFFUSE: boolean;
  14728. DIFFUSEDIRECTUV: number;
  14729. AMBIENT: boolean;
  14730. AMBIENTDIRECTUV: number;
  14731. OPACITY: boolean;
  14732. OPACITYDIRECTUV: number;
  14733. OPACITYRGB: boolean;
  14734. REFLECTION: boolean;
  14735. EMISSIVE: boolean;
  14736. EMISSIVEDIRECTUV: number;
  14737. SPECULAR: boolean;
  14738. SPECULARDIRECTUV: number;
  14739. BUMP: boolean;
  14740. BUMPDIRECTUV: number;
  14741. PARALLAX: boolean;
  14742. PARALLAXOCCLUSION: boolean;
  14743. SPECULAROVERALPHA: boolean;
  14744. CLIPPLANE: boolean;
  14745. ALPHATEST: boolean;
  14746. DEPTHPREPASS: boolean;
  14747. ALPHAFROMDIFFUSE: boolean;
  14748. POINTSIZE: boolean;
  14749. FOG: boolean;
  14750. SPECULARTERM: boolean;
  14751. DIFFUSEFRESNEL: boolean;
  14752. OPACITYFRESNEL: boolean;
  14753. REFLECTIONFRESNEL: boolean;
  14754. REFRACTIONFRESNEL: boolean;
  14755. EMISSIVEFRESNEL: boolean;
  14756. FRESNEL: boolean;
  14757. NORMAL: boolean;
  14758. UV1: boolean;
  14759. UV2: boolean;
  14760. VERTEXCOLOR: boolean;
  14761. VERTEXALPHA: boolean;
  14762. NUM_BONE_INFLUENCERS: number;
  14763. BonesPerMesh: number;
  14764. INSTANCES: boolean;
  14765. GLOSSINESS: boolean;
  14766. ROUGHNESS: boolean;
  14767. EMISSIVEASILLUMINATION: boolean;
  14768. LINKEMISSIVEWITHDIFFUSE: boolean;
  14769. REFLECTIONFRESNELFROMSPECULAR: boolean;
  14770. LIGHTMAP: boolean;
  14771. LIGHTMAPDIRECTUV: number;
  14772. OBJECTSPACE_NORMALMAP: boolean;
  14773. USELIGHTMAPASSHADOWMAP: boolean;
  14774. REFLECTIONMAP_3D: boolean;
  14775. REFLECTIONMAP_SPHERICAL: boolean;
  14776. REFLECTIONMAP_PLANAR: boolean;
  14777. REFLECTIONMAP_CUBIC: boolean;
  14778. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  14779. REFLECTIONMAP_PROJECTION: boolean;
  14780. REFLECTIONMAP_SKYBOX: boolean;
  14781. REFLECTIONMAP_EXPLICIT: boolean;
  14782. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  14783. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  14784. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  14785. INVERTCUBICMAP: boolean;
  14786. LOGARITHMICDEPTH: boolean;
  14787. REFRACTION: boolean;
  14788. REFRACTIONMAP_3D: boolean;
  14789. REFLECTIONOVERALPHA: boolean;
  14790. TWOSIDEDLIGHTING: boolean;
  14791. SHADOWFLOAT: boolean;
  14792. MORPHTARGETS: boolean;
  14793. MORPHTARGETS_NORMAL: boolean;
  14794. MORPHTARGETS_TANGENT: boolean;
  14795. NUM_MORPH_INFLUENCERS: number;
  14796. NONUNIFORMSCALING: boolean;
  14797. PREMULTIPLYALPHA: boolean;
  14798. IMAGEPROCESSING: boolean;
  14799. VIGNETTE: boolean;
  14800. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14801. VIGNETTEBLENDMODEOPAQUE: boolean;
  14802. TONEMAPPING: boolean;
  14803. CONTRAST: boolean;
  14804. COLORCURVES: boolean;
  14805. COLORGRADING: boolean;
  14806. COLORGRADING3D: boolean;
  14807. SAMPLER3DGREENDEPTH: boolean;
  14808. SAMPLER3DBGRMAP: boolean;
  14809. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14810. /**
  14811. * If the reflection texture on this material is in linear color space
  14812. * @hidden
  14813. */
  14814. IS_REFLECTION_LINEAR: boolean;
  14815. /**
  14816. * If the refraction texture on this material is in linear color space
  14817. * @hidden
  14818. */
  14819. IS_REFRACTION_LINEAR: boolean;
  14820. EXPOSURE: boolean;
  14821. constructor();
  14822. setReflectionMode(modeToEnable: string): void;
  14823. }
  14824. class StandardMaterial extends PushMaterial {
  14825. private _diffuseTexture;
  14826. diffuseTexture: Nullable<BaseTexture>;
  14827. private _ambientTexture;
  14828. ambientTexture: Nullable<BaseTexture>;
  14829. private _opacityTexture;
  14830. opacityTexture: Nullable<BaseTexture>;
  14831. private _reflectionTexture;
  14832. reflectionTexture: Nullable<BaseTexture>;
  14833. private _emissiveTexture;
  14834. emissiveTexture: Nullable<BaseTexture>;
  14835. private _specularTexture;
  14836. specularTexture: Nullable<BaseTexture>;
  14837. private _bumpTexture;
  14838. bumpTexture: Nullable<BaseTexture>;
  14839. private _lightmapTexture;
  14840. lightmapTexture: Nullable<BaseTexture>;
  14841. private _refractionTexture;
  14842. refractionTexture: Nullable<BaseTexture>;
  14843. ambientColor: Color3;
  14844. diffuseColor: Color3;
  14845. specularColor: Color3;
  14846. emissiveColor: Color3;
  14847. specularPower: number;
  14848. private _useAlphaFromDiffuseTexture;
  14849. useAlphaFromDiffuseTexture: boolean;
  14850. private _useEmissiveAsIllumination;
  14851. useEmissiveAsIllumination: boolean;
  14852. private _linkEmissiveWithDiffuse;
  14853. linkEmissiveWithDiffuse: boolean;
  14854. private _useSpecularOverAlpha;
  14855. useSpecularOverAlpha: boolean;
  14856. private _useReflectionOverAlpha;
  14857. useReflectionOverAlpha: boolean;
  14858. private _disableLighting;
  14859. disableLighting: boolean;
  14860. private _useObjectSpaceNormalMap;
  14861. /**
  14862. * Allows using an object space normal map (instead of tangent space).
  14863. */
  14864. useObjectSpaceNormalMap: boolean;
  14865. private _useParallax;
  14866. useParallax: boolean;
  14867. private _useParallaxOcclusion;
  14868. useParallaxOcclusion: boolean;
  14869. parallaxScaleBias: number;
  14870. private _roughness;
  14871. roughness: number;
  14872. indexOfRefraction: number;
  14873. invertRefractionY: boolean;
  14874. /**
  14875. * Defines the alpha limits in alpha test mode
  14876. */
  14877. alphaCutOff: number;
  14878. private _useLightmapAsShadowmap;
  14879. useLightmapAsShadowmap: boolean;
  14880. private _diffuseFresnelParameters;
  14881. diffuseFresnelParameters: FresnelParameters;
  14882. private _opacityFresnelParameters;
  14883. opacityFresnelParameters: FresnelParameters;
  14884. private _reflectionFresnelParameters;
  14885. reflectionFresnelParameters: FresnelParameters;
  14886. private _refractionFresnelParameters;
  14887. refractionFresnelParameters: FresnelParameters;
  14888. private _emissiveFresnelParameters;
  14889. emissiveFresnelParameters: FresnelParameters;
  14890. private _useReflectionFresnelFromSpecular;
  14891. useReflectionFresnelFromSpecular: boolean;
  14892. private _useGlossinessFromSpecularMapAlpha;
  14893. useGlossinessFromSpecularMapAlpha: boolean;
  14894. private _maxSimultaneousLights;
  14895. maxSimultaneousLights: number;
  14896. /**
  14897. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  14898. */
  14899. private _invertNormalMapX;
  14900. invertNormalMapX: boolean;
  14901. /**
  14902. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  14903. */
  14904. private _invertNormalMapY;
  14905. invertNormalMapY: boolean;
  14906. /**
  14907. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  14908. */
  14909. private _twoSidedLighting;
  14910. twoSidedLighting: boolean;
  14911. /**
  14912. * Default configuration related to image processing available in the standard Material.
  14913. */
  14914. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14915. /**
  14916. * Gets the image processing configuration used either in this material.
  14917. */
  14918. /**
  14919. * Sets the Default image processing configuration used either in the this material.
  14920. *
  14921. * If sets to null, the scene one is in use.
  14922. */
  14923. imageProcessingConfiguration: ImageProcessingConfiguration;
  14924. /**
  14925. * Keep track of the image processing observer to allow dispose and replace.
  14926. */
  14927. private _imageProcessingObserver;
  14928. /**
  14929. * Attaches a new image processing configuration to the Standard Material.
  14930. * @param configuration
  14931. */
  14932. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14933. /**
  14934. * Gets wether the color curves effect is enabled.
  14935. */
  14936. /**
  14937. * Sets wether the color curves effect is enabled.
  14938. */
  14939. cameraColorCurvesEnabled: boolean;
  14940. /**
  14941. * Gets wether the color grading effect is enabled.
  14942. */
  14943. /**
  14944. * Gets wether the color grading effect is enabled.
  14945. */
  14946. cameraColorGradingEnabled: boolean;
  14947. /**
  14948. * Gets wether tonemapping is enabled or not.
  14949. */
  14950. /**
  14951. * Sets wether tonemapping is enabled or not
  14952. */
  14953. cameraToneMappingEnabled: boolean;
  14954. /**
  14955. * The camera exposure used on this material.
  14956. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14957. * This corresponds to a photographic exposure.
  14958. */
  14959. /**
  14960. * The camera exposure used on this material.
  14961. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14962. * This corresponds to a photographic exposure.
  14963. */
  14964. cameraExposure: number;
  14965. /**
  14966. * Gets The camera contrast used on this material.
  14967. */
  14968. /**
  14969. * Sets The camera contrast used on this material.
  14970. */
  14971. cameraContrast: number;
  14972. /**
  14973. * Gets the Color Grading 2D Lookup Texture.
  14974. */
  14975. /**
  14976. * Sets the Color Grading 2D Lookup Texture.
  14977. */
  14978. cameraColorGradingTexture: Nullable<BaseTexture>;
  14979. /**
  14980. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14981. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14982. * 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;
  14983. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14984. */
  14985. /**
  14986. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14987. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14988. * 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;
  14989. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14990. */
  14991. cameraColorCurves: Nullable<ColorCurves>;
  14992. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  14993. protected _renderTargets: SmartArray<RenderTargetTexture>;
  14994. protected _worldViewProjectionMatrix: Matrix;
  14995. protected _globalAmbientColor: Color3;
  14996. protected _useLogarithmicDepth: boolean;
  14997. constructor(name: string, scene: Scene);
  14998. getClassName(): string;
  14999. useLogarithmicDepth: boolean;
  15000. needAlphaBlending(): boolean;
  15001. needAlphaTesting(): boolean;
  15002. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  15003. getAlphaTestTexture(): Nullable<BaseTexture>;
  15004. /**
  15005. * Child classes can use it to update shaders
  15006. */
  15007. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  15008. buildUniformLayout(): void;
  15009. unbind(): void;
  15010. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15011. getAnimatables(): IAnimatable[];
  15012. getActiveTextures(): BaseTexture[];
  15013. hasTexture(texture: BaseTexture): boolean;
  15014. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  15015. clone(name: string): StandardMaterial;
  15016. serialize(): any;
  15017. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  15018. static _DiffuseTextureEnabled: boolean;
  15019. static DiffuseTextureEnabled: boolean;
  15020. static _AmbientTextureEnabled: boolean;
  15021. static AmbientTextureEnabled: boolean;
  15022. static _OpacityTextureEnabled: boolean;
  15023. static OpacityTextureEnabled: boolean;
  15024. static _ReflectionTextureEnabled: boolean;
  15025. static ReflectionTextureEnabled: boolean;
  15026. static _EmissiveTextureEnabled: boolean;
  15027. static EmissiveTextureEnabled: boolean;
  15028. static _SpecularTextureEnabled: boolean;
  15029. static SpecularTextureEnabled: boolean;
  15030. static _BumpTextureEnabled: boolean;
  15031. static BumpTextureEnabled: boolean;
  15032. static _LightmapTextureEnabled: boolean;
  15033. static LightmapTextureEnabled: boolean;
  15034. static _RefractionTextureEnabled: boolean;
  15035. static RefractionTextureEnabled: boolean;
  15036. static _ColorGradingTextureEnabled: boolean;
  15037. static ColorGradingTextureEnabled: boolean;
  15038. static _FresnelEnabled: boolean;
  15039. static FresnelEnabled: boolean;
  15040. }
  15041. }
  15042. declare module BABYLON {
  15043. class UniformBuffer {
  15044. private _engine;
  15045. private _buffer;
  15046. private _data;
  15047. private _bufferData;
  15048. private _dynamic?;
  15049. private _uniformLocations;
  15050. private _uniformSizes;
  15051. private _uniformLocationPointer;
  15052. private _needSync;
  15053. private _noUBO;
  15054. private _currentEffect;
  15055. private static _MAX_UNIFORM_SIZE;
  15056. private static _tempBuffer;
  15057. /**
  15058. * Wrapper for updateUniform.
  15059. * @method updateMatrix3x3
  15060. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15061. * @param {Float32Array} matrix
  15062. */
  15063. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  15064. /**
  15065. * Wrapper for updateUniform.
  15066. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15067. * @param {Float32Array} matrix
  15068. */
  15069. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  15070. /**
  15071. * Wrapper for updateUniform.
  15072. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15073. * @param {number} x
  15074. */
  15075. updateFloat: (name: string, x: number) => void;
  15076. /**
  15077. * Wrapper for updateUniform.
  15078. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15079. * @param {number} x
  15080. * @param {number} y
  15081. * @param {string} [suffix] Suffix to add to the uniform name.
  15082. */
  15083. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  15084. /**
  15085. * Wrapper for updateUniform.
  15086. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15087. * @param {number} x
  15088. * @param {number} y
  15089. * @param {number} z
  15090. * @param {string} [suffix] Suffix to add to the uniform name.
  15091. */
  15092. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  15093. /**
  15094. * Wrapper for updateUniform.
  15095. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15096. * @param {number} x
  15097. * @param {number} y
  15098. * @param {number} z
  15099. * @param {number} w
  15100. * @param {string} [suffix] Suffix to add to the uniform name.
  15101. */
  15102. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  15103. /**
  15104. * Wrapper for updateUniform.
  15105. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15106. * @param {Matrix} A 4x4 matrix.
  15107. */
  15108. updateMatrix: (name: string, mat: Matrix) => void;
  15109. /**
  15110. * Wrapper for updateUniform.
  15111. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15112. * @param {Vector3} vector
  15113. */
  15114. updateVector3: (name: string, vector: Vector3) => void;
  15115. /**
  15116. * Wrapper for updateUniform.
  15117. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15118. * @param {Vector4} vector
  15119. */
  15120. updateVector4: (name: string, vector: Vector4) => void;
  15121. /**
  15122. * Wrapper for updateUniform.
  15123. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15124. * @param {Color3} color
  15125. * @param {string} [suffix] Suffix to add to the uniform name.
  15126. */
  15127. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  15128. /**
  15129. * Wrapper for updateUniform.
  15130. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15131. * @param {Color3} color
  15132. * @param {number} alpha
  15133. * @param {string} [suffix] Suffix to add to the uniform name.
  15134. */
  15135. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  15136. /**
  15137. * Uniform buffer objects.
  15138. *
  15139. * Handles blocks of uniform on the GPU.
  15140. *
  15141. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  15142. *
  15143. * For more information, please refer to :
  15144. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  15145. */
  15146. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  15147. /**
  15148. * Indicates if the buffer is using the WebGL2 UBO implementation,
  15149. * or just falling back on setUniformXXX calls.
  15150. */
  15151. readonly useUbo: boolean;
  15152. /**
  15153. * Indicates if the WebGL underlying uniform buffer is in sync
  15154. * with the javascript cache data.
  15155. */
  15156. readonly isSync: boolean;
  15157. /**
  15158. * Indicates if the WebGL underlying uniform buffer is dynamic.
  15159. * Also, a dynamic UniformBuffer will disable cache verification and always
  15160. * update the underlying WebGL uniform buffer to the GPU.
  15161. */
  15162. isDynamic(): boolean;
  15163. /**
  15164. * The data cache on JS side.
  15165. */
  15166. getData(): Float32Array;
  15167. /**
  15168. * The underlying WebGL Uniform buffer.
  15169. */
  15170. getBuffer(): Nullable<WebGLBuffer>;
  15171. /**
  15172. * std140 layout specifies how to align data within an UBO structure.
  15173. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  15174. * for specs.
  15175. */
  15176. private _fillAlignment(size);
  15177. /**
  15178. * Adds an uniform in the buffer.
  15179. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  15180. * for the layout to be correct !
  15181. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15182. * @param {number|number[]} size Data size, or data directly.
  15183. */
  15184. addUniform(name: string, size: number | number[]): void;
  15185. /**
  15186. * Wrapper for addUniform.
  15187. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15188. * @param {Matrix} mat A 4x4 matrix.
  15189. */
  15190. addMatrix(name: string, mat: Matrix): void;
  15191. /**
  15192. * Wrapper for addUniform.
  15193. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15194. * @param {number} x
  15195. * @param {number} y
  15196. */
  15197. addFloat2(name: string, x: number, y: number): void;
  15198. /**
  15199. * Wrapper for addUniform.
  15200. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15201. * @param {number} x
  15202. * @param {number} y
  15203. * @param {number} z
  15204. */
  15205. addFloat3(name: string, x: number, y: number, z: number): void;
  15206. /**
  15207. * Wrapper for addUniform.
  15208. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15209. * @param {Color3} color
  15210. */
  15211. addColor3(name: string, color: Color3): void;
  15212. /**
  15213. * Wrapper for addUniform.
  15214. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15215. * @param {Color3} color
  15216. * @param {number} alpha
  15217. */
  15218. addColor4(name: string, color: Color3, alpha: number): void;
  15219. /**
  15220. * Wrapper for addUniform.
  15221. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15222. * @param {Vector3} vector
  15223. */
  15224. addVector3(name: string, vector: Vector3): void;
  15225. /**
  15226. * Wrapper for addUniform.
  15227. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15228. */
  15229. addMatrix3x3(name: string): void;
  15230. /**
  15231. * Wrapper for addUniform.
  15232. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  15233. */
  15234. addMatrix2x2(name: string): void;
  15235. /**
  15236. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  15237. */
  15238. create(): void;
  15239. _rebuild(): void;
  15240. /**
  15241. * Updates the WebGL Uniform Buffer on the GPU.
  15242. * If the `dynamic` flag is set to true, no cache comparison is done.
  15243. * Otherwise, the buffer will be updated only if the cache differs.
  15244. */
  15245. update(): void;
  15246. /**
  15247. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  15248. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15249. * @param {number[]|Float32Array} data Flattened data
  15250. * @param {number} size Size of the data.
  15251. */
  15252. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  15253. private _updateMatrix3x3ForUniform(name, matrix);
  15254. private _updateMatrix3x3ForEffect(name, matrix);
  15255. private _updateMatrix2x2ForEffect(name, matrix);
  15256. private _updateMatrix2x2ForUniform(name, matrix);
  15257. private _updateFloatForEffect(name, x);
  15258. private _updateFloatForUniform(name, x);
  15259. private _updateFloat2ForEffect(name, x, y, suffix?);
  15260. private _updateFloat2ForUniform(name, x, y, suffix?);
  15261. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  15262. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  15263. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  15264. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  15265. private _updateMatrixForEffect(name, mat);
  15266. private _updateMatrixForUniform(name, mat);
  15267. private _updateVector3ForEffect(name, vector);
  15268. private _updateVector3ForUniform(name, vector);
  15269. private _updateVector4ForEffect(name, vector);
  15270. private _updateVector4ForUniform(name, vector);
  15271. private _updateColor3ForEffect(name, color, suffix?);
  15272. private _updateColor3ForUniform(name, color, suffix?);
  15273. private _updateColor4ForEffect(name, color, alpha, suffix?);
  15274. private _updateColor4ForUniform(name, color, alpha, suffix?);
  15275. /**
  15276. * Sets a sampler uniform on the effect.
  15277. * @param {string} name Name of the sampler.
  15278. * @param {Texture} texture
  15279. */
  15280. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  15281. /**
  15282. * Directly updates the value of the uniform in the cache AND on the GPU.
  15283. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  15284. * @param {number[]|Float32Array} data Flattened data
  15285. */
  15286. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  15287. /**
  15288. * Binds this uniform buffer to an effect.
  15289. * @param {Effect} effect
  15290. * @param {string} name Name of the uniform block in the shader.
  15291. */
  15292. bindToEffect(effect: Effect, name: string): void;
  15293. /**
  15294. * Disposes the uniform buffer.
  15295. */
  15296. dispose(): void;
  15297. }
  15298. }
  15299. declare module BABYLON {
  15300. class Scalar {
  15301. /**
  15302. * Two pi constants convenient for computation.
  15303. */
  15304. static TwoPi: number;
  15305. /**
  15306. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  15307. */
  15308. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  15309. /**
  15310. * Returns a string : the upper case translation of the number i to hexadecimal.
  15311. */
  15312. static ToHex(i: number): string;
  15313. /**
  15314. * Returns -1 if value is negative and +1 is value is positive.
  15315. * Returns the value itself if it's equal to zero.
  15316. */
  15317. static Sign(value: number): number;
  15318. /**
  15319. * Returns the value itself if it's between min and max.
  15320. * Returns min if the value is lower than min.
  15321. * Returns max if the value is greater than max.
  15322. */
  15323. static Clamp(value: number, min?: number, max?: number): number;
  15324. /**
  15325. * Returns the log2 of value.
  15326. */
  15327. static Log2(value: number): number;
  15328. /**
  15329. * Loops the value, so that it is never larger than length and never smaller than 0.
  15330. *
  15331. * This is similar to the modulo operator but it works with floating point numbers.
  15332. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  15333. * With t = 5 and length = 2.5, the result would be 0.0.
  15334. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  15335. */
  15336. static Repeat(value: number, length: number): number;
  15337. /**
  15338. * Normalize the value between 0.0 and 1.0 using min and max values
  15339. */
  15340. static Normalize(value: number, min: number, max: number): number;
  15341. /**
  15342. * Denormalize the value from 0.0 and 1.0 using min and max values
  15343. */
  15344. static Denormalize(normalized: number, min: number, max: number): number;
  15345. /**
  15346. * Calculates the shortest difference between two given angles given in degrees.
  15347. */
  15348. static DeltaAngle(current: number, target: number): number;
  15349. /**
  15350. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  15351. *
  15352. * The returned value will move back and forth between 0 and length
  15353. */
  15354. static PingPong(tx: number, length: number): number;
  15355. /**
  15356. * Interpolates between min and max with smoothing at the limits.
  15357. *
  15358. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  15359. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  15360. */
  15361. static SmoothStep(from: number, to: number, tx: number): number;
  15362. /**
  15363. * Moves a value current towards target.
  15364. *
  15365. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  15366. * Negative values of maxDelta pushes the value away from target.
  15367. */
  15368. static MoveTowards(current: number, target: number, maxDelta: number): number;
  15369. /**
  15370. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15371. *
  15372. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  15373. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  15374. */
  15375. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  15376. /**
  15377. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  15378. */
  15379. static Lerp(start: number, end: number, amount: number): number;
  15380. /**
  15381. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  15382. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  15383. */
  15384. static LerpAngle(start: number, end: number, amount: number): number;
  15385. /**
  15386. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  15387. */
  15388. static InverseLerp(a: number, b: number, value: number): number;
  15389. /**
  15390. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  15391. */
  15392. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  15393. /**
  15394. * Returns a random float number between and min and max values
  15395. */
  15396. static RandomRange(min: number, max: number): number;
  15397. /**
  15398. * This function returns percentage of a number in a given range.
  15399. *
  15400. * RangeToPercent(40,20,60) will return 0.5 (50%)
  15401. * RangeToPercent(34,0,100) will return 0.34 (34%)
  15402. */
  15403. static RangeToPercent(number: number, min: number, max: number): number;
  15404. /**
  15405. * This function returns number that corresponds to the percentage in a given range.
  15406. *
  15407. * PercentToRange(0.34,0,100) will return 34.
  15408. */
  15409. static PercentToRange(percent: number, min: number, max: number): number;
  15410. /**
  15411. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  15412. * @param angle The angle to normalize in radian.
  15413. * @return The converted angle.
  15414. */
  15415. static NormalizeRadians(angle: number): number;
  15416. }
  15417. }
  15418. declare module BABYLON {
  15419. const ToGammaSpace: number;
  15420. const ToLinearSpace = 2.2;
  15421. const Epsilon = 0.001;
  15422. /**
  15423. * Class used to hold a RBG color
  15424. */
  15425. class Color3 {
  15426. /**
  15427. * Defines the red component (between 0 and 1, default is 0)
  15428. */
  15429. r: number;
  15430. /**
  15431. * Defines the green component (between 0 and 1, default is 0)
  15432. */
  15433. g: number;
  15434. /**
  15435. * Defines the blue component (between 0 and 1, default is 0)
  15436. */
  15437. b: number;
  15438. /**
  15439. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  15440. * @param r defines the red component (between 0 and 1, default is 0)
  15441. * @param g defines the green component (between 0 and 1, default is 0)
  15442. * @param b defines the blue component (between 0 and 1, default is 0)
  15443. */
  15444. constructor(
  15445. /**
  15446. * Defines the red component (between 0 and 1, default is 0)
  15447. */
  15448. r?: number,
  15449. /**
  15450. * Defines the green component (between 0 and 1, default is 0)
  15451. */
  15452. g?: number,
  15453. /**
  15454. * Defines the blue component (between 0 and 1, default is 0)
  15455. */
  15456. b?: number);
  15457. /**
  15458. * Creates a string with the Color3 current values
  15459. * @returns the string representation of the Color3 object
  15460. */
  15461. toString(): string;
  15462. /**
  15463. * Returns the string "Color3"
  15464. * @returns "Color3"
  15465. */
  15466. getClassName(): string;
  15467. /**
  15468. * Compute the Color3 hash code
  15469. * @returns an unique number that can be used to hash Color3 objects
  15470. */
  15471. getHashCode(): number;
  15472. /**
  15473. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  15474. * @param array defines the array where to store the r,g,b components
  15475. * @param index defines an optional index in the target array to define where to start storing values
  15476. * @returns the current Color3 object
  15477. */
  15478. toArray(array: FloatArray, index?: number): Color3;
  15479. /**
  15480. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  15481. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  15482. * @returns a new {BABYLON.Color4} object
  15483. */
  15484. toColor4(alpha?: number): Color4;
  15485. /**
  15486. * Returns a new array populated with 3 numeric elements : red, green and blue values
  15487. * @returns the new array
  15488. */
  15489. asArray(): number[];
  15490. /**
  15491. * Returns the luminance value
  15492. * @returns a float value
  15493. */
  15494. toLuminance(): number;
  15495. /**
  15496. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  15497. * @param otherColor defines the second operand
  15498. * @returns the new Color3 object
  15499. */
  15500. multiply(otherColor: Color3): Color3;
  15501. /**
  15502. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  15503. * @param otherColor defines the second operand
  15504. * @param result defines the Color3 object where to store the result
  15505. * @returns the current Color3
  15506. */
  15507. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  15508. /**
  15509. * Determines equality between Color3 objects
  15510. * @param otherColor defines the second operand
  15511. * @returns true if the rgb values are equal to the given ones
  15512. */
  15513. equals(otherColor: Color3): boolean;
  15514. /**
  15515. * Determines equality between the current Color3 object and a set of r,b,g values
  15516. * @param r defines the red component to check
  15517. * @param g defines the green component to check
  15518. * @param b defines the blue component to check
  15519. * @returns true if the rgb values are equal to the given ones
  15520. */
  15521. equalsFloats(r: number, g: number, b: number): boolean;
  15522. /**
  15523. * Multiplies in place each rgb value by scale
  15524. * @param scale defines the scaling factor
  15525. * @returns the updated Color3
  15526. */
  15527. scale(scale: number): Color3;
  15528. /**
  15529. * Multiplies the rgb values by scale and stores the result into "result"
  15530. * @param scale defines the scaling factor
  15531. * @param result defines the Color3 object where to store the result
  15532. * @returns the unmodified current Color3
  15533. */
  15534. scaleToRef(scale: number, result: Color3): Color3;
  15535. /**
  15536. * Scale the current Color3 values by a factor and add the result to a given Color3
  15537. * @param scale defines the scale factor
  15538. * @param result defines color to store the result into
  15539. * @returns the unmodified current Color3
  15540. */
  15541. scaleAndAddToRef(scale: number, result: Color3): Color3;
  15542. /**
  15543. * Clamps the rgb values by the min and max values and stores the result into "result"
  15544. * @param min defines minimum clamping value (default is 0)
  15545. * @param max defines maximum clamping value (default is 1)
  15546. * @param result defines color to store the result into
  15547. * @returns the original Color3
  15548. */
  15549. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  15550. /**
  15551. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  15552. * @param otherColor defines the second operand
  15553. * @returns the new Color3
  15554. */
  15555. add(otherColor: Color3): Color3;
  15556. /**
  15557. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  15558. * @param otherColor defines the second operand
  15559. * @param result defines Color3 object to store the result into
  15560. * @returns the unmodified current Color3
  15561. */
  15562. addToRef(otherColor: Color3, result: Color3): Color3;
  15563. /**
  15564. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  15565. * @param otherColor defines the second operand
  15566. * @returns the new Color3
  15567. */
  15568. subtract(otherColor: Color3): Color3;
  15569. /**
  15570. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  15571. * @param otherColor defines the second operand
  15572. * @param result defines Color3 object to store the result into
  15573. * @returns the unmodified current Color3
  15574. */
  15575. subtractToRef(otherColor: Color3, result: Color3): Color3;
  15576. /**
  15577. * Copy the current object
  15578. * @returns a new Color3 copied the current one
  15579. */
  15580. clone(): Color3;
  15581. /**
  15582. * Copies the rgb values from the source in the current Color3
  15583. * @param source defines the source Color3 object
  15584. * @returns the updated Color3 object
  15585. */
  15586. copyFrom(source: Color3): Color3;
  15587. /**
  15588. * Updates the Color3 rgb values from the given floats
  15589. * @param r defines the red component to read from
  15590. * @param g defines the green component to read from
  15591. * @param b defines the blue component to read from
  15592. * @returns the current Color3 object
  15593. */
  15594. copyFromFloats(r: number, g: number, b: number): Color3;
  15595. /**
  15596. * Updates the Color3 rgb values from the given floats
  15597. * @param r defines the red component to read from
  15598. * @param g defines the green component to read from
  15599. * @param b defines the blue component to read from
  15600. * @returns the current Color3 object
  15601. */
  15602. set(r: number, g: number, b: number): Color3;
  15603. /**
  15604. * Compute the Color3 hexadecimal code as a string
  15605. * @returns a string containing the hexadecimal representation of the Color3 object
  15606. */
  15607. toHexString(): string;
  15608. /**
  15609. * Computes a new Color3 converted from the current one to linear space
  15610. * @returns a new Color3 object
  15611. */
  15612. toLinearSpace(): Color3;
  15613. /**
  15614. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  15615. * @param convertedColor defines the Color3 object where to store the linear space version
  15616. * @returns the unmodified Color3
  15617. */
  15618. toLinearSpaceToRef(convertedColor: Color3): Color3;
  15619. /**
  15620. * Computes a new Color3 converted from the current one to gamma space
  15621. * @returns a new Color3 object
  15622. */
  15623. toGammaSpace(): Color3;
  15624. /**
  15625. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  15626. * @param convertedColor defines the Color3 object where to store the gamma space version
  15627. * @returns the unmodified Color3
  15628. */
  15629. toGammaSpaceToRef(convertedColor: Color3): Color3;
  15630. /**
  15631. * Creates a new Color3 from the string containing valid hexadecimal values
  15632. * @param hex defines a string containing valid hexadecimal values
  15633. * @returns a new Color3 object
  15634. */
  15635. static FromHexString(hex: string): Color3;
  15636. /**
  15637. * Creates a new Vector3 from the starting index of the given array
  15638. * @param array defines the source array
  15639. * @param offset defines an offset in the source array
  15640. * @returns a new Color3 object
  15641. */
  15642. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  15643. /**
  15644. * Creates a new Color3 from integer values (< 256)
  15645. * @param r defines the red component to read from (value between 0 and 255)
  15646. * @param g defines the green component to read from (value between 0 and 255)
  15647. * @param b defines the blue component to read from (value between 0 and 255)
  15648. * @returns a new Color3 object
  15649. */
  15650. static FromInts(r: number, g: number, b: number): Color3;
  15651. /**
  15652. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  15653. * @param start defines the start Color3 value
  15654. * @param end defines the end Color3 value
  15655. * @param amount defines the gradient value between start and end
  15656. * @returns a new Color3 object
  15657. */
  15658. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  15659. /**
  15660. * Returns a Color3 value containing a red color
  15661. * @returns a new Color3 object
  15662. */
  15663. static Red(): Color3;
  15664. /**
  15665. * Returns a Color3 value containing a green color
  15666. * @returns a new Color3 object
  15667. */
  15668. static Green(): Color3;
  15669. /**
  15670. * Returns a Color3 value containing a blue color
  15671. * @returns a new Color3 object
  15672. */
  15673. static Blue(): Color3;
  15674. /**
  15675. * Returns a Color3 value containing a black color
  15676. * @returns a new Color3 object
  15677. */
  15678. static Black(): Color3;
  15679. /**
  15680. * Returns a Color3 value containing a white color
  15681. * @returns a new Color3 object
  15682. */
  15683. static White(): Color3;
  15684. /**
  15685. * Returns a Color3 value containing a purple color
  15686. * @returns a new Color3 object
  15687. */
  15688. static Purple(): Color3;
  15689. /**
  15690. * Returns a Color3 value containing a magenta color
  15691. * @returns a new Color3 object
  15692. */
  15693. static Magenta(): Color3;
  15694. /**
  15695. * Returns a Color3 value containing a yellow color
  15696. * @returns a new Color3 object
  15697. */
  15698. static Yellow(): Color3;
  15699. /**
  15700. * Returns a Color3 value containing a gray color
  15701. * @returns a new Color3 object
  15702. */
  15703. static Gray(): Color3;
  15704. /**
  15705. * Returns a Color3 value containing a teal color
  15706. * @returns a new Color3 object
  15707. */
  15708. static Teal(): Color3;
  15709. /**
  15710. * Returns a Color3 value containing a random color
  15711. * @returns a new Color3 object
  15712. */
  15713. static Random(): Color3;
  15714. }
  15715. /**
  15716. * Class used to hold a RBGA color
  15717. */
  15718. class Color4 {
  15719. /**
  15720. * Defines the red component (between 0 and 1, default is 0)
  15721. */
  15722. r: number;
  15723. /**
  15724. * Defines the green component (between 0 and 1, default is 0)
  15725. */
  15726. g: number;
  15727. /**
  15728. * Defines the blue component (between 0 and 1, default is 0)
  15729. */
  15730. b: number;
  15731. /**
  15732. * Defines the alpha component (between 0 and 1, default is 1)
  15733. */
  15734. a: number;
  15735. /**
  15736. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  15737. * @param r defines the red component (between 0 and 1, default is 0)
  15738. * @param g defines the green component (between 0 and 1, default is 0)
  15739. * @param b defines the blue component (between 0 and 1, default is 0)
  15740. * @param a defines the alpha component (between 0 and 1, default is 1)
  15741. */
  15742. constructor(
  15743. /**
  15744. * Defines the red component (between 0 and 1, default is 0)
  15745. */
  15746. r?: number,
  15747. /**
  15748. * Defines the green component (between 0 and 1, default is 0)
  15749. */
  15750. g?: number,
  15751. /**
  15752. * Defines the blue component (between 0 and 1, default is 0)
  15753. */
  15754. b?: number,
  15755. /**
  15756. * Defines the alpha component (between 0 and 1, default is 1)
  15757. */
  15758. a?: number);
  15759. /**
  15760. * Adds in place the given Color4 values to the current Color4 object
  15761. * @param right defines the second operand
  15762. * @returns the current updated Color4 object
  15763. */
  15764. addInPlace(right: Color4): Color4;
  15765. /**
  15766. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  15767. * @returns the new array
  15768. */
  15769. asArray(): number[];
  15770. /**
  15771. * Stores from the starting index in the given array the Color4 successive values
  15772. * @param array defines the array where to store the r,g,b components
  15773. * @param index defines an optional index in the target array to define where to start storing values
  15774. * @returns the current Color4 object
  15775. */
  15776. toArray(array: number[], index?: number): Color4;
  15777. /**
  15778. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  15779. * @param right defines the second operand
  15780. * @returns a new Color4 object
  15781. */
  15782. add(right: Color4): Color4;
  15783. /**
  15784. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  15785. * @param right defines the second operand
  15786. * @returns a new Color4 object
  15787. */
  15788. subtract(right: Color4): Color4;
  15789. /**
  15790. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  15791. * @param right defines the second operand
  15792. * @param result defines the Color4 object where to store the result
  15793. * @returns the current Color4 object
  15794. */
  15795. subtractToRef(right: Color4, result: Color4): Color4;
  15796. /**
  15797. * Creates a new Color4 with the current Color4 values multiplied by scale
  15798. * @param scale defines the scaling factor to apply
  15799. * @returns a new Color4 object
  15800. */
  15801. scale(scale: number): Color4;
  15802. /**
  15803. * Multiplies the current Color4 values by scale and stores the result in "result"
  15804. * @param scale defines the scaling factor to apply
  15805. * @param result defines the Color4 object where to store the result
  15806. * @returns the current unmodified Color4
  15807. */
  15808. scaleToRef(scale: number, result: Color4): Color4;
  15809. /**
  15810. * Scale the current Color4 values by a factor and add the result to a given Color4
  15811. * @param scale defines the scale factor
  15812. * @param result defines the Color4 object where to store the result
  15813. * @returns the unmodified current Color4
  15814. */
  15815. scaleAndAddToRef(scale: number, result: Color4): Color4;
  15816. /**
  15817. * Clamps the rgb values by the min and max values and stores the result into "result"
  15818. * @param min defines minimum clamping value (default is 0)
  15819. * @param max defines maximum clamping value (default is 1)
  15820. * @param result defines color to store the result into.
  15821. * @returns the cuurent Color4
  15822. */
  15823. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  15824. /**
  15825. * Multipy an Color4 value by another and return a new Color4 object
  15826. * @param color defines the Color4 value to multiply by
  15827. * @returns a new Color4 object
  15828. */
  15829. multiply(color: Color4): Color4;
  15830. /**
  15831. * Multipy a Color4 value by another and push the result in a reference value
  15832. * @param color defines the Color4 value to multiply by
  15833. * @param result defines the Color4 to fill the result in
  15834. * @returns the result Color4
  15835. */
  15836. multiplyToRef(color: Color4, result: Color4): Color4;
  15837. /**
  15838. * Creates a string with the Color4 current values
  15839. * @returns the string representation of the Color4 object
  15840. */
  15841. toString(): string;
  15842. /**
  15843. * Returns the string "Color4"
  15844. * @returns "Color4"
  15845. */
  15846. getClassName(): string;
  15847. /**
  15848. * Compute the Color4 hash code
  15849. * @returns an unique number that can be used to hash Color4 objects
  15850. */
  15851. getHashCode(): number;
  15852. /**
  15853. * Creates a new Color4 copied from the current one
  15854. * @returns a new Color4 object
  15855. */
  15856. clone(): Color4;
  15857. /**
  15858. * Copies the given Color4 values into the current one
  15859. * @param source defines the source Color4 object
  15860. * @returns the current updated Color4 object
  15861. */
  15862. copyFrom(source: Color4): Color4;
  15863. /**
  15864. * Copies the given float values into the current one
  15865. * @param r defines the red component to read from
  15866. * @param g defines the green component to read from
  15867. * @param b defines the blue component to read from
  15868. * @param a defines the alpha component to read from
  15869. * @returns the current updated Color4 object
  15870. */
  15871. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  15872. /**
  15873. * Copies the given float values into the current one
  15874. * @param r defines the red component to read from
  15875. * @param g defines the green component to read from
  15876. * @param b defines the blue component to read from
  15877. * @param a defines the alpha component to read from
  15878. * @returns the current updated Color4 object
  15879. */
  15880. set(r: number, g: number, b: number, a: number): Color4;
  15881. /**
  15882. * Compute the Color4 hexadecimal code as a string
  15883. * @returns a string containing the hexadecimal representation of the Color4 object
  15884. */
  15885. toHexString(): string;
  15886. /**
  15887. * Computes a new Color4 converted from the current one to linear space
  15888. * @returns a new Color4 object
  15889. */
  15890. toLinearSpace(): Color4;
  15891. /**
  15892. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  15893. * @param convertedColor defines the Color4 object where to store the linear space version
  15894. * @returns the unmodified Color4
  15895. */
  15896. toLinearSpaceToRef(convertedColor: Color4): Color4;
  15897. /**
  15898. * Computes a new Color4 converted from the current one to gamma space
  15899. * @returns a new Color4 object
  15900. */
  15901. toGammaSpace(): Color4;
  15902. /**
  15903. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  15904. * @param convertedColor defines the Color4 object where to store the gamma space version
  15905. * @returns the unmodified Color4
  15906. */
  15907. toGammaSpaceToRef(convertedColor: Color4): Color4;
  15908. /**
  15909. * Creates a new Color4 from the string containing valid hexadecimal values
  15910. * @param hex defines a string containing valid hexadecimal values
  15911. * @returns a new Color4 object
  15912. */
  15913. static FromHexString(hex: string): Color4;
  15914. /**
  15915. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15916. * @param left defines the start value
  15917. * @param right defines the end value
  15918. * @param amount defines the gradient factor
  15919. * @returns a new Color4 object
  15920. */
  15921. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  15922. /**
  15923. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15924. * @param left defines the start value
  15925. * @param right defines the end value
  15926. * @param amount defines the gradient factor
  15927. * @param result defines the Color4 object where to store data
  15928. */
  15929. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  15930. /**
  15931. * Creates a new Color4 from the starting index element of the given array
  15932. * @param array defines the source array to read from
  15933. * @param offset defines the offset in the source array
  15934. * @returns a new Color4 object
  15935. */
  15936. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  15937. /**
  15938. * Creates a new Color3 from integer values (< 256)
  15939. * @param r defines the red component to read from (value between 0 and 255)
  15940. * @param g defines the green component to read from (value between 0 and 255)
  15941. * @param b defines the blue component to read from (value between 0 and 255)
  15942. * @param a defines the alpha component to read from (value between 0 and 255)
  15943. * @returns a new Color3 object
  15944. */
  15945. static FromInts(r: number, g: number, b: number, a: number): Color4;
  15946. /**
  15947. * Check the content of a given array and convert it to an array containing RGBA data
  15948. * If the original array was already containing count * 4 values then it is returned directly
  15949. * @param colors defines the array to check
  15950. * @param count defines the number of RGBA data to expect
  15951. * @returns an array containing count * 4 values (RGBA)
  15952. */
  15953. static CheckColors4(colors: number[], count: number): number[];
  15954. }
  15955. /**
  15956. * Class representing a vector containing 2 coordinates
  15957. */
  15958. class Vector2 {
  15959. /** defines the first coordinate */
  15960. x: number;
  15961. /** defines the second coordinate */
  15962. y: number;
  15963. /**
  15964. * Creates a new Vector2 from the given x and y coordinates
  15965. * @param x defines the first coordinate
  15966. * @param y defines the second coordinate
  15967. */
  15968. constructor(
  15969. /** defines the first coordinate */
  15970. x?: number,
  15971. /** defines the second coordinate */
  15972. y?: number);
  15973. /**
  15974. * Gets a string with the Vector2 coordinates
  15975. * @returns a string with the Vector2 coordinates
  15976. */
  15977. toString(): string;
  15978. /**
  15979. * Gets class name
  15980. * @returns the string "Vector2"
  15981. */
  15982. getClassName(): string;
  15983. /**
  15984. * Gets current vector hash code
  15985. * @returns the Vector2 hash code as a number
  15986. */
  15987. getHashCode(): number;
  15988. /**
  15989. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  15990. * @param array defines the source array
  15991. * @param index defines the offset in source array
  15992. * @returns the current Vector2
  15993. */
  15994. toArray(array: FloatArray, index?: number): Vector2;
  15995. /**
  15996. * Copy the current vector to an array
  15997. * @returns a new array with 2 elements: the Vector2 coordinates.
  15998. */
  15999. asArray(): number[];
  16000. /**
  16001. * Sets the Vector2 coordinates with the given Vector2 coordinates
  16002. * @param source defines the source Vector2
  16003. * @returns the current updated Vector2
  16004. */
  16005. copyFrom(source: Vector2): Vector2;
  16006. /**
  16007. * Sets the Vector2 coordinates with the given floats
  16008. * @param x defines the first coordinate
  16009. * @param y defines the second coordinate
  16010. * @returns the current updated Vector2
  16011. */
  16012. copyFromFloats(x: number, y: number): Vector2;
  16013. /**
  16014. * Sets the Vector2 coordinates with the given floats
  16015. * @param x defines the first coordinate
  16016. * @param y defines the second coordinate
  16017. * @returns the current updated Vector2
  16018. */
  16019. set(x: number, y: number): Vector2;
  16020. /**
  16021. * Add another vector with the current one
  16022. * @param otherVector defines the other vector
  16023. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  16024. */
  16025. add(otherVector: Vector2): Vector2;
  16026. /**
  16027. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  16028. * @param otherVector defines the other vector
  16029. * @param result defines the target vector
  16030. * @returns the unmodified current Vector2
  16031. */
  16032. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  16033. /**
  16034. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  16035. * @param otherVector defines the other vector
  16036. * @returns the current updated Vector2
  16037. */
  16038. addInPlace(otherVector: Vector2): Vector2;
  16039. /**
  16040. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  16041. * @param otherVector defines the other vector
  16042. * @returns a new Vector2
  16043. */
  16044. addVector3(otherVector: Vector3): Vector2;
  16045. /**
  16046. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  16047. * @param otherVector defines the other vector
  16048. * @returns a new Vector2
  16049. */
  16050. subtract(otherVector: Vector2): Vector2;
  16051. /**
  16052. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  16053. * @param otherVector defines the other vector
  16054. * @param result defines the target vector
  16055. * @returns the unmodified current Vector2
  16056. */
  16057. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  16058. /**
  16059. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  16060. * @param otherVector defines the other vector
  16061. * @returns the current updated Vector2
  16062. */
  16063. subtractInPlace(otherVector: Vector2): Vector2;
  16064. /**
  16065. * Multiplies in place the current Vector2 coordinates by the given ones
  16066. * @param otherVector defines the other vector
  16067. * @returns the current updated Vector2
  16068. */
  16069. multiplyInPlace(otherVector: Vector2): Vector2;
  16070. /**
  16071. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  16072. * @param otherVector defines the other vector
  16073. * @returns a new Vector2
  16074. */
  16075. multiply(otherVector: Vector2): Vector2;
  16076. /**
  16077. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  16078. * @param otherVector defines the other vector
  16079. * @param result defines the target vector
  16080. * @returns the unmodified current Vector2
  16081. */
  16082. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  16083. /**
  16084. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  16085. * @param x defines the first coordinate
  16086. * @param y defines the second coordinate
  16087. * @returns a new Vector2
  16088. */
  16089. multiplyByFloats(x: number, y: number): Vector2;
  16090. /**
  16091. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  16092. * @param otherVector defines the other vector
  16093. * @returns a new Vector2
  16094. */
  16095. divide(otherVector: Vector2): Vector2;
  16096. /**
  16097. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  16098. * @param otherVector defines the other vector
  16099. * @param result defines the target vector
  16100. * @returns the unmodified current Vector2
  16101. */
  16102. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  16103. /**
  16104. * Divides the current Vector2 coordinates by the given ones
  16105. * @param otherVector defines the other vector
  16106. * @returns the current updated Vector2
  16107. */
  16108. divideInPlace(otherVector: Vector2): Vector2;
  16109. /**
  16110. * Gets a new Vector2 with current Vector2 negated coordinates
  16111. * @returns a new Vector2
  16112. */
  16113. negate(): Vector2;
  16114. /**
  16115. * Multiply the Vector2 coordinates by scale
  16116. * @param scale defines the scaling factor
  16117. * @returns the current updated Vector2
  16118. */
  16119. scaleInPlace(scale: number): Vector2;
  16120. /**
  16121. * Returns a new Vector2 scaled by "scale" from the current Vector2
  16122. * @param scale defines the scaling factor
  16123. * @returns a new Vector2
  16124. */
  16125. scale(scale: number): Vector2;
  16126. /**
  16127. * Scale the current Vector2 values by a factor to a given Vector2
  16128. * @param scale defines the scale factor
  16129. * @param result defines the Vector2 object where to store the result
  16130. * @returns the unmodified current Vector2
  16131. */
  16132. scaleToRef(scale: number, result: Vector2): Vector2;
  16133. /**
  16134. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  16135. * @param scale defines the scale factor
  16136. * @param result defines the Vector2 object where to store the result
  16137. * @returns the unmodified current Vector2
  16138. */
  16139. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  16140. /**
  16141. * Gets a boolean if two vectors are equals
  16142. * @param otherVector defines the other vector
  16143. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  16144. */
  16145. equals(otherVector: Vector2): boolean;
  16146. /**
  16147. * Gets a boolean if two vectors are equals (using an epsilon value)
  16148. * @param otherVector defines the other vector
  16149. * @param epsilon defines the minimal distance to consider equality
  16150. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  16151. */
  16152. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  16153. /**
  16154. * Gets a new Vector2 from current Vector2 floored values
  16155. * @returns a new Vector2
  16156. */
  16157. floor(): Vector2;
  16158. /**
  16159. * Gets a new Vector2 from current Vector2 floored values
  16160. * @returns a new Vector2
  16161. */
  16162. fract(): Vector2;
  16163. /**
  16164. * Gets the length of the vector
  16165. * @returns the vector length (float)
  16166. */
  16167. length(): number;
  16168. /**
  16169. * Gets the vector squared length
  16170. * @returns the vector squared length (float)
  16171. */
  16172. lengthSquared(): number;
  16173. /**
  16174. * Normalize the vector
  16175. * @returns the current updated Vector2
  16176. */
  16177. normalize(): Vector2;
  16178. /**
  16179. * Gets a new Vector2 copied from the Vector2
  16180. * @returns a new Vector2
  16181. */
  16182. clone(): Vector2;
  16183. /**
  16184. * Gets a new Vector2(0, 0)
  16185. * @returns a new Vector2
  16186. */
  16187. static Zero(): Vector2;
  16188. /**
  16189. * Gets a new Vector2(1, 1)
  16190. * @returns a new Vector2
  16191. */
  16192. static One(): Vector2;
  16193. /**
  16194. * Gets a new Vector2 set from the given index element of the given array
  16195. * @param array defines the data source
  16196. * @param offset defines the offset in the data source
  16197. * @returns a new Vector2
  16198. */
  16199. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  16200. /**
  16201. * Sets "result" from the given index element of the given array
  16202. * @param array defines the data source
  16203. * @param offset defines the offset in the data source
  16204. * @param result defines the target vector
  16205. */
  16206. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  16207. /**
  16208. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  16209. * @param value1 defines 1st point of control
  16210. * @param value2 defines 2nd point of control
  16211. * @param value3 defines 3rd point of control
  16212. * @param value4 defines 4th point of control
  16213. * @param amount defines the interpolation factor
  16214. * @returns a new Vector2
  16215. */
  16216. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  16217. /**
  16218. * 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".
  16219. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  16220. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  16221. * @param value defines the value to clamp
  16222. * @param min defines the lower limit
  16223. * @param max defines the upper limit
  16224. * @returns a new Vector2
  16225. */
  16226. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  16227. /**
  16228. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  16229. * @param value1 defines the 1st control point
  16230. * @param tangent1 defines the outgoing tangent
  16231. * @param value2 defines the 2nd control point
  16232. * @param tangent2 defines the incoming tangent
  16233. * @param amount defines the interpolation factor
  16234. * @returns a new Vector2
  16235. */
  16236. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  16237. /**
  16238. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  16239. * @param start defines the start vector
  16240. * @param end defines the end vector
  16241. * @param amount defines the interpolation factor
  16242. * @returns a new Vector2
  16243. */
  16244. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  16245. /**
  16246. * Gets the dot product of the vector "left" and the vector "right"
  16247. * @param left defines first vector
  16248. * @param right defines second vector
  16249. * @returns the dot product (float)
  16250. */
  16251. static Dot(left: Vector2, right: Vector2): number;
  16252. /**
  16253. * Returns a new Vector2 equal to the normalized given vector
  16254. * @param vector defines the vector to normalize
  16255. * @returns a new Vector2
  16256. */
  16257. static Normalize(vector: Vector2): Vector2;
  16258. /**
  16259. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  16260. * @param left defines 1st vector
  16261. * @param right defines 2nd vector
  16262. * @returns a new Vector2
  16263. */
  16264. static Minimize(left: Vector2, right: Vector2): Vector2;
  16265. /**
  16266. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  16267. * @param left defines 1st vector
  16268. * @param right defines 2nd vector
  16269. * @returns a new Vector2
  16270. */
  16271. static Maximize(left: Vector2, right: Vector2): Vector2;
  16272. /**
  16273. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  16274. * @param vector defines the vector to transform
  16275. * @param transformation defines the matrix to apply
  16276. * @returns a new Vector2
  16277. */
  16278. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  16279. /**
  16280. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  16281. * @param vector defines the vector to transform
  16282. * @param transformation defines the matrix to apply
  16283. * @param result defines the target vector
  16284. */
  16285. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  16286. /**
  16287. * Determines if a given vector is included in a triangle
  16288. * @param p defines the vector to test
  16289. * @param p0 defines 1st triangle point
  16290. * @param p1 defines 2nd triangle point
  16291. * @param p2 defines 3rd triangle point
  16292. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  16293. */
  16294. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  16295. /**
  16296. * Gets the distance between the vectors "value1" and "value2"
  16297. * @param value1 defines first vector
  16298. * @param value2 defines second vector
  16299. * @returns the distance between vectors
  16300. */
  16301. static Distance(value1: Vector2, value2: Vector2): number;
  16302. /**
  16303. * Returns the squared distance between the vectors "value1" and "value2"
  16304. * @param value1 defines first vector
  16305. * @param value2 defines second vector
  16306. * @returns the squared distance between vectors
  16307. */
  16308. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  16309. /**
  16310. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  16311. * @param value1 defines first vector
  16312. * @param value2 defines second vector
  16313. * @returns a new Vector2
  16314. */
  16315. static Center(value1: Vector2, value2: Vector2): Vector2;
  16316. /**
  16317. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  16318. * @param p defines the middle point
  16319. * @param segA defines one point of the segment
  16320. * @param segB defines the other point of the segment
  16321. * @returns the shortest distance
  16322. */
  16323. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  16324. }
  16325. /**
  16326. * Classed used to store (x,y,z) vector representation
  16327. * A Vector3 is the main object used in 3D geometry
  16328. * It can represent etiher the coordinates of a point the space, either a direction
  16329. * Reminder: Babylon.js uses a left handed forward facing system
  16330. */
  16331. class Vector3 {
  16332. /**
  16333. * Defines the first coordinates (on X axis)
  16334. */
  16335. x: number;
  16336. /**
  16337. * Defines the second coordinates (on Y axis)
  16338. */
  16339. y: number;
  16340. /**
  16341. * Defines the third coordinates (on Z axis)
  16342. */
  16343. z: number;
  16344. /**
  16345. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  16346. * @param x defines the first coordinates (on X axis)
  16347. * @param y defines the second coordinates (on Y axis)
  16348. * @param z defines the third coordinates (on Z axis)
  16349. */
  16350. constructor(
  16351. /**
  16352. * Defines the first coordinates (on X axis)
  16353. */
  16354. x?: number,
  16355. /**
  16356. * Defines the second coordinates (on Y axis)
  16357. */
  16358. y?: number,
  16359. /**
  16360. * Defines the third coordinates (on Z axis)
  16361. */
  16362. z?: number);
  16363. /**
  16364. * Creates a string representation of the Vector3
  16365. * @returns a string with the Vector3 coordinates.
  16366. */
  16367. toString(): string;
  16368. /**
  16369. * Gets the class name
  16370. * @returns the string "Vector3"
  16371. */
  16372. getClassName(): string;
  16373. /**
  16374. * Creates the Vector3 hash code
  16375. * @returns a number which tends to be unique between Vector3 instances
  16376. */
  16377. getHashCode(): number;
  16378. /**
  16379. * Creates an array containing three elements : the coordinates of the Vector3
  16380. * @returns a new array of numbers
  16381. */
  16382. asArray(): number[];
  16383. /**
  16384. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  16385. * @param array defines the destination array
  16386. * @param index defines the offset in the destination array
  16387. * @returns the current Vector3
  16388. */
  16389. toArray(array: FloatArray, index?: number): Vector3;
  16390. /**
  16391. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  16392. * @returns a new Quaternion object, computed from the Vector3 coordinates
  16393. */
  16394. toQuaternion(): Quaternion;
  16395. /**
  16396. * Adds the given vector to the current Vector3
  16397. * @param otherVector defines the second operand
  16398. * @returns the current updated Vector3
  16399. */
  16400. addInPlace(otherVector: Vector3): Vector3;
  16401. /**
  16402. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  16403. * @param otherVector defines the second operand
  16404. * @returns the resulting Vector3
  16405. */
  16406. add(otherVector: Vector3): Vector3;
  16407. /**
  16408. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  16409. * @param otherVector defines the second operand
  16410. * @param result defines the Vector3 object where to store the result
  16411. * @returns the current Vector3
  16412. */
  16413. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  16414. /**
  16415. * Subtract the given vector from the current Vector3
  16416. * @param otherVector defines the second operand
  16417. * @returns the current updated Vector3
  16418. */
  16419. subtractInPlace(otherVector: Vector3): Vector3;
  16420. /**
  16421. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  16422. * @param otherVector defines the second operand
  16423. * @returns the resulting Vector3
  16424. */
  16425. subtract(otherVector: Vector3): Vector3;
  16426. /**
  16427. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  16428. * @param otherVector defines the second operand
  16429. * @param result defines the Vector3 object where to store the result
  16430. * @returns the current Vector3
  16431. */
  16432. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  16433. /**
  16434. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  16435. * @param x defines the x coordinate of the operand
  16436. * @param y defines the y coordinate of the operand
  16437. * @param z defines the z coordinate of the operand
  16438. * @returns the resulting Vector3
  16439. */
  16440. subtractFromFloats(x: number, y: number, z: number): Vector3;
  16441. /**
  16442. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  16443. * @param x defines the x coordinate of the operand
  16444. * @param y defines the y coordinate of the operand
  16445. * @param z defines the z coordinate of the operand
  16446. * @param result defines the Vector3 object where to store the result
  16447. * @returns the current Vector3
  16448. */
  16449. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  16450. /**
  16451. * Gets a new Vector3 set with the current Vector3 negated coordinates
  16452. * @returns a new Vector3
  16453. */
  16454. negate(): Vector3;
  16455. /**
  16456. * Multiplies the Vector3 coordinates by the float "scale"
  16457. * @param scale defines the multiplier factor
  16458. * @returns the current updated Vector3
  16459. */
  16460. scaleInPlace(scale: number): Vector3;
  16461. /**
  16462. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  16463. * @param scale defines the multiplier factor
  16464. * @returns a new Vector3
  16465. */
  16466. scale(scale: number): Vector3;
  16467. /**
  16468. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  16469. * @param scale defines the multiplier factor
  16470. * @param result defines the Vector3 object where to store the result
  16471. * @returns the current Vector3
  16472. */
  16473. scaleToRef(scale: number, result: Vector3): Vector3;
  16474. /**
  16475. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  16476. * @param scale defines the scale factor
  16477. * @param result defines the Vector3 object where to store the result
  16478. * @returns the unmodified current Vector3
  16479. */
  16480. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  16481. /**
  16482. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  16483. * @param otherVector defines the second operand
  16484. * @returns true if both vectors are equals
  16485. */
  16486. equals(otherVector: Vector3): boolean;
  16487. /**
  16488. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  16489. * @param otherVector defines the second operand
  16490. * @param epsilon defines the minimal distance to define values as equals
  16491. * @returns true if both vectors are distant less than epsilon
  16492. */
  16493. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  16494. /**
  16495. * Returns true if the current Vector3 coordinates equals the given floats
  16496. * @param x defines the x coordinate of the operand
  16497. * @param y defines the y coordinate of the operand
  16498. * @param z defines the z coordinate of the operand
  16499. * @returns true if both vectors are equals
  16500. */
  16501. equalsToFloats(x: number, y: number, z: number): boolean;
  16502. /**
  16503. * Multiplies the current Vector3 coordinates by the given ones
  16504. * @param otherVector defines the second operand
  16505. * @returns the current updated Vector3
  16506. */
  16507. multiplyInPlace(otherVector: Vector3): Vector3;
  16508. /**
  16509. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  16510. * @param otherVector defines the second operand
  16511. * @returns the new Vector3
  16512. */
  16513. multiply(otherVector: Vector3): Vector3;
  16514. /**
  16515. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  16516. * @param otherVector defines the second operand
  16517. * @param result defines the Vector3 object where to store the result
  16518. * @returns the current Vector3
  16519. */
  16520. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  16521. /**
  16522. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  16523. * @param x defines the x coordinate of the operand
  16524. * @param y defines the y coordinate of the operand
  16525. * @param z defines the z coordinate of the operand
  16526. * @returns the new Vector3
  16527. */
  16528. multiplyByFloats(x: number, y: number, z: number): Vector3;
  16529. /**
  16530. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  16531. * @param otherVector defines the second operand
  16532. * @returns the new Vector3
  16533. */
  16534. divide(otherVector: Vector3): Vector3;
  16535. /**
  16536. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  16537. * @param otherVector defines the second operand
  16538. * @param result defines the Vector3 object where to store the result
  16539. * @returns the current Vector3
  16540. */
  16541. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  16542. /**
  16543. * Divides the current Vector3 coordinates by the given ones.
  16544. * @param otherVector defines the second operand
  16545. * @returns the current updated Vector3
  16546. */
  16547. divideInPlace(otherVector: Vector3): Vector3;
  16548. /**
  16549. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  16550. * @param other defines the second operand
  16551. * @returns the current updated Vector3
  16552. */
  16553. minimizeInPlace(other: Vector3): Vector3;
  16554. /**
  16555. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  16556. * @param other defines the second operand
  16557. * @returns the current updated Vector3
  16558. */
  16559. maximizeInPlace(other: Vector3): Vector3;
  16560. /**
  16561. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  16562. */
  16563. readonly isNonUniform: boolean;
  16564. /**
  16565. * Gets a new Vector3 from current Vector3 floored values
  16566. * @returns a new Vector3
  16567. */
  16568. floor(): Vector3;
  16569. /**
  16570. * Gets a new Vector3 from current Vector3 floored values
  16571. * @returns a new Vector3
  16572. */
  16573. fract(): Vector3;
  16574. /**
  16575. * Gets the length of the Vector3
  16576. * @returns the length of the Vecto3
  16577. */
  16578. length(): number;
  16579. /**
  16580. * Gets the squared length of the Vector3
  16581. * @returns squared length of the Vector3
  16582. */
  16583. lengthSquared(): number;
  16584. /**
  16585. * Normalize the current Vector3.
  16586. * Please note that this is an in place operation.
  16587. * @returns the current updated Vector3
  16588. */
  16589. normalize(): Vector3;
  16590. /**
  16591. * Normalize the current Vector3 to a new vector
  16592. * @returns the new Vector3
  16593. */
  16594. normalizeToNew(): Vector3;
  16595. /**
  16596. * Normalize the current Vector3 to the reference
  16597. * @param reference define the Vector3 to update
  16598. * @returns the updated Vector3
  16599. */
  16600. normalizeToRef(reference: Vector3): Vector3;
  16601. /**
  16602. * Creates a new Vector3 copied from the current Vector3
  16603. * @returns the new Vector3
  16604. */
  16605. clone(): Vector3;
  16606. /**
  16607. * Copies the given vector coordinates to the current Vector3 ones
  16608. * @param source defines the source Vector3
  16609. * @returns the current updated Vector3
  16610. */
  16611. copyFrom(source: Vector3): Vector3;
  16612. /**
  16613. * Copies the given floats to the current Vector3 coordinates
  16614. * @param x defines the x coordinate of the operand
  16615. * @param y defines the y coordinate of the operand
  16616. * @param z defines the z coordinate of the operand
  16617. * @returns the current updated Vector3
  16618. */
  16619. copyFromFloats(x: number, y: number, z: number): Vector3;
  16620. /**
  16621. * Copies the given floats to the current Vector3 coordinates
  16622. * @param x defines the x coordinate of the operand
  16623. * @param y defines the y coordinate of the operand
  16624. * @param z defines the z coordinate of the operand
  16625. * @returns the current updated Vector3
  16626. */
  16627. set(x: number, y: number, z: number): Vector3;
  16628. /**
  16629. * Get the clip factor between two vectors
  16630. * @param vector0 defines the first operand
  16631. * @param vector1 defines the second operand
  16632. * @param axis defines the axis to use
  16633. * @param size defines the size along the axis
  16634. * @returns the clip factor
  16635. */
  16636. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  16637. /**
  16638. * Get angle between two vectors
  16639. * @param vector0 angle between vector0 and vector1
  16640. * @param vector1 angle between vector0 and vector1
  16641. * @param normal direction of the normal
  16642. * @return the angle between vector0 and vector1
  16643. */
  16644. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  16645. /**
  16646. * Returns a new Vector3 set from the index "offset" of the given array
  16647. * @param array defines the source array
  16648. * @param offset defines the offset in the source array
  16649. * @returns the new Vector3
  16650. */
  16651. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  16652. /**
  16653. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  16654. * This function is deprecated. Use FromArray instead
  16655. * @param array defines the source array
  16656. * @param offset defines the offset in the source array
  16657. * @returns the new Vector3
  16658. */
  16659. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  16660. /**
  16661. * Sets the given vector "result" with the element values from the index "offset" of the given array
  16662. * @param array defines the source array
  16663. * @param offset defines the offset in the source array
  16664. * @param result defines the Vector3 where to store the result
  16665. */
  16666. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  16667. /**
  16668. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  16669. * This function is deprecated. Use FromArrayToRef instead.
  16670. * @param array defines the source array
  16671. * @param offset defines the offset in the source array
  16672. * @param result defines the Vector3 where to store the result
  16673. */
  16674. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  16675. /**
  16676. * Sets the given vector "result" with the given floats.
  16677. * @param x defines the x coordinate of the source
  16678. * @param y defines the y coordinate of the source
  16679. * @param z defines the z coordinate of the source
  16680. * @param result defines the Vector3 where to store the result
  16681. */
  16682. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  16683. /**
  16684. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  16685. * @returns a new empty Vector3
  16686. */
  16687. static Zero(): Vector3;
  16688. /**
  16689. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  16690. * @returns a new unit Vector3
  16691. */
  16692. static One(): Vector3;
  16693. /**
  16694. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  16695. * @returns a new up Vector3
  16696. */
  16697. static Up(): Vector3;
  16698. /**
  16699. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  16700. * @returns a new down Vector3
  16701. */
  16702. static Down(): Vector3;
  16703. /**
  16704. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  16705. * @returns a new forward Vector3
  16706. */
  16707. static Forward(): Vector3;
  16708. /**
  16709. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  16710. * @returns a new right Vector3
  16711. */
  16712. static Right(): Vector3;
  16713. /**
  16714. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  16715. * @returns a new left Vector3
  16716. */
  16717. static Left(): Vector3;
  16718. /**
  16719. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  16720. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16721. * @param vector defines the Vector3 to transform
  16722. * @param transformation defines the transformation matrix
  16723. * @returns the transformed Vector3
  16724. */
  16725. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  16726. /**
  16727. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  16728. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16729. * @param vector defines the Vector3 to transform
  16730. * @param transformation defines the transformation matrix
  16731. * @param result defines the Vector3 where to store the result
  16732. */
  16733. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16734. /**
  16735. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  16736. * This method computes tranformed coordinates only, not transformed direction vectors
  16737. * @param x define the x coordinate of the source vector
  16738. * @param y define the y coordinate of the source vector
  16739. * @param z define the z coordinate of the source vector
  16740. * @param transformation defines the transformation matrix
  16741. * @param result defines the Vector3 where to store the result
  16742. */
  16743. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16744. /**
  16745. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  16746. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16747. * @param vector defines the Vector3 to transform
  16748. * @param transformation defines the transformation matrix
  16749. * @returns the new Vector3
  16750. */
  16751. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  16752. /**
  16753. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  16754. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16755. * @param vector defines the Vector3 to transform
  16756. * @param transformation defines the transformation matrix
  16757. * @param result defines the Vector3 where to store the result
  16758. */
  16759. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16760. /**
  16761. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  16762. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16763. * @param x define the x coordinate of the source vector
  16764. * @param y define the y coordinate of the source vector
  16765. * @param z define the z coordinate of the source vector
  16766. * @param transformation defines the transformation matrix
  16767. * @param result defines the Vector3 where to store the result
  16768. */
  16769. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16770. /**
  16771. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  16772. * @param value1 defines the first control point
  16773. * @param value2 defines the second control point
  16774. * @param value3 defines the third control point
  16775. * @param value4 defines the fourth control point
  16776. * @param amount defines the amount on the spline to use
  16777. * @returns the new Vector3
  16778. */
  16779. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  16780. /**
  16781. * 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"
  16782. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  16783. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  16784. * @param value defines the current value
  16785. * @param min defines the lower range value
  16786. * @param max defines the upper range value
  16787. * @returns the new Vector3
  16788. */
  16789. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  16790. /**
  16791. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  16792. * @param value1 defines the first control point
  16793. * @param tangent1 defines the first tangent vector
  16794. * @param value2 defines the second control point
  16795. * @param tangent2 defines the second tangent vector
  16796. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  16797. * @returns the new Vector3
  16798. */
  16799. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  16800. /**
  16801. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  16802. * @param start defines the start value
  16803. * @param end defines the end value
  16804. * @param amount max defines amount between both (between 0 and 1)
  16805. * @returns the new Vector3
  16806. */
  16807. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  16808. /**
  16809. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  16810. * @param start defines the start value
  16811. * @param end defines the end value
  16812. * @param amount max defines amount between both (between 0 and 1)
  16813. * @param result defines the Vector3 where to store the result
  16814. */
  16815. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  16816. /**
  16817. * Returns the dot product (float) between the vectors "left" and "right"
  16818. * @param left defines the left operand
  16819. * @param right defines the right operand
  16820. * @returns the dot product
  16821. */
  16822. static Dot(left: Vector3, right: Vector3): number;
  16823. /**
  16824. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  16825. * The cross product is then orthogonal to both "left" and "right"
  16826. * @param left defines the left operand
  16827. * @param right defines the right operand
  16828. * @returns the cross product
  16829. */
  16830. static Cross(left: Vector3, right: Vector3): Vector3;
  16831. /**
  16832. * Sets the given vector "result" with the cross product of "left" and "right"
  16833. * The cross product is then orthogonal to both "left" and "right"
  16834. * @param left defines the left operand
  16835. * @param right defines the right operand
  16836. * @param result defines the Vector3 where to store the result
  16837. */
  16838. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  16839. /**
  16840. * Returns a new Vector3 as the normalization of the given vector
  16841. * @param vector defines the Vector3 to normalize
  16842. * @returns the new Vector3
  16843. */
  16844. static Normalize(vector: Vector3): Vector3;
  16845. /**
  16846. * Sets the given vector "result" with the normalization of the given first vector
  16847. * @param vector defines the Vector3 to normalize
  16848. * @param result defines the Vector3 where to store the result
  16849. */
  16850. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  16851. private static _viewportMatrixCache;
  16852. /**
  16853. * Project a Vector3 onto screen space
  16854. * @param vector defines the Vector3 to project
  16855. * @param world defines the world matrix to use
  16856. * @param transform defines the transform (view x projection) matrix to use
  16857. * @param viewport defines the screen viewport to use
  16858. * @returns the new Vector3
  16859. */
  16860. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  16861. /**
  16862. * Unproject from screen space to object space
  16863. * @param source defines the screen space Vector3 to use
  16864. * @param viewportWidth defines the current width of the viewport
  16865. * @param viewportHeight defines the current height of the viewport
  16866. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16867. * @param transform defines the transform (view x projection) matrix to use
  16868. * @returns the new Vector3
  16869. */
  16870. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  16871. /**
  16872. * Unproject from screen space to object space
  16873. * @param source defines the screen space Vector3 to use
  16874. * @param viewportWidth defines the current width of the viewport
  16875. * @param viewportHeight defines the current height of the viewport
  16876. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16877. * @param view defines the view matrix to use
  16878. * @param projection defines the projection matrix to use
  16879. * @returns the new Vector3
  16880. */
  16881. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  16882. /**
  16883. * Unproject from screen space to object space
  16884. * @param source defines the screen space Vector3 to use
  16885. * @param viewportWidth defines the current width of the viewport
  16886. * @param viewportHeight defines the current height of the viewport
  16887. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16888. * @param view defines the view matrix to use
  16889. * @param projection defines the projection matrix to use
  16890. * @param result defines the Vector3 where to store the result
  16891. */
  16892. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16893. /**
  16894. * Unproject from screen space to object space
  16895. * @param sourceX defines the screen space x coordinate to use
  16896. * @param sourceY defines the screen space y coordinate to use
  16897. * @param sourceZ defines the screen space z coordinate to use
  16898. * @param viewportWidth defines the current width of the viewport
  16899. * @param viewportHeight defines the current height of the viewport
  16900. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16901. * @param view defines the view matrix to use
  16902. * @param projection defines the projection matrix to use
  16903. * @param result defines the Vector3 where to store the result
  16904. */
  16905. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16906. /**
  16907. * Gets the minimal coordinate values between two Vector3
  16908. * @param left defines the first operand
  16909. * @param right defines the second operand
  16910. * @returns the new Vector3
  16911. */
  16912. static Minimize(left: Vector3, right: Vector3): Vector3;
  16913. /**
  16914. * Gets the maximal coordinate values between two Vector3
  16915. * @param left defines the first operand
  16916. * @param right defines the second operand
  16917. * @returns the new Vector3
  16918. */
  16919. static Maximize(left: Vector3, right: Vector3): Vector3;
  16920. /**
  16921. * Returns the distance between the vectors "value1" and "value2"
  16922. * @param value1 defines the first operand
  16923. * @param value2 defines the second operand
  16924. * @returns the distance
  16925. */
  16926. static Distance(value1: Vector3, value2: Vector3): number;
  16927. /**
  16928. * Returns the squared distance between the vectors "value1" and "value2"
  16929. * @param value1 defines the first operand
  16930. * @param value2 defines the second operand
  16931. * @returns the squared distance
  16932. */
  16933. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  16934. /**
  16935. * Returns a new Vector3 located at the center between "value1" and "value2"
  16936. * @param value1 defines the first operand
  16937. * @param value2 defines the second operand
  16938. * @returns the new Vector3
  16939. */
  16940. static Center(value1: Vector3, value2: Vector3): Vector3;
  16941. /**
  16942. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  16943. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  16944. * to something in order to rotate it from its local system to the given target system
  16945. * Note: axis1, axis2 and axis3 are normalized during this operation
  16946. * @param axis1 defines the first axis
  16947. * @param axis2 defines the second axis
  16948. * @param axis3 defines the third axis
  16949. * @returns a new Vector3
  16950. */
  16951. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  16952. /**
  16953. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  16954. * @param axis1 defines the first axis
  16955. * @param axis2 defines the second axis
  16956. * @param axis3 defines the third axis
  16957. * @param ref defines the Vector3 where to store the result
  16958. */
  16959. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  16960. }
  16961. class Vector4 {
  16962. x: number;
  16963. y: number;
  16964. z: number;
  16965. w: number;
  16966. /**
  16967. * Creates a Vector4 object from the given floats.
  16968. */
  16969. constructor(x: number, y: number, z: number, w: number);
  16970. /**
  16971. * Returns the string with the Vector4 coordinates.
  16972. */
  16973. toString(): string;
  16974. /**
  16975. * Returns the string "Vector4".
  16976. */
  16977. getClassName(): string;
  16978. /**
  16979. * Returns the Vector4 hash code.
  16980. */
  16981. getHashCode(): number;
  16982. /**
  16983. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  16984. */
  16985. asArray(): number[];
  16986. /**
  16987. * Populates the given array from the given index with the Vector4 coordinates.
  16988. * Returns the Vector4.
  16989. */
  16990. toArray(array: FloatArray, index?: number): Vector4;
  16991. /**
  16992. * Adds the given vector to the current Vector4.
  16993. * Returns the updated Vector4.
  16994. */
  16995. addInPlace(otherVector: Vector4): Vector4;
  16996. /**
  16997. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  16998. */
  16999. add(otherVector: Vector4): Vector4;
  17000. /**
  17001. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  17002. * Returns the current Vector4.
  17003. */
  17004. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  17005. /**
  17006. * Subtract in place the given vector from the current Vector4.
  17007. * Returns the updated Vector4.
  17008. */
  17009. subtractInPlace(otherVector: Vector4): Vector4;
  17010. /**
  17011. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  17012. */
  17013. subtract(otherVector: Vector4): Vector4;
  17014. /**
  17015. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  17016. * Returns the current Vector4.
  17017. */
  17018. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  17019. /**
  17020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  17021. */
  17022. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17023. /**
  17024. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  17025. * Returns the current Vector4.
  17026. */
  17027. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  17028. /**
  17029. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  17030. */
  17031. negate(): Vector4;
  17032. /**
  17033. * Multiplies the current Vector4 coordinates by scale (float).
  17034. * Returns the updated Vector4.
  17035. */
  17036. scaleInPlace(scale: number): Vector4;
  17037. /**
  17038. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  17039. */
  17040. scale(scale: number): Vector4;
  17041. /**
  17042. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  17043. * Returns the current Vector4.
  17044. */
  17045. scaleToRef(scale: number, result: Vector4): Vector4;
  17046. /**
  17047. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  17048. * @param scale defines the scale factor
  17049. * @param result defines the Vector4 object where to store the result
  17050. * @returns the unmodified current Vector4
  17051. */
  17052. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  17053. /**
  17054. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  17055. */
  17056. equals(otherVector: Vector4): boolean;
  17057. /**
  17058. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  17059. */
  17060. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  17061. /**
  17062. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  17063. */
  17064. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  17065. /**
  17066. * Multiplies in place the current Vector4 by the given one.
  17067. * Returns the updated Vector4.
  17068. */
  17069. multiplyInPlace(otherVector: Vector4): Vector4;
  17070. /**
  17071. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  17072. */
  17073. multiply(otherVector: Vector4): Vector4;
  17074. /**
  17075. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  17076. * Returns the current Vector4.
  17077. */
  17078. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  17079. /**
  17080. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  17081. */
  17082. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  17083. /**
  17084. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  17085. */
  17086. divide(otherVector: Vector4): Vector4;
  17087. /**
  17088. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  17089. * Returns the current Vector4.
  17090. */
  17091. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  17092. /**
  17093. * Divides the current Vector3 coordinates by the given ones.
  17094. * @returns the updated Vector3.
  17095. */
  17096. divideInPlace(otherVector: Vector4): Vector4;
  17097. /**
  17098. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  17099. * @param other defines the second operand
  17100. * @returns the current updated Vector4
  17101. */
  17102. minimizeInPlace(other: Vector4): Vector4;
  17103. /**
  17104. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  17105. * @param other defines the second operand
  17106. * @returns the current updated Vector4
  17107. */
  17108. maximizeInPlace(other: Vector4): Vector4;
  17109. /**
  17110. * Gets a new Vector4 from current Vector4 floored values
  17111. * @returns a new Vector4
  17112. */
  17113. floor(): Vector4;
  17114. /**
  17115. * Gets a new Vector4 from current Vector3 floored values
  17116. * @returns a new Vector4
  17117. */
  17118. fract(): Vector4;
  17119. /**
  17120. * Returns the Vector4 length (float).
  17121. */
  17122. length(): number;
  17123. /**
  17124. * Returns the Vector4 squared length (float).
  17125. */
  17126. lengthSquared(): number;
  17127. /**
  17128. * Normalizes in place the Vector4.
  17129. * Returns the updated Vector4.
  17130. */
  17131. normalize(): Vector4;
  17132. /**
  17133. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  17134. */
  17135. toVector3(): Vector3;
  17136. /**
  17137. * Returns a new Vector4 copied from the current one.
  17138. */
  17139. clone(): Vector4;
  17140. /**
  17141. * Updates the current Vector4 with the given one coordinates.
  17142. * Returns the updated Vector4.
  17143. */
  17144. copyFrom(source: Vector4): Vector4;
  17145. /**
  17146. * Updates the current Vector4 coordinates with the given floats.
  17147. * Returns the updated Vector4.
  17148. */
  17149. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  17150. /**
  17151. * Updates the current Vector4 coordinates with the given floats.
  17152. * Returns the updated Vector4.
  17153. */
  17154. set(x: number, y: number, z: number, w: number): Vector4;
  17155. /**
  17156. * Returns a new Vector4 set from the starting index of the given array.
  17157. */
  17158. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  17159. /**
  17160. * Updates the given vector "result" from the starting index of the given array.
  17161. */
  17162. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  17163. /**
  17164. * Updates the given vector "result" from the starting index of the given Float32Array.
  17165. */
  17166. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  17167. /**
  17168. * Updates the given vector "result" coordinates from the given floats.
  17169. */
  17170. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  17171. /**
  17172. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  17173. */
  17174. static Zero(): Vector4;
  17175. /**
  17176. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  17177. */
  17178. static One(): Vector4;
  17179. /**
  17180. * Returns a new normalized Vector4 from the given one.
  17181. */
  17182. static Normalize(vector: Vector4): Vector4;
  17183. /**
  17184. * Updates the given vector "result" from the normalization of the given one.
  17185. */
  17186. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  17187. static Minimize(left: Vector4, right: Vector4): Vector4;
  17188. static Maximize(left: Vector4, right: Vector4): Vector4;
  17189. /**
  17190. * Returns the distance (float) between the vectors "value1" and "value2".
  17191. */
  17192. static Distance(value1: Vector4, value2: Vector4): number;
  17193. /**
  17194. * Returns the squared distance (float) between the vectors "value1" and "value2".
  17195. */
  17196. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  17197. /**
  17198. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  17199. */
  17200. static Center(value1: Vector4, value2: Vector4): Vector4;
  17201. /**
  17202. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  17203. * This methods computes transformed normalized direction vectors only.
  17204. */
  17205. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  17206. /**
  17207. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  17208. * This methods computes transformed normalized direction vectors only.
  17209. */
  17210. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  17211. /**
  17212. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  17213. * This methods computes transformed normalized direction vectors only.
  17214. */
  17215. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  17216. }
  17217. interface ISize {
  17218. width: number;
  17219. height: number;
  17220. }
  17221. class Size implements ISize {
  17222. width: number;
  17223. height: number;
  17224. /**
  17225. * Creates a Size object from the given width and height (floats).
  17226. */
  17227. constructor(width: number, height: number);
  17228. toString(): string;
  17229. /**
  17230. * Returns the string "Size"
  17231. */
  17232. getClassName(): string;
  17233. /**
  17234. * Returns the Size hash code.
  17235. */
  17236. getHashCode(): number;
  17237. /**
  17238. * Updates the current size from the given one.
  17239. * Returns the updated Size.
  17240. */
  17241. copyFrom(src: Size): void;
  17242. /**
  17243. * Updates in place the current Size from the given floats.
  17244. * Returns the updated Size.
  17245. */
  17246. copyFromFloats(width: number, height: number): Size;
  17247. /**
  17248. * Updates in place the current Size from the given floats.
  17249. * Returns the updated Size.
  17250. */
  17251. set(width: number, height: number): Size;
  17252. /**
  17253. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  17254. */
  17255. multiplyByFloats(w: number, h: number): Size;
  17256. /**
  17257. * Returns a new Size copied from the given one.
  17258. */
  17259. clone(): Size;
  17260. /**
  17261. * Boolean : True if the current Size and the given one width and height are strictly equal.
  17262. */
  17263. equals(other: Size): boolean;
  17264. /**
  17265. * Returns the surface of the Size : width * height (float).
  17266. */
  17267. readonly surface: number;
  17268. /**
  17269. * Returns a new Size set to (0.0, 0.0)
  17270. */
  17271. static Zero(): Size;
  17272. /**
  17273. * Returns a new Size set as the addition result of the current Size and the given one.
  17274. */
  17275. add(otherSize: Size): Size;
  17276. /**
  17277. * Returns a new Size set as the subtraction result of the given one from the current Size.
  17278. */
  17279. subtract(otherSize: Size): Size;
  17280. /**
  17281. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  17282. */
  17283. static Lerp(start: Size, end: Size, amount: number): Size;
  17284. }
  17285. /**
  17286. * Class used to store quaternion data
  17287. * @see https://en.wikipedia.org/wiki/Quaternion
  17288. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  17289. */
  17290. class Quaternion {
  17291. /** defines the first component (0 by default) */
  17292. x: number;
  17293. /** defines the second component (0 by default) */
  17294. y: number;
  17295. /** defines the third component (0 by default) */
  17296. z: number;
  17297. /** defines the fourth component (1.0 by default) */
  17298. w: number;
  17299. /**
  17300. * Creates a new Quaternion from the given floats
  17301. * @param x defines the first component (0 by default)
  17302. * @param y defines the second component (0 by default)
  17303. * @param z defines the third component (0 by default)
  17304. * @param w defines the fourth component (1.0 by default)
  17305. */
  17306. constructor(
  17307. /** defines the first component (0 by default) */
  17308. x?: number,
  17309. /** defines the second component (0 by default) */
  17310. y?: number,
  17311. /** defines the third component (0 by default) */
  17312. z?: number,
  17313. /** defines the fourth component (1.0 by default) */
  17314. w?: number);
  17315. /**
  17316. * Gets a string representation for the current quaternion
  17317. * @returns a string with the Quaternion coordinates
  17318. */
  17319. toString(): string;
  17320. /**
  17321. * Gets the class name of the quaternion
  17322. * @returns the string "Quaternion"
  17323. */
  17324. getClassName(): string;
  17325. /**
  17326. * Gets a hash code for this quaternion
  17327. * @returns the quaternion hash code
  17328. */
  17329. getHashCode(): number;
  17330. /**
  17331. * Copy the quaternion to an array
  17332. * @returns a new array populated with 4 elements from the quaternion coordinates
  17333. */
  17334. asArray(): number[];
  17335. /**
  17336. * Check if two quaternions are equals
  17337. * @param otherQuaternion defines the second operand
  17338. * @return true if the current quaternion and the given one coordinates are strictly equals
  17339. */
  17340. equals(otherQuaternion: Quaternion): boolean;
  17341. /**
  17342. * Clone the current quaternion
  17343. * @returns a new quaternion copied from the current one
  17344. */
  17345. clone(): Quaternion;
  17346. /**
  17347. * Copy a quaternion to the current one
  17348. * @param other defines the other quaternion
  17349. * @returns the updated current quaternion
  17350. */
  17351. copyFrom(other: Quaternion): Quaternion;
  17352. /**
  17353. * Updates the current quaternion with the given float coordinates
  17354. * @param x defines the x coordinate
  17355. * @param y defines the y coordinate
  17356. * @param z defines the z coordinate
  17357. * @param w defines the w coordinate
  17358. * @returns the updated current quaternion
  17359. */
  17360. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  17361. /**
  17362. * Updates the current quaternion from the given float coordinates
  17363. * @param x defines the x coordinate
  17364. * @param y defines the y coordinate
  17365. * @param z defines the z coordinate
  17366. * @param w defines the w coordinate
  17367. * @returns the updated current quaternion
  17368. */
  17369. set(x: number, y: number, z: number, w: number): Quaternion;
  17370. /**
  17371. * Adds two quaternions
  17372. * @param other defines the second operand
  17373. * @returns a new quaternion as the addition result of the given one and the current quaternion
  17374. */
  17375. add(other: Quaternion): Quaternion;
  17376. /**
  17377. * Add a quaternion to the current one
  17378. * @param other defines the quaternion to add
  17379. * @returns the current quaternion
  17380. */
  17381. addInPlace(other: Quaternion): Quaternion;
  17382. /**
  17383. * Subtract two quaternions
  17384. * @param other defines the second operand
  17385. * @returns a new quaternion as the subtraction result of the given one from the current one
  17386. */
  17387. subtract(other: Quaternion): Quaternion;
  17388. /**
  17389. * Multiplies the current quaternion by a scale factor
  17390. * @param value defines the scale factor
  17391. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  17392. */
  17393. scale(value: number): Quaternion;
  17394. /**
  17395. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  17396. * @param scale defines the scale factor
  17397. * @param result defines the Quaternion object where to store the result
  17398. * @returns the unmodified current quaternion
  17399. */
  17400. scaleToRef(scale: number, result: Quaternion): Quaternion;
  17401. /**
  17402. * Multiplies in place the current quaternion by a scale factor
  17403. * @param value defines the scale factor
  17404. * @returns the current modified quaternion
  17405. */
  17406. scaleInPlace(value: number): Quaternion;
  17407. /**
  17408. * Scale the current quaternion values by a factor and add the result to a given quaternion
  17409. * @param scale defines the scale factor
  17410. * @param result defines the Quaternion object where to store the result
  17411. * @returns the unmodified current quaternion
  17412. */
  17413. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  17414. /**
  17415. * Multiplies two quaternions
  17416. * @param q1 defines the second operand
  17417. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  17418. */
  17419. multiply(q1: Quaternion): Quaternion;
  17420. /**
  17421. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  17422. * @param q1 defines the second operand
  17423. * @param result defines the target quaternion
  17424. * @returns the current quaternion
  17425. */
  17426. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  17427. /**
  17428. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  17429. * @param q1 defines the second operand
  17430. * @returns the currentupdated quaternion
  17431. */
  17432. multiplyInPlace(q1: Quaternion): Quaternion;
  17433. /**
  17434. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  17435. * @param ref defines the target quaternion
  17436. * @returns the current quaternion
  17437. */
  17438. conjugateToRef(ref: Quaternion): Quaternion;
  17439. /**
  17440. * Conjugates in place (1-q) the current quaternion
  17441. * @returns the current updated quaternion
  17442. */
  17443. conjugateInPlace(): Quaternion;
  17444. /**
  17445. * Conjugates in place (1-q) the current quaternion
  17446. * @returns a new quaternion
  17447. */
  17448. conjugate(): Quaternion;
  17449. /**
  17450. * Gets length of current quaternion
  17451. * @returns the quaternion length (float)
  17452. */
  17453. length(): number;
  17454. /**
  17455. * Normalize in place the current quaternion
  17456. * @returns the current updated quaternion
  17457. */
  17458. normalize(): Quaternion;
  17459. /**
  17460. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  17461. * @param order is a reserved parameter and is ignore for now
  17462. * @returns a new Vector3 containing the Euler angles
  17463. */
  17464. toEulerAngles(order?: string): Vector3;
  17465. /**
  17466. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  17467. * @param result defines the vector which will be filled with the Euler angles
  17468. * @param order is a reserved parameter and is ignore for now
  17469. * @returns the current unchanged quaternion
  17470. */
  17471. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  17472. /**
  17473. * Updates the given rotation matrix with the current quaternion values
  17474. * @param result defines the target matrix
  17475. * @returns the current unchanged quaternion
  17476. */
  17477. toRotationMatrix(result: Matrix): Quaternion;
  17478. /**
  17479. * Updates the current quaternion from the given rotation matrix values
  17480. * @param matrix defines the source matrix
  17481. * @returns the current updated quaternion
  17482. */
  17483. fromRotationMatrix(matrix: Matrix): Quaternion;
  17484. /**
  17485. * Creates a new quaternion from a rotation matrix
  17486. * @param matrix defines the source matrix
  17487. * @returns a new quaternion created from the given rotation matrix values
  17488. */
  17489. static FromRotationMatrix(matrix: Matrix): Quaternion;
  17490. /**
  17491. * Updates the given quaternion with the given rotation matrix values
  17492. * @param matrix defines the source matrix
  17493. * @param result defines the target quaternion
  17494. */
  17495. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  17496. /**
  17497. * Returns the dot product (float) between the quaternions "left" and "right"
  17498. * @param left defines the left operand
  17499. * @param right defines the right operand
  17500. * @returns the dot product
  17501. */
  17502. static Dot(left: Quaternion, right: Quaternion): number;
  17503. /**
  17504. * Checks if the two quaternions are close to each other
  17505. * @param quat0 defines the first quaternion to check
  17506. * @param quat1 defines the second quaternion to check
  17507. * @returns true if the two quaternions are close to each other
  17508. */
  17509. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  17510. /**
  17511. * Creates an empty quaternion
  17512. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  17513. */
  17514. static Zero(): Quaternion;
  17515. /**
  17516. * Inverse a given quaternion
  17517. * @param q defines the source quaternion
  17518. * @returns a new quaternion as the inverted current quaternion
  17519. */
  17520. static Inverse(q: Quaternion): Quaternion;
  17521. /**
  17522. * Creates an identity quaternion
  17523. * @returns the identity quaternion
  17524. */
  17525. static Identity(): Quaternion;
  17526. /**
  17527. * Gets a boolean indicating if the given quaternion is identity
  17528. * @param quaternion defines the quaternion to check
  17529. * @returns true if the quaternion is identity
  17530. */
  17531. static IsIdentity(quaternion: Quaternion): boolean;
  17532. /**
  17533. * Creates a quaternion from a rotation around an axis
  17534. * @param axis defines the axis to use
  17535. * @param angle defines the angle to use
  17536. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  17537. */
  17538. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  17539. /**
  17540. * Creates a rotation around an axis and stores it into the given quaternion
  17541. * @param axis defines the axis to use
  17542. * @param angle defines the angle to use
  17543. * @param result defines the target quaternion
  17544. * @returns the target quaternion
  17545. */
  17546. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  17547. /**
  17548. * Creates a new quaternion from data stored into an array
  17549. * @param array defines the data source
  17550. * @param offset defines the offset in the source array where the data starts
  17551. * @returns a new quaternion
  17552. */
  17553. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  17554. /**
  17555. * Creates a new quaternion from the given Euler float angles (y, x, z)
  17556. * @param yaw defines the rotation around Y axis
  17557. * @param pitch defines the rotation around X axis
  17558. * @param roll defines the rotation around Z axis
  17559. * @returns the new quaternion
  17560. */
  17561. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  17562. /**
  17563. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  17564. * @param yaw defines the rotation around Y axis
  17565. * @param pitch defines the rotation around X axis
  17566. * @param roll defines the rotation around Z axis
  17567. * @param result defines the target quaternion
  17568. */
  17569. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  17570. /**
  17571. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  17572. * @param alpha defines the rotation around first axis
  17573. * @param beta defines the rotation around second axis
  17574. * @param gamma defines the rotation around third axis
  17575. * @returns the new quaternion
  17576. */
  17577. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  17578. /**
  17579. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  17580. * @param alpha defines the rotation around first axis
  17581. * @param beta defines the rotation around second axis
  17582. * @param gamma defines the rotation around third axis
  17583. * @param result defines the target quaternion
  17584. */
  17585. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  17586. /**
  17587. * 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)
  17588. * @param axis1 defines the first axis
  17589. * @param axis2 defines the second axis
  17590. * @param axis3 defines the third axis
  17591. * @returns the new quaternion
  17592. */
  17593. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  17594. /**
  17595. * 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
  17596. * @param axis1 defines the first axis
  17597. * @param axis2 defines the second axis
  17598. * @param axis3 defines the third axis
  17599. * @param ref defines the target quaternion
  17600. */
  17601. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  17602. /**
  17603. * Interpolates between two quaternions
  17604. * @param left defines first quaternion
  17605. * @param right defines second quaternion
  17606. * @param amount defines the gradient to use
  17607. * @returns the new interpolated quaternion
  17608. */
  17609. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  17610. /**
  17611. * Interpolates between two quaternions and stores it into a target quaternion
  17612. * @param left defines first quaternion
  17613. * @param right defines second quaternion
  17614. * @param amount defines the gradient to use
  17615. * @param result defines the target quaternion
  17616. */
  17617. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  17618. /**
  17619. * Interpolate between two quaternions using Hermite interpolation
  17620. * @param value1 defines first quaternion
  17621. * @param tangent1 defines the incoming tangent
  17622. * @param value2 defines second quaternion
  17623. * @param tangent2 defines the outgoing tangent
  17624. * @param amount defines the target quaternion
  17625. * @returns the new interpolated quaternion
  17626. */
  17627. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  17628. }
  17629. /**
  17630. * Class used to store matrix data (4x4)
  17631. */
  17632. class Matrix {
  17633. private static _tempQuaternion;
  17634. private static _xAxis;
  17635. private static _yAxis;
  17636. private static _zAxis;
  17637. private static _updateFlagSeed;
  17638. private static _identityReadOnly;
  17639. private _isIdentity;
  17640. private _isIdentityDirty;
  17641. /**
  17642. * Gets the update flag of the matrix which is an unique number for the matrix.
  17643. * It will be incremented every time the matrix data change.
  17644. * You can use it to speed the comparison between two versions of the same matrix.
  17645. */
  17646. updateFlag: number;
  17647. /**
  17648. * Gets or sets the internal data of the matrix
  17649. */
  17650. m: Float32Array;
  17651. /** @hidden */
  17652. _markAsUpdated(): void;
  17653. /**
  17654. * Creates an empty matrix (filled with zeros)
  17655. */
  17656. constructor();
  17657. /**
  17658. * Check if the current matrix is indentity
  17659. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  17660. * @returns true is the matrix is the identity matrix
  17661. */
  17662. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  17663. /**
  17664. * Gets the determinant of the matrix
  17665. * @returns the matrix determinant
  17666. */
  17667. determinant(): number;
  17668. /**
  17669. * Returns the matrix as a Float32Array
  17670. * @returns the matrix underlying array
  17671. */
  17672. toArray(): Float32Array;
  17673. /**
  17674. * Returns the matrix as a Float32Array
  17675. * @returns the matrix underlying array.
  17676. */
  17677. asArray(): Float32Array;
  17678. /**
  17679. * Inverts the current matrix in place
  17680. * @returns the current inverted matrix
  17681. */
  17682. invert(): Matrix;
  17683. /**
  17684. * Sets all the matrix elements to zero
  17685. * @returns the current matrix
  17686. */
  17687. reset(): Matrix;
  17688. /**
  17689. * Adds the current matrix with a second one
  17690. * @param other defines the matrix to add
  17691. * @returns a new matrix as the addition of the current matrix and the given one
  17692. */
  17693. add(other: Matrix): Matrix;
  17694. /**
  17695. * Sets the given matrix "result" to the addition of the current matrix and the given one
  17696. * @param other defines the matrix to add
  17697. * @param result defines the target matrix
  17698. * @returns the current matrix
  17699. */
  17700. addToRef(other: Matrix, result: Matrix): Matrix;
  17701. /**
  17702. * Adds in place the given matrix to the current matrix
  17703. * @param other defines the second operand
  17704. * @returns the current updated matrix
  17705. */
  17706. addToSelf(other: Matrix): Matrix;
  17707. /**
  17708. * Sets the given matrix to the current inverted Matrix
  17709. * @param other defines the target matrix
  17710. * @returns the unmodified current matrix
  17711. */
  17712. invertToRef(other: Matrix): Matrix;
  17713. /**
  17714. * Inserts the translation vector (using 3 floats) in the current matrix
  17715. * @param x defines the 1st component of the translation
  17716. * @param y defines the 2nd component of the translation
  17717. * @param z defines the 3rd component of the translation
  17718. * @returns the current updated matrix
  17719. */
  17720. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  17721. /**
  17722. * Inserts the translation vector in the current matrix
  17723. * @param vector3 defines the translation to insert
  17724. * @returns the current updated matrix
  17725. */
  17726. setTranslation(vector3: Vector3): Matrix;
  17727. /**
  17728. * Gets the translation value of the current matrix
  17729. * @returns a new Vector3 as the extracted translation from the matrix
  17730. */
  17731. getTranslation(): Vector3;
  17732. /**
  17733. * Fill a Vector3 with the extracted translation from the matrix
  17734. * @param result defines the Vector3 where to store the translation
  17735. * @returns the current matrix
  17736. */
  17737. getTranslationToRef(result: Vector3): Matrix;
  17738. /**
  17739. * Remove rotation and scaling part from the matrix
  17740. * @returns the updated matrix
  17741. */
  17742. removeRotationAndScaling(): Matrix;
  17743. /**
  17744. * Multiply two matrices
  17745. * @param other defines the second operand
  17746. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  17747. */
  17748. multiply(other: Matrix): Matrix;
  17749. /**
  17750. * Copy the current matrix from the given one
  17751. * @param other defines the source matrix
  17752. * @returns the current updated matrix
  17753. */
  17754. copyFrom(other: Matrix): Matrix;
  17755. /**
  17756. * Populates the given array from the starting index with the current matrix values
  17757. * @param array defines the target array
  17758. * @param offset defines the offset in the target array where to start storing values
  17759. * @returns the current matrix
  17760. */
  17761. copyToArray(array: Float32Array, offset?: number): Matrix;
  17762. /**
  17763. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  17764. * @param other defines the second operand
  17765. * @param result defines the matrix where to store the multiplication
  17766. * @returns the current matrix
  17767. */
  17768. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  17769. /**
  17770. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  17771. * @param other defines the second operand
  17772. * @param result defines the array where to store the multiplication
  17773. * @param offset defines the offset in the target array where to start storing values
  17774. * @returns the current matrix
  17775. */
  17776. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  17777. /**
  17778. * Check equality between this matrix and a second one
  17779. * @param value defines the second matrix to compare
  17780. * @returns true is the current matrix and the given one values are strictly equal
  17781. */
  17782. equals(value: Matrix): boolean;
  17783. /**
  17784. * Clone the current matrix
  17785. * @returns a new matrix from the current matrix
  17786. */
  17787. clone(): Matrix;
  17788. /**
  17789. * Returns the name of the current matrix class
  17790. * @returns the string "Matrix"
  17791. */
  17792. getClassName(): string;
  17793. /**
  17794. * Gets the hash code of the current matrix
  17795. * @returns the hash code
  17796. */
  17797. getHashCode(): number;
  17798. /**
  17799. * Decomposes the current Matrix into a translation, rotation and scaling components
  17800. * @param scale defines the scale vector3 given as a reference to update
  17801. * @param rotation defines the rotation quaternion given as a reference to update
  17802. * @param translation defines the translation vector3 given as a reference to update
  17803. * @returns true if operation was successful
  17804. */
  17805. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  17806. /**
  17807. * Gets specific row of the matrix
  17808. * @param index defines the number of the row to get
  17809. * @returns the index-th row of the current matrix as a new Vector4
  17810. */
  17811. getRow(index: number): Nullable<Vector4>;
  17812. /**
  17813. * Sets the index-th row of the current matrix to the vector4 values
  17814. * @param index defines the number of the row to set
  17815. * @param row defines the target vector4
  17816. * @returns the updated current matrix
  17817. */
  17818. setRow(index: number, row: Vector4): Matrix;
  17819. /**
  17820. * Compute the transpose of the matrix
  17821. * @returns the new transposed matrix
  17822. */
  17823. transpose(): Matrix;
  17824. /**
  17825. * Compute the transpose of the matrix and store it in a given matrix
  17826. * @param result defines the target matrix
  17827. * @returns the current matrix
  17828. */
  17829. transposeToRef(result: Matrix): Matrix;
  17830. /**
  17831. * Sets the index-th row of the current matrix with the given 4 x float values
  17832. * @param index defines the row index
  17833. * @param x defines the x component to set
  17834. * @param y defines the y component to set
  17835. * @param z defines the z component to set
  17836. * @param w defines the w component to set
  17837. * @returns the updated current matrix
  17838. */
  17839. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  17840. /**
  17841. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  17842. * @param scale defines the scale factor
  17843. * @returns a new matrix
  17844. */
  17845. scale(scale: number): Matrix;
  17846. /**
  17847. * Scale the current matrix values by a factor to a given result matrix
  17848. * @param scale defines the scale factor
  17849. * @param result defines the matrix to store the result
  17850. * @returns the current matrix
  17851. */
  17852. scaleToRef(scale: number, result: Matrix): Matrix;
  17853. /**
  17854. * Scale the current matrix values by a factor and add the result to a given matrix
  17855. * @param scale defines the scale factor
  17856. * @param result defines the Matrix to store the result
  17857. * @returns the current matrix
  17858. */
  17859. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  17860. /**
  17861. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  17862. * @param ref matrix to store the result
  17863. */
  17864. toNormalMatrix(ref: Matrix): void;
  17865. /**
  17866. * Gets only rotation part of the current matrix
  17867. * @returns a new matrix sets to the extracted rotation matrix from the current one
  17868. */
  17869. getRotationMatrix(): Matrix;
  17870. /**
  17871. * Extracts the rotation matrix from the current one and sets it as the given "result"
  17872. * @param result defines the target matrix to store data to
  17873. * @returns the current matrix
  17874. */
  17875. getRotationMatrixToRef(result: Matrix): Matrix;
  17876. /**
  17877. * Creates a matrix from an array
  17878. * @param array defines the source array
  17879. * @param offset defines an offset in the source array
  17880. * @returns a new Matrix set from the starting index of the given array
  17881. */
  17882. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  17883. /**
  17884. * Copy the content of an array into a given matrix
  17885. * @param array defines the source array
  17886. * @param offset defines an offset in the source array
  17887. * @param result defines the target matrix
  17888. */
  17889. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  17890. /**
  17891. * Stores an array into a matrix after having multiplied each component by a given factor
  17892. * @param array defines the source array
  17893. * @param offset defines the offset in the source array
  17894. * @param scale defines the scaling factor
  17895. * @param result defines the target matrix
  17896. */
  17897. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  17898. /**
  17899. * Stores a list of values (16) inside a given matrix
  17900. * @param initialM11 defines 1st value of 1st row
  17901. * @param initialM12 defines 2nd value of 1st row
  17902. * @param initialM13 defines 3rd value of 1st row
  17903. * @param initialM14 defines 4th value of 1st row
  17904. * @param initialM21 defines 1st value of 2nd row
  17905. * @param initialM22 defines 2nd value of 2nd row
  17906. * @param initialM23 defines 3rd value of 2nd row
  17907. * @param initialM24 defines 4th value of 2nd row
  17908. * @param initialM31 defines 1st value of 3rd row
  17909. * @param initialM32 defines 2nd value of 3rd row
  17910. * @param initialM33 defines 3rd value of 3rd row
  17911. * @param initialM34 defines 4th value of 3rd row
  17912. * @param initialM41 defines 1st value of 4th row
  17913. * @param initialM42 defines 2nd value of 4th row
  17914. * @param initialM43 defines 3rd value of 4th row
  17915. * @param initialM44 defines 4th value of 4th row
  17916. * @param result defines the target matrix
  17917. */
  17918. 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;
  17919. /**
  17920. * Gets an identity matrix that must not be updated
  17921. */
  17922. static readonly IdentityReadOnly: Matrix;
  17923. /**
  17924. * Creates new matrix from a list of values (16)
  17925. * @param initialM11 defines 1st value of 1st row
  17926. * @param initialM12 defines 2nd value of 1st row
  17927. * @param initialM13 defines 3rd value of 1st row
  17928. * @param initialM14 defines 4th value of 1st row
  17929. * @param initialM21 defines 1st value of 2nd row
  17930. * @param initialM22 defines 2nd value of 2nd row
  17931. * @param initialM23 defines 3rd value of 2nd row
  17932. * @param initialM24 defines 4th value of 2nd row
  17933. * @param initialM31 defines 1st value of 3rd row
  17934. * @param initialM32 defines 2nd value of 3rd row
  17935. * @param initialM33 defines 3rd value of 3rd row
  17936. * @param initialM34 defines 4th value of 3rd row
  17937. * @param initialM41 defines 1st value of 4th row
  17938. * @param initialM42 defines 2nd value of 4th row
  17939. * @param initialM43 defines 3rd value of 4th row
  17940. * @param initialM44 defines 4th value of 4th row
  17941. * @returns the new matrix
  17942. */
  17943. 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;
  17944. /**
  17945. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17946. * @param scale defines the scale vector3
  17947. * @param rotation defines the rotation quaternion
  17948. * @param translation defines the translation vector3
  17949. * @returns a new matrix
  17950. */
  17951. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  17952. /**
  17953. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17954. * @param scale defines the scale vector3
  17955. * @param rotation defines the rotation quaternion
  17956. * @param translation defines the translation vector3
  17957. * @param result defines the target matrix
  17958. */
  17959. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  17960. /**
  17961. * Creates a new identity matrix
  17962. * @returns a new identity matrix
  17963. */
  17964. static Identity(): Matrix;
  17965. /**
  17966. * Creates a new identity matrix and stores the result in a given matrix
  17967. * @param result defines the target matrix
  17968. */
  17969. static IdentityToRef(result: Matrix): void;
  17970. /**
  17971. * Creates a new zero matrix
  17972. * @returns a new zero matrix
  17973. */
  17974. static Zero(): Matrix;
  17975. /**
  17976. * Creates a new rotation matrix for "angle" radians around the X axis
  17977. * @param angle defines the angle (in radians) to use
  17978. * @return the new matrix
  17979. */
  17980. static RotationX(angle: number): Matrix;
  17981. /**
  17982. * Creates a new matrix as the invert of a given matrix
  17983. * @param source defines the source matrix
  17984. * @returns the new matrix
  17985. */
  17986. static Invert(source: Matrix): Matrix;
  17987. /**
  17988. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  17989. * @param angle defines the angle (in radians) to use
  17990. * @param result defines the target matrix
  17991. */
  17992. static RotationXToRef(angle: number, result: Matrix): void;
  17993. /**
  17994. * Creates a new rotation matrix for "angle" radians around the Y axis
  17995. * @param angle defines the angle (in radians) to use
  17996. * @return the new matrix
  17997. */
  17998. static RotationY(angle: number): Matrix;
  17999. /**
  18000. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  18001. * @param angle defines the angle (in radians) to use
  18002. * @param result defines the target matrix
  18003. */
  18004. static RotationYToRef(angle: number, result: Matrix): void;
  18005. /**
  18006. * Creates a new rotation matrix for "angle" radians around the Z axis
  18007. * @param angle defines the angle (in radians) to use
  18008. * @return the new matrix
  18009. */
  18010. static RotationZ(angle: number): Matrix;
  18011. /**
  18012. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  18013. * @param angle defines the angle (in radians) to use
  18014. * @param result defines the target matrix
  18015. */
  18016. static RotationZToRef(angle: number, result: Matrix): void;
  18017. /**
  18018. * Creates a new rotation matrix for "angle" radians around the given axis
  18019. * @param axis defines the axis to use
  18020. * @param angle defines the angle (in radians) to use
  18021. * @return the new matrix
  18022. */
  18023. static RotationAxis(axis: Vector3, angle: number): Matrix;
  18024. /**
  18025. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  18026. * @param axis defines the axis to use
  18027. * @param angle defines the angle (in radians) to use
  18028. * @param result defines the target matrix
  18029. */
  18030. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  18031. /**
  18032. * Creates a rotation matrix
  18033. * @param yaw defines the yaw angle in radians (Y axis)
  18034. * @param pitch defines the pitch angle in radians (X axis)
  18035. * @param roll defines the roll angle in radians (X axis)
  18036. * @returns the new rotation matrix
  18037. */
  18038. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  18039. /**
  18040. * Creates a rotation matrix and stores it in a given matrix
  18041. * @param yaw defines the yaw angle in radians (Y axis)
  18042. * @param pitch defines the pitch angle in radians (X axis)
  18043. * @param roll defines the roll angle in radians (X axis)
  18044. * @param result defines the target matrix
  18045. */
  18046. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  18047. /**
  18048. * Creates a scaling matrix
  18049. * @param x defines the scale factor on X axis
  18050. * @param y defines the scale factor on Y axis
  18051. * @param z defines the scale factor on Z axis
  18052. * @returns the new matrix
  18053. */
  18054. static Scaling(x: number, y: number, z: number): Matrix;
  18055. /**
  18056. * Creates a scaling matrix and stores it in a given matrix
  18057. * @param x defines the scale factor on X axis
  18058. * @param y defines the scale factor on Y axis
  18059. * @param z defines the scale factor on Z axis
  18060. * @param result defines the target matrix
  18061. */
  18062. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  18063. /**
  18064. * Creates a translation matrix
  18065. * @param x defines the translation on X axis
  18066. * @param y defines the translation on Y axis
  18067. * @param z defines the translationon Z axis
  18068. * @returns the new matrix
  18069. */
  18070. static Translation(x: number, y: number, z: number): Matrix;
  18071. /**
  18072. * Creates a translation matrix and stores it in a given matrix
  18073. * @param x defines the translation on X axis
  18074. * @param y defines the translation on Y axis
  18075. * @param z defines the translationon Z axis
  18076. * @param result defines the target matrix
  18077. */
  18078. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  18079. /**
  18080. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18081. * @param startValue defines the start value
  18082. * @param endValue defines the end value
  18083. * @param gradient defines the gradient factor
  18084. * @returns the new matrix
  18085. */
  18086. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18087. /**
  18088. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  18089. * @param startValue defines the start value
  18090. * @param endValue defines the end value
  18091. * @param gradient defines the gradient factor
  18092. * @param result defines the Matrix object where to store data
  18093. */
  18094. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18095. /**
  18096. * Builds a new matrix whose values are computed by:
  18097. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18098. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18099. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18100. * @param startValue defines the first matrix
  18101. * @param endValue defines the second matrix
  18102. * @param gradient defines the gradient between the two matrices
  18103. * @returns the new matrix
  18104. */
  18105. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  18106. /**
  18107. * Update a matrix to values which are computed by:
  18108. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  18109. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  18110. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  18111. * @param startValue defines the first matrix
  18112. * @param endValue defines the second matrix
  18113. * @param gradient defines the gradient between the two matrices
  18114. * @param result defines the target matrix
  18115. */
  18116. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  18117. /**
  18118. * 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"
  18119. * This function works in left handed mode
  18120. * @param eye defines the final position of the entity
  18121. * @param target defines where the entity should look at
  18122. * @param up defines the up vector for the entity
  18123. * @returns the new matrix
  18124. */
  18125. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18126. /**
  18127. * 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".
  18128. * This function works in left handed mode
  18129. * @param eye defines the final position of the entity
  18130. * @param target defines where the entity should look at
  18131. * @param up defines the up vector for the entity
  18132. * @param result defines the target matrix
  18133. */
  18134. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18135. /**
  18136. * 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"
  18137. * This function works in right handed mode
  18138. * @param eye defines the final position of the entity
  18139. * @param target defines where the entity should look at
  18140. * @param up defines the up vector for the entity
  18141. * @returns the new matrix
  18142. */
  18143. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  18144. /**
  18145. * 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".
  18146. * This function works in right handed mode
  18147. * @param eye defines the final position of the entity
  18148. * @param target defines where the entity should look at
  18149. * @param up defines the up vector for the entity
  18150. * @param result defines the target matrix
  18151. */
  18152. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  18153. /**
  18154. * Create a left-handed orthographic projection matrix
  18155. * @param width defines the viewport width
  18156. * @param height defines the viewport height
  18157. * @param znear defines the near clip plane
  18158. * @param zfar defines the far clip plane
  18159. * @returns a new matrix as a left-handed orthographic projection matrix
  18160. */
  18161. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18162. /**
  18163. * Store a left-handed orthographic projection to a given matrix
  18164. * @param width defines the viewport width
  18165. * @param height defines the viewport height
  18166. * @param znear defines the near clip plane
  18167. * @param zfar defines the far clip plane
  18168. * @param result defines the target matrix
  18169. */
  18170. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  18171. /**
  18172. * Create a left-handed orthographic projection matrix
  18173. * @param left defines the viewport left coordinate
  18174. * @param right defines the viewport right coordinate
  18175. * @param bottom defines the viewport bottom coordinate
  18176. * @param top defines the viewport top coordinate
  18177. * @param znear defines the near clip plane
  18178. * @param zfar defines the far clip plane
  18179. * @returns a new matrix as a left-handed orthographic projection matrix
  18180. */
  18181. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18182. /**
  18183. * Stores a left-handed orthographic projection into a given matrix
  18184. * @param left defines the viewport left coordinate
  18185. * @param right defines the viewport right coordinate
  18186. * @param bottom defines the viewport bottom coordinate
  18187. * @param top defines the viewport top coordinate
  18188. * @param znear defines the near clip plane
  18189. * @param zfar defines the far clip plane
  18190. * @param result defines the target matrix
  18191. */
  18192. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18193. /**
  18194. * Creates a right-handed orthographic projection matrix
  18195. * @param left defines the viewport left coordinate
  18196. * @param right defines the viewport right coordinate
  18197. * @param bottom defines the viewport bottom coordinate
  18198. * @param top defines the viewport top coordinate
  18199. * @param znear defines the near clip plane
  18200. * @param zfar defines the far clip plane
  18201. * @returns a new matrix as a right-handed orthographic projection matrix
  18202. */
  18203. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  18204. /**
  18205. * Stores a right-handed orthographic projection into a given matrix
  18206. * @param left defines the viewport left coordinate
  18207. * @param right defines the viewport right coordinate
  18208. * @param bottom defines the viewport bottom coordinate
  18209. * @param top defines the viewport top coordinate
  18210. * @param znear defines the near clip plane
  18211. * @param zfar defines the far clip plane
  18212. * @param result defines the target matrix
  18213. */
  18214. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  18215. /**
  18216. * Creates a left-handed perspective projection matrix
  18217. * @param width defines the viewport width
  18218. * @param height defines the viewport height
  18219. * @param znear defines the near clip plane
  18220. * @param zfar defines the far clip plane
  18221. * @returns a new matrix as a left-handed perspective projection matrix
  18222. */
  18223. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  18224. /**
  18225. * Creates a left-handed perspective projection matrix
  18226. * @param fov defines the horizontal field of view
  18227. * @param aspect defines the aspect ratio
  18228. * @param znear defines the near clip plane
  18229. * @param zfar defines the far clip plane
  18230. * @returns a new matrix as a left-handed perspective projection matrix
  18231. */
  18232. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18233. /**
  18234. * Stores a left-handed perspective projection into a given matrix
  18235. * @param fov defines the horizontal field of view
  18236. * @param aspect defines the aspect ratio
  18237. * @param znear defines the near clip plane
  18238. * @param zfar defines the far clip plane
  18239. * @param result defines the target matrix
  18240. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18241. */
  18242. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18243. /**
  18244. * Creates a right-handed perspective projection matrix
  18245. * @param fov defines the horizontal field of view
  18246. * @param aspect defines the aspect ratio
  18247. * @param znear defines the near clip plane
  18248. * @param zfar defines the far clip plane
  18249. * @returns a new matrix as a right-handed perspective projection matrix
  18250. */
  18251. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  18252. /**
  18253. * Stores a right-handed perspective projection into a given matrix
  18254. * @param fov defines the horizontal field of view
  18255. * @param aspect defines the aspect ratio
  18256. * @param znear defines the near clip plane
  18257. * @param zfar defines the far clip plane
  18258. * @param result defines the target matrix
  18259. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  18260. */
  18261. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  18262. /**
  18263. * Stores a perspective projection for WebVR info a given matrix
  18264. * @param fov defines the field of view
  18265. * @param znear defines the near clip plane
  18266. * @param zfar defines the far clip plane
  18267. * @param result defines the target matrix
  18268. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  18269. */
  18270. static PerspectiveFovWebVRToRef(fov: {
  18271. upDegrees: number;
  18272. downDegrees: number;
  18273. leftDegrees: number;
  18274. rightDegrees: number;
  18275. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  18276. /**
  18277. * Computes a complete transformation matrix
  18278. * @param viewport defines the viewport to use
  18279. * @param world defines the world matrix
  18280. * @param view defines the view matrix
  18281. * @param projection defines the projection matrix
  18282. * @param zmin defines the near clip plane
  18283. * @param zmax defines the far clip plane
  18284. * @returns the transformation matrix
  18285. */
  18286. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  18287. /**
  18288. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  18289. * @param matrix defines the matrix to use
  18290. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  18291. */
  18292. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  18293. /**
  18294. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  18295. * @param matrix defines the matrix to use
  18296. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  18297. */
  18298. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  18299. /**
  18300. * Compute the transpose of a given matrix
  18301. * @param matrix defines the matrix to transpose
  18302. * @returns the new matrix
  18303. */
  18304. static Transpose(matrix: Matrix): Matrix;
  18305. /**
  18306. * Compute the transpose of a matrix and store it in a target matrix
  18307. * @param matrix defines the matrix to transpose
  18308. * @param result defines the target matrix
  18309. */
  18310. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  18311. /**
  18312. * Computes a reflection matrix from a plane
  18313. * @param plane defines the reflection plane
  18314. * @returns a new matrix
  18315. */
  18316. static Reflection(plane: Plane): Matrix;
  18317. /**
  18318. * Computes a reflection matrix from a plane
  18319. * @param plane defines the reflection plane
  18320. * @param result defines the target matrix
  18321. */
  18322. static ReflectionToRef(plane: Plane, result: Matrix): void;
  18323. /**
  18324. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  18325. * @param xaxis defines the value of the 1st axis
  18326. * @param yaxis defines the value of the 2nd axis
  18327. * @param zaxis defines the value of the 3rd axis
  18328. * @param result defines the target matrix
  18329. */
  18330. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  18331. /**
  18332. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  18333. * @param quat defines the quaternion to use
  18334. * @param result defines the target matrix
  18335. */
  18336. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  18337. }
  18338. class Plane {
  18339. normal: Vector3;
  18340. d: number;
  18341. /**
  18342. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  18343. */
  18344. constructor(a: number, b: number, c: number, d: number);
  18345. /**
  18346. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  18347. */
  18348. asArray(): number[];
  18349. /**
  18350. * Returns a new plane copied from the current Plane.
  18351. */
  18352. clone(): Plane;
  18353. /**
  18354. * Returns the string "Plane".
  18355. */
  18356. getClassName(): string;
  18357. /**
  18358. * Returns the Plane hash code.
  18359. */
  18360. getHashCode(): number;
  18361. /**
  18362. * Normalize the current Plane in place.
  18363. * Returns the updated Plane.
  18364. */
  18365. normalize(): Plane;
  18366. /**
  18367. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  18368. */
  18369. transform(transformation: Matrix): Plane;
  18370. /**
  18371. * Returns the dot product (float) of the point coordinates and the plane normal.
  18372. */
  18373. dotCoordinate(point: Vector3): number;
  18374. /**
  18375. * Updates the current Plane from the plane defined by the three given points.
  18376. * Returns the updated Plane.
  18377. */
  18378. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18379. /**
  18380. * Boolean : True is the vector "direction" is the same side than the plane normal.
  18381. */
  18382. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  18383. /**
  18384. * Returns the signed distance (float) from the given point to the Plane.
  18385. */
  18386. signedDistanceTo(point: Vector3): number;
  18387. /**
  18388. * Returns a new Plane from the given array.
  18389. */
  18390. static FromArray(array: ArrayLike<number>): Plane;
  18391. /**
  18392. * Returns a new Plane defined by the three given points.
  18393. */
  18394. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  18395. /**
  18396. * Returns a new Plane the normal vector to this plane at the given origin point.
  18397. * Note : the vector "normal" is updated because normalized.
  18398. */
  18399. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  18400. /**
  18401. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  18402. */
  18403. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  18404. }
  18405. class Viewport {
  18406. x: number;
  18407. y: number;
  18408. width: number;
  18409. height: number;
  18410. /**
  18411. * Creates a Viewport object located at (x, y) and sized (width, height).
  18412. */
  18413. constructor(x: number, y: number, width: number, height: number);
  18414. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  18415. /**
  18416. * Returns a new Viewport copied from the current one.
  18417. */
  18418. clone(): Viewport;
  18419. }
  18420. class Frustum {
  18421. /**
  18422. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  18423. */
  18424. static GetPlanes(transform: Matrix): Plane[];
  18425. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18426. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18427. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18428. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18429. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18430. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  18431. /**
  18432. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  18433. */
  18434. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  18435. }
  18436. /** Defines supported spaces */
  18437. enum Space {
  18438. /** Local (object) space */
  18439. LOCAL = 0,
  18440. /** World space */
  18441. WORLD = 1,
  18442. /** Bone space */
  18443. BONE = 2,
  18444. }
  18445. /** Defines the 3 main axes */
  18446. class Axis {
  18447. /** X axis */
  18448. static X: Vector3;
  18449. /** Y axis */
  18450. static Y: Vector3;
  18451. /** Z axis */
  18452. static Z: Vector3;
  18453. }
  18454. class BezierCurve {
  18455. /**
  18456. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  18457. */
  18458. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  18459. }
  18460. /**
  18461. * Defines potential orientation for back face culling
  18462. */
  18463. enum Orientation {
  18464. /**
  18465. * Clockwise
  18466. */
  18467. CW = 0,
  18468. /** Counter clockwise */
  18469. CCW = 1,
  18470. }
  18471. /**
  18472. * Defines angle representation
  18473. */
  18474. class Angle {
  18475. private _radians;
  18476. /**
  18477. * Creates an Angle object of "radians" radians (float).
  18478. */
  18479. constructor(radians: number);
  18480. /**
  18481. * Get value in degrees
  18482. * @returns the Angle value in degrees (float)
  18483. */
  18484. degrees(): number;
  18485. /**
  18486. * Get value in radians
  18487. * @returns the Angle value in radians (float)
  18488. */
  18489. radians(): number;
  18490. /**
  18491. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  18492. * @param a defines first vector
  18493. * @param b defines second vector
  18494. * @returns a new Angle
  18495. */
  18496. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  18497. /**
  18498. * Gets a new Angle object from the given float in radians
  18499. * @param radians defines the angle value in radians
  18500. * @returns a new Angle
  18501. */
  18502. static FromRadians(radians: number): Angle;
  18503. /**
  18504. * Gets a new Angle object from the given float in degrees
  18505. * @param degrees defines the angle value in degrees
  18506. * @returns a new Angle
  18507. */
  18508. static FromDegrees(degrees: number): Angle;
  18509. }
  18510. class Arc2 {
  18511. startPoint: Vector2;
  18512. midPoint: Vector2;
  18513. endPoint: Vector2;
  18514. centerPoint: Vector2;
  18515. radius: number;
  18516. angle: Angle;
  18517. startAngle: Angle;
  18518. orientation: Orientation;
  18519. /**
  18520. * Creates an Arc object from the three given points : start, middle and end.
  18521. */
  18522. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  18523. }
  18524. class Path2 {
  18525. private _points;
  18526. private _length;
  18527. closed: boolean;
  18528. /**
  18529. * Creates a Path2 object from the starting 2D coordinates x and y.
  18530. */
  18531. constructor(x: number, y: number);
  18532. /**
  18533. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  18534. * Returns the updated Path2.
  18535. */
  18536. addLineTo(x: number, y: number): Path2;
  18537. /**
  18538. * 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.
  18539. * Returns the updated Path2.
  18540. */
  18541. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  18542. /**
  18543. * Closes the Path2.
  18544. * Returns the Path2.
  18545. */
  18546. close(): Path2;
  18547. /**
  18548. * Returns the Path2 total length (float).
  18549. */
  18550. length(): number;
  18551. /**
  18552. * Returns the Path2 internal array of points.
  18553. */
  18554. getPoints(): Vector2[];
  18555. /**
  18556. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  18557. */
  18558. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  18559. /**
  18560. * Returns a new Path2 starting at the coordinates (x, y).
  18561. */
  18562. static StartingAt(x: number, y: number): Path2;
  18563. }
  18564. class Path3D {
  18565. path: Vector3[];
  18566. private _curve;
  18567. private _distances;
  18568. private _tangents;
  18569. private _normals;
  18570. private _binormals;
  18571. private _raw;
  18572. /**
  18573. * new Path3D(path, normal, raw)
  18574. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  18575. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  18576. * path : an array of Vector3, the curve axis of the Path3D
  18577. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  18578. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  18579. */
  18580. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  18581. /**
  18582. * Returns the Path3D array of successive Vector3 designing its curve.
  18583. */
  18584. getCurve(): Vector3[];
  18585. /**
  18586. * Returns an array populated with tangent vectors on each Path3D curve point.
  18587. */
  18588. getTangents(): Vector3[];
  18589. /**
  18590. * Returns an array populated with normal vectors on each Path3D curve point.
  18591. */
  18592. getNormals(): Vector3[];
  18593. /**
  18594. * Returns an array populated with binormal vectors on each Path3D curve point.
  18595. */
  18596. getBinormals(): Vector3[];
  18597. /**
  18598. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  18599. */
  18600. getDistances(): number[];
  18601. /**
  18602. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  18603. * Returns the same object updated.
  18604. */
  18605. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  18606. private _compute(firstNormal);
  18607. private _getFirstNonNullVector(index);
  18608. private _getLastNonNullVector(index);
  18609. private _normalVector(v0, vt, va);
  18610. }
  18611. class Curve3 {
  18612. private _points;
  18613. private _length;
  18614. /**
  18615. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  18616. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  18617. * @param v1 (Vector3) the control point
  18618. * @param v2 (Vector3) the end point of the Quadratic Bezier
  18619. * @param nbPoints (integer) the wanted number of points in the curve
  18620. */
  18621. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  18622. /**
  18623. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  18624. * @param v0 (Vector3) the origin point of the Cubic Bezier
  18625. * @param v1 (Vector3) the first control point
  18626. * @param v2 (Vector3) the second control point
  18627. * @param v3 (Vector3) the end point of the Cubic Bezier
  18628. * @param nbPoints (integer) the wanted number of points in the curve
  18629. */
  18630. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  18631. /**
  18632. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  18633. * @param p1 (Vector3) the origin point of the Hermite Spline
  18634. * @param t1 (Vector3) the tangent vector at the origin point
  18635. * @param p2 (Vector3) the end point of the Hermite Spline
  18636. * @param t2 (Vector3) the tangent vector at the end point
  18637. * @param nbPoints (integer) the wanted number of points in the curve
  18638. */
  18639. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  18640. /**
  18641. * Returns a Curve3 object along a CatmullRom Spline curve :
  18642. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  18643. * @param nbPoints (integer) the wanted number of points between each curve control points
  18644. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  18645. */
  18646. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  18647. /**
  18648. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  18649. * A Curve3 is designed from a series of successive Vector3.
  18650. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  18651. */
  18652. constructor(points: Vector3[]);
  18653. /**
  18654. * Returns the Curve3 stored array of successive Vector3
  18655. */
  18656. getPoints(): Vector3[];
  18657. /**
  18658. * Returns the computed length (float) of the curve.
  18659. */
  18660. length(): number;
  18661. /**
  18662. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  18663. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  18664. * curveA and curveB keep unchanged.
  18665. */
  18666. continue(curve: Curve3): Curve3;
  18667. private _computeLength(path);
  18668. }
  18669. class PositionNormalVertex {
  18670. position: Vector3;
  18671. normal: Vector3;
  18672. constructor(position?: Vector3, normal?: Vector3);
  18673. clone(): PositionNormalVertex;
  18674. }
  18675. class PositionNormalTextureVertex {
  18676. position: Vector3;
  18677. normal: Vector3;
  18678. uv: Vector2;
  18679. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  18680. clone(): PositionNormalTextureVertex;
  18681. }
  18682. class Tmp {
  18683. static Color3: Color3[];
  18684. static Color4: Color4[];
  18685. static Vector2: Vector2[];
  18686. static Vector3: Vector3[];
  18687. static Vector4: Vector4[];
  18688. static Quaternion: Quaternion[];
  18689. static Matrix: Matrix[];
  18690. }
  18691. }
  18692. declare module BABYLON {
  18693. /**
  18694. * Class representing spherical polynomial coefficients to the 3rd degree
  18695. */
  18696. class SphericalPolynomial {
  18697. /**
  18698. * The x coefficients of the spherical polynomial
  18699. */
  18700. x: Vector3;
  18701. /**
  18702. * The y coefficients of the spherical polynomial
  18703. */
  18704. y: Vector3;
  18705. /**
  18706. * The z coefficients of the spherical polynomial
  18707. */
  18708. z: Vector3;
  18709. /**
  18710. * The xx coefficients of the spherical polynomial
  18711. */
  18712. xx: Vector3;
  18713. /**
  18714. * The yy coefficients of the spherical polynomial
  18715. */
  18716. yy: Vector3;
  18717. /**
  18718. * The zz coefficients of the spherical polynomial
  18719. */
  18720. zz: Vector3;
  18721. /**
  18722. * The xy coefficients of the spherical polynomial
  18723. */
  18724. xy: Vector3;
  18725. /**
  18726. * The yz coefficients of the spherical polynomial
  18727. */
  18728. yz: Vector3;
  18729. /**
  18730. * The zx coefficients of the spherical polynomial
  18731. */
  18732. zx: Vector3;
  18733. /**
  18734. * Adds an ambient color to the spherical polynomial
  18735. * @param color the color to add
  18736. */
  18737. addAmbient(color: Color3): void;
  18738. /**
  18739. * Scales the spherical polynomial by the given amount
  18740. * @param scale the amount to scale
  18741. */
  18742. scale(scale: number): void;
  18743. /**
  18744. * Gets the spherical polynomial from harmonics
  18745. * @param harmonics the spherical harmonics
  18746. * @returns the spherical polynomial
  18747. */
  18748. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  18749. /**
  18750. * Constructs a spherical polynomial from an array.
  18751. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  18752. * @returns the spherical polynomial
  18753. */
  18754. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  18755. }
  18756. /**
  18757. * Class representing spherical harmonics coefficients to the 3rd degree
  18758. */
  18759. class SphericalHarmonics {
  18760. /**
  18761. * The l0,0 coefficients of the spherical harmonics
  18762. */
  18763. l00: Vector3;
  18764. /**
  18765. * The l1,-1 coefficients of the spherical harmonics
  18766. */
  18767. l1_1: Vector3;
  18768. /**
  18769. * The l1,0 coefficients of the spherical harmonics
  18770. */
  18771. l10: Vector3;
  18772. /**
  18773. * The l1,1 coefficients of the spherical harmonics
  18774. */
  18775. l11: Vector3;
  18776. /**
  18777. * The l2,-2 coefficients of the spherical harmonics
  18778. */
  18779. l2_2: Vector3;
  18780. /**
  18781. * The l2,-1 coefficients of the spherical harmonics
  18782. */
  18783. l2_1: Vector3;
  18784. /**
  18785. * The l2,0 coefficients of the spherical harmonics
  18786. */
  18787. l20: Vector3;
  18788. /**
  18789. * The l2,1 coefficients of the spherical harmonics
  18790. */
  18791. l21: Vector3;
  18792. /**
  18793. * The l2,2 coefficients of the spherical harmonics
  18794. */
  18795. lL22: Vector3;
  18796. /**
  18797. * Adds a light to the spherical harmonics
  18798. * @param direction the direction of the light
  18799. * @param color the color of the light
  18800. * @param deltaSolidAngle the delta solid angle of the light
  18801. */
  18802. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  18803. /**
  18804. * Scales the spherical harmonics by the given amount
  18805. * @param scale the amount to scale
  18806. */
  18807. scale(scale: number): void;
  18808. /**
  18809. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  18810. *
  18811. * ```
  18812. * E_lm = A_l * L_lm
  18813. * ```
  18814. *
  18815. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  18816. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  18817. * the scaling factors are given in equation 9.
  18818. */
  18819. convertIncidentRadianceToIrradiance(): void;
  18820. /**
  18821. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  18822. *
  18823. * ```
  18824. * L = (1/pi) * E * rho
  18825. * ```
  18826. *
  18827. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  18828. */
  18829. convertIrradianceToLambertianRadiance(): void;
  18830. /**
  18831. * Gets the spherical harmonics from polynomial
  18832. * @param polynomial the spherical polynomial
  18833. * @returns the spherical harmonics
  18834. */
  18835. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  18836. /**
  18837. * Constructs a spherical harmonics from an array.
  18838. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  18839. * @returns the spherical harmonics
  18840. */
  18841. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  18842. }
  18843. }
  18844. declare module BABYLON {
  18845. /**
  18846. * Class used to store all common mesh properties
  18847. */
  18848. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  18849. /** No occlusion */
  18850. static OCCLUSION_TYPE_NONE: number;
  18851. /** Occlusion set to optimisitic */
  18852. static OCCLUSION_TYPE_OPTIMISTIC: number;
  18853. /** Occlusion set to strict */
  18854. static OCCLUSION_TYPE_STRICT: number;
  18855. /** Use an accurante occlusion algorithm */
  18856. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  18857. /** Use a conservative occlusion algorithm */
  18858. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  18859. /**
  18860. * No billboard
  18861. */
  18862. static readonly BILLBOARDMODE_NONE: number;
  18863. /** Billboard on X axis */
  18864. static readonly BILLBOARDMODE_X: number;
  18865. /** Billboard on Y axis */
  18866. static readonly BILLBOARDMODE_Y: number;
  18867. /** Billboard on Z axis */
  18868. static readonly BILLBOARDMODE_Z: number;
  18869. /** Billboard on all axes */
  18870. static readonly BILLBOARDMODE_ALL: number;
  18871. private _facetPositions;
  18872. private _facetNormals;
  18873. private _facetPartitioning;
  18874. private _facetNb;
  18875. private _partitioningSubdivisions;
  18876. private _partitioningBBoxRatio;
  18877. private _facetDataEnabled;
  18878. private _facetParameters;
  18879. private _bbSize;
  18880. private _subDiv;
  18881. private _facetDepthSort;
  18882. private _facetDepthSortEnabled;
  18883. private _depthSortedIndices;
  18884. private _depthSortedFacets;
  18885. private _facetDepthSortFunction;
  18886. private _facetDepthSortFrom;
  18887. private _facetDepthSortOrigin;
  18888. private _invertedMatrix;
  18889. /**
  18890. * Gets the number of facets in the mesh
  18891. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  18892. */
  18893. readonly facetNb: number;
  18894. /**
  18895. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  18896. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  18897. */
  18898. partitioningSubdivisions: number;
  18899. /**
  18900. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  18901. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  18902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  18903. */
  18904. partitioningBBoxRatio: number;
  18905. /**
  18906. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  18907. * Works only for updatable meshes.
  18908. * Doesn't work with multi-materials
  18909. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  18910. */
  18911. mustDepthSortFacets: boolean;
  18912. /**
  18913. * The location (Vector3) where the facet depth sort must be computed from.
  18914. * By default, the active camera position.
  18915. * Used only when facet depth sort is enabled
  18916. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  18917. */
  18918. facetDepthSortFrom: Vector3;
  18919. /**
  18920. * gets a boolean indicating if facetData is enabled
  18921. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  18922. */
  18923. readonly isFacetDataEnabled: boolean;
  18924. /** @hidden */
  18925. _updateNonUniformScalingState(value: boolean): boolean;
  18926. /**
  18927. * An event triggered when this mesh collides with another one
  18928. */
  18929. onCollideObservable: Observable<AbstractMesh>;
  18930. private _onCollideObserver;
  18931. /** Set a function to call when this mesh collides with another one */
  18932. onCollide: () => void;
  18933. /**
  18934. * An event triggered when the collision's position changes
  18935. */
  18936. onCollisionPositionChangeObservable: Observable<Vector3>;
  18937. private _onCollisionPositionChangeObserver;
  18938. /** Set a function to call when the collision's position changes */
  18939. onCollisionPositionChange: () => void;
  18940. /**
  18941. * An event triggered when material is changed
  18942. */
  18943. onMaterialChangedObservable: Observable<AbstractMesh>;
  18944. /**
  18945. * Gets or sets the orientation for POV movement & rotation
  18946. */
  18947. definedFacingForward: boolean;
  18948. /**
  18949. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  18950. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  18951. * * 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.
  18952. * @see http://doc.babylonjs.com/features/occlusionquery
  18953. */
  18954. occlusionQueryAlgorithmType: number;
  18955. /**
  18956. * 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:
  18957. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  18958. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  18959. * * 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.
  18960. * @see http://doc.babylonjs.com/features/occlusionquery
  18961. */
  18962. occlusionType: number;
  18963. /**
  18964. * 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.
  18965. * The default value is -1 which means don't break the query and wait till the result
  18966. * @see http://doc.babylonjs.com/features/occlusionquery
  18967. */
  18968. occlusionRetryCount: number;
  18969. /** @hidden */
  18970. _occlusionInternalRetryCounter: number;
  18971. /** @hidden */
  18972. _isOccluded: boolean;
  18973. /**
  18974. * 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
  18975. * @see http://doc.babylonjs.com/features/occlusionquery
  18976. */
  18977. isOccluded: boolean;
  18978. /** @hidden */
  18979. _isOcclusionQueryInProgress: boolean;
  18980. /**
  18981. * Flag to check the progress status of the query
  18982. * @see http://doc.babylonjs.com/features/occlusionquery
  18983. */
  18984. readonly isOcclusionQueryInProgress: boolean;
  18985. /** @hidden */
  18986. _occlusionQuery: Nullable<WebGLQuery>;
  18987. private _visibility;
  18988. /**
  18989. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  18990. */
  18991. /**
  18992. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  18993. */
  18994. visibility: number;
  18995. /** Gets or sets the alpha index used to sort transparent meshes
  18996. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  18997. */
  18998. alphaIndex: number;
  18999. /**
  19000. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  19001. */
  19002. isVisible: boolean;
  19003. /**
  19004. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  19005. */
  19006. isPickable: boolean;
  19007. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  19008. showSubMeshesBoundingBox: boolean;
  19009. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  19010. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  19011. */
  19012. isBlocker: boolean;
  19013. /**
  19014. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  19015. */
  19016. enablePointerMoveEvents: boolean;
  19017. /**
  19018. * Specifies the rendering group id for this mesh (0 by default)
  19019. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  19020. */
  19021. renderingGroupId: number;
  19022. private _material;
  19023. /** Gets or sets current material */
  19024. material: Nullable<Material>;
  19025. private _receiveShadows;
  19026. /**
  19027. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  19028. * @see http://doc.babylonjs.com/babylon101/shadows
  19029. */
  19030. receiveShadows: boolean;
  19031. /**
  19032. * Gets or sets a boolean indicating if the outline must be rendered as well
  19033. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  19034. */
  19035. renderOutline: boolean;
  19036. /** Defines color to use when rendering outline */
  19037. outlineColor: Color3;
  19038. /** Define width to use when rendering outline */
  19039. outlineWidth: number;
  19040. /**
  19041. * Gets or sets a boolean indicating if the overlay must be rendered as well
  19042. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  19043. */
  19044. renderOverlay: boolean;
  19045. /** Defines color to use when rendering overlay */
  19046. overlayColor: Color3;
  19047. /** Defines alpha to use when rendering overlay */
  19048. overlayAlpha: number;
  19049. private _hasVertexAlpha;
  19050. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  19051. hasVertexAlpha: boolean;
  19052. private _useVertexColors;
  19053. /** 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) */
  19054. useVertexColors: boolean;
  19055. private _computeBonesUsingShaders;
  19056. /**
  19057. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  19058. */
  19059. computeBonesUsingShaders: boolean;
  19060. private _numBoneInfluencers;
  19061. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  19062. numBoneInfluencers: number;
  19063. private _applyFog;
  19064. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  19065. applyFog: boolean;
  19066. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  19067. useOctreeForRenderingSelection: boolean;
  19068. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  19069. useOctreeForPicking: boolean;
  19070. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  19071. useOctreeForCollisions: boolean;
  19072. private _layerMask;
  19073. /**
  19074. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  19075. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  19076. */
  19077. layerMask: number;
  19078. /**
  19079. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  19080. */
  19081. alwaysSelectAsActiveMesh: boolean;
  19082. /**
  19083. * Gets or sets the current action manager
  19084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19085. */
  19086. actionManager: Nullable<ActionManager>;
  19087. /**
  19088. * Gets or sets impostor used for physic simulation
  19089. * @see http://doc.babylonjs.com/features/physics_engine
  19090. */
  19091. physicsImpostor: Nullable<PhysicsImpostor>;
  19092. private _checkCollisions;
  19093. private _collisionMask;
  19094. private _collisionGroup;
  19095. /**
  19096. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  19097. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19098. */
  19099. ellipsoid: Vector3;
  19100. /**
  19101. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  19102. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19103. */
  19104. ellipsoidOffset: Vector3;
  19105. private _collider;
  19106. private _oldPositionForCollisions;
  19107. private _diffPositionForCollisions;
  19108. /**
  19109. * Gets or sets a collision mask used to mask collisions (default is -1).
  19110. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19111. */
  19112. collisionMask: number;
  19113. /**
  19114. * Gets or sets the current collision group mask (-1 by default).
  19115. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  19116. */
  19117. collisionGroup: number;
  19118. /**
  19119. * Defines edge width used when edgesRenderer is enabled
  19120. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19121. */
  19122. edgesWidth: number;
  19123. /**
  19124. * Defines edge color used when edgesRenderer is enabled
  19125. * @see https://www.babylonjs-playground.com/#10OJSG#13
  19126. */
  19127. edgesColor: Color4;
  19128. /** @hidden */
  19129. _edgesRenderer: Nullable<EdgesRenderer>;
  19130. private _collisionsTransformMatrix;
  19131. private _collisionsScalingMatrix;
  19132. /** @hidden */
  19133. _masterMesh: Nullable<AbstractMesh>;
  19134. /** @hidden */
  19135. _boundingInfo: Nullable<BoundingInfo>;
  19136. /** @hidden */
  19137. _renderId: number;
  19138. /**
  19139. * Gets or sets the list of subMeshes
  19140. * @see http://doc.babylonjs.com/how_to/multi_materials
  19141. */
  19142. subMeshes: SubMesh[];
  19143. /** @hidden */
  19144. _submeshesOctree: Octree<SubMesh>;
  19145. /** @hidden */
  19146. _intersectionsInProgress: AbstractMesh[];
  19147. /** @hidden */
  19148. _unIndexed: boolean;
  19149. /** @hidden */
  19150. _lightSources: Light[];
  19151. /** @hidden */
  19152. readonly _positions: Nullable<Vector3[]>;
  19153. /** @hidden */
  19154. _waitingActions: any;
  19155. /** @hidden */
  19156. _waitingFreezeWorldMatrix: Nullable<boolean>;
  19157. private _skeleton;
  19158. /** @hidden */
  19159. _bonesTransformMatrices: Nullable<Float32Array>;
  19160. /**
  19161. * Gets or sets a skeleton to apply skining transformations
  19162. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19163. */
  19164. skeleton: Nullable<Skeleton>;
  19165. /**
  19166. * Creates a new AbstractMesh
  19167. * @param name defines the name of the mesh
  19168. * @param scene defines the hosting scene
  19169. */
  19170. constructor(name: string, scene?: Nullable<Scene>);
  19171. /**
  19172. * Returns the string "AbstractMesh"
  19173. * @returns "AbstractMesh"
  19174. */
  19175. getClassName(): string;
  19176. /**
  19177. * Gets a string representation of the current mesh
  19178. * @param fullDetails defines a boolean indicating if full details must be included
  19179. * @returns a string representation of the current mesh
  19180. */
  19181. toString(fullDetails?: boolean): string;
  19182. /** @hidden */
  19183. _rebuild(): void;
  19184. /** @hidden */
  19185. _resyncLightSources(): void;
  19186. /** @hidden */
  19187. _resyncLighSource(light: Light): void;
  19188. /** @hidden */
  19189. _unBindEffect(): void;
  19190. /** @hidden */
  19191. _removeLightSource(light: Light): void;
  19192. private _markSubMeshesAsDirty(func);
  19193. /** @hidden */
  19194. _markSubMeshesAsLightDirty(): void;
  19195. /** @hidden */
  19196. _markSubMeshesAsAttributesDirty(): void;
  19197. /** @hidden */
  19198. _markSubMeshesAsMiscDirty(): void;
  19199. /**
  19200. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  19201. */
  19202. scaling: Vector3;
  19203. /**
  19204. * Disables the mesh edge rendering mode
  19205. * @returns the currentAbstractMesh
  19206. */
  19207. disableEdgesRendering(): AbstractMesh;
  19208. /**
  19209. * Enables the edge rendering mode on the mesh.
  19210. * This mode makes the mesh edges visible
  19211. * @param epsilon defines the maximal distance between two angles to detect a face
  19212. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19213. * @returns the currentAbstractMesh
  19214. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19215. */
  19216. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19217. /**
  19218. * Gets the edgesRenderer associated with the mesh
  19219. */
  19220. readonly edgesRenderer: Nullable<EdgesRenderer>;
  19221. /**
  19222. * Returns true if the mesh is blocked. Implemented by child classes
  19223. */
  19224. readonly isBlocked: boolean;
  19225. /**
  19226. * Returns the mesh itself by default. Implemented by child classes
  19227. * @param camera defines the camera to use to pick the right LOD level
  19228. * @returns the currentAbstractMesh
  19229. */
  19230. getLOD(camera: Camera): Nullable<AbstractMesh>;
  19231. /**
  19232. * Returns 0 by default. Implemented by child classes
  19233. * @returns an integer
  19234. */
  19235. getTotalVertices(): number;
  19236. /**
  19237. * Returns null by default. Implemented by child classes
  19238. * @returns null
  19239. */
  19240. getIndices(): Nullable<IndicesArray>;
  19241. /**
  19242. * Returns the array of the requested vertex data kind. Implemented by child classes
  19243. * @param kind defines the vertex data kind to use
  19244. * @returns null
  19245. */
  19246. getVerticesData(kind: string): Nullable<FloatArray>;
  19247. /**
  19248. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19249. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19250. * Note that a new underlying VertexBuffer object is created each call.
  19251. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19252. * @param kind defines vertex data kind:
  19253. * * BABYLON.VertexBuffer.PositionKind
  19254. * * BABYLON.VertexBuffer.UVKind
  19255. * * BABYLON.VertexBuffer.UV2Kind
  19256. * * BABYLON.VertexBuffer.UV3Kind
  19257. * * BABYLON.VertexBuffer.UV4Kind
  19258. * * BABYLON.VertexBuffer.UV5Kind
  19259. * * BABYLON.VertexBuffer.UV6Kind
  19260. * * BABYLON.VertexBuffer.ColorKind
  19261. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19262. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19263. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19264. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19265. * @param data defines the data source
  19266. * @param updatable defines if the data must be flagged as updatable (or static)
  19267. * @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
  19268. * @returns the current mesh
  19269. */
  19270. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19271. /**
  19272. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19273. * If the mesh has no geometry, it is simply returned as it is.
  19274. * @param kind defines vertex data kind:
  19275. * * BABYLON.VertexBuffer.PositionKind
  19276. * * BABYLON.VertexBuffer.UVKind
  19277. * * BABYLON.VertexBuffer.UV2Kind
  19278. * * BABYLON.VertexBuffer.UV3Kind
  19279. * * BABYLON.VertexBuffer.UV4Kind
  19280. * * BABYLON.VertexBuffer.UV5Kind
  19281. * * BABYLON.VertexBuffer.UV6Kind
  19282. * * BABYLON.VertexBuffer.ColorKind
  19283. * * BABYLON.VertexBuffer.MatricesIndicesKind
  19284. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19285. * * BABYLON.VertexBuffer.MatricesWeightsKind
  19286. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19287. * @param data defines the data source
  19288. * @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
  19289. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  19290. * @returns the current mesh
  19291. */
  19292. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  19293. /**
  19294. * Sets the mesh indices,
  19295. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19296. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19297. * @param totalVertices Defines the total number of vertices
  19298. * @returns the current mesh
  19299. */
  19300. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  19301. /**
  19302. * Gets a boolean indicating if specific vertex data is present
  19303. * @param kind defines the vertex data kind to use
  19304. * @returns true is data kind is present
  19305. */
  19306. isVerticesDataPresent(kind: string): boolean;
  19307. /**
  19308. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  19309. * @returns a BoundingInfo
  19310. */
  19311. getBoundingInfo(): BoundingInfo;
  19312. /**
  19313. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  19314. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  19315. * @returns the current mesh
  19316. */
  19317. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  19318. /**
  19319. * Overwrite the current bounding info
  19320. * @param boundingInfo defines the new bounding info
  19321. * @returns the current mesh
  19322. */
  19323. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  19324. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  19325. readonly useBones: boolean;
  19326. /** @hidden */
  19327. _preActivate(): void;
  19328. /** @hidden */
  19329. _preActivateForIntermediateRendering(renderId: number): void;
  19330. /** @hidden */
  19331. _activate(renderId: number): void;
  19332. /**
  19333. * Gets the current world matrix
  19334. * @returns a Matrix
  19335. */
  19336. getWorldMatrix(): Matrix;
  19337. /** @hidden */
  19338. _getWorldMatrixDeterminant(): number;
  19339. /**
  19340. * Perform relative position change from the point of view of behind the front of the mesh.
  19341. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19342. * Supports definition of mesh facing forward or backward
  19343. * @param amountRight defines the distance on the right axis
  19344. * @param amountUp defines the distance on the up axis
  19345. * @param amountForward defines the distance on the forward axis
  19346. * @returns the current mesh
  19347. */
  19348. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  19349. /**
  19350. * Calculate relative position change from the point of view of behind the front of the mesh.
  19351. * This is performed taking into account the meshes current rotation, so you do not have to care.
  19352. * Supports definition of mesh facing forward or backward
  19353. * @param amountRight defines the distance on the right axis
  19354. * @param amountUp defines the distance on the up axis
  19355. * @param amountForward defines the distance on the forward axis
  19356. * @returns the new displacement vector
  19357. */
  19358. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  19359. /**
  19360. * Perform relative rotation change from the point of view of behind the front of the mesh.
  19361. * Supports definition of mesh facing forward or backward
  19362. * @param flipBack defines the flip
  19363. * @param twirlClockwise defines the twirl
  19364. * @param tiltRight defines the tilt
  19365. * @returns the current mesh
  19366. */
  19367. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  19368. /**
  19369. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  19370. * Supports definition of mesh facing forward or backward.
  19371. * @param flipBack defines the flip
  19372. * @param twirlClockwise defines the twirl
  19373. * @param tiltRight defines the tilt
  19374. * @returns the new rotation vector
  19375. */
  19376. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  19377. /**
  19378. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  19379. * @param includeDescendants Include bounding info from descendants as well (true by default)
  19380. * @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
  19381. * @returns the new bounding vectors
  19382. */
  19383. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  19384. min: Vector3;
  19385. max: Vector3;
  19386. };
  19387. /** @hidden */
  19388. _updateBoundingInfo(): AbstractMesh;
  19389. /** @hidden */
  19390. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  19391. /** @hidden */
  19392. protected _afterComputeWorldMatrix(): void;
  19393. /**
  19394. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19395. * A mesh is in the frustum if its bounding box intersects the frustum
  19396. * @param frustumPlanes defines the frustum to test
  19397. * @returns true if the mesh is in the frustum planes
  19398. */
  19399. isInFrustum(frustumPlanes: Plane[]): boolean;
  19400. /**
  19401. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  19402. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  19403. * @param frustumPlanes defines the frustum to test
  19404. * @returns true if the mesh is completely in the frustum planes
  19405. */
  19406. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19407. /**
  19408. * True if the mesh intersects another mesh or a SolidParticle object
  19409. * @param mesh defines a target mesh or SolidParticle to test
  19410. * @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)
  19411. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  19412. * @returns true if there is an intersection
  19413. */
  19414. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  19415. /**
  19416. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  19417. * @param point defines the point to test
  19418. * @returns true if there is an intersection
  19419. */
  19420. intersectsPoint(point: Vector3): boolean;
  19421. /**
  19422. * Gets the current physics impostor
  19423. * @see http://doc.babylonjs.com/features/physics_engine
  19424. * @returns a physics impostor or null
  19425. */
  19426. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  19427. /**
  19428. * Gets the position of the current mesh in camera space
  19429. * @param camera defines the camera to use
  19430. * @returns a position
  19431. */
  19432. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  19433. /**
  19434. * Returns the distance from the mesh to the active camera
  19435. * @param camera defines the camera to use
  19436. * @returns the distance
  19437. */
  19438. getDistanceToCamera(camera?: Nullable<Camera>): number;
  19439. /**
  19440. * Apply a physic impulse to the mesh
  19441. * @param force defines the force to apply
  19442. * @param contactPoint defines where to apply the force
  19443. * @returns the current mesh
  19444. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19445. */
  19446. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  19447. /**
  19448. * Creates a physic joint between two meshes
  19449. * @param otherMesh defines the other mesh to use
  19450. * @param pivot1 defines the pivot to use on this mesh
  19451. * @param pivot2 defines the pivot to use on the other mesh
  19452. * @param options defines additional options (can be plugin dependent)
  19453. * @returns the current mesh
  19454. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  19455. */
  19456. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  19457. /**
  19458. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  19459. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19460. */
  19461. checkCollisions: boolean;
  19462. /**
  19463. * Gets Collider object used to compute collisions (not physics)
  19464. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19465. */
  19466. readonly collider: Collider;
  19467. /**
  19468. * Move the mesh using collision engine
  19469. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  19470. * @param displacement defines the requested displacement vector
  19471. * @returns the current mesh
  19472. */
  19473. moveWithCollisions(displacement: Vector3): AbstractMesh;
  19474. private _onCollisionPositionChange;
  19475. /**
  19476. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  19477. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19478. * @param maxCapacity defines the maximum size of each block (64 by default)
  19479. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  19480. * @returns the new octree
  19481. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  19482. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  19483. */
  19484. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  19485. /** @hidden */
  19486. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  19487. /** @hidden */
  19488. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  19489. /** @hidden */
  19490. _checkCollision(collider: Collider): AbstractMesh;
  19491. /** @hidden */
  19492. _generatePointsArray(): boolean;
  19493. /**
  19494. * Checks if the passed Ray intersects with the mesh
  19495. * @param ray defines the ray to use
  19496. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  19497. * @returns the picking info
  19498. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  19499. */
  19500. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  19501. /**
  19502. * Clones the current mesh
  19503. * @param name defines the mesh name
  19504. * @param newParent defines the new mesh parent
  19505. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  19506. * @returns the new mesh
  19507. */
  19508. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19509. /**
  19510. * Disposes all the submeshes of the current meshnp
  19511. * @returns the current mesh
  19512. */
  19513. releaseSubMeshes(): AbstractMesh;
  19514. /**
  19515. * Releases resources associated with this abstract mesh.
  19516. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19517. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19518. */
  19519. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19520. /**
  19521. * Adds the passed mesh as a child to the current mesh
  19522. * @param mesh defines the child mesh
  19523. * @returns the current mesh
  19524. */
  19525. addChild(mesh: AbstractMesh): AbstractMesh;
  19526. /**
  19527. * Removes the passed mesh from the current mesh children list
  19528. * @param mesh defines the child mesh
  19529. * @returns the current mesh
  19530. */
  19531. removeChild(mesh: AbstractMesh): AbstractMesh;
  19532. /** @hidden */
  19533. private _initFacetData();
  19534. /**
  19535. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  19536. * This method can be called within the render loop.
  19537. * 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
  19538. * @returns the current mesh
  19539. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19540. */
  19541. updateFacetData(): AbstractMesh;
  19542. /**
  19543. * Returns the facetLocalNormals array.
  19544. * The normals are expressed in the mesh local spac
  19545. * @returns an array of Vector3
  19546. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19547. */
  19548. getFacetLocalNormals(): Vector3[];
  19549. /**
  19550. * Returns the facetLocalPositions array.
  19551. * The facet positions are expressed in the mesh local space
  19552. * @returns an array of Vector3
  19553. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19554. */
  19555. getFacetLocalPositions(): Vector3[];
  19556. /**
  19557. * Returns the facetLocalPartioning array
  19558. * @returns an array of array of numbers
  19559. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19560. */
  19561. getFacetLocalPartitioning(): number[][];
  19562. /**
  19563. * Returns the i-th facet position in the world system.
  19564. * This method allocates a new Vector3 per call
  19565. * @param i defines the facet index
  19566. * @returns a new Vector3
  19567. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19568. */
  19569. getFacetPosition(i: number): Vector3;
  19570. /**
  19571. * Sets the reference Vector3 with the i-th facet position in the world system
  19572. * @param i defines the facet index
  19573. * @param ref defines the target vector
  19574. * @returns the current mesh
  19575. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19576. */
  19577. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  19578. /**
  19579. * Returns the i-th facet normal in the world system.
  19580. * This method allocates a new Vector3 per call
  19581. * @param i defines the facet index
  19582. * @returns a new Vector3
  19583. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19584. */
  19585. getFacetNormal(i: number): Vector3;
  19586. /**
  19587. * Sets the reference Vector3 with the i-th facet normal in the world system
  19588. * @param i defines the facet index
  19589. * @param ref defines the target vector
  19590. * @returns the current mesh
  19591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19592. */
  19593. getFacetNormalToRef(i: number, ref: Vector3): this;
  19594. /**
  19595. * 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)
  19596. * @param x defines x coordinate
  19597. * @param y defines y coordinate
  19598. * @param z defines z coordinate
  19599. * @returns the array of facet indexes
  19600. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19601. */
  19602. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  19603. /**
  19604. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  19605. * @param projected sets as the (x,y,z) world projection on the facet
  19606. * @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
  19607. * @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
  19608. * @param x defines x coordinate
  19609. * @param y defines y coordinate
  19610. * @param z defines z coordinate
  19611. * @returns the face index if found (or null instead)
  19612. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19613. */
  19614. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19615. /**
  19616. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  19617. * @param projected sets as the (x,y,z) local projection on the facet
  19618. * @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
  19619. * @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
  19620. * @param x defines x coordinate
  19621. * @param y defines y coordinate
  19622. * @param z defines z coordinate
  19623. * @returns the face index if found (or null instead)
  19624. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19625. */
  19626. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19627. /**
  19628. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  19629. * @returns the parameters
  19630. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19631. */
  19632. getFacetDataParameters(): any;
  19633. /**
  19634. * Disables the feature FacetData and frees the related memory
  19635. * @returns the current mesh
  19636. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19637. */
  19638. disableFacetData(): AbstractMesh;
  19639. /**
  19640. * Updates the AbstractMesh indices array
  19641. * @param indices defines the data source
  19642. * @returns the current mesh
  19643. */
  19644. updateIndices(indices: IndicesArray): AbstractMesh;
  19645. /**
  19646. * Creates new normals data for the mesh
  19647. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  19648. * @returns the current mesh
  19649. */
  19650. createNormals(updatable: boolean): AbstractMesh;
  19651. /**
  19652. * Align the mesh with a normal
  19653. * @param normal defines the normal to use
  19654. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  19655. * @returns the current mesh
  19656. */
  19657. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  19658. /** @hidden */
  19659. _checkOcclusionQuery(): void;
  19660. }
  19661. }
  19662. declare module BABYLON {
  19663. class Buffer {
  19664. private _engine;
  19665. private _buffer;
  19666. /** @hidden */
  19667. _data: Nullable<DataArray>;
  19668. private _updatable;
  19669. private _instanced;
  19670. /**
  19671. * Gets the byte stride.
  19672. */
  19673. readonly byteStride: number;
  19674. /**
  19675. * Constructor
  19676. * @param engine the engine
  19677. * @param data the data to use for this buffer
  19678. * @param updatable whether the data is updatable
  19679. * @param stride the stride (optional)
  19680. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  19681. * @param instanced whether the buffer is instanced (optional)
  19682. * @param useBytes set to true if the stride in in bytes (optional)
  19683. */
  19684. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  19685. /**
  19686. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  19687. * @param kind defines the vertex buffer kind (position, normal, etc.)
  19688. * @param offset defines offset in the buffer (0 by default)
  19689. * @param size defines the size in floats of attributes (position is 3 for instance)
  19690. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  19691. * @param instanced defines if the vertex buffer contains indexed data
  19692. * @param useBytes defines if the offset and stride are in bytes
  19693. * @returns the new vertex buffer
  19694. */
  19695. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  19696. isUpdatable(): boolean;
  19697. getData(): Nullable<DataArray>;
  19698. getBuffer(): Nullable<WebGLBuffer>;
  19699. /**
  19700. * Gets the stride in float32 units (i.e. byte stride / 4).
  19701. * May not be an integer if the byte stride is not divisible by 4.
  19702. * DEPRECATED. Use byteStride instead.
  19703. * @returns the stride in float32 units
  19704. */
  19705. getStrideSize(): number;
  19706. create(data?: Nullable<DataArray>): void;
  19707. _rebuild(): void;
  19708. update(data: DataArray): void;
  19709. /**
  19710. * Updates the data directly.
  19711. * @param data the new data
  19712. * @param offset the new offset
  19713. * @param vertexCount the vertex count (optional)
  19714. * @param useBytes set to true if the offset is in bytes
  19715. */
  19716. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  19717. dispose(): void;
  19718. }
  19719. }
  19720. declare module BABYLON {
  19721. class CSG {
  19722. private polygons;
  19723. matrix: Matrix;
  19724. position: Vector3;
  19725. rotation: Vector3;
  19726. rotationQuaternion: Nullable<Quaternion>;
  19727. scaling: Vector3;
  19728. static FromMesh(mesh: Mesh): CSG;
  19729. private static FromPolygons(polygons);
  19730. clone(): CSG;
  19731. union(csg: CSG): CSG;
  19732. unionInPlace(csg: CSG): void;
  19733. subtract(csg: CSG): CSG;
  19734. subtractInPlace(csg: CSG): void;
  19735. intersect(csg: CSG): CSG;
  19736. intersectInPlace(csg: CSG): void;
  19737. inverse(): CSG;
  19738. inverseInPlace(): void;
  19739. copyTransformAttributes(csg: CSG): CSG;
  19740. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  19741. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  19742. }
  19743. }
  19744. declare module BABYLON {
  19745. /**
  19746. * Class used to store geometry data (vertex buffers + index buffer)
  19747. */
  19748. class Geometry implements IGetSetVerticesData {
  19749. /**
  19750. * Gets or sets the unique ID of the geometry
  19751. */
  19752. id: string;
  19753. /**
  19754. * Gets the delay loading state of the geometry (none by default which means not delayed)
  19755. */
  19756. delayLoadState: number;
  19757. /**
  19758. * Gets the file containing the data to load when running in delay load state
  19759. */
  19760. delayLoadingFile: Nullable<string>;
  19761. /**
  19762. * Callback called when the geometry is updated
  19763. */
  19764. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  19765. private _scene;
  19766. private _engine;
  19767. private _meshes;
  19768. private _totalVertices;
  19769. /** @hidden */
  19770. _indices: IndicesArray;
  19771. /** @hidden */
  19772. _vertexBuffers: {
  19773. [key: string]: VertexBuffer;
  19774. };
  19775. private _isDisposed;
  19776. private _extend;
  19777. private _boundingBias;
  19778. /** @hidden */
  19779. _delayInfo: Array<string>;
  19780. private _indexBuffer;
  19781. private _indexBufferIsUpdatable;
  19782. /** @hidden */
  19783. _boundingInfo: Nullable<BoundingInfo>;
  19784. /** @hidden */
  19785. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  19786. /** @hidden */
  19787. _softwareSkinningRenderId: number;
  19788. private _vertexArrayObjects;
  19789. private _updatable;
  19790. /** @hidden */
  19791. _positions: Nullable<Vector3[]>;
  19792. /**
  19793. * 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
  19794. */
  19795. /**
  19796. * 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
  19797. */
  19798. boundingBias: Vector2;
  19799. /**
  19800. * Static function used to attach a new empty geometry to a mesh
  19801. * @param mesh defines the mesh to attach the geometry to
  19802. * @returns the new {BABYLON.Geometry}
  19803. */
  19804. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  19805. /**
  19806. * Creates a new geometry
  19807. * @param id defines the unique ID
  19808. * @param scene defines the hosting scene
  19809. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  19810. * @param updatable defines if geometry must be updatable (false by default)
  19811. * @param mesh defines the mesh that will be associated with the geometry
  19812. */
  19813. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  19814. /**
  19815. * Gets the current extend of the geometry
  19816. */
  19817. readonly extend: {
  19818. minimum: Vector3;
  19819. maximum: Vector3;
  19820. };
  19821. /**
  19822. * Gets the hosting scene
  19823. * @returns the hosting {BABYLON.Scene}
  19824. */
  19825. getScene(): Scene;
  19826. /**
  19827. * Gets the hosting engine
  19828. * @returns the hosting {BABYLON.Engine}
  19829. */
  19830. getEngine(): Engine;
  19831. /**
  19832. * Defines if the geometry is ready to use
  19833. * @returns true if the geometry is ready to be used
  19834. */
  19835. isReady(): boolean;
  19836. /**
  19837. * Gets a value indicating that the geometry should not be serialized
  19838. */
  19839. readonly doNotSerialize: boolean;
  19840. /** @hidden */
  19841. _rebuild(): void;
  19842. /**
  19843. * Affects all geometry data in one call
  19844. * @param vertexData defines the geometry data
  19845. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  19846. */
  19847. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19848. /**
  19849. * Set specific vertex data
  19850. * @param kind defines the data kind (Position, normal, etc...)
  19851. * @param data defines the vertex data to use
  19852. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  19853. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  19854. */
  19855. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  19856. /**
  19857. * Removes a specific vertex data
  19858. * @param kind defines the data kind (Position, normal, etc...)
  19859. */
  19860. removeVerticesData(kind: string): void;
  19861. /**
  19862. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  19863. * @param buffer defines the vertex buffer to use
  19864. * @param totalVertices defines the total number of vertices for position kind (could be null)
  19865. */
  19866. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  19867. /**
  19868. * Update a specific vertex buffer
  19869. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  19870. * It will do nothing if the buffer is not updatable
  19871. * @param kind defines the data kind (Position, normal, etc...)
  19872. * @param data defines the data to use
  19873. * @param offset defines the offset in the target buffer where to store the data
  19874. * @param useBytes set to true if the offset is in bytes
  19875. */
  19876. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  19877. /**
  19878. * Update a specific vertex buffer
  19879. * This function will create a new buffer if the current one is not updatable
  19880. * @param kind defines the data kind (Position, normal, etc...)
  19881. * @param data defines the data to use
  19882. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  19883. */
  19884. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  19885. private _updateBoundingInfo(updateExtends, data);
  19886. /** @hidden */
  19887. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  19888. /**
  19889. * Gets total number of vertices
  19890. * @returns the total number of vertices
  19891. */
  19892. getTotalVertices(): number;
  19893. /**
  19894. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  19895. * @param kind defines the data kind (Position, normal, etc...)
  19896. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19897. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19898. * @returns a float array containing vertex data
  19899. */
  19900. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19901. /**
  19902. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  19903. * @param kind defines the data kind (Position, normal, etc...)
  19904. * @returns true if the vertex buffer with the specified kind is updatable
  19905. */
  19906. isVertexBufferUpdatable(kind: string): boolean;
  19907. /**
  19908. * Gets a specific vertex buffer
  19909. * @param kind defines the data kind (Position, normal, etc...)
  19910. * @returns a {BABYLON.VertexBuffer}
  19911. */
  19912. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19913. /**
  19914. * Returns all vertex buffers
  19915. * @return an object holding all vertex buffers indexed by kind
  19916. */
  19917. getVertexBuffers(): Nullable<{
  19918. [key: string]: VertexBuffer;
  19919. }>;
  19920. /**
  19921. * Gets a boolean indicating if specific vertex buffer is present
  19922. * @param kind defines the data kind (Position, normal, etc...)
  19923. * @returns true if data is present
  19924. */
  19925. isVerticesDataPresent(kind: string): boolean;
  19926. /**
  19927. * Gets a list of all attached data kinds (Position, normal, etc...)
  19928. * @returns a list of string containing all kinds
  19929. */
  19930. getVerticesDataKinds(): string[];
  19931. /**
  19932. * Update index buffer
  19933. * @param indices defines the indices to store in the index buffer
  19934. * @param offset defines the offset in the target buffer where to store the data
  19935. */
  19936. updateIndices(indices: IndicesArray, offset?: number): void;
  19937. /**
  19938. * Creates a new index buffer
  19939. * @param indices defines the indices to store in the index buffer
  19940. * @param totalVertices defines the total number of vertices (could be null)
  19941. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  19942. */
  19943. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  19944. /**
  19945. * Return the total number of indices
  19946. * @returns the total number of indices
  19947. */
  19948. getTotalIndices(): number;
  19949. /**
  19950. * Gets the index buffer array
  19951. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19952. * @returns the index buffer array
  19953. */
  19954. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  19955. /**
  19956. * Gets the index buffer
  19957. * @return the index buffer
  19958. */
  19959. getIndexBuffer(): Nullable<WebGLBuffer>;
  19960. /** @hidden */
  19961. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  19962. /**
  19963. * Release the associated resources for a specific mesh
  19964. * @param mesh defines the source mesh
  19965. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  19966. */
  19967. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  19968. /**
  19969. * Apply current geometry to a given mesh
  19970. * @param mesh defines the mesh to apply geometry to
  19971. */
  19972. applyToMesh(mesh: Mesh): void;
  19973. private _updateExtend(data?);
  19974. private _applyToMesh(mesh);
  19975. private notifyUpdate(kind?);
  19976. /**
  19977. * Load the geometry if it was flagged as delay loaded
  19978. * @param scene defines the hosting scene
  19979. * @param onLoaded defines a callback called when the geometry is loaded
  19980. */
  19981. load(scene: Scene, onLoaded?: () => void): void;
  19982. private _queueLoad(scene, onLoaded?);
  19983. /**
  19984. * Invert the geometry to move from a right handed system to a left handed one.
  19985. */
  19986. toLeftHanded(): void;
  19987. /** @hidden */
  19988. _resetPointsArrayCache(): void;
  19989. /** @hidden */
  19990. _generatePointsArray(): boolean;
  19991. /**
  19992. * Gets a value indicating if the geometry is disposed
  19993. * @returns true if the geometry was disposed
  19994. */
  19995. isDisposed(): boolean;
  19996. private _disposeVertexArrayObjects();
  19997. /**
  19998. * Free all associated resources
  19999. */
  20000. dispose(): void;
  20001. /**
  20002. * Clone the current geometry into a new geometry
  20003. * @param id defines the unique ID of the new geometry
  20004. * @returns a new geometry object
  20005. */
  20006. copy(id: string): Geometry;
  20007. /**
  20008. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20009. * @return a JSON representation of the current geometry data (without the vertices data)
  20010. */
  20011. serialize(): any;
  20012. private toNumberArray(origin);
  20013. /**
  20014. * Serialize all vertices data into a JSON oject
  20015. * @returns a JSON representation of the current geometry data
  20016. */
  20017. serializeVerticeData(): any;
  20018. /**
  20019. * Extracts a clone of a mesh geometry
  20020. * @param mesh defines the source mesh
  20021. * @param id defines the unique ID of the new geometry object
  20022. * @returns the new geometry object
  20023. */
  20024. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20025. /**
  20026. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20027. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20028. * Be aware Math.random() could cause collisions, but:
  20029. * "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"
  20030. * @returns a string containing a new GUID
  20031. */
  20032. static RandomId(): string;
  20033. /** @hidden */
  20034. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20035. private static _CleanMatricesWeights(parsedGeometry, mesh);
  20036. /**
  20037. * Create a new geometry from persisted data (Using .babylon file format)
  20038. * @param parsedVertexData defines the persisted data
  20039. * @param scene defines the hosting scene
  20040. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20041. * @returns the new geometry object
  20042. */
  20043. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20044. }
  20045. /**
  20046. * Abstract class used to provide common services for all typed geometries
  20047. * @hidden
  20048. */
  20049. class _PrimitiveGeometry extends Geometry {
  20050. private _canBeRegenerated;
  20051. private _beingRegenerated;
  20052. /**
  20053. * Creates a new typed geometry
  20054. * @param id defines the unique ID of the geometry
  20055. * @param scene defines the hosting scene
  20056. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20057. * @param mesh defines the hosting mesh (can be null)
  20058. */
  20059. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20060. /**
  20061. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  20062. * @returns true if the geometry can be regenerated
  20063. */
  20064. canBeRegenerated(): boolean;
  20065. /**
  20066. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  20067. */
  20068. regenerate(): void;
  20069. /**
  20070. * Clone the geometry
  20071. * @param id defines the unique ID of the new geometry
  20072. * @returns the new geometry
  20073. */
  20074. asNewGeometry(id: string): Geometry;
  20075. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20076. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  20077. /** @hidden */
  20078. _regenerateVertexData(): VertexData;
  20079. copy(id: string): Geometry;
  20080. serialize(): any;
  20081. }
  20082. /**
  20083. * Creates a ribbon geometry
  20084. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  20085. */
  20086. class RibbonGeometry extends _PrimitiveGeometry {
  20087. /**
  20088. * Defines the array of paths to use
  20089. */
  20090. pathArray: Vector3[][];
  20091. /**
  20092. * Defines if the last and first points of each path in your pathArray must be joined
  20093. */
  20094. closeArray: boolean;
  20095. /**
  20096. * Defines if the last and first points of each path in your pathArray must be joined
  20097. */
  20098. closePath: boolean;
  20099. /**
  20100. * Defines the offset between points
  20101. */
  20102. offset: number;
  20103. /**
  20104. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20105. */
  20106. side: number;
  20107. /**
  20108. * Creates a ribbon geometry
  20109. * @param id defines the unique ID of the geometry
  20110. * @param scene defines the hosting scene
  20111. * @param pathArray defines the array of paths to use
  20112. * @param closeArray defines if the last path and the first path must be joined
  20113. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  20114. * @param offset defines the offset between points
  20115. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20116. * @param mesh defines the hosting mesh (can be null)
  20117. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20118. */
  20119. constructor(id: string, scene: Scene,
  20120. /**
  20121. * Defines the array of paths to use
  20122. */
  20123. pathArray: Vector3[][],
  20124. /**
  20125. * Defines if the last and first points of each path in your pathArray must be joined
  20126. */
  20127. closeArray: boolean,
  20128. /**
  20129. * Defines if the last and first points of each path in your pathArray must be joined
  20130. */
  20131. closePath: boolean,
  20132. /**
  20133. * Defines the offset between points
  20134. */
  20135. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  20136. /**
  20137. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20138. */
  20139. side?: number);
  20140. /** @hidden */
  20141. _regenerateVertexData(): VertexData;
  20142. copy(id: string): Geometry;
  20143. }
  20144. /**
  20145. * Creates a box geometry
  20146. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  20147. */
  20148. class BoxGeometry extends _PrimitiveGeometry {
  20149. /**
  20150. * Defines the zise of the box (width, height and depth are the same)
  20151. */
  20152. size: number;
  20153. /**
  20154. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20155. */
  20156. side: number;
  20157. /**
  20158. * Creates a box geometry
  20159. * @param id defines the unique ID of the geometry
  20160. * @param scene defines the hosting scene
  20161. * @param size defines the zise of the box (width, height and depth are the same)
  20162. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20163. * @param mesh defines the hosting mesh (can be null)
  20164. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20165. */
  20166. constructor(id: string, scene: Scene,
  20167. /**
  20168. * Defines the zise of the box (width, height and depth are the same)
  20169. */
  20170. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20171. /**
  20172. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20173. */
  20174. side?: number);
  20175. _regenerateVertexData(): VertexData;
  20176. copy(id: string): Geometry;
  20177. serialize(): any;
  20178. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  20179. }
  20180. /**
  20181. * Creates a sphere geometry
  20182. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  20183. */
  20184. class SphereGeometry extends _PrimitiveGeometry {
  20185. /**
  20186. * Defines the number of segments to use to create the sphere
  20187. */
  20188. segments: number;
  20189. /**
  20190. * Defines the diameter of the sphere
  20191. */
  20192. diameter: number;
  20193. /**
  20194. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20195. */
  20196. side: number;
  20197. /**
  20198. * Create a new sphere geometry
  20199. * @param id defines the unique ID of the geometry
  20200. * @param scene defines the hosting scene
  20201. * @param segments defines the number of segments to use to create the sphere
  20202. * @param diameter defines the diameter of the sphere
  20203. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20204. * @param mesh defines the hosting mesh (can be null)
  20205. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20206. */
  20207. constructor(id: string, scene: Scene,
  20208. /**
  20209. * Defines the number of segments to use to create the sphere
  20210. */
  20211. segments: number,
  20212. /**
  20213. * Defines the diameter of the sphere
  20214. */
  20215. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20216. /**
  20217. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20218. */
  20219. side?: number);
  20220. _regenerateVertexData(): VertexData;
  20221. copy(id: string): Geometry;
  20222. serialize(): any;
  20223. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  20224. }
  20225. /**
  20226. * Creates a disc geometry
  20227. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  20228. */
  20229. class DiscGeometry extends _PrimitiveGeometry {
  20230. /**
  20231. * Defines the radius of the disc
  20232. */
  20233. radius: number;
  20234. /**
  20235. * Defines the tesselation factor to apply to the disc
  20236. */
  20237. tessellation: number;
  20238. /**
  20239. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20240. */
  20241. side: number;
  20242. /**
  20243. * Creates a new disc geometry
  20244. * @param id defines the unique ID of the geometry
  20245. * @param scene defines the hosting scene
  20246. * @param radius defines the radius of the disc
  20247. * @param tessellation defines the tesselation factor to apply to the disc
  20248. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20249. * @param mesh defines the hosting mesh (can be null)
  20250. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20251. */
  20252. constructor(id: string, scene: Scene,
  20253. /**
  20254. * Defines the radius of the disc
  20255. */
  20256. radius: number,
  20257. /**
  20258. * Defines the tesselation factor to apply to the disc
  20259. */
  20260. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20261. /**
  20262. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20263. */
  20264. side?: number);
  20265. _regenerateVertexData(): VertexData;
  20266. copy(id: string): Geometry;
  20267. }
  20268. /**
  20269. * Creates a new cylinder geometry
  20270. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  20271. */
  20272. class CylinderGeometry extends _PrimitiveGeometry {
  20273. /**
  20274. * Defines the height of the cylinder
  20275. */
  20276. height: number;
  20277. /**
  20278. * Defines the diameter of the cylinder's top cap
  20279. */
  20280. diameterTop: number;
  20281. /**
  20282. * Defines the diameter of the cylinder's bottom cap
  20283. */
  20284. diameterBottom: number;
  20285. /**
  20286. * Defines the tessellation factor to apply to the cylinder
  20287. */
  20288. tessellation: number;
  20289. /**
  20290. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20291. */
  20292. subdivisions: number;
  20293. /**
  20294. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20295. */
  20296. side: number;
  20297. /**
  20298. * Creates a new cylinder geometry
  20299. * @param id defines the unique ID of the geometry
  20300. * @param scene defines the hosting scene
  20301. * @param height defines the height of the cylinder
  20302. * @param diameterTop defines the diameter of the cylinder's top cap
  20303. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  20304. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  20305. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  20306. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20307. * @param mesh defines the hosting mesh (can be null)
  20308. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20309. */
  20310. constructor(id: string, scene: Scene,
  20311. /**
  20312. * Defines the height of the cylinder
  20313. */
  20314. height: number,
  20315. /**
  20316. * Defines the diameter of the cylinder's top cap
  20317. */
  20318. diameterTop: number,
  20319. /**
  20320. * Defines the diameter of the cylinder's bottom cap
  20321. */
  20322. diameterBottom: number,
  20323. /**
  20324. * Defines the tessellation factor to apply to the cylinder
  20325. */
  20326. tessellation: number,
  20327. /**
  20328. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  20329. */
  20330. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20331. /**
  20332. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20333. */
  20334. side?: number);
  20335. _regenerateVertexData(): VertexData;
  20336. copy(id: string): Geometry;
  20337. serialize(): any;
  20338. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  20339. }
  20340. /**
  20341. * Creates a new torus geometry
  20342. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  20343. */
  20344. class TorusGeometry extends _PrimitiveGeometry {
  20345. /**
  20346. * Defines the diameter of the torus
  20347. */
  20348. diameter: number;
  20349. /**
  20350. * Defines the thickness of the torus (ie. internal diameter)
  20351. */
  20352. thickness: number;
  20353. /**
  20354. * Defines the tesselation factor to apply to the torus
  20355. */
  20356. tessellation: number;
  20357. /**
  20358. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20359. */
  20360. side: number;
  20361. /**
  20362. * Creates a new torus geometry
  20363. * @param id defines the unique ID of the geometry
  20364. * @param scene defines the hosting scene
  20365. * @param diameter defines the diameter of the torus
  20366. * @param thickness defines the thickness of the torus (ie. internal diameter)
  20367. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  20368. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20369. * @param mesh defines the hosting mesh (can be null)
  20370. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20371. */
  20372. constructor(id: string, scene: Scene,
  20373. /**
  20374. * Defines the diameter of the torus
  20375. */
  20376. diameter: number,
  20377. /**
  20378. * Defines the thickness of the torus (ie. internal diameter)
  20379. */
  20380. thickness: number,
  20381. /**
  20382. * Defines the tesselation factor to apply to the torus
  20383. */
  20384. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20385. /**
  20386. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20387. */
  20388. side?: number);
  20389. _regenerateVertexData(): VertexData;
  20390. copy(id: string): Geometry;
  20391. serialize(): any;
  20392. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  20393. }
  20394. /**
  20395. * Creates a new ground geometry
  20396. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  20397. */
  20398. class GroundGeometry extends _PrimitiveGeometry {
  20399. /**
  20400. * Defines the width of the ground
  20401. */
  20402. width: number;
  20403. /**
  20404. * Defines the height of the ground
  20405. */
  20406. height: number;
  20407. /**
  20408. * Defines the subdivisions to apply to the ground
  20409. */
  20410. subdivisions: number;
  20411. /**
  20412. * Creates a new ground geometry
  20413. * @param id defines the unique ID of the geometry
  20414. * @param scene defines the hosting scene
  20415. * @param width defines the width of the ground
  20416. * @param height defines the height of the ground
  20417. * @param subdivisions defines the subdivisions to apply to the ground
  20418. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20419. * @param mesh defines the hosting mesh (can be null)
  20420. */
  20421. constructor(id: string, scene: Scene,
  20422. /**
  20423. * Defines the width of the ground
  20424. */
  20425. width: number,
  20426. /**
  20427. * Defines the height of the ground
  20428. */
  20429. height: number,
  20430. /**
  20431. * Defines the subdivisions to apply to the ground
  20432. */
  20433. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20434. _regenerateVertexData(): VertexData;
  20435. copy(id: string): Geometry;
  20436. serialize(): any;
  20437. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  20438. }
  20439. /**
  20440. * Creates a tiled ground geometry
  20441. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  20442. */
  20443. class TiledGroundGeometry extends _PrimitiveGeometry {
  20444. /**
  20445. * Defines the minimum value on X axis
  20446. */
  20447. xmin: number;
  20448. /**
  20449. * Defines the minimum value on Z axis
  20450. */
  20451. zmin: number;
  20452. /**
  20453. * Defines the maximum value on X axis
  20454. */
  20455. xmax: number;
  20456. /**
  20457. * Defines the maximum value on Z axis
  20458. */
  20459. zmax: number;
  20460. /**
  20461. * Defines the subdivisions to apply to the ground
  20462. */
  20463. subdivisions: {
  20464. w: number;
  20465. h: number;
  20466. };
  20467. /**
  20468. * Defines the precision to use when computing the tiles
  20469. */
  20470. precision: {
  20471. w: number;
  20472. h: number;
  20473. };
  20474. /**
  20475. * Creates a tiled ground geometry
  20476. * @param id defines the unique ID of the geometry
  20477. * @param scene defines the hosting scene
  20478. * @param xmin defines the minimum value on X axis
  20479. * @param zmin defines the minimum value on Z axis
  20480. * @param xmax defines the maximum value on X axis
  20481. * @param zmax defines the maximum value on Z axis
  20482. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  20483. * @param precision defines the precision to use when computing the tiles
  20484. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20485. * @param mesh defines the hosting mesh (can be null)
  20486. */
  20487. constructor(id: string, scene: Scene,
  20488. /**
  20489. * Defines the minimum value on X axis
  20490. */
  20491. xmin: number,
  20492. /**
  20493. * Defines the minimum value on Z axis
  20494. */
  20495. zmin: number,
  20496. /**
  20497. * Defines the maximum value on X axis
  20498. */
  20499. xmax: number,
  20500. /**
  20501. * Defines the maximum value on Z axis
  20502. */
  20503. zmax: number,
  20504. /**
  20505. * Defines the subdivisions to apply to the ground
  20506. */
  20507. subdivisions: {
  20508. w: number;
  20509. h: number;
  20510. },
  20511. /**
  20512. * Defines the precision to use when computing the tiles
  20513. */
  20514. precision: {
  20515. w: number;
  20516. h: number;
  20517. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  20518. _regenerateVertexData(): VertexData;
  20519. copy(id: string): Geometry;
  20520. }
  20521. /**
  20522. * Creates a plane geometry
  20523. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  20524. */
  20525. class PlaneGeometry extends _PrimitiveGeometry {
  20526. /**
  20527. * Defines the size of the plane (width === height)
  20528. */
  20529. size: number;
  20530. /**
  20531. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20532. */
  20533. side: number;
  20534. /**
  20535. * Creates a plane geometry
  20536. * @param id defines the unique ID of the geometry
  20537. * @param scene defines the hosting scene
  20538. * @param size defines the size of the plane (width === height)
  20539. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20540. * @param mesh defines the hosting mesh (can be null)
  20541. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20542. */
  20543. constructor(id: string, scene: Scene,
  20544. /**
  20545. * Defines the size of the plane (width === height)
  20546. */
  20547. size: 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(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  20556. }
  20557. /**
  20558. * Creates a torus knot geometry
  20559. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  20560. */
  20561. class TorusKnotGeometry extends _PrimitiveGeometry {
  20562. /**
  20563. * Defines the radius of the torus knot
  20564. */
  20565. radius: number;
  20566. /**
  20567. * Defines the thickness of the torus knot tube
  20568. */
  20569. tube: number;
  20570. /**
  20571. * Defines the number of radial segments
  20572. */
  20573. radialSegments: number;
  20574. /**
  20575. * Defines the number of tubular segments
  20576. */
  20577. tubularSegments: number;
  20578. /**
  20579. * Defines the first number of windings
  20580. */
  20581. p: number;
  20582. /**
  20583. * Defines the second number of windings
  20584. */
  20585. q: number;
  20586. /**
  20587. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20588. */
  20589. side: number;
  20590. /**
  20591. * Creates a torus knot geometry
  20592. * @param id defines the unique ID of the geometry
  20593. * @param scene defines the hosting scene
  20594. * @param radius defines the radius of the torus knot
  20595. * @param tube defines the thickness of the torus knot tube
  20596. * @param radialSegments defines the number of radial segments
  20597. * @param tubularSegments defines the number of tubular segments
  20598. * @param p defines the first number of windings
  20599. * @param q defines the second number of windings
  20600. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  20601. * @param mesh defines the hosting mesh (can be null)
  20602. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20603. */
  20604. constructor(id: string, scene: Scene,
  20605. /**
  20606. * Defines the radius of the torus knot
  20607. */
  20608. radius: number,
  20609. /**
  20610. * Defines the thickness of the torus knot tube
  20611. */
  20612. tube: number,
  20613. /**
  20614. * Defines the number of radial segments
  20615. */
  20616. radialSegments: number,
  20617. /**
  20618. * Defines the number of tubular segments
  20619. */
  20620. tubularSegments: number,
  20621. /**
  20622. * Defines the first number of windings
  20623. */
  20624. p: number,
  20625. /**
  20626. * Defines the second number of windings
  20627. */
  20628. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20629. /**
  20630. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20631. */
  20632. side?: number);
  20633. _regenerateVertexData(): VertexData;
  20634. copy(id: string): Geometry;
  20635. serialize(): any;
  20636. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  20637. }
  20638. }
  20639. declare module BABYLON {
  20640. class GroundMesh extends Mesh {
  20641. generateOctree: boolean;
  20642. private _heightQuads;
  20643. _subdivisionsX: number;
  20644. _subdivisionsY: number;
  20645. _width: number;
  20646. _height: number;
  20647. _minX: number;
  20648. _maxX: number;
  20649. _minZ: number;
  20650. _maxZ: number;
  20651. constructor(name: string, scene: Scene);
  20652. getClassName(): string;
  20653. readonly subdivisions: number;
  20654. readonly subdivisionsX: number;
  20655. readonly subdivisionsY: number;
  20656. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20657. /**
  20658. * Returns a height (y) value in the Worl system :
  20659. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20660. * Returns the ground y position if (x, z) are outside the ground surface.
  20661. */
  20662. getHeightAtCoordinates(x: number, z: number): number;
  20663. /**
  20664. * Returns a normalized vector (Vector3) orthogonal to the ground
  20665. * at the ground coordinates (x, z) expressed in the World system.
  20666. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20667. */
  20668. getNormalAtCoordinates(x: number, z: number): Vector3;
  20669. /**
  20670. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20671. * at the ground coordinates (x, z) expressed in the World system.
  20672. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20673. * Returns the GroundMesh.
  20674. */
  20675. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20676. /**
  20677. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20678. * if the ground has been updated.
  20679. * This can be used in the render loop.
  20680. * Returns the GroundMesh.
  20681. */
  20682. updateCoordinateHeights(): GroundMesh;
  20683. private _getFacetAt(x, z);
  20684. private _initHeightQuads();
  20685. private _computeHeightQuads();
  20686. serialize(serializationObject: any): void;
  20687. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20688. }
  20689. }
  20690. declare module BABYLON {
  20691. /**
  20692. * Creates an instance based on a source mesh.
  20693. */
  20694. class InstancedMesh extends AbstractMesh {
  20695. private _sourceMesh;
  20696. private _currentLOD;
  20697. constructor(name: string, source: Mesh);
  20698. /**
  20699. * Returns the string "InstancedMesh".
  20700. */
  20701. getClassName(): string;
  20702. readonly receiveShadows: boolean;
  20703. readonly material: Nullable<Material>;
  20704. readonly visibility: number;
  20705. readonly skeleton: Nullable<Skeleton>;
  20706. renderingGroupId: number;
  20707. /**
  20708. * Returns the total number of vertices (integer).
  20709. */
  20710. getTotalVertices(): number;
  20711. readonly sourceMesh: Mesh;
  20712. /**
  20713. * Is this node ready to be used/rendered
  20714. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20715. * @return {boolean} is it ready
  20716. */
  20717. isReady(completeCheck?: boolean): boolean;
  20718. /**
  20719. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  20720. */
  20721. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  20722. /**
  20723. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20724. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20725. * The `data` are either a numeric array either a Float32Array.
  20726. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  20727. * 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).
  20728. * Note that a new underlying VertexBuffer object is created each call.
  20729. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20730. *
  20731. * Possible `kind` values :
  20732. * - BABYLON.VertexBuffer.PositionKind
  20733. * - BABYLON.VertexBuffer.UVKind
  20734. * - BABYLON.VertexBuffer.UV2Kind
  20735. * - BABYLON.VertexBuffer.UV3Kind
  20736. * - BABYLON.VertexBuffer.UV4Kind
  20737. * - BABYLON.VertexBuffer.UV5Kind
  20738. * - BABYLON.VertexBuffer.UV6Kind
  20739. * - BABYLON.VertexBuffer.ColorKind
  20740. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20741. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20742. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20743. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20744. *
  20745. * Returns the Mesh.
  20746. */
  20747. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20748. /**
  20749. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20750. * If the mesh has no geometry, it is simply returned as it is.
  20751. * The `data` are either a numeric array either a Float32Array.
  20752. * No new underlying VertexBuffer object is created.
  20753. * 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.
  20754. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  20755. *
  20756. * Possible `kind` values :
  20757. * - BABYLON.VertexBuffer.PositionKind
  20758. * - BABYLON.VertexBuffer.UVKind
  20759. * - BABYLON.VertexBuffer.UV2Kind
  20760. * - BABYLON.VertexBuffer.UV3Kind
  20761. * - BABYLON.VertexBuffer.UV4Kind
  20762. * - BABYLON.VertexBuffer.UV5Kind
  20763. * - BABYLON.VertexBuffer.UV6Kind
  20764. * - BABYLON.VertexBuffer.ColorKind
  20765. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20766. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20767. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20768. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20769. *
  20770. * Returns the Mesh.
  20771. */
  20772. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20773. /**
  20774. * Sets the mesh indices.
  20775. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  20776. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20777. * This method creates a new index buffer each call.
  20778. * Returns the Mesh.
  20779. */
  20780. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  20781. /**
  20782. * Boolean : True if the mesh owns the requested kind of data.
  20783. */
  20784. isVerticesDataPresent(kind: string): boolean;
  20785. /**
  20786. * Returns an array of indices (IndicesArray).
  20787. */
  20788. getIndices(): Nullable<IndicesArray>;
  20789. readonly _positions: Nullable<Vector3[]>;
  20790. /**
  20791. * Sets a new updated BoundingInfo to the mesh.
  20792. * Returns the mesh.
  20793. */
  20794. refreshBoundingInfo(): InstancedMesh;
  20795. _preActivate(): InstancedMesh;
  20796. _activate(renderId: number): InstancedMesh;
  20797. /**
  20798. * Returns the current associated LOD AbstractMesh.
  20799. */
  20800. getLOD(camera: Camera): AbstractMesh;
  20801. _syncSubMeshes(): InstancedMesh;
  20802. _generatePointsArray(): boolean;
  20803. /**
  20804. * Creates a new InstancedMesh from the current mesh.
  20805. * - name (string) : the cloned mesh name
  20806. * - newParent (optional Node) : the optional Node to parent the clone to.
  20807. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  20808. *
  20809. * Returns the clone.
  20810. */
  20811. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  20812. /**
  20813. * Disposes the InstancedMesh.
  20814. * Returns nothing.
  20815. */
  20816. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20817. }
  20818. }
  20819. declare module BABYLON {
  20820. class LinesMesh extends Mesh {
  20821. useVertexColor: boolean | undefined;
  20822. useVertexAlpha: boolean | undefined;
  20823. color: Color3;
  20824. alpha: number;
  20825. /**
  20826. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20827. * This margin is expressed in world space coordinates, so its value may vary.
  20828. * Default value is 0.1
  20829. * @returns the intersection Threshold value.
  20830. */
  20831. /**
  20832. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20833. * This margin is expressed in world space coordinates, so its value may vary.
  20834. * @param value the new threshold to apply
  20835. */
  20836. intersectionThreshold: number;
  20837. private _intersectionThreshold;
  20838. private _colorShader;
  20839. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  20840. /**
  20841. * Returns the string "LineMesh"
  20842. */
  20843. getClassName(): string;
  20844. /**
  20845. * @hidden
  20846. */
  20847. /**
  20848. * @hidden
  20849. */
  20850. material: Material;
  20851. /**
  20852. * @hidden
  20853. */
  20854. readonly checkCollisions: boolean;
  20855. createInstance(name: string): InstancedMesh;
  20856. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  20857. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  20858. dispose(doNotRecurse?: boolean): void;
  20859. /**
  20860. * Returns a new LineMesh object cloned from the current one.
  20861. */
  20862. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  20863. }
  20864. }
  20865. declare module BABYLON {
  20866. /**
  20867. * @hidden
  20868. **/
  20869. class _InstancesBatch {
  20870. mustReturn: boolean;
  20871. visibleInstances: Nullable<InstancedMesh[]>[];
  20872. renderSelf: boolean[];
  20873. }
  20874. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20875. static _FRONTSIDE: number;
  20876. static _BACKSIDE: number;
  20877. static _DOUBLESIDE: number;
  20878. static _DEFAULTSIDE: number;
  20879. static _NO_CAP: number;
  20880. static _CAP_START: number;
  20881. static _CAP_END: number;
  20882. static _CAP_ALL: number;
  20883. /**
  20884. * Mesh side orientation : usually the external or front surface
  20885. */
  20886. static readonly FRONTSIDE: number;
  20887. /**
  20888. * Mesh side orientation : usually the internal or back surface
  20889. */
  20890. static readonly BACKSIDE: number;
  20891. /**
  20892. * Mesh side orientation : both internal and external or front and back surfaces
  20893. */
  20894. static readonly DOUBLESIDE: number;
  20895. /**
  20896. * Mesh side orientation : by default, `FRONTSIDE`
  20897. */
  20898. static readonly DEFAULTSIDE: number;
  20899. /**
  20900. * Mesh cap setting : no cap
  20901. */
  20902. static readonly NO_CAP: number;
  20903. /**
  20904. * Mesh cap setting : one cap at the beginning of the mesh
  20905. */
  20906. static readonly CAP_START: number;
  20907. /**
  20908. * Mesh cap setting : one cap at the end of the mesh
  20909. */
  20910. static readonly CAP_END: number;
  20911. /**
  20912. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20913. */
  20914. static readonly CAP_ALL: number;
  20915. private _onBeforeRenderObservable;
  20916. private _onAfterRenderObservable;
  20917. private _onBeforeDrawObservable;
  20918. /**
  20919. * An event triggered before rendering the mesh
  20920. */
  20921. readonly onBeforeRenderObservable: Observable<Mesh>;
  20922. /**
  20923. * An event triggered after rendering the mesh
  20924. */
  20925. readonly onAfterRenderObservable: Observable<Mesh>;
  20926. /**
  20927. * An event triggered before drawing the mesh
  20928. */
  20929. readonly onBeforeDrawObservable: Observable<Mesh>;
  20930. private _onBeforeDrawObserver;
  20931. onBeforeDraw: () => void;
  20932. delayLoadState: number;
  20933. instances: InstancedMesh[];
  20934. delayLoadingFile: string;
  20935. _binaryInfo: any;
  20936. private _LODLevels;
  20937. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20938. private _morphTargetManager;
  20939. morphTargetManager: Nullable<MorphTargetManager>;
  20940. _geometry: Nullable<Geometry>;
  20941. _delayInfo: Array<string>;
  20942. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20943. _visibleInstances: any;
  20944. private _renderIdForInstances;
  20945. private _batchCache;
  20946. private _instancesBufferSize;
  20947. private _instancesBuffer;
  20948. private _instancesData;
  20949. private _overridenInstanceCount;
  20950. private _effectiveMaterial;
  20951. _shouldGenerateFlatShading: boolean;
  20952. private _preActivateId;
  20953. _originalBuilderSideOrientation: number;
  20954. overrideMaterialSideOrientation: Nullable<number>;
  20955. private _areNormalsFrozen;
  20956. private _sourcePositions;
  20957. private _sourceNormals;
  20958. private _source;
  20959. readonly source: Nullable<Mesh>;
  20960. isUnIndexed: boolean;
  20961. /**
  20962. * @constructor
  20963. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  20964. * @param {Scene} scene The scene to add this mesh to.
  20965. * @param {Node} parent The parent of this mesh, if it has one
  20966. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  20967. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20968. * When false, achieved by calling a clone(), also passing False.
  20969. * This will make creation of children, recursive.
  20970. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20971. */
  20972. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20973. /**
  20974. * Returns the string "Mesh".
  20975. */
  20976. getClassName(): string;
  20977. /**
  20978. * Returns a string.
  20979. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  20980. */
  20981. toString(fullDetails?: boolean): string;
  20982. _unBindEffect(): void;
  20983. /**
  20984. * True if the mesh has some Levels Of Details (LOD).
  20985. * Returns a boolean.
  20986. */
  20987. readonly hasLODLevels: boolean;
  20988. /**
  20989. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  20990. * @returns an array of {BABYLON.MeshLODLevel}
  20991. */
  20992. getLODLevels(): MeshLODLevel[];
  20993. private _sortLODLevels();
  20994. /**
  20995. * Add a mesh as LOD level triggered at the given distance.
  20996. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20997. * @param distance The distance from the center of the object to show this level
  20998. * @param mesh The mesh to be added as LOD level (can be null)
  20999. * @return This mesh (for chaining)
  21000. */
  21001. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21002. /**
  21003. * Returns the LOD level mesh at the passed distance or null if not found.
  21004. * It is related to the method `addLODLevel(distance, mesh)`.
  21005. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21006. * Returns an object Mesh or `null`.
  21007. */
  21008. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21009. /**
  21010. * Remove a mesh from the LOD array
  21011. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  21012. * @param {Mesh} mesh The mesh to be removed.
  21013. * @return {Mesh} This mesh (for chaining)
  21014. */
  21015. removeLODLevel(mesh: Mesh): Mesh;
  21016. /**
  21017. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21018. * tuto : http://doc.babylonjs.com/how_to/how_to_use_lod
  21019. */
  21020. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21021. /**
  21022. * Returns the mesh internal Geometry object.
  21023. */
  21024. readonly geometry: Nullable<Geometry>;
  21025. /**
  21026. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21027. */
  21028. getTotalVertices(): number;
  21029. /**
  21030. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  21031. * 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.
  21032. * You can force the copy with forceCopy === true
  21033. * Returns null if the mesh has no geometry or no vertex buffer.
  21034. * Possible `kind` values :
  21035. * - BABYLON.VertexBuffer.PositionKind
  21036. * - BABYLON.VertexBuffer.UVKind
  21037. * - BABYLON.VertexBuffer.UV2Kind
  21038. * - BABYLON.VertexBuffer.UV3Kind
  21039. * - BABYLON.VertexBuffer.UV4Kind
  21040. * - BABYLON.VertexBuffer.UV5Kind
  21041. * - BABYLON.VertexBuffer.UV6Kind
  21042. * - BABYLON.VertexBuffer.ColorKind
  21043. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21044. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21045. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21046. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21047. */
  21048. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21049. /**
  21050. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  21051. * Returns `null` if the mesh has no geometry.
  21052. * Possible `kind` values :
  21053. * - BABYLON.VertexBuffer.PositionKind
  21054. * - BABYLON.VertexBuffer.UVKind
  21055. * - BABYLON.VertexBuffer.UV2Kind
  21056. * - BABYLON.VertexBuffer.UV3Kind
  21057. * - BABYLON.VertexBuffer.UV4Kind
  21058. * - BABYLON.VertexBuffer.UV5Kind
  21059. * - BABYLON.VertexBuffer.UV6Kind
  21060. * - BABYLON.VertexBuffer.ColorKind
  21061. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21062. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21063. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21064. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21065. */
  21066. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21067. isVerticesDataPresent(kind: string): boolean;
  21068. /**
  21069. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21070. * Possible `kind` values :
  21071. * - BABYLON.VertexBuffer.PositionKind
  21072. * - BABYLON.VertexBuffer.UVKind
  21073. * - BABYLON.VertexBuffer.UV2Kind
  21074. * - BABYLON.VertexBuffer.UV3Kind
  21075. * - BABYLON.VertexBuffer.UV4Kind
  21076. * - BABYLON.VertexBuffer.UV5Kind
  21077. * - BABYLON.VertexBuffer.UV6Kind
  21078. * - BABYLON.VertexBuffer.ColorKind
  21079. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21080. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21081. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21082. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21083. */
  21084. isVertexBufferUpdatable(kind: string): boolean;
  21085. /**
  21086. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  21087. * Possible `kind` values :
  21088. * - BABYLON.VertexBuffer.PositionKind
  21089. * - BABYLON.VertexBuffer.UVKind
  21090. * - BABYLON.VertexBuffer.UV2Kind
  21091. * - BABYLON.VertexBuffer.UV3Kind
  21092. * - BABYLON.VertexBuffer.UV4Kind
  21093. * - BABYLON.VertexBuffer.UV5Kind
  21094. * - BABYLON.VertexBuffer.UV6Kind
  21095. * - BABYLON.VertexBuffer.ColorKind
  21096. * - BABYLON.VertexBuffer.MatricesIndicesKind
  21097. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  21098. * - BABYLON.VertexBuffer.MatricesWeightsKind
  21099. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  21100. */
  21101. getVerticesDataKinds(): string[];
  21102. /**
  21103. * Returns a positive integer : the total number of indices in this mesh geometry.
  21104. * Returns zero if the mesh has no geometry.
  21105. */
  21106. getTotalIndices(): number;
  21107. /**
  21108. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21109. * 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.
  21110. * Returns an empty array if the mesh has no geometry.
  21111. */
  21112. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21113. readonly isBlocked: boolean;
  21114. /**
  21115. * Determine if the current mesh is ready to be rendered
  21116. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21117. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21118. * @returns true if all associated assets are ready (material, textures, shaders)
  21119. */
  21120. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21121. /**
  21122. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  21123. * This property is pertinent only for updatable parametric shapes.
  21124. */
  21125. readonly areNormalsFrozen: boolean;
  21126. /**
  21127. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21128. * It has no effect at all on other shapes.
  21129. * It prevents the mesh normals from being recomputed on next `positions` array update.
  21130. * Returns the Mesh.
  21131. */
  21132. freezeNormals(): Mesh;
  21133. /**
  21134. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  21135. * It has no effect at all on other shapes.
  21136. * It reactivates the mesh normals computation if it was previously frozen.
  21137. * Returns the Mesh.
  21138. */
  21139. unfreezeNormals(): Mesh;
  21140. /**
  21141. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21142. */
  21143. overridenInstanceCount: number;
  21144. _preActivate(): Mesh;
  21145. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21146. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21147. /**
  21148. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21149. * This means the mesh underlying bounding box and sphere are recomputed.
  21150. * Returns the Mesh.
  21151. */
  21152. refreshBoundingInfo(): Mesh;
  21153. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  21154. private _getPositionData(applySkeleton);
  21155. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21156. subdivide(count: number): void;
  21157. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21158. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21159. /**
  21160. * Sets the mesh VertexBuffer.
  21161. * Returns the Mesh.
  21162. */
  21163. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21164. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21165. /**
  21166. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21167. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21168. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  21169. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  21170. * Returns the Mesh.
  21171. */
  21172. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21173. /**
  21174. * Creates a un-shared specific occurence of the geometry for the mesh.
  21175. * Returns the Mesh.
  21176. */
  21177. makeGeometryUnique(): Mesh;
  21178. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21179. /**
  21180. * Update the current index buffer
  21181. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  21182. * Returns the Mesh.
  21183. */
  21184. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  21185. /**
  21186. * Invert the geometry to move from a right handed system to a left handed one.
  21187. * Returns the Mesh.
  21188. */
  21189. toLeftHanded(): Mesh;
  21190. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21191. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  21192. /**
  21193. * Registers for this mesh a javascript function called just before the rendering process.
  21194. * This function is passed the current mesh.
  21195. * Return the Mesh.
  21196. */
  21197. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21198. /**
  21199. * Disposes a previously registered javascript function called before the rendering.
  21200. * This function is passed the current mesh.
  21201. * Returns the Mesh.
  21202. */
  21203. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21204. /**
  21205. * Registers for this mesh a javascript function called just after the rendering is complete.
  21206. * This function is passed the current mesh.
  21207. * Returns the Mesh.
  21208. */
  21209. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21210. /**
  21211. * Disposes a previously registered javascript function called after the rendering.
  21212. * This function is passed the current mesh.
  21213. * Return the Mesh.
  21214. */
  21215. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21216. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21217. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21218. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21219. /**
  21220. * 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
  21221. * @param subMesh defines the subMesh to render
  21222. * @param enableAlphaMode defines if alpha mode can be changed
  21223. * @returns the current mesh
  21224. */
  21225. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21226. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  21227. /**
  21228. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter.
  21229. */
  21230. getEmittedParticleSystems(): IParticleSystem[];
  21231. /**
  21232. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter.
  21233. */
  21234. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  21235. /**
  21236. * Normalize matrix weights so that all vertices have a total weight set to 1
  21237. */
  21238. cleanMatrixWeights(): void;
  21239. _checkDelayState(): Mesh;
  21240. private _queueLoad(scene);
  21241. /**
  21242. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  21243. */
  21244. isInFrustum(frustumPlanes: Plane[]): boolean;
  21245. /**
  21246. * Sets the mesh material by the material or multiMaterial `id` property.
  21247. * The material `id` is a string identifying the material or the multiMaterial.
  21248. * This method returns the Mesh.
  21249. */
  21250. setMaterialByID(id: string): Mesh;
  21251. /**
  21252. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21253. */
  21254. getAnimatables(): IAnimatable[];
  21255. /**
  21256. * Modifies the mesh geometry according to the passed transformation matrix.
  21257. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21258. * The mesh normals are modified accordingly the same transformation.
  21259. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  21260. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21261. * Returns the Mesh.
  21262. */
  21263. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21264. /**
  21265. * Modifies the mesh geometry according to its own current World Matrix.
  21266. * The mesh World Matrix is then reset.
  21267. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21268. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  21269. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21270. * Returns the Mesh.
  21271. */
  21272. bakeCurrentTransformIntoVertices(): Mesh;
  21273. readonly _positions: Nullable<Vector3[]>;
  21274. _resetPointsArrayCache(): Mesh;
  21275. _generatePointsArray(): boolean;
  21276. /**
  21277. * Returns a new Mesh object generated from the current mesh properties.
  21278. * This method must not get confused with createInstance().
  21279. * The parameter `name` is a string, the name given to the new mesh.
  21280. * The optional parameter `newParent` can be any Node object (default `null`).
  21281. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  21282. * 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.
  21283. */
  21284. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21285. /**
  21286. * Releases resources associated with this mesh.
  21287. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21288. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21289. */
  21290. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21291. /**
  21292. * Modifies the mesh geometry according to a displacement map.
  21293. * 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.
  21294. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21295. * This method returns nothing.
  21296. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  21297. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21298. * 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.
  21299. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21300. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21301. *
  21302. * Returns the Mesh.
  21303. */
  21304. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21305. /**
  21306. * Modifies the mesh geometry according to a displacementMap buffer.
  21307. * 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.
  21308. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21309. * This method returns nothing.
  21310. * 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.
  21311. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  21312. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  21313. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  21314. * The parameter `uvScale` is an optional vector2 used to scale UV.
  21315. *
  21316. * Returns the Mesh.
  21317. */
  21318. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  21319. /**
  21320. * Modify the mesh to get a flat shading rendering.
  21321. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21322. * This method returns the Mesh.
  21323. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21324. */
  21325. convertToFlatShadedMesh(): Mesh;
  21326. /**
  21327. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21328. * In other words, more vertices, no more indices and a single bigger VBO.
  21329. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21330. * Returns the Mesh.
  21331. */
  21332. convertToUnIndexedMesh(): Mesh;
  21333. /**
  21334. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  21335. * This method returns the Mesh.
  21336. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21337. */
  21338. flipFaces(flipNormals?: boolean): Mesh;
  21339. /**
  21340. * Creates a new InstancedMesh object from the mesh model.
  21341. * An instance shares the same properties and the same material than its model.
  21342. * Only these properties of each instance can then be set individually :
  21343. * - position
  21344. * - rotation
  21345. * - rotationQuaternion
  21346. * - setPivotMatrix
  21347. * - scaling
  21348. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  21349. * Warning : this method is not supported for Line mesh and LineSystem
  21350. */
  21351. createInstance(name: string): InstancedMesh;
  21352. /**
  21353. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21354. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21355. * This method returns the Mesh.
  21356. */
  21357. synchronizeInstances(): Mesh;
  21358. /**
  21359. * Simplify the mesh according to the given array of settings.
  21360. * Function will return immediately and will simplify async. It returns the Mesh.
  21361. * @param settings a collection of simplification settings.
  21362. * @param parallelProcessing should all levels calculate parallel or one after the other.
  21363. * @param type the type of simplification to run.
  21364. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  21365. */
  21366. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  21367. /**
  21368. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21369. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21370. * This should be used together with the simplification to avoid disappearing triangles.
  21371. * Returns the Mesh.
  21372. * @param successCallback an optional success callback to be called after the optimization finished.
  21373. */
  21374. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21375. serialize(serializationObject: any): void;
  21376. _syncGeometryWithMorphTargetManager(): void;
  21377. /**
  21378. * Returns a new Mesh object parsed from the source provided.
  21379. * The parameter `parsedMesh` is the source.
  21380. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  21381. */
  21382. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21383. /**
  21384. * Creates a ribbon mesh.
  21385. * Please consider using the same method from the MeshBuilder class instead.
  21386. * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21387. *
  21388. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21389. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21390. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  21391. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  21392. * 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.
  21393. * 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.
  21394. * 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
  21395. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21396. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21397. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21398. */
  21399. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21400. /**
  21401. * Creates a plane polygonal mesh. By default, this is a disc.
  21402. * Please consider using the same method from the MeshBuilder class instead.
  21403. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  21404. * 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.
  21405. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21406. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21407. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21408. */
  21409. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21410. /**
  21411. * Creates a box mesh.
  21412. * Please consider using the same method from the MeshBuilder class instead.
  21413. * The parameter `size` sets the size (float) of each box side (default 1).
  21414. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21415. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21416. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21417. */
  21418. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21419. /**
  21420. * Creates a sphere mesh.
  21421. * Please consider using the same method from the MeshBuilder class instead.
  21422. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  21423. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  21424. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21425. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21426. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21427. */
  21428. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21429. /**
  21430. * Creates a cylinder or a cone mesh.
  21431. * Please consider using the same method from the MeshBuilder class instead.
  21432. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21433. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21434. * 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.
  21435. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21436. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21437. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21438. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21439. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21440. */
  21441. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21442. /**
  21443. * Creates a torus mesh.
  21444. * Please consider using the same method from the MeshBuilder class instead.
  21445. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  21446. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  21447. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  21448. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21449. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21450. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21451. */
  21452. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21453. /**
  21454. * Creates a torus knot mesh.
  21455. * Please consider using the same method from the MeshBuilder class instead.
  21456. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  21457. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  21458. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  21459. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  21460. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21461. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21462. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21463. */
  21464. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21465. /**
  21466. * Creates a line mesh.
  21467. * Please consider using the same method from the MeshBuilder class instead.
  21468. * 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.
  21469. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21470. * The parameter `points` is an array successive Vector3.
  21471. * 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
  21472. * When updating an instance, remember that only point positions can change, not the number of points.
  21473. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21474. */
  21475. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21476. /**
  21477. * Creates a dashed line mesh.
  21478. * Please consider using the same method from the MeshBuilder class instead.
  21479. * 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.
  21480. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  21481. * The parameter `points` is an array successive Vector3.
  21482. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  21483. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  21484. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  21485. * 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
  21486. * When updating an instance, remember that only point positions can change, not the number of points.
  21487. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21488. */
  21489. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21490. /**
  21491. * Creates a polygon mesh.
  21492. * Please consider using the same method from the MeshBuilder class instead.
  21493. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21494. * 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.
  21495. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21496. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21497. * Remember you can only change the shape positions, not their number when updating a polygon.
  21498. */
  21499. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21500. /**
  21501. * Creates an extruded polygon mesh, with depth in the Y direction.
  21502. * Please consider using the same method from the MeshBuilder class instead.
  21503. */
  21504. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  21505. /**
  21506. * Creates an extruded shape mesh.
  21507. * The extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21508. * Please consider using the same method from the MeshBuilder class instead.
  21509. *
  21510. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21511. * 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
  21512. * extruded along the Z axis.
  21513. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21514. * 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.
  21515. * The parameter `scale` (float, default 1) is the value to scale the shape.
  21516. * 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
  21517. * 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
  21518. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21519. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21520. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21521. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21522. */
  21523. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21524. /**
  21525. * Creates an custom extruded shape mesh.
  21526. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21527. * Please consider using the same method from the MeshBuilder class instead.
  21528. *
  21529. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21530. * 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
  21531. * extruded along the Z axis.
  21532. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21533. * 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
  21534. * and the distance of this point from the begining of the path :
  21535. * ```javascript
  21536. * var rotationFunction = function(i, distance) {
  21537. * // do things
  21538. * return rotationValue; }
  21539. * ```
  21540. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  21541. * 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
  21542. * and the distance of this point from the begining of the path :
  21543. * ```javascript
  21544. * var scaleFunction = function(i, distance) {
  21545. * // do things
  21546. * return scaleValue;}
  21547. * ```
  21548. * It must returns a float value that will be the scale value applied to the shape on each path point.
  21549. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  21550. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  21551. * 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
  21552. * 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
  21553. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21554. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21555. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21556. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21557. */
  21558. 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;
  21559. /**
  21560. * Creates lathe mesh.
  21561. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21562. * Please consider using the same method from the MeshBuilder class instead.
  21563. * 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
  21564. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  21565. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  21566. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  21567. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21568. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21569. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21570. */
  21571. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21572. /**
  21573. * Creates a plane mesh.
  21574. * Please consider using the same method from the MeshBuilder class instead.
  21575. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  21576. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21577. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21578. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21579. */
  21580. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21581. /**
  21582. * Creates a ground mesh.
  21583. * Please consider using the same method from the MeshBuilder class instead.
  21584. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  21585. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  21586. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21587. */
  21588. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21589. /**
  21590. * Creates a tiled ground mesh.
  21591. * Please consider using the same method from the MeshBuilder class instead.
  21592. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  21593. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  21594. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  21595. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  21596. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  21597. * numbers of subdivisions on the ground width and height of each tile.
  21598. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21599. */
  21600. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21601. w: number;
  21602. h: number;
  21603. }, precision: {
  21604. w: number;
  21605. h: number;
  21606. }, scene: Scene, updatable?: boolean): Mesh;
  21607. /**
  21608. * Creates a ground mesh from a height map.
  21609. * tuto : http://doc.babylonjs.com/babylon101/height_map
  21610. * Please consider using the same method from the MeshBuilder class instead.
  21611. * The parameter `url` sets the URL of the height map image resource.
  21612. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  21613. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  21614. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  21615. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  21616. * 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).
  21617. * This function is passed the newly built mesh :
  21618. * ```javascript
  21619. * function(mesh) { // do things
  21620. * return; }
  21621. * ```
  21622. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21623. */
  21624. 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;
  21625. /**
  21626. * Creates a tube mesh.
  21627. * The tube is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  21628. * Please consider using the same method from the MeshBuilder class instead.
  21629. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  21630. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  21631. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  21632. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  21633. * 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.
  21634. * It must return a radius value (positive float) :
  21635. * ```javascript
  21636. * var radiusFunction = function(i, distance) {
  21637. * // do things
  21638. * return radius; }
  21639. * ```
  21640. * 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
  21641. * 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
  21642. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21643. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21644. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21645. */
  21646. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21647. (i: number, distance: number): number;
  21648. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21649. /**
  21650. * Creates a polyhedron mesh.
  21651. * Please consider using the same method from the MeshBuilder class instead.
  21652. * 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
  21653. * to choose the wanted type.
  21654. * The parameter `size` (positive float, default 1) sets the polygon size.
  21655. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  21656. * 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`.
  21657. * 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
  21658. * 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)`).
  21659. * 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
  21660. * 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.
  21661. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21662. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21663. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21664. */
  21665. static CreatePolyhedron(name: string, options: {
  21666. type?: number;
  21667. size?: number;
  21668. sizeX?: number;
  21669. sizeY?: number;
  21670. sizeZ?: number;
  21671. custom?: any;
  21672. faceUV?: Vector4[];
  21673. faceColors?: Color4[];
  21674. updatable?: boolean;
  21675. sideOrientation?: number;
  21676. }, scene: Scene): Mesh;
  21677. /**
  21678. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  21679. * Please consider using the same method from the MeshBuilder class instead.
  21680. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  21681. * 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`).
  21682. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  21683. * 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.
  21684. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21685. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21686. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21687. */
  21688. static CreateIcoSphere(name: string, options: {
  21689. radius?: number;
  21690. flat?: boolean;
  21691. subdivisions?: number;
  21692. sideOrientation?: number;
  21693. updatable?: boolean;
  21694. }, scene: Scene): Mesh;
  21695. /**
  21696. * Creates a decal mesh.
  21697. * Please consider using the same method from the MeshBuilder class instead.
  21698. * 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.
  21699. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  21700. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  21701. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  21702. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  21703. */
  21704. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21705. /**
  21706. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21707. */
  21708. setPositionsForCPUSkinning(): Float32Array;
  21709. /**
  21710. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21711. */
  21712. setNormalsForCPUSkinning(): Float32Array;
  21713. /**
  21714. * Updates the vertex buffer by applying transformation from the bones.
  21715. * Returns the Mesh.
  21716. *
  21717. * @param {skeleton} skeleton to apply
  21718. */
  21719. applySkeleton(skeleton: Skeleton): Mesh;
  21720. /**
  21721. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  21722. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  21723. */
  21724. static MinMax(meshes: AbstractMesh[]): {
  21725. min: Vector3;
  21726. max: Vector3;
  21727. };
  21728. /**
  21729. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  21730. */
  21731. static Center(meshesOrMinMaxVector: {
  21732. min: Vector3;
  21733. max: Vector3;
  21734. } | AbstractMesh[]): Vector3;
  21735. /**
  21736. * Merge the array of meshes into a single mesh for performance reasons.
  21737. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  21738. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  21739. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  21740. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21741. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  21742. */
  21743. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  21744. }
  21745. }
  21746. declare module BABYLON {
  21747. /**
  21748. * Define an interface for all classes that will get and set the data on vertices
  21749. */
  21750. interface IGetSetVerticesData {
  21751. isVerticesDataPresent(kind: string): boolean;
  21752. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21753. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21754. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21755. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21756. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21757. }
  21758. /**
  21759. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21760. */
  21761. class VertexData {
  21762. /**
  21763. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21764. */
  21765. positions: Nullable<FloatArray>;
  21766. /**
  21767. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21768. */
  21769. normals: Nullable<FloatArray>;
  21770. /**
  21771. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21772. */
  21773. tangents: Nullable<FloatArray>;
  21774. /**
  21775. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21776. */
  21777. uvs: Nullable<FloatArray>;
  21778. /**
  21779. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21780. */
  21781. uvs2: Nullable<FloatArray>;
  21782. /**
  21783. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21784. */
  21785. uvs3: Nullable<FloatArray>;
  21786. /**
  21787. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21788. */
  21789. uvs4: Nullable<FloatArray>;
  21790. /**
  21791. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21792. */
  21793. uvs5: Nullable<FloatArray>;
  21794. /**
  21795. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21796. */
  21797. uvs6: Nullable<FloatArray>;
  21798. /**
  21799. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21800. */
  21801. colors: Nullable<FloatArray>;
  21802. /**
  21803. * 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).
  21804. */
  21805. matricesIndices: Nullable<FloatArray>;
  21806. /**
  21807. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21808. */
  21809. matricesWeights: Nullable<FloatArray>;
  21810. /**
  21811. * An array extending the number of possible indices
  21812. */
  21813. matricesIndicesExtra: Nullable<FloatArray>;
  21814. /**
  21815. * An array extending the number of possible weights when the number of indices is extended
  21816. */
  21817. matricesWeightsExtra: Nullable<FloatArray>;
  21818. /**
  21819. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21820. */
  21821. indices: Nullable<IndicesArray>;
  21822. /**
  21823. * Uses the passed data array to set the set the values for the specified kind of data
  21824. * @param data a linear array of floating numbers
  21825. * @param kind the type of data that is being set, eg positions, colors etc
  21826. */
  21827. set(data: FloatArray, kind: string): void;
  21828. /**
  21829. * Associates the vertexData to the passed Mesh.
  21830. * Sets it as updatable or not (default `false`)
  21831. * @param mesh the mesh the vertexData is applied to
  21832. * @param updatable when used and having the value true allows new data to update the vertexData
  21833. * @returns the VertexData
  21834. */
  21835. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21836. /**
  21837. * Associates the vertexData to the passed Geometry.
  21838. * Sets it as updatable or not (default `false`)
  21839. * @param geometry the geometry the vertexData is applied to
  21840. * @param updatable when used and having the value true allows new data to update the vertexData
  21841. * @returns VertexData
  21842. */
  21843. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21844. /**
  21845. * Updates the associated mesh
  21846. * @param mesh the mesh to be updated
  21847. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21848. * @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
  21849. * @returns VertexData
  21850. */
  21851. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21852. /**
  21853. * Updates the associated geometry
  21854. * @param geometry the geometry to be updated
  21855. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21856. * @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
  21857. * @returns VertexData.
  21858. */
  21859. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21860. private _applyTo(meshOrGeometry, updatable?);
  21861. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  21862. /**
  21863. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21864. * @param matrix the transforming matrix
  21865. * @returns the VertexData
  21866. */
  21867. transform(matrix: Matrix): VertexData;
  21868. /**
  21869. * Merges the passed VertexData into the current one
  21870. * @param other the VertexData to be merged into the current one
  21871. * @returns the modified VertexData
  21872. */
  21873. merge(other: VertexData): VertexData;
  21874. private _mergeElement(source, other);
  21875. private _validate();
  21876. /**
  21877. * Serializes the VertexData
  21878. * @returns a serialized object
  21879. */
  21880. serialize(): any;
  21881. /**
  21882. * Extracts the vertexData from a mesh
  21883. * @param mesh the mesh from which to extract the VertexData
  21884. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21885. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21886. * @returns the object VertexData associated to the passed mesh
  21887. */
  21888. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21889. /**
  21890. * Extracts the vertexData from the geometry
  21891. * @param geometry the geometry from which to extract the VertexData
  21892. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21893. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21894. * @returns the object VertexData associated to the passed mesh
  21895. */
  21896. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21897. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  21898. /**
  21899. * Creates the VertexData for a Ribbon
  21900. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21901. * * pathArray array of paths, each of which an array of successive Vector3
  21902. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21903. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21904. * * 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
  21905. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21906. * * 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)
  21907. * * 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)
  21908. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21909. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21910. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21911. * @returns the VertexData of the ribbon
  21912. */
  21913. static CreateRibbon(options: {
  21914. pathArray: Vector3[][];
  21915. closeArray?: boolean;
  21916. closePath?: boolean;
  21917. offset?: number;
  21918. sideOrientation?: number;
  21919. frontUVs?: Vector4;
  21920. backUVs?: Vector4;
  21921. invertUV?: boolean;
  21922. uvs?: Vector2[];
  21923. colors?: Color4[];
  21924. }): VertexData;
  21925. /**
  21926. * Creates the VertexData for a box
  21927. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21928. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21929. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21930. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21931. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21932. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21933. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21934. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21935. * * 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)
  21936. * * 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)
  21937. * @returns the VertexData of the box
  21938. */
  21939. static CreateBox(options: {
  21940. size?: number;
  21941. width?: number;
  21942. height?: number;
  21943. depth?: number;
  21944. faceUV?: Vector4[];
  21945. faceColors?: Color4[];
  21946. sideOrientation?: number;
  21947. frontUVs?: Vector4;
  21948. backUVs?: Vector4;
  21949. }): VertexData;
  21950. /**
  21951. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21952. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21953. * * segments sets the number of horizontal strips optional, default 32
  21954. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21955. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21956. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21957. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21958. * * 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
  21959. * * 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
  21960. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21961. * * 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)
  21962. * * 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)
  21963. * @returns the VertexData of the ellipsoid
  21964. */
  21965. static CreateSphere(options: {
  21966. segments?: number;
  21967. diameter?: number;
  21968. diameterX?: number;
  21969. diameterY?: number;
  21970. diameterZ?: number;
  21971. arc?: number;
  21972. slice?: number;
  21973. sideOrientation?: number;
  21974. frontUVs?: Vector4;
  21975. backUVs?: Vector4;
  21976. }): VertexData;
  21977. /**
  21978. * Creates the VertexData for a cylinder, cone or prism
  21979. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21980. * * height sets the height (y direction) of the cylinder, optional, default 2
  21981. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21982. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21983. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21984. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21985. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21986. * * 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
  21987. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21988. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21989. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21990. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21991. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21992. * * 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)
  21993. * * 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)
  21994. * @returns the VertexData of the cylinder, cone or prism
  21995. */
  21996. static CreateCylinder(options: {
  21997. height?: number;
  21998. diameterTop?: number;
  21999. diameterBottom?: number;
  22000. diameter?: number;
  22001. tessellation?: number;
  22002. subdivisions?: number;
  22003. arc?: number;
  22004. faceColors?: Color4[];
  22005. faceUV?: Vector4[];
  22006. hasRings?: boolean;
  22007. enclose?: boolean;
  22008. sideOrientation?: number;
  22009. frontUVs?: Vector4;
  22010. backUVs?: Vector4;
  22011. }): VertexData;
  22012. /**
  22013. * Creates the VertexData for a torus
  22014. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22015. * * diameter the diameter of the torus, optional default 1
  22016. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22017. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22018. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22019. * * 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)
  22020. * * 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)
  22021. * @returns the VertexData of the torus
  22022. */
  22023. static CreateTorus(options: {
  22024. diameter?: number;
  22025. thickness?: number;
  22026. tessellation?: number;
  22027. sideOrientation?: number;
  22028. frontUVs?: Vector4;
  22029. backUVs?: Vector4;
  22030. }): VertexData;
  22031. /**
  22032. * Creates the VertexData of the LineSystem
  22033. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22034. * - lines an array of lines, each line being an array of successive Vector3
  22035. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22036. * @returns the VertexData of the LineSystem
  22037. */
  22038. static CreateLineSystem(options: {
  22039. lines: Vector3[][];
  22040. colors?: Nullable<Color4[][]>;
  22041. }): VertexData;
  22042. /**
  22043. * Create the VertexData for a DashedLines
  22044. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22045. * - points an array successive Vector3
  22046. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22047. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22048. * - dashNb the intended total number of dashes, optional, default 200
  22049. * @returns the VertexData for the DashedLines
  22050. */
  22051. static CreateDashedLines(options: {
  22052. points: Vector3[];
  22053. dashSize?: number;
  22054. gapSize?: number;
  22055. dashNb?: number;
  22056. }): VertexData;
  22057. /**
  22058. * Creates the VertexData for a Ground
  22059. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22060. * - width the width (x direction) of the ground, optional, default 1
  22061. * - height the height (z direction) of the ground, optional, default 1
  22062. * - subdivisions the number of subdivisions per side, optional, default 1
  22063. * @returns the VertexData of the Ground
  22064. */
  22065. static CreateGround(options: {
  22066. width?: number;
  22067. height?: number;
  22068. subdivisions?: number;
  22069. subdivisionsX?: number;
  22070. subdivisionsY?: number;
  22071. }): VertexData;
  22072. /**
  22073. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22074. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22075. * * xmin the ground minimum X coordinate, optional, default -1
  22076. * * zmin the ground minimum Z coordinate, optional, default -1
  22077. * * xmax the ground maximum X coordinate, optional, default 1
  22078. * * zmax the ground maximum Z coordinate, optional, default 1
  22079. * * 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}
  22080. * * 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}
  22081. * @returns the VertexData of the TiledGround
  22082. */
  22083. static CreateTiledGround(options: {
  22084. xmin: number;
  22085. zmin: number;
  22086. xmax: number;
  22087. zmax: number;
  22088. subdivisions?: {
  22089. w: number;
  22090. h: number;
  22091. };
  22092. precision?: {
  22093. w: number;
  22094. h: number;
  22095. };
  22096. }): VertexData;
  22097. /**
  22098. * Creates the VertexData of the Ground designed from a heightmap
  22099. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22100. * * width the width (x direction) of the ground
  22101. * * height the height (z direction) of the ground
  22102. * * subdivisions the number of subdivisions per side
  22103. * * minHeight the minimum altitude on the ground, optional, default 0
  22104. * * maxHeight the maximum altitude on the ground, optional default 1
  22105. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22106. * * buffer the array holding the image color data
  22107. * * bufferWidth the width of image
  22108. * * bufferHeight the height of image
  22109. * @returns the VertexData of the Ground designed from a heightmap
  22110. */
  22111. static CreateGroundFromHeightMap(options: {
  22112. width: number;
  22113. height: number;
  22114. subdivisions: number;
  22115. minHeight: number;
  22116. maxHeight: number;
  22117. colorFilter: Color3;
  22118. buffer: Uint8Array;
  22119. bufferWidth: number;
  22120. bufferHeight: number;
  22121. }): VertexData;
  22122. /**
  22123. * Creates the VertexData for a Plane
  22124. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22125. * * size sets the width and height of the plane to the value of size, optional default 1
  22126. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22127. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22128. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22129. * * 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)
  22130. * * 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)
  22131. * @returns the VertexData of the box
  22132. */
  22133. static CreatePlane(options: {
  22134. size?: number;
  22135. width?: number;
  22136. height?: number;
  22137. sideOrientation?: number;
  22138. frontUVs?: Vector4;
  22139. backUVs?: Vector4;
  22140. }): VertexData;
  22141. /**
  22142. * Creates the VertexData of the Disc or regular Polygon
  22143. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22144. * * radius the radius of the disc, optional default 0.5
  22145. * * tessellation the number of polygon sides, optional, default 64
  22146. * * 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
  22147. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22148. * * 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)
  22149. * * 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)
  22150. * @returns the VertexData of the box
  22151. */
  22152. static CreateDisc(options: {
  22153. radius?: number;
  22154. tessellation?: number;
  22155. arc?: number;
  22156. sideOrientation?: number;
  22157. frontUVs?: Vector4;
  22158. backUVs?: Vector4;
  22159. }): VertexData;
  22160. /**
  22161. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22162. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22163. * @param polygon a mesh built from polygonTriangulation.build()
  22164. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22165. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22166. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22167. * @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)
  22168. * @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)
  22169. * @returns the VertexData of the Polygon
  22170. */
  22171. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22172. /**
  22173. * Creates the VertexData of the IcoSphere
  22174. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22175. * * radius the radius of the IcoSphere, optional default 1
  22176. * * radiusX allows stretching in the x direction, optional, default radius
  22177. * * radiusY allows stretching in the y direction, optional, default radius
  22178. * * radiusZ allows stretching in the z direction, optional, default radius
  22179. * * flat when true creates a flat shaded mesh, optional, default true
  22180. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22181. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22182. * * 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)
  22183. * * 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)
  22184. * @returns the VertexData of the IcoSphere
  22185. */
  22186. static CreateIcoSphere(options: {
  22187. radius?: number;
  22188. radiusX?: number;
  22189. radiusY?: number;
  22190. radiusZ?: number;
  22191. flat?: boolean;
  22192. subdivisions?: number;
  22193. sideOrientation?: number;
  22194. frontUVs?: Vector4;
  22195. backUVs?: Vector4;
  22196. }): VertexData;
  22197. /**
  22198. * Creates the VertexData for a Polyhedron
  22199. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22200. * * type provided types are:
  22201. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22202. * * 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)
  22203. * * size the size of the IcoSphere, optional default 1
  22204. * * sizeX allows stretching in the x direction, optional, default size
  22205. * * sizeY allows stretching in the y direction, optional, default size
  22206. * * sizeZ allows stretching in the z direction, optional, default size
  22207. * * 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
  22208. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22209. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22210. * * flat when true creates a flat shaded mesh, optional, default true
  22211. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22212. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22213. * * 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)
  22214. * * 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)
  22215. * @returns the VertexData of the Polyhedron
  22216. */
  22217. static CreatePolyhedron(options: {
  22218. type?: number;
  22219. size?: number;
  22220. sizeX?: number;
  22221. sizeY?: number;
  22222. sizeZ?: number;
  22223. custom?: any;
  22224. faceUV?: Vector4[];
  22225. faceColors?: Color4[];
  22226. flat?: boolean;
  22227. sideOrientation?: number;
  22228. frontUVs?: Vector4;
  22229. backUVs?: Vector4;
  22230. }): VertexData;
  22231. /**
  22232. * Creates the VertexData for a TorusKnot
  22233. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22234. * * radius the radius of the torus knot, optional, default 2
  22235. * * tube the thickness of the tube, optional, default 0.5
  22236. * * radialSegments the number of sides on each tube segments, optional, default 32
  22237. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22238. * * p the number of windings around the z axis, optional, default 2
  22239. * * q the number of windings around the x axis, optional, default 3
  22240. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22241. * * 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)
  22242. * * 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)
  22243. * @returns the VertexData of the Torus Knot
  22244. */
  22245. static CreateTorusKnot(options: {
  22246. radius?: number;
  22247. tube?: number;
  22248. radialSegments?: number;
  22249. tubularSegments?: number;
  22250. p?: number;
  22251. q?: number;
  22252. sideOrientation?: number;
  22253. frontUVs?: Vector4;
  22254. backUVs?: Vector4;
  22255. }): VertexData;
  22256. /**
  22257. * Compute normals for given positions and indices
  22258. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22259. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22260. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22261. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22262. * * facetNormals : optional array of facet normals (vector3)
  22263. * * facetPositions : optional array of facet positions (vector3)
  22264. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22265. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22266. * * bInfo : optional bounding info, required for facetPartitioning computation
  22267. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22268. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22269. * * useRightHandedSystem: optional boolean to for right handed system computation
  22270. * * depthSort : optional boolean to enable the facet depth sort computation
  22271. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22272. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22273. */
  22274. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22275. facetNormals?: any;
  22276. facetPositions?: any;
  22277. facetPartitioning?: any;
  22278. ratio?: number;
  22279. bInfo?: any;
  22280. bbSize?: Vector3;
  22281. subDiv?: any;
  22282. useRightHandedSystem?: boolean;
  22283. depthSort?: boolean;
  22284. distanceTo?: Vector3;
  22285. depthSortedFacets?: any;
  22286. }): void;
  22287. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  22288. /**
  22289. * Applies VertexData created from the imported parameters to the geometry
  22290. * @param parsedVertexData the parsed data from an imported file
  22291. * @param geometry the geometry to apply the VertexData to
  22292. */
  22293. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22294. }
  22295. }
  22296. declare module BABYLON {
  22297. /**
  22298. * Class containing static functions to help procedurally build meshes
  22299. */
  22300. class MeshBuilder {
  22301. private static updateSideOrientation(orientation?);
  22302. /**
  22303. * Creates a box mesh
  22304. * * The parameter `size` sets the size (float) of each box side (default 1)
  22305. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  22306. * * 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)
  22307. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22309. * * 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
  22310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22311. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  22312. * @param name defines the name of the mesh
  22313. * @param options defines the options used to create the mesh
  22314. * @param scene defines the hosting scene
  22315. * @returns the box mesh
  22316. */
  22317. static CreateBox(name: string, options: {
  22318. size?: number;
  22319. width?: number;
  22320. height?: number;
  22321. depth?: number;
  22322. faceUV?: Vector4[];
  22323. faceColors?: Color4[];
  22324. sideOrientation?: number;
  22325. frontUVs?: Vector4;
  22326. backUVs?: Vector4;
  22327. updatable?: boolean;
  22328. }, scene?: Nullable<Scene>): Mesh;
  22329. /**
  22330. * Creates a sphere mesh
  22331. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  22332. * * 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`)
  22333. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  22334. * * 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
  22335. * * 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)
  22336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22337. * * 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
  22338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22339. * @param name defines the name of the mesh
  22340. * @param options defines the options used to create the mesh
  22341. * @param scene defines the hosting scene
  22342. * @returns the sphere mesh
  22343. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  22344. */
  22345. static CreateSphere(name: string, options: {
  22346. segments?: number;
  22347. diameter?: number;
  22348. diameterX?: number;
  22349. diameterY?: number;
  22350. diameterZ?: number;
  22351. arc?: number;
  22352. slice?: number;
  22353. sideOrientation?: number;
  22354. frontUVs?: Vector4;
  22355. backUVs?: Vector4;
  22356. updatable?: boolean;
  22357. }, scene: any): Mesh;
  22358. /**
  22359. * Creates a plane polygonal mesh. By default, this is a disc
  22360. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22361. * * 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
  22362. * * 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
  22363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22364. * * 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
  22365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22366. * @param name defines the name of the mesh
  22367. * @param options defines the options used to create the mesh
  22368. * @param scene defines the hosting scene
  22369. * @returns the plane polygonal mesh
  22370. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22371. */
  22372. static CreateDisc(name: string, options: {
  22373. radius?: number;
  22374. tessellation?: number;
  22375. arc?: number;
  22376. updatable?: boolean;
  22377. sideOrientation?: number;
  22378. frontUVs?: Vector4;
  22379. backUVs?: Vector4;
  22380. }, scene?: Nullable<Scene>): Mesh;
  22381. /**
  22382. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22383. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22384. * * 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`)
  22385. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22386. * * 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
  22387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22388. * * 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
  22389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22390. * @param name defines the name of the mesh
  22391. * @param options defines the options used to create the mesh
  22392. * @param scene defines the hosting scene
  22393. * @returns the icosahedron mesh
  22394. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22395. */
  22396. static CreateIcoSphere(name: string, options: {
  22397. radius?: number;
  22398. radiusX?: number;
  22399. radiusY?: number;
  22400. radiusZ?: number;
  22401. flat?: boolean;
  22402. subdivisions?: number;
  22403. sideOrientation?: number;
  22404. frontUVs?: Vector4;
  22405. backUVs?: Vector4;
  22406. updatable?: boolean;
  22407. }, scene: Scene): Mesh;
  22408. /**
  22409. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22410. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  22411. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  22412. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  22413. * * 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
  22414. * * 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
  22415. * * 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
  22416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22417. * * 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
  22418. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22419. * * 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
  22420. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  22421. * * 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
  22422. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  22423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22424. * @param name defines the name of the mesh
  22425. * @param options defines the options used to create the mesh
  22426. * @param scene defines the hosting scene
  22427. * @returns the ribbon mesh
  22428. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  22429. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22430. */
  22431. static CreateRibbon(name: string, options: {
  22432. pathArray: Vector3[][];
  22433. closeArray?: boolean;
  22434. closePath?: boolean;
  22435. offset?: number;
  22436. updatable?: boolean;
  22437. sideOrientation?: number;
  22438. frontUVs?: Vector4;
  22439. backUVs?: Vector4;
  22440. instance?: Mesh;
  22441. invertUV?: boolean;
  22442. uvs?: Vector2[];
  22443. colors?: Color4[];
  22444. }, scene?: Nullable<Scene>): Mesh;
  22445. /**
  22446. * Creates a cylinder or a cone mesh
  22447. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  22448. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  22449. * * 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.
  22450. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  22451. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  22452. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  22453. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  22454. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  22455. * * 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).
  22456. * * 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
  22457. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  22458. * * 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
  22459. * * 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.
  22460. * * If `enclose` is false, a ring surface is one element.
  22461. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  22462. * * 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
  22463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22464. * * 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
  22465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22466. * @param name defines the name of the mesh
  22467. * @param options defines the options used to create the mesh
  22468. * @param scene defines the hosting scene
  22469. * @returns the cylinder mesh
  22470. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  22471. */
  22472. static CreateCylinder(name: string, options: {
  22473. height?: number;
  22474. diameterTop?: number;
  22475. diameterBottom?: number;
  22476. diameter?: number;
  22477. tessellation?: number;
  22478. subdivisions?: number;
  22479. arc?: number;
  22480. faceColors?: Color4[];
  22481. faceUV?: Vector4[];
  22482. updatable?: boolean;
  22483. hasRings?: boolean;
  22484. enclose?: boolean;
  22485. sideOrientation?: number;
  22486. frontUVs?: Vector4;
  22487. backUVs?: Vector4;
  22488. }, scene: any): Mesh;
  22489. /**
  22490. * Creates a torus mesh
  22491. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  22492. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  22493. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  22494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22495. * * 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
  22496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22497. * @param name defines the name of the mesh
  22498. * @param options defines the options used to create the mesh
  22499. * @param scene defines the hosting scene
  22500. * @returns the torus mesh
  22501. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  22502. */
  22503. static CreateTorus(name: string, options: {
  22504. diameter?: number;
  22505. thickness?: number;
  22506. tessellation?: number;
  22507. updatable?: boolean;
  22508. sideOrientation?: number;
  22509. frontUVs?: Vector4;
  22510. backUVs?: Vector4;
  22511. }, scene: any): Mesh;
  22512. /**
  22513. * Creates a torus knot mesh
  22514. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  22515. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  22516. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  22517. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  22518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22519. * * 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
  22520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22521. * @param name defines the name of the mesh
  22522. * @param options defines the options used to create the mesh
  22523. * @param scene defines the hosting scene
  22524. * @returns the torus knot mesh
  22525. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  22526. */
  22527. static CreateTorusKnot(name: string, options: {
  22528. radius?: number;
  22529. tube?: number;
  22530. radialSegments?: number;
  22531. tubularSegments?: number;
  22532. p?: number;
  22533. q?: number;
  22534. updatable?: boolean;
  22535. sideOrientation?: number;
  22536. frontUVs?: Vector4;
  22537. backUVs?: Vector4;
  22538. }, scene: any): Mesh;
  22539. /**
  22540. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  22541. * * 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
  22542. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  22543. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  22544. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  22545. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  22546. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  22547. * * 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
  22548. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  22549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22550. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  22551. * @param name defines the name of the new line system
  22552. * @param options defines the options used to create the line system
  22553. * @param scene defines the hosting scene
  22554. * @returns a new line system mesh
  22555. */
  22556. static CreateLineSystem(name: string, options: {
  22557. lines: Vector3[][];
  22558. updatable?: boolean;
  22559. instance?: Nullable<LinesMesh>;
  22560. colors?: Nullable<Color4[][]>;
  22561. useVertexAlpha?: boolean;
  22562. }, scene: Nullable<Scene>): LinesMesh;
  22563. /**
  22564. * Creates a line mesh
  22565. * 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
  22566. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22567. * * The parameter `points` is an array successive Vector3
  22568. * * 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
  22569. * * The optional parameter `colors` is an array of successive Color4, one per line point
  22570. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  22571. * * When updating an instance, remember that only point positions can change, not the number of points
  22572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22573. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  22574. * @param name defines the name of the new line system
  22575. * @param options defines the options used to create the line system
  22576. * @param scene defines the hosting scene
  22577. * @returns a new line mesh
  22578. */
  22579. static CreateLines(name: string, options: {
  22580. points: Vector3[];
  22581. updatable?: boolean;
  22582. instance?: Nullable<LinesMesh>;
  22583. colors?: Color4[];
  22584. useVertexAlpha?: boolean;
  22585. }, scene?: Nullable<Scene>): LinesMesh;
  22586. /**
  22587. * Creates a dashed line mesh
  22588. * * 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
  22589. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  22590. * * The parameter `points` is an array successive Vector3
  22591. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  22592. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  22593. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22594. * * 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
  22595. * * When updating an instance, remember that only point positions can change, not the number of points
  22596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22597. * @param name defines the name of the mesh
  22598. * @param options defines the options used to create the mesh
  22599. * @param scene defines the hosting scene
  22600. * @returns the dashed line mesh
  22601. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  22602. */
  22603. static CreateDashedLines(name: string, options: {
  22604. points: Vector3[];
  22605. dashSize?: number;
  22606. gapSize?: number;
  22607. dashNb?: number;
  22608. updatable?: boolean;
  22609. instance?: LinesMesh;
  22610. }, scene?: Nullable<Scene>): LinesMesh;
  22611. /**
  22612. * 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.
  22613. * * 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.
  22614. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22615. * * 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.
  22616. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  22617. * * 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
  22618. * * 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
  22619. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  22620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22621. * * 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
  22622. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  22623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22624. * @param name defines the name of the mesh
  22625. * @param options defines the options used to create the mesh
  22626. * @param scene defines the hosting scene
  22627. * @returns the extruded shape mesh
  22628. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22629. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22630. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22631. */
  22632. static ExtrudeShape(name: string, options: {
  22633. shape: Vector3[];
  22634. path: Vector3[];
  22635. scale?: number;
  22636. rotation?: number;
  22637. cap?: number;
  22638. updatable?: boolean;
  22639. sideOrientation?: number;
  22640. frontUVs?: Vector4;
  22641. backUVs?: Vector4;
  22642. instance?: Mesh;
  22643. invertUV?: boolean;
  22644. }, scene?: Nullable<Scene>): Mesh;
  22645. /**
  22646. * Creates an custom extruded shape mesh.
  22647. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  22648. * * 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.
  22649. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22650. * * 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
  22651. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22652. * * 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
  22653. * * It must returns a float value that will be the scale value applied to the shape on each path point
  22654. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22655. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  22656. * * 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
  22657. * * 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
  22658. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  22659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22660. * * 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
  22661. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22663. * @param name defines the name of the mesh
  22664. * @param options defines the options used to create the mesh
  22665. * @param scene defines the hosting scene
  22666. * @returns the custom extruded shape mesh
  22667. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  22668. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22669. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22670. */
  22671. static ExtrudeShapeCustom(name: string, options: {
  22672. shape: Vector3[];
  22673. path: Vector3[];
  22674. scaleFunction?: any;
  22675. rotationFunction?: any;
  22676. ribbonCloseArray?: boolean;
  22677. ribbonClosePath?: boolean;
  22678. cap?: number;
  22679. updatable?: boolean;
  22680. sideOrientation?: number;
  22681. frontUVs?: Vector4;
  22682. backUVs?: Vector4;
  22683. instance?: Mesh;
  22684. invertUV?: boolean;
  22685. }, scene: Scene): Mesh;
  22686. /**
  22687. * Creates lathe mesh.
  22688. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  22689. * * 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
  22690. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  22691. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  22692. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  22693. * * 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
  22694. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  22695. * * 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
  22696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22697. * * 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
  22698. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22700. * @param name defines the name of the mesh
  22701. * @param options defines the options used to create the mesh
  22702. * @param scene defines the hosting scene
  22703. * @returns the lathe mesh
  22704. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  22705. */
  22706. static CreateLathe(name: string, options: {
  22707. shape: Vector3[];
  22708. radius?: number;
  22709. tessellation?: number;
  22710. clip?: number;
  22711. arc?: number;
  22712. closed?: boolean;
  22713. updatable?: boolean;
  22714. sideOrientation?: number;
  22715. frontUVs?: Vector4;
  22716. backUVs?: Vector4;
  22717. cap?: number;
  22718. invertUV?: boolean;
  22719. }, scene: Scene): Mesh;
  22720. /**
  22721. * Creates a plane mesh
  22722. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  22723. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  22724. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  22725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22726. * * 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
  22727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22728. * @param name defines the name of the mesh
  22729. * @param options defines the options used to create the mesh
  22730. * @param scene defines the hosting scene
  22731. * @returns the plane mesh
  22732. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22733. */
  22734. static CreatePlane(name: string, options: {
  22735. size?: number;
  22736. width?: number;
  22737. height?: number;
  22738. sideOrientation?: number;
  22739. frontUVs?: Vector4;
  22740. backUVs?: Vector4;
  22741. updatable?: boolean;
  22742. sourcePlane?: Plane;
  22743. }, scene: Scene): Mesh;
  22744. /**
  22745. * Creates a ground mesh
  22746. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  22747. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  22748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22749. * @param name defines the name of the mesh
  22750. * @param options defines the options used to create the mesh
  22751. * @param scene defines the hosting scene
  22752. * @returns the ground mesh
  22753. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22754. */
  22755. static CreateGround(name: string, options: {
  22756. width?: number;
  22757. height?: number;
  22758. subdivisions?: number;
  22759. subdivisionsX?: number;
  22760. subdivisionsY?: number;
  22761. updatable?: boolean;
  22762. }, scene: any): Mesh;
  22763. /**
  22764. * Creates a tiled ground mesh
  22765. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  22766. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  22767. * * 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
  22768. * * 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
  22769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22770. * @param name defines the name of the mesh
  22771. * @param options defines the options used to create the mesh
  22772. * @param scene defines the hosting scene
  22773. * @returns the tiled ground mesh
  22774. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  22775. */
  22776. static CreateTiledGround(name: string, options: {
  22777. xmin: number;
  22778. zmin: number;
  22779. xmax: number;
  22780. zmax: number;
  22781. subdivisions?: {
  22782. w: number;
  22783. h: number;
  22784. };
  22785. precision?: {
  22786. w: number;
  22787. h: number;
  22788. };
  22789. updatable?: boolean;
  22790. }, scene: Scene): Mesh;
  22791. /**
  22792. * Creates a ground mesh from a height map
  22793. * * The parameter `url` sets the URL of the height map image resource.
  22794. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22795. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22796. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22797. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22798. * * 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.
  22799. * * 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).
  22800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22801. * @param name defines the name of the mesh
  22802. * @param url defines the url to the height map
  22803. * @param options defines the options used to create the mesh
  22804. * @param scene defines the hosting scene
  22805. * @returns the ground mesh
  22806. * @see http://doc.babylonjs.com/babylon101/height_map
  22807. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  22808. */
  22809. static CreateGroundFromHeightMap(name: string, url: string, options: {
  22810. width?: number;
  22811. height?: number;
  22812. subdivisions?: number;
  22813. minHeight?: number;
  22814. maxHeight?: number;
  22815. colorFilter?: Color3;
  22816. updatable?: boolean;
  22817. onReady?: (mesh: GroundMesh) => void;
  22818. }, scene: Scene): GroundMesh;
  22819. /**
  22820. * Creates a polygon mesh
  22821. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  22822. * * 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
  22823. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22825. * * 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)
  22826. * * Remember you can only change the shape positions, not their number when updating a polygon
  22827. * @param name defines the name of the mesh
  22828. * @param options defines the options used to create the mesh
  22829. * @param scene defines the hosting scene
  22830. * @returns the polygon mesh
  22831. */
  22832. static CreatePolygon(name: string, options: {
  22833. shape: Vector3[];
  22834. holes?: Vector3[][];
  22835. depth?: number;
  22836. faceUV?: Vector4[];
  22837. faceColors?: Color4[];
  22838. updatable?: boolean;
  22839. sideOrientation?: number;
  22840. frontUVs?: Vector4;
  22841. backUVs?: Vector4;
  22842. }, scene: Scene): Mesh;
  22843. /**
  22844. * Creates an extruded polygon mesh, with depth in the Y direction.
  22845. * * 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)
  22846. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22847. * @param name defines the name of the mesh
  22848. * @param options defines the options used to create the mesh
  22849. * @param scene defines the hosting scene
  22850. * @returns the polygon mesh
  22851. */
  22852. static ExtrudePolygon(name: string, options: {
  22853. shape: Vector3[];
  22854. holes?: Vector3[][];
  22855. depth?: number;
  22856. faceUV?: Vector4[];
  22857. faceColors?: Color4[];
  22858. updatable?: boolean;
  22859. sideOrientation?: number;
  22860. frontUVs?: Vector4;
  22861. backUVs?: Vector4;
  22862. }, scene: Scene): Mesh;
  22863. /**
  22864. * Creates a tube mesh.
  22865. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22866. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  22867. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  22868. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  22869. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  22870. * * 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)
  22871. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  22872. * * 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
  22873. * * 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
  22874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22875. * * 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
  22876. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22878. * @param name defines the name of the mesh
  22879. * @param options defines the options used to create the mesh
  22880. * @param scene defines the hosting scene
  22881. * @returns the tube mesh
  22882. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22883. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  22884. */
  22885. static CreateTube(name: string, options: {
  22886. path: Vector3[];
  22887. radius?: number;
  22888. tessellation?: number;
  22889. radiusFunction?: {
  22890. (i: number, distance: number): number;
  22891. };
  22892. cap?: number;
  22893. arc?: number;
  22894. updatable?: boolean;
  22895. sideOrientation?: number;
  22896. frontUVs?: Vector4;
  22897. backUVs?: Vector4;
  22898. instance?: Mesh;
  22899. invertUV?: boolean;
  22900. }, scene: Scene): Mesh;
  22901. /**
  22902. * Creates a polyhedron mesh
  22903. * * 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
  22904. * * The parameter `size` (positive float, default 1) sets the polygon size
  22905. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22906. * * 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`
  22907. * * 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
  22908. * * 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)`)
  22909. * * 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
  22910. * * 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
  22911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22912. * * 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
  22913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22914. * @param name defines the name of the mesh
  22915. * @param options defines the options used to create the mesh
  22916. * @param scene defines the hosting scene
  22917. * @returns the polyhedron mesh
  22918. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  22919. */
  22920. static CreatePolyhedron(name: string, options: {
  22921. type?: number;
  22922. size?: number;
  22923. sizeX?: number;
  22924. sizeY?: number;
  22925. sizeZ?: number;
  22926. custom?: any;
  22927. faceUV?: Vector4[];
  22928. faceColors?: Color4[];
  22929. flat?: boolean;
  22930. updatable?: boolean;
  22931. sideOrientation?: number;
  22932. frontUVs?: Vector4;
  22933. backUVs?: Vector4;
  22934. }, scene: Scene): Mesh;
  22935. /**
  22936. * Creates a decal mesh.
  22937. * 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
  22938. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  22939. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  22940. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  22941. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  22942. * @param name defines the name of the mesh
  22943. * @param sourceMesh defines the mesh where the decal must be applied
  22944. * @param options defines the options used to create the mesh
  22945. * @param scene defines the hosting scene
  22946. * @returns the decal mesh
  22947. * @see http://doc.babylonjs.com/how_to/decals
  22948. */
  22949. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  22950. position?: Vector3;
  22951. normal?: Vector3;
  22952. size?: Vector3;
  22953. angle?: number;
  22954. }): Mesh;
  22955. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  22956. }
  22957. }
  22958. declare module BABYLON {
  22959. class MeshLODLevel {
  22960. distance: number;
  22961. mesh: Nullable<Mesh>;
  22962. constructor(distance: number, mesh: Nullable<Mesh>);
  22963. }
  22964. }
  22965. declare module BABYLON {
  22966. /**
  22967. * A simplifier interface for future simplification implementations.
  22968. */
  22969. interface ISimplifier {
  22970. /**
  22971. * Simplification of a given mesh according to the given settings.
  22972. * Since this requires computation, it is assumed that the function runs async.
  22973. * @param settings The settings of the simplification, including quality and distance
  22974. * @param successCallback A callback that will be called after the mesh was simplified.
  22975. * @param errorCallback in case of an error, this callback will be called. optional.
  22976. */
  22977. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  22978. }
  22979. /**
  22980. * Expected simplification settings.
  22981. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  22982. */
  22983. interface ISimplificationSettings {
  22984. quality: number;
  22985. distance: number;
  22986. optimizeMesh?: boolean;
  22987. }
  22988. class SimplificationSettings implements ISimplificationSettings {
  22989. quality: number;
  22990. distance: number;
  22991. optimizeMesh: boolean | undefined;
  22992. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  22993. }
  22994. interface ISimplificationTask {
  22995. settings: Array<ISimplificationSettings>;
  22996. simplificationType: SimplificationType;
  22997. mesh: Mesh;
  22998. successCallback?: () => void;
  22999. parallelProcessing: boolean;
  23000. }
  23001. class SimplificationQueue {
  23002. private _simplificationArray;
  23003. running: boolean;
  23004. constructor();
  23005. addTask(task: ISimplificationTask): void;
  23006. executeNext(): void;
  23007. runSimplification(task: ISimplificationTask): void;
  23008. private getSimplifier(task);
  23009. }
  23010. /**
  23011. * The implemented types of simplification
  23012. * At the moment only Quadratic Error Decimation is implemented
  23013. */
  23014. enum SimplificationType {
  23015. /** Quadratic error decimation */
  23016. QUADRATIC = 0,
  23017. }
  23018. class DecimationTriangle {
  23019. vertices: Array<DecimationVertex>;
  23020. normal: Vector3;
  23021. error: Array<number>;
  23022. deleted: boolean;
  23023. isDirty: boolean;
  23024. borderFactor: number;
  23025. deletePending: boolean;
  23026. originalOffset: number;
  23027. constructor(vertices: Array<DecimationVertex>);
  23028. }
  23029. class DecimationVertex {
  23030. position: Vector3;
  23031. id: number;
  23032. q: QuadraticMatrix;
  23033. isBorder: boolean;
  23034. triangleStart: number;
  23035. triangleCount: number;
  23036. originalOffsets: Array<number>;
  23037. constructor(position: Vector3, id: number);
  23038. updatePosition(newPosition: Vector3): void;
  23039. }
  23040. class QuadraticMatrix {
  23041. data: Array<number>;
  23042. constructor(data?: Array<number>);
  23043. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  23044. addInPlace(matrix: QuadraticMatrix): void;
  23045. addArrayInPlace(data: Array<number>): void;
  23046. add(matrix: QuadraticMatrix): QuadraticMatrix;
  23047. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  23048. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  23049. }
  23050. class Reference {
  23051. vertexId: number;
  23052. triangleId: number;
  23053. constructor(vertexId: number, triangleId: number);
  23054. }
  23055. /**
  23056. * An implementation of the Quadratic Error simplification algorithm.
  23057. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  23058. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  23059. * @author RaananW
  23060. */
  23061. class QuadraticErrorSimplification implements ISimplifier {
  23062. private _mesh;
  23063. private triangles;
  23064. private vertices;
  23065. private references;
  23066. private _reconstructedMesh;
  23067. syncIterations: number;
  23068. aggressiveness: number;
  23069. decimationIterations: number;
  23070. boundingBoxEpsilon: number;
  23071. constructor(_mesh: Mesh);
  23072. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  23073. private runDecimation(settings, submeshIndex, successCallback);
  23074. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  23075. private init(callback);
  23076. private reconstructMesh(submeshIndex);
  23077. private initDecimatedMesh();
  23078. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  23079. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  23080. private identifyBorder();
  23081. private updateMesh(identifyBorders?);
  23082. private vertexError(q, point);
  23083. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  23084. }
  23085. }
  23086. declare module BABYLON {
  23087. class Polygon {
  23088. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23089. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23090. static Parse(input: string): Vector2[];
  23091. static StartingAt(x: number, y: number): Path2;
  23092. }
  23093. class PolygonMeshBuilder {
  23094. private _points;
  23095. private _outlinepoints;
  23096. private _holes;
  23097. private _name;
  23098. private _scene;
  23099. private _epoints;
  23100. private _eholes;
  23101. private _addToepoint(points);
  23102. constructor(name: string, contours: Path2, scene: Scene);
  23103. constructor(name: string, contours: Vector2[], scene: Scene);
  23104. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23105. build(updatable?: boolean, depth?: number): Mesh;
  23106. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  23107. }
  23108. }
  23109. declare module BABYLON {
  23110. class BaseSubMesh {
  23111. _materialDefines: Nullable<MaterialDefines>;
  23112. _materialEffect: Nullable<Effect>;
  23113. readonly effect: Nullable<Effect>;
  23114. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23115. }
  23116. class SubMesh extends BaseSubMesh implements ICullable {
  23117. materialIndex: number;
  23118. verticesStart: number;
  23119. verticesCount: number;
  23120. indexStart: number;
  23121. indexCount: number;
  23122. linesIndexCount: number;
  23123. private _mesh;
  23124. private _renderingMesh;
  23125. private _boundingInfo;
  23126. private _linesIndexBuffer;
  23127. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23128. _trianglePlanes: Plane[];
  23129. _lastColliderTransformMatrix: Matrix;
  23130. _renderId: number;
  23131. _alphaIndex: number;
  23132. _distanceToCamera: number;
  23133. _id: number;
  23134. private _currentMaterial;
  23135. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23136. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23137. readonly IsGlobal: boolean;
  23138. /**
  23139. * Returns the submesh BoudingInfo object.
  23140. */
  23141. getBoundingInfo(): BoundingInfo;
  23142. /**
  23143. * Sets the submesh BoundingInfo.
  23144. * Return the SubMesh.
  23145. */
  23146. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23147. /**
  23148. * Returns the mesh of the current submesh.
  23149. */
  23150. getMesh(): AbstractMesh;
  23151. /**
  23152. * Returns the rendering mesh of the submesh.
  23153. */
  23154. getRenderingMesh(): Mesh;
  23155. /**
  23156. * Returns the submesh material.
  23157. */
  23158. getMaterial(): Nullable<Material>;
  23159. /**
  23160. * Sets a new updated BoundingInfo object to the submesh.
  23161. * Returns the SubMesh.
  23162. */
  23163. refreshBoundingInfo(): SubMesh;
  23164. _checkCollision(collider: Collider): boolean;
  23165. /**
  23166. * Updates the submesh BoundingInfo.
  23167. * Returns the Submesh.
  23168. */
  23169. updateBoundingInfo(world: Matrix): SubMesh;
  23170. /**
  23171. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23172. * Boolean returned.
  23173. */
  23174. isInFrustum(frustumPlanes: Plane[]): boolean;
  23175. /**
  23176. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  23177. * Boolean returned.
  23178. */
  23179. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23180. /**
  23181. * Renders the submesh.
  23182. * Returns it.
  23183. */
  23184. render(enableAlphaMode: boolean): SubMesh;
  23185. /**
  23186. * Returns a new Index Buffer.
  23187. * Type returned : WebGLBuffer.
  23188. */
  23189. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  23190. /**
  23191. * True is the passed Ray intersects the submesh bounding box.
  23192. * Boolean returned.
  23193. */
  23194. canIntersects(ray: Ray): boolean;
  23195. /**
  23196. * Returns an object IntersectionInfo.
  23197. */
  23198. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  23199. _rebuild(): void;
  23200. /**
  23201. * Creates a new Submesh from the passed Mesh.
  23202. */
  23203. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23204. /**
  23205. * Disposes the Submesh.
  23206. * Returns nothing.
  23207. */
  23208. dispose(): void;
  23209. /**
  23210. * Creates a new Submesh from the passed parameters :
  23211. * - materialIndex (integer) : the index of the main mesh material.
  23212. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  23213. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  23214. * - mesh (Mesh) : the main mesh to create the submesh from.
  23215. * - renderingMesh (optional Mesh) : rendering mesh.
  23216. */
  23217. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23218. }
  23219. }
  23220. declare module BABYLON {
  23221. class TransformNode extends Node {
  23222. static BILLBOARDMODE_NONE: number;
  23223. static BILLBOARDMODE_X: number;
  23224. static BILLBOARDMODE_Y: number;
  23225. static BILLBOARDMODE_Z: number;
  23226. static BILLBOARDMODE_ALL: number;
  23227. private _forward;
  23228. private _forwardInverted;
  23229. private _up;
  23230. private _right;
  23231. private _rightInverted;
  23232. private _rotation;
  23233. private _rotationQuaternion;
  23234. protected _scaling: Vector3;
  23235. protected _isDirty: boolean;
  23236. private _transformToBoneReferal;
  23237. /**
  23238. * Set the billboard mode. Default is 0.
  23239. *
  23240. * | Value | Type | Description |
  23241. * | --- | --- | --- |
  23242. * | 0 | BILLBOARDMODE_NONE | |
  23243. * | 1 | BILLBOARDMODE_X | |
  23244. * | 2 | BILLBOARDMODE_Y | |
  23245. * | 4 | BILLBOARDMODE_Z | |
  23246. * | 7 | BILLBOARDMODE_ALL | |
  23247. *
  23248. */
  23249. billboardMode: number;
  23250. scalingDeterminant: number;
  23251. infiniteDistance: boolean;
  23252. /**
  23253. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  23254. * By default the system will update normals to compensate
  23255. */
  23256. ignoreNonUniformScaling: boolean;
  23257. position: Vector3;
  23258. _poseMatrix: Matrix;
  23259. private _localWorld;
  23260. _worldMatrix: Matrix;
  23261. _worldMatrixDeterminant: number;
  23262. private _absolutePosition;
  23263. private _pivotMatrix;
  23264. private _pivotMatrixInverse;
  23265. private _postMultiplyPivotMatrix;
  23266. protected _isWorldMatrixFrozen: boolean;
  23267. /**
  23268. * An event triggered after the world matrix is updated
  23269. */
  23270. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  23271. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  23272. /**
  23273. * Gets a string idenfifying the name of the class
  23274. * @returns "TransformNode" string
  23275. */
  23276. getClassName(): string;
  23277. /**
  23278. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  23279. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  23280. * Default : (0.0, 0.0, 0.0)
  23281. */
  23282. rotation: Vector3;
  23283. /**
  23284. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23285. * Default : (1.0, 1.0, 1.0)
  23286. */
  23287. /**
  23288. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  23289. * Default : (1.0, 1.0, 1.0)
  23290. */
  23291. scaling: Vector3;
  23292. /**
  23293. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  23294. * It's null by default.
  23295. * 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)
  23296. */
  23297. rotationQuaternion: Nullable<Quaternion>;
  23298. /**
  23299. * The forward direction of that transform in world space.
  23300. */
  23301. readonly forward: Vector3;
  23302. /**
  23303. * The up direction of that transform in world space.
  23304. */
  23305. readonly up: Vector3;
  23306. /**
  23307. * The right direction of that transform in world space.
  23308. */
  23309. readonly right: Vector3;
  23310. /**
  23311. * Returns the latest update of the World matrix
  23312. * Returns a Matrix.
  23313. */
  23314. getWorldMatrix(): Matrix;
  23315. /** @hidden */
  23316. _getWorldMatrixDeterminant(): number;
  23317. /**
  23318. * Returns directly the latest state of the mesh World matrix.
  23319. * A Matrix is returned.
  23320. */
  23321. readonly worldMatrixFromCache: Matrix;
  23322. /**
  23323. * Copies the paramater passed Matrix into the mesh Pose matrix.
  23324. * Returns the TransformNode.
  23325. */
  23326. updatePoseMatrix(matrix: Matrix): TransformNode;
  23327. /**
  23328. * Returns the mesh Pose matrix.
  23329. * Returned object : Matrix
  23330. */
  23331. getPoseMatrix(): Matrix;
  23332. _isSynchronized(): boolean;
  23333. _initCache(): void;
  23334. markAsDirty(property: string): TransformNode;
  23335. /**
  23336. * Returns the current mesh absolute position.
  23337. * Retuns a Vector3.
  23338. */
  23339. readonly absolutePosition: Vector3;
  23340. /**
  23341. * Sets a new matrix to apply before all other transformation
  23342. * @param matrix defines the transform matrix
  23343. * @returns the current TransformNode
  23344. */
  23345. setPreTransformMatrix(matrix: Matrix): TransformNode;
  23346. /**
  23347. * Sets a new pivot matrix to the current node
  23348. * @param matrix defines the new pivot matrix to use
  23349. * @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
  23350. * @returns the current TransformNode
  23351. */
  23352. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  23353. /**
  23354. * Returns the mesh pivot matrix.
  23355. * Default : Identity.
  23356. * A Matrix is returned.
  23357. */
  23358. getPivotMatrix(): Matrix;
  23359. /**
  23360. * Prevents the World matrix to be computed any longer.
  23361. * Returns the TransformNode.
  23362. */
  23363. freezeWorldMatrix(): TransformNode;
  23364. /**
  23365. * Allows back the World matrix computation.
  23366. * Returns the TransformNode.
  23367. */
  23368. unfreezeWorldMatrix(): this;
  23369. /**
  23370. * True if the World matrix has been frozen.
  23371. * Returns a boolean.
  23372. */
  23373. readonly isWorldMatrixFrozen: boolean;
  23374. /**
  23375. * Retuns the mesh absolute position in the World.
  23376. * Returns a Vector3.
  23377. */
  23378. getAbsolutePosition(): Vector3;
  23379. /**
  23380. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  23381. * Returns the TransformNode.
  23382. */
  23383. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23384. /**
  23385. * Sets the mesh position in its local space.
  23386. * Returns the TransformNode.
  23387. */
  23388. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  23389. /**
  23390. * Returns the mesh position in the local space from the current World matrix values.
  23391. * Returns a new Vector3.
  23392. */
  23393. getPositionExpressedInLocalSpace(): Vector3;
  23394. /**
  23395. * Translates the mesh along the passed Vector3 in its local space.
  23396. * Returns the TransformNode.
  23397. */
  23398. locallyTranslate(vector3: Vector3): TransformNode;
  23399. private static _lookAtVectorCache;
  23400. /**
  23401. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  23402. * @param targetPoint the position (must be in same space as current mesh) to look at
  23403. * @param yawCor optional yaw (y-axis) correction in radians
  23404. * @param pitchCor optional pitch (x-axis) correction in radians
  23405. * @param rollCor optional roll (z-axis) correction in radians
  23406. * @param space the choosen space of the target
  23407. * @returns the TransformNode.
  23408. */
  23409. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  23410. /**
  23411. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  23412. * This Vector3 is expressed in the World space.
  23413. */
  23414. getDirection(localAxis: Vector3): Vector3;
  23415. /**
  23416. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  23417. * localAxis is expressed in the mesh local space.
  23418. * result is computed in the Wordl space from the mesh World matrix.
  23419. * Returns the TransformNode.
  23420. */
  23421. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  23422. /**
  23423. * Sets a new pivot point to the current node
  23424. * @param point defines the new pivot point to use
  23425. * @param space defines if the point is in world or local space (local by default)
  23426. * @returns the current TransformNode
  23427. */
  23428. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  23429. /**
  23430. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  23431. */
  23432. getPivotPoint(): Vector3;
  23433. /**
  23434. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  23435. * Returns the TransformNode.
  23436. */
  23437. getPivotPointToRef(result: Vector3): TransformNode;
  23438. /**
  23439. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  23440. */
  23441. getAbsolutePivotPoint(): Vector3;
  23442. /**
  23443. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  23444. * Returns the TransformNode.
  23445. */
  23446. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  23447. /**
  23448. * Defines the passed node as the parent of the current node.
  23449. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  23450. * Returns the TransformNode.
  23451. */
  23452. setParent(node: Nullable<Node>): TransformNode;
  23453. private _nonUniformScaling;
  23454. readonly nonUniformScaling: boolean;
  23455. _updateNonUniformScalingState(value: boolean): boolean;
  23456. /**
  23457. * Attach the current TransformNode to another TransformNode associated with a bone
  23458. * @param bone Bone affecting the TransformNode
  23459. * @param affectedTransformNode TransformNode associated with the bone
  23460. */
  23461. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  23462. detachFromBone(): TransformNode;
  23463. private static _rotationAxisCache;
  23464. /**
  23465. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  23466. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23467. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23468. * The passed axis is also normalized.
  23469. * Returns the TransformNode.
  23470. */
  23471. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23472. /**
  23473. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  23474. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  23475. * The passed axis is also normalized.
  23476. * Returns the TransformNode.
  23477. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  23478. */
  23479. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  23480. /**
  23481. * Translates the mesh along the axis vector for the passed distance in the given space.
  23482. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  23483. * Returns the TransformNode.
  23484. */
  23485. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23486. /**
  23487. * Adds a rotation step to the mesh current rotation.
  23488. * x, y, z are Euler angles expressed in radians.
  23489. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  23490. * This means this rotation is made in the mesh local space only.
  23491. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  23492. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  23493. * ```javascript
  23494. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  23495. * ```
  23496. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  23497. * 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.
  23498. * Returns the TransformNode.
  23499. */
  23500. addRotation(x: number, y: number, z: number): TransformNode;
  23501. /**
  23502. * Computes the mesh World matrix and returns it.
  23503. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  23504. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  23505. * If the parameter `force`is set to `true`, the actual computation is done.
  23506. * Returns the mesh World Matrix.
  23507. */
  23508. computeWorldMatrix(force?: boolean): Matrix;
  23509. protected _afterComputeWorldMatrix(): void;
  23510. /**
  23511. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  23512. * @param func: callback function to add
  23513. *
  23514. * Returns the TransformNode.
  23515. */
  23516. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23517. /**
  23518. * Removes a registered callback function.
  23519. * Returns the TransformNode.
  23520. */
  23521. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  23522. /**
  23523. * Clone the current transform node
  23524. * Returns the new transform node
  23525. * @param name Name of the new clone
  23526. * @param newParent New parent for the clone
  23527. * @param doNotCloneChildren Do not clone children hierarchy
  23528. */
  23529. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  23530. serialize(currentSerializationObject?: any): any;
  23531. /**
  23532. * Returns a new TransformNode object parsed from the source provided.
  23533. * The parameter `parsedMesh` is the source.
  23534. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  23535. */
  23536. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  23537. /**
  23538. * Releases resources associated with this transform node.
  23539. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23540. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23541. */
  23542. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23543. }
  23544. }
  23545. declare module BABYLON {
  23546. class VertexBuffer {
  23547. /** @hidden */
  23548. _buffer: Buffer;
  23549. private _kind;
  23550. private _size;
  23551. private _ownsBuffer;
  23552. private _instanced;
  23553. private _instanceDivisor;
  23554. /**
  23555. * The byte type.
  23556. */
  23557. static readonly BYTE: number;
  23558. /**
  23559. * The unsigned byte type.
  23560. */
  23561. static readonly UNSIGNED_BYTE: number;
  23562. /**
  23563. * The short type.
  23564. */
  23565. static readonly SHORT: number;
  23566. /**
  23567. * The unsigned short type.
  23568. */
  23569. static readonly UNSIGNED_SHORT: number;
  23570. /**
  23571. * The integer type.
  23572. */
  23573. static readonly INT: number;
  23574. /**
  23575. * The unsigned integer type.
  23576. */
  23577. static readonly UNSIGNED_INT: number;
  23578. /**
  23579. * The float type.
  23580. */
  23581. static readonly FLOAT: number;
  23582. /**
  23583. * Gets or sets the instance divisor when in instanced mode
  23584. */
  23585. instanceDivisor: number;
  23586. /**
  23587. * Gets the byte stride.
  23588. */
  23589. readonly byteStride: number;
  23590. /**
  23591. * Gets the byte offset.
  23592. */
  23593. readonly byteOffset: number;
  23594. /**
  23595. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  23596. */
  23597. readonly normalized: boolean;
  23598. /**
  23599. * Gets the data type of each component in the array.
  23600. */
  23601. readonly type: number;
  23602. /**
  23603. * Constructor
  23604. * @param engine the engine
  23605. * @param data the data to use for this vertex buffer
  23606. * @param kind the vertex buffer kind
  23607. * @param updatable whether the data is updatable
  23608. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  23609. * @param stride the stride (optional)
  23610. * @param instanced whether the buffer is instanced (optional)
  23611. * @param offset the offset of the data (optional)
  23612. * @param size the number of components (optional)
  23613. * @param type the type of the component (optional)
  23614. * @param normalized whether the data contains normalized data (optional)
  23615. * @param useBytes set to true if stride and offset are in bytes (optional)
  23616. */
  23617. 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);
  23618. _rebuild(): void;
  23619. /**
  23620. * Returns the kind of the VertexBuffer (string).
  23621. */
  23622. getKind(): string;
  23623. /**
  23624. * Boolean : is the VertexBuffer updatable ?
  23625. */
  23626. isUpdatable(): boolean;
  23627. /**
  23628. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  23629. */
  23630. getData(): Nullable<DataArray>;
  23631. /**
  23632. * Returns the WebGLBuffer associated to the VertexBuffer.
  23633. */
  23634. getBuffer(): Nullable<WebGLBuffer>;
  23635. /**
  23636. * Returns the stride as a multiple of the type byte length.
  23637. * DEPRECATED. Use byteStride instead.
  23638. */
  23639. getStrideSize(): number;
  23640. /**
  23641. * Returns the offset as a multiple of the type byte length.
  23642. * DEPRECATED. Use byteOffset instead.
  23643. */
  23644. getOffset(): number;
  23645. /**
  23646. * Returns the number of components per vertex attribute (integer).
  23647. */
  23648. getSize(): number;
  23649. /**
  23650. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  23651. */
  23652. getIsInstanced(): boolean;
  23653. /**
  23654. * Returns the instancing divisor, zero for non-instanced (integer).
  23655. */
  23656. getInstanceDivisor(): number;
  23657. /**
  23658. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  23659. * Returns the created WebGLBuffer.
  23660. */
  23661. create(data?: DataArray): void;
  23662. /**
  23663. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23664. * This function will create a new buffer if the current one is not updatable
  23665. * Returns the updated WebGLBuffer.
  23666. */
  23667. update(data: DataArray): void;
  23668. /**
  23669. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23670. * Returns the directly updated WebGLBuffer.
  23671. * @param data the new data
  23672. * @param offset the new offset
  23673. * @param useBytes set to true if the offset is in bytes
  23674. */
  23675. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  23676. /**
  23677. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  23678. */
  23679. dispose(): void;
  23680. /**
  23681. * Enumerates each value of this vertex buffer as numbers.
  23682. * @param count the number of values to enumerate
  23683. * @param callback the callback function called for each value
  23684. */
  23685. forEach(count: number, callback: (value: number, index: number) => void): void;
  23686. private static _PositionKind;
  23687. private static _NormalKind;
  23688. private static _TangentKind;
  23689. private static _UVKind;
  23690. private static _UV2Kind;
  23691. private static _UV3Kind;
  23692. private static _UV4Kind;
  23693. private static _UV5Kind;
  23694. private static _UV6Kind;
  23695. private static _ColorKind;
  23696. private static _MatricesIndicesKind;
  23697. private static _MatricesWeightsKind;
  23698. private static _MatricesIndicesExtraKind;
  23699. private static _MatricesWeightsExtraKind;
  23700. static readonly PositionKind: string;
  23701. static readonly NormalKind: string;
  23702. static readonly TangentKind: string;
  23703. static readonly UVKind: string;
  23704. static readonly UV2Kind: string;
  23705. static readonly UV3Kind: string;
  23706. static readonly UV4Kind: string;
  23707. static readonly UV5Kind: string;
  23708. static readonly UV6Kind: string;
  23709. static readonly ColorKind: string;
  23710. static readonly MatricesIndicesKind: string;
  23711. static readonly MatricesWeightsKind: string;
  23712. static readonly MatricesIndicesExtraKind: string;
  23713. static readonly MatricesWeightsExtraKind: string;
  23714. /**
  23715. * Deduces the stride given a kind.
  23716. * @param kind The kind string to deduce
  23717. * @returns The deduced stride
  23718. */
  23719. static DeduceStride(kind: string): number;
  23720. /**
  23721. * Gets the byte length of the given type.
  23722. * @param type the type
  23723. * @returns the number of bytes
  23724. */
  23725. static GetTypeByteLength(type: number): number;
  23726. /**
  23727. * Enumerates each value of the given parameters as numbers.
  23728. * @param data the data to enumerate
  23729. * @param byteOffset the byte offset of the data
  23730. * @param byteStride the byte stride of the data
  23731. * @param componentCount the number of components per element
  23732. * @param componentType the type of the component
  23733. * @param count the total number of components
  23734. * @param normalized whether the data is normalized
  23735. * @param callback the callback function called for each value
  23736. */
  23737. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  23738. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  23739. }
  23740. }
  23741. declare module BABYLON {
  23742. /**
  23743. * Defines a target to use with MorphTargetManager
  23744. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23745. */
  23746. class MorphTarget implements IAnimatable {
  23747. /** defines the name of the target */
  23748. name: string;
  23749. /**
  23750. * Gets or sets the list of animations
  23751. */
  23752. animations: Animation[];
  23753. private _scene;
  23754. private _positions;
  23755. private _normals;
  23756. private _tangents;
  23757. private _influence;
  23758. /**
  23759. * Observable raised when the influence changes
  23760. */
  23761. onInfluenceChanged: Observable<boolean>;
  23762. /**
  23763. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23764. */
  23765. influence: number;
  23766. private _animationPropertiesOverride;
  23767. /**
  23768. * Gets or sets the animation properties override
  23769. */
  23770. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23771. /**
  23772. * Creates a new MorphTarget
  23773. * @param name defines the name of the target
  23774. * @param influence defines the influence to use
  23775. */
  23776. constructor(
  23777. /** defines the name of the target */
  23778. name: string, influence?: number, scene?: Nullable<Scene>);
  23779. /**
  23780. * Gets a boolean defining if the target contains position data
  23781. */
  23782. readonly hasPositions: boolean;
  23783. /**
  23784. * Gets a boolean defining if the target contains normal data
  23785. */
  23786. readonly hasNormals: boolean;
  23787. /**
  23788. * Gets a boolean defining if the target contains tangent data
  23789. */
  23790. readonly hasTangents: boolean;
  23791. /**
  23792. * Affects position data to this target
  23793. * @param data defines the position data to use
  23794. */
  23795. setPositions(data: Nullable<FloatArray>): void;
  23796. /**
  23797. * Gets the position data stored in this target
  23798. * @returns a FloatArray containing the position data (or null if not present)
  23799. */
  23800. getPositions(): Nullable<FloatArray>;
  23801. /**
  23802. * Affects normal data to this target
  23803. * @param data defines the normal data to use
  23804. */
  23805. setNormals(data: Nullable<FloatArray>): void;
  23806. /**
  23807. * Gets the normal data stored in this target
  23808. * @returns a FloatArray containing the normal data (or null if not present)
  23809. */
  23810. getNormals(): Nullable<FloatArray>;
  23811. /**
  23812. * Affects tangent data to this target
  23813. * @param data defines the tangent data to use
  23814. */
  23815. setTangents(data: Nullable<FloatArray>): void;
  23816. /**
  23817. * Gets the tangent data stored in this target
  23818. * @returns a FloatArray containing the tangent data (or null if not present)
  23819. */
  23820. getTangents(): Nullable<FloatArray>;
  23821. /**
  23822. * Serializes the current target into a Serialization object
  23823. * @returns the serialized object
  23824. */
  23825. serialize(): any;
  23826. /**
  23827. * Creates a new target from serialized data
  23828. * @param serializationObject defines the serialized data to use
  23829. * @returns a new MorphTarget
  23830. */
  23831. static Parse(serializationObject: any): MorphTarget;
  23832. /**
  23833. * Creates a MorphTarget from mesh data
  23834. * @param mesh defines the source mesh
  23835. * @param name defines the name to use for the new target
  23836. * @param influence defines the influence to attach to the target
  23837. * @returns a new MorphTarget
  23838. */
  23839. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23840. }
  23841. }
  23842. declare module BABYLON {
  23843. /**
  23844. * This class is used to deform meshes using morphing between different targets
  23845. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23846. */
  23847. class MorphTargetManager {
  23848. private _targets;
  23849. private _targetObservable;
  23850. private _activeTargets;
  23851. private _scene;
  23852. private _influences;
  23853. private _supportsNormals;
  23854. private _supportsTangents;
  23855. private _vertexCount;
  23856. private _uniqueId;
  23857. private _tempInfluences;
  23858. /**
  23859. * Creates a new MorphTargetManager
  23860. * @param scene defines the current scene
  23861. */
  23862. constructor(scene?: Nullable<Scene>);
  23863. /**
  23864. * Gets the unique ID of this manager
  23865. */
  23866. readonly uniqueId: number;
  23867. /**
  23868. * Gets the number of vertices handled by this manager
  23869. */
  23870. readonly vertexCount: number;
  23871. /**
  23872. * Gets a boolean indicating if this manager supports morphing of normals
  23873. */
  23874. readonly supportsNormals: boolean;
  23875. /**
  23876. * Gets a boolean indicating if this manager supports morphing of tangents
  23877. */
  23878. readonly supportsTangents: boolean;
  23879. /**
  23880. * Gets the number of targets stored in this manager
  23881. */
  23882. readonly numTargets: number;
  23883. /**
  23884. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23885. */
  23886. readonly numInfluencers: number;
  23887. /**
  23888. * Gets the list of influences (one per target)
  23889. */
  23890. readonly influences: Float32Array;
  23891. /**
  23892. * Gets the active target at specified index. An active target is a target with an influence > 0
  23893. * @param index defines the index to check
  23894. * @returns the requested target
  23895. */
  23896. getActiveTarget(index: number): MorphTarget;
  23897. /**
  23898. * Gets the target at specified index
  23899. * @param index defines the index to check
  23900. * @returns the requested target
  23901. */
  23902. getTarget(index: number): MorphTarget;
  23903. /**
  23904. * Add a new target to this manager
  23905. * @param target defines the target to add
  23906. */
  23907. addTarget(target: MorphTarget): void;
  23908. /**
  23909. * Removes a target from the manager
  23910. * @param target defines the target to remove
  23911. */
  23912. removeTarget(target: MorphTarget): void;
  23913. /**
  23914. * Serializes the current manager into a Serialization object
  23915. * @returns the serialized object
  23916. */
  23917. serialize(): any;
  23918. private _syncActiveTargets(needUpdate);
  23919. /**
  23920. * Syncrhonize the targets with all the meshes using this morph target manager
  23921. */
  23922. synchronize(): void;
  23923. /**
  23924. * Creates a new MorphTargetManager from serialized data
  23925. * @param serializationObject defines the serialized data
  23926. * @param scene defines the hosting scene
  23927. * @returns the new MorphTargetManager
  23928. */
  23929. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23930. }
  23931. }
  23932. declare module BABYLON {
  23933. interface PhysicsImpostorJoint {
  23934. mainImpostor: PhysicsImpostor;
  23935. connectedImpostor: PhysicsImpostor;
  23936. joint: PhysicsJoint;
  23937. }
  23938. class PhysicsEngine {
  23939. private _physicsPlugin;
  23940. gravity: Vector3;
  23941. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  23942. setGravity(gravity: Vector3): void;
  23943. /**
  23944. * Set the time step of the physics engine.
  23945. * default is 1/60.
  23946. * To slow it down, enter 1/600 for example.
  23947. * To speed it up, 1/30
  23948. * @param {number} newTimeStep the new timestep to apply to this world.
  23949. */
  23950. setTimeStep(newTimeStep?: number): void;
  23951. /**
  23952. * Get the time step of the physics engine.
  23953. */
  23954. getTimeStep(): number;
  23955. dispose(): void;
  23956. getPhysicsPluginName(): string;
  23957. static Epsilon: number;
  23958. private _impostors;
  23959. private _joints;
  23960. /**
  23961. * Adding a new impostor for the impostor tracking.
  23962. * This will be done by the impostor itself.
  23963. * @param {PhysicsImpostor} impostor the impostor to add
  23964. */
  23965. addImpostor(impostor: PhysicsImpostor): void;
  23966. /**
  23967. * Remove an impostor from the engine.
  23968. * This impostor and its mesh will not longer be updated by the physics engine.
  23969. * @param {PhysicsImpostor} impostor the impostor to remove
  23970. */
  23971. removeImpostor(impostor: PhysicsImpostor): void;
  23972. /**
  23973. * Add a joint to the physics engine
  23974. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  23975. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  23976. * @param {PhysicsJoint} the joint that will connect both impostors.
  23977. */
  23978. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23979. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23980. /**
  23981. * Called by the scene. no need to call it.
  23982. */
  23983. _step(delta: number): void;
  23984. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23985. getImpostors(): Array<PhysicsImpostor>;
  23986. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23987. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23988. }
  23989. interface IPhysicsEnginePlugin {
  23990. world: any;
  23991. name: string;
  23992. setGravity(gravity: Vector3): void;
  23993. setTimeStep(timeStep: number): void;
  23994. getTimeStep(): number;
  23995. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23996. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23997. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23998. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23999. removePhysicsBody(impostor: PhysicsImpostor): void;
  24000. generateJoint(joint: PhysicsImpostorJoint): void;
  24001. removeJoint(joint: PhysicsImpostorJoint): void;
  24002. isSupported(): boolean;
  24003. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24004. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24005. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24006. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24007. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24008. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24009. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24010. getBodyMass(impostor: PhysicsImpostor): number;
  24011. getBodyFriction(impostor: PhysicsImpostor): number;
  24012. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24013. getBodyRestitution(impostor: PhysicsImpostor): number;
  24014. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24015. sleepBody(impostor: PhysicsImpostor): void;
  24016. wakeUpBody(impostor: PhysicsImpostor): void;
  24017. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24018. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24019. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24020. getRadius(impostor: PhysicsImpostor): number;
  24021. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24022. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24023. dispose(): void;
  24024. }
  24025. }
  24026. declare module BABYLON {
  24027. class PhysicsHelper {
  24028. private _scene;
  24029. private _physicsEngine;
  24030. constructor(scene: Scene);
  24031. /**
  24032. * @param {Vector3} origin the origin of the explosion
  24033. * @param {number} radius the explosion radius
  24034. * @param {number} strength the explosion strength
  24035. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24036. */
  24037. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24038. /**
  24039. * @param {Vector3} origin the origin of the explosion
  24040. * @param {number} radius the explosion radius
  24041. * @param {number} strength the explosion strength
  24042. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24043. */
  24044. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24045. /**
  24046. * @param {Vector3} origin the origin of the explosion
  24047. * @param {number} radius the explosion radius
  24048. * @param {number} strength the explosion strength
  24049. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24050. */
  24051. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  24052. /**
  24053. * @param {Vector3} origin the origin of the updraft
  24054. * @param {number} radius the radius of the updraft
  24055. * @param {number} strength the strength of the updraft
  24056. * @param {number} height the height of the updraft
  24057. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  24058. */
  24059. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  24060. /**
  24061. * @param {Vector3} origin the of the vortex
  24062. * @param {number} radius the radius of the vortex
  24063. * @param {number} strength the strength of the vortex
  24064. * @param {number} height the height of the vortex
  24065. */
  24066. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  24067. }
  24068. /***** Radial explosion *****/
  24069. class PhysicsRadialExplosionEvent {
  24070. private _scene;
  24071. private _sphere;
  24072. private _sphereOptions;
  24073. private _rays;
  24074. private _dataFetched;
  24075. constructor(scene: Scene);
  24076. /**
  24077. * Returns the data related to the radial explosion event (sphere & rays).
  24078. * @returns {PhysicsRadialExplosionEventData}
  24079. */
  24080. getData(): PhysicsRadialExplosionEventData;
  24081. /**
  24082. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  24083. * @param impostor
  24084. * @param {Vector3} origin the origin of the explosion
  24085. * @param {number} radius the explosion radius
  24086. * @param {number} strength the explosion strength
  24087. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  24088. * @returns {Nullable<PhysicsForceAndContactPoint>}
  24089. */
  24090. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  24091. /**
  24092. * Disposes the sphere.
  24093. * @param {bolean} force
  24094. */
  24095. dispose(force?: boolean): void;
  24096. /*** Helpers ***/
  24097. private _prepareSphere();
  24098. private _intersectsWithSphere(impostor, origin, radius);
  24099. }
  24100. /***** Gravitational Field *****/
  24101. class PhysicsGravitationalFieldEvent {
  24102. private _physicsHelper;
  24103. private _scene;
  24104. private _origin;
  24105. private _radius;
  24106. private _strength;
  24107. private _falloff;
  24108. private _tickCallback;
  24109. private _sphere;
  24110. private _dataFetched;
  24111. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  24112. /**
  24113. * Returns the data related to the gravitational field event (sphere).
  24114. * @returns {PhysicsGravitationalFieldEventData}
  24115. */
  24116. getData(): PhysicsGravitationalFieldEventData;
  24117. /**
  24118. * Enables the gravitational field.
  24119. */
  24120. enable(): void;
  24121. /**
  24122. * Disables the gravitational field.
  24123. */
  24124. disable(): void;
  24125. /**
  24126. * Disposes the sphere.
  24127. * @param {bolean} force
  24128. */
  24129. dispose(force?: boolean): void;
  24130. private _tick();
  24131. }
  24132. /***** Updraft *****/
  24133. class PhysicsUpdraftEvent {
  24134. private _scene;
  24135. private _origin;
  24136. private _radius;
  24137. private _strength;
  24138. private _height;
  24139. private _updraftMode;
  24140. private _physicsEngine;
  24141. private _originTop;
  24142. private _originDirection;
  24143. private _tickCallback;
  24144. private _cylinder;
  24145. private _cylinderPosition;
  24146. private _dataFetched;
  24147. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  24148. /**
  24149. * Returns the data related to the updraft event (cylinder).
  24150. * @returns {PhysicsUpdraftEventData}
  24151. */
  24152. getData(): PhysicsUpdraftEventData;
  24153. /**
  24154. * Enables the updraft.
  24155. */
  24156. enable(): void;
  24157. /**
  24158. * Disables the cortex.
  24159. */
  24160. disable(): void;
  24161. /**
  24162. * Disposes the sphere.
  24163. * @param {bolean} force
  24164. */
  24165. dispose(force?: boolean): void;
  24166. private getImpostorForceAndContactPoint(impostor);
  24167. private _tick();
  24168. /*** Helpers ***/
  24169. private _prepareCylinder();
  24170. private _intersectsWithCylinder(impostor);
  24171. }
  24172. /***** Vortex *****/
  24173. class PhysicsVortexEvent {
  24174. private _scene;
  24175. private _origin;
  24176. private _radius;
  24177. private _strength;
  24178. private _height;
  24179. private _physicsEngine;
  24180. private _originTop;
  24181. private _centripetalForceThreshold;
  24182. private _updraftMultiplier;
  24183. private _tickCallback;
  24184. private _cylinder;
  24185. private _cylinderPosition;
  24186. private _dataFetched;
  24187. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  24188. /**
  24189. * Returns the data related to the vortex event (cylinder).
  24190. * @returns {PhysicsVortexEventData}
  24191. */
  24192. getData(): PhysicsVortexEventData;
  24193. /**
  24194. * Enables the vortex.
  24195. */
  24196. enable(): void;
  24197. /**
  24198. * Disables the cortex.
  24199. */
  24200. disable(): void;
  24201. /**
  24202. * Disposes the sphere.
  24203. * @param {bolean} force
  24204. */
  24205. dispose(force?: boolean): void;
  24206. private getImpostorForceAndContactPoint(impostor);
  24207. private _tick();
  24208. /*** Helpers ***/
  24209. private _prepareCylinder();
  24210. private _intersectsWithCylinder(impostor);
  24211. }
  24212. /***** Enums *****/
  24213. /**
  24214. * The strenght of the force in correspondence to the distance of the affected object
  24215. */
  24216. enum PhysicsRadialImpulseFalloff {
  24217. /** Defines that impulse is constant in strength across it's whole radius */
  24218. Constant = 0,
  24219. /** DEfines that impulse gets weaker if it's further from the origin */
  24220. Linear = 1,
  24221. }
  24222. /**
  24223. * The strenght of the force in correspondence to the distance of the affected object
  24224. */
  24225. enum PhysicsUpdraftMode {
  24226. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  24227. Center = 0,
  24228. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  24229. Perpendicular = 1,
  24230. }
  24231. /***** Data interfaces *****/
  24232. interface PhysicsForceAndContactPoint {
  24233. force: Vector3;
  24234. contactPoint: Vector3;
  24235. }
  24236. interface PhysicsRadialExplosionEventData {
  24237. sphere: Mesh;
  24238. rays: Array<Ray>;
  24239. }
  24240. interface PhysicsGravitationalFieldEventData {
  24241. sphere: Mesh;
  24242. }
  24243. interface PhysicsUpdraftEventData {
  24244. cylinder: Mesh;
  24245. }
  24246. interface PhysicsVortexEventData {
  24247. cylinder: Mesh;
  24248. }
  24249. }
  24250. declare module BABYLON {
  24251. interface PhysicsImpostorParameters {
  24252. mass: number;
  24253. friction?: number;
  24254. restitution?: number;
  24255. nativeOptions?: any;
  24256. ignoreParent?: boolean;
  24257. disableBidirectionalTransformation?: boolean;
  24258. }
  24259. interface IPhysicsEnabledObject {
  24260. position: Vector3;
  24261. rotationQuaternion: Nullable<Quaternion>;
  24262. scaling: Vector3;
  24263. rotation?: Vector3;
  24264. parent?: any;
  24265. getBoundingInfo(): BoundingInfo;
  24266. computeWorldMatrix(force: boolean): Matrix;
  24267. getWorldMatrix?(): Matrix;
  24268. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24269. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24270. getIndices?(): Nullable<IndicesArray>;
  24271. getScene?(): Scene;
  24272. getAbsolutePosition(): Vector3;
  24273. getAbsolutePivotPoint(): Vector3;
  24274. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24275. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24276. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24277. getClassName(): string;
  24278. }
  24279. class PhysicsImpostor {
  24280. object: IPhysicsEnabledObject;
  24281. type: number;
  24282. private _options;
  24283. private _scene;
  24284. static DEFAULT_OBJECT_SIZE: Vector3;
  24285. static IDENTITY_QUATERNION: Quaternion;
  24286. private _physicsEngine;
  24287. private _physicsBody;
  24288. private _bodyUpdateRequired;
  24289. private _onBeforePhysicsStepCallbacks;
  24290. private _onAfterPhysicsStepCallbacks;
  24291. private _onPhysicsCollideCallbacks;
  24292. private _deltaPosition;
  24293. private _deltaRotation;
  24294. private _deltaRotationConjugated;
  24295. private _parent;
  24296. private _isDisposed;
  24297. private static _tmpVecs;
  24298. private static _tmpQuat;
  24299. readonly isDisposed: boolean;
  24300. mass: number;
  24301. friction: number;
  24302. restitution: number;
  24303. uniqueId: number;
  24304. private _joints;
  24305. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24306. /**
  24307. * This function will completly initialize this impostor.
  24308. * It will create a new body - but only if this mesh has no parent.
  24309. * If it has, this impostor will not be used other than to define the impostor
  24310. * of the child mesh.
  24311. */
  24312. _init(): void;
  24313. private _getPhysicsParent();
  24314. /**
  24315. * Should a new body be generated.
  24316. */
  24317. isBodyInitRequired(): boolean;
  24318. setScalingUpdated(updated: boolean): void;
  24319. /**
  24320. * Force a regeneration of this or the parent's impostor's body.
  24321. * Use under cautious - This will remove all joints already implemented.
  24322. */
  24323. forceUpdate(): void;
  24324. /**
  24325. * Gets the body that holds this impostor. Either its own, or its parent.
  24326. */
  24327. /**
  24328. * Set the physics body. Used mainly by the physics engine/plugin
  24329. */
  24330. physicsBody: any;
  24331. parent: Nullable<PhysicsImpostor>;
  24332. resetUpdateFlags(): void;
  24333. getObjectExtendSize(): Vector3;
  24334. getObjectCenter(): Vector3;
  24335. /**
  24336. * Get a specific parametes from the options parameter.
  24337. */
  24338. getParam(paramName: string): any;
  24339. /**
  24340. * Sets a specific parameter in the options given to the physics plugin
  24341. */
  24342. setParam(paramName: string, value: number): void;
  24343. /**
  24344. * Specifically change the body's mass option. Won't recreate the physics body object
  24345. */
  24346. setMass(mass: number): void;
  24347. getLinearVelocity(): Nullable<Vector3>;
  24348. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24349. getAngularVelocity(): Nullable<Vector3>;
  24350. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24351. /**
  24352. * Execute a function with the physics plugin native code.
  24353. * Provide a function the will have two variables - the world object and the physics body object.
  24354. */
  24355. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24356. /**
  24357. * Register a function that will be executed before the physics world is stepping forward.
  24358. */
  24359. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24360. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24361. /**
  24362. * Register a function that will be executed after the physics step
  24363. */
  24364. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24365. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24366. /**
  24367. * register a function that will be executed when this impostor collides against a different body.
  24368. */
  24369. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24370. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24371. private _tmpQuat;
  24372. private _tmpQuat2;
  24373. getParentsRotation(): Quaternion;
  24374. /**
  24375. * this function is executed by the physics engine.
  24376. */
  24377. beforeStep: () => void;
  24378. /**
  24379. * this function is executed by the physics engine.
  24380. */
  24381. afterStep: () => void;
  24382. /**
  24383. * Legacy collision detection event support
  24384. */
  24385. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24386. onCollide: (e: {
  24387. body: any;
  24388. }) => void;
  24389. /**
  24390. * Apply a force
  24391. */
  24392. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24393. /**
  24394. * Apply an impulse
  24395. */
  24396. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24397. /**
  24398. * A help function to create a joint.
  24399. */
  24400. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24401. /**
  24402. * Add a joint to this impostor with a different impostor.
  24403. */
  24404. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24405. /**
  24406. * Will keep this body still, in a sleep mode.
  24407. */
  24408. sleep(): PhysicsImpostor;
  24409. /**
  24410. * Wake the body up.
  24411. */
  24412. wakeUp(): PhysicsImpostor;
  24413. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24414. dispose(): void;
  24415. setDeltaPosition(position: Vector3): void;
  24416. setDeltaRotation(rotation: Quaternion): void;
  24417. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24418. getRadius(): number;
  24419. /**
  24420. * Sync a bone with this impostor
  24421. * @param bone The bone to sync to the impostor.
  24422. * @param boneMesh The mesh that the bone is influencing.
  24423. * @param jointPivot The pivot of the joint / bone in local space.
  24424. * @param distToJoint Optional distance from the impostor to the joint.
  24425. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24426. */
  24427. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24428. /**
  24429. * Sync impostor to a bone
  24430. * @param bone The bone that the impostor will be synced to.
  24431. * @param boneMesh The mesh that the bone is influencing.
  24432. * @param jointPivot The pivot of the joint / bone in local space.
  24433. * @param distToJoint Optional distance from the impostor to the joint.
  24434. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24435. * @param boneAxis Optional vector3 axis the bone is aligned with
  24436. */
  24437. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24438. static NoImpostor: number;
  24439. static SphereImpostor: number;
  24440. static BoxImpostor: number;
  24441. static PlaneImpostor: number;
  24442. static MeshImpostor: number;
  24443. static CylinderImpostor: number;
  24444. static ParticleImpostor: number;
  24445. static HeightmapImpostor: number;
  24446. }
  24447. }
  24448. declare module BABYLON {
  24449. interface PhysicsJointData {
  24450. mainPivot?: Vector3;
  24451. connectedPivot?: Vector3;
  24452. mainAxis?: Vector3;
  24453. connectedAxis?: Vector3;
  24454. collision?: boolean;
  24455. nativeParams?: any;
  24456. }
  24457. /**
  24458. * This is a holder class for the physics joint created by the physics plugin.
  24459. * It holds a set of functions to control the underlying joint.
  24460. */
  24461. class PhysicsJoint {
  24462. type: number;
  24463. jointData: PhysicsJointData;
  24464. private _physicsJoint;
  24465. protected _physicsPlugin: IPhysicsEnginePlugin;
  24466. constructor(type: number, jointData: PhysicsJointData);
  24467. physicsJoint: any;
  24468. physicsPlugin: IPhysicsEnginePlugin;
  24469. /**
  24470. * Execute a function that is physics-plugin specific.
  24471. * @param {Function} func the function that will be executed.
  24472. * It accepts two parameters: the physics world and the physics joint.
  24473. */
  24474. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24475. static DistanceJoint: number;
  24476. static HingeJoint: number;
  24477. static BallAndSocketJoint: number;
  24478. static WheelJoint: number;
  24479. static SliderJoint: number;
  24480. static PrismaticJoint: number;
  24481. static UniversalJoint: number;
  24482. static Hinge2Joint: number;
  24483. static PointToPointJoint: number;
  24484. static SpringJoint: number;
  24485. static LockJoint: number;
  24486. }
  24487. /**
  24488. * A class representing a physics distance joint.
  24489. */
  24490. class DistanceJoint extends PhysicsJoint {
  24491. constructor(jointData: DistanceJointData);
  24492. /**
  24493. * Update the predefined distance.
  24494. */
  24495. updateDistance(maxDistance: number, minDistance?: number): void;
  24496. }
  24497. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24498. constructor(type: number, jointData: PhysicsJointData);
  24499. /**
  24500. * Set the motor values.
  24501. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24502. * @param {number} force the force to apply
  24503. * @param {number} maxForce max force for this motor.
  24504. */
  24505. setMotor(force?: number, maxForce?: number): void;
  24506. /**
  24507. * Set the motor's limits.
  24508. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24509. */
  24510. setLimit(upperLimit: number, lowerLimit?: number): void;
  24511. }
  24512. /**
  24513. * This class represents a single hinge physics joint
  24514. */
  24515. class HingeJoint extends MotorEnabledJoint {
  24516. constructor(jointData: PhysicsJointData);
  24517. /**
  24518. * Set the motor values.
  24519. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24520. * @param {number} force the force to apply
  24521. * @param {number} maxForce max force for this motor.
  24522. */
  24523. setMotor(force?: number, maxForce?: number): void;
  24524. /**
  24525. * Set the motor's limits.
  24526. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24527. */
  24528. setLimit(upperLimit: number, lowerLimit?: number): void;
  24529. }
  24530. /**
  24531. * This class represents a dual hinge physics joint (same as wheel joint)
  24532. */
  24533. class Hinge2Joint extends MotorEnabledJoint {
  24534. constructor(jointData: PhysicsJointData);
  24535. /**
  24536. * Set the motor values.
  24537. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24538. * @param {number} force the force to apply
  24539. * @param {number} maxForce max force for this motor.
  24540. * @param {motorIndex} the motor's index, 0 or 1.
  24541. */
  24542. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24543. /**
  24544. * Set the motor limits.
  24545. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24546. * @param {number} upperLimit the upper limit
  24547. * @param {number} lowerLimit lower limit
  24548. * @param {motorIndex} the motor's index, 0 or 1.
  24549. */
  24550. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24551. }
  24552. interface IMotorEnabledJoint {
  24553. physicsJoint: any;
  24554. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24555. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24556. }
  24557. interface DistanceJointData extends PhysicsJointData {
  24558. maxDistance: number;
  24559. }
  24560. interface SpringJointData extends PhysicsJointData {
  24561. length: number;
  24562. stiffness: number;
  24563. damping: number;
  24564. }
  24565. }
  24566. declare module BABYLON {
  24567. /**
  24568. * This represents a GPU particle system in Babylon
  24569. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  24570. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  24571. */
  24572. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  24573. /**
  24574. * The id of the Particle system.
  24575. */
  24576. id: string;
  24577. /**
  24578. * The friendly name of the Particle system.
  24579. */
  24580. name: string;
  24581. /**
  24582. * The emitter represents the Mesh or position we are attaching the particle system to.
  24583. */
  24584. emitter: Nullable<AbstractMesh | Vector3>;
  24585. /**
  24586. * The rendering group used by the Particle system to chose when to render.
  24587. */
  24588. renderingGroupId: number;
  24589. /**
  24590. * The layer mask we are rendering the particles through.
  24591. */
  24592. layerMask: number;
  24593. private _capacity;
  24594. private _activeCount;
  24595. private _currentActiveCount;
  24596. private _accumulatedCount;
  24597. private _renderEffect;
  24598. private _updateEffect;
  24599. private _buffer0;
  24600. private _buffer1;
  24601. private _spriteBuffer;
  24602. private _updateVAO;
  24603. private _renderVAO;
  24604. private _targetIndex;
  24605. private _sourceBuffer;
  24606. private _targetBuffer;
  24607. private _scene;
  24608. private _engine;
  24609. private _currentRenderId;
  24610. private _started;
  24611. private _stopped;
  24612. private _timeDelta;
  24613. private _randomTexture;
  24614. private _randomTexture2;
  24615. private _attributesStrideSize;
  24616. private _updateEffectOptions;
  24617. private _randomTextureSize;
  24618. private _actualFrame;
  24619. private readonly _rawTextureWidth;
  24620. /**
  24621. * List of animations used by the particle system.
  24622. */
  24623. animations: Animation[];
  24624. /**
  24625. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  24626. */
  24627. static readonly IsSupported: boolean;
  24628. /**
  24629. * An event triggered when the system is disposed.
  24630. */
  24631. onDisposeObservable: Observable<GPUParticleSystem>;
  24632. /**
  24633. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  24634. */
  24635. updateSpeed: number;
  24636. /**
  24637. * The amount of time the particle system is running (depends of the overall update speed).
  24638. */
  24639. targetStopDuration: number;
  24640. /**
  24641. * The texture used to render each particle. (this can be a spritesheet)
  24642. */
  24643. particleTexture: Nullable<Texture>;
  24644. /**
  24645. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  24646. */
  24647. blendMode: number;
  24648. /**
  24649. * Minimum life time of emitting particles.
  24650. */
  24651. minLifeTime: number;
  24652. /**
  24653. * Maximum life time of emitting particles.
  24654. */
  24655. maxLifeTime: number;
  24656. /**
  24657. * Minimum Size of emitting particles.
  24658. */
  24659. minSize: number;
  24660. /**
  24661. * Maximum Size of emitting particles.
  24662. */
  24663. maxSize: number;
  24664. /**
  24665. * Minimum scale of emitting particles on X axis.
  24666. */
  24667. minScaleX: number;
  24668. /**
  24669. * Maximum scale of emitting particles on X axis.
  24670. */
  24671. maxScaleX: number;
  24672. /**
  24673. * Minimum scale of emitting particles on Y axis.
  24674. */
  24675. minScaleY: number;
  24676. /**
  24677. * Maximum scale of emitting particles on Y axis.
  24678. */
  24679. maxScaleY: number;
  24680. /**
  24681. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24682. */
  24683. color1: Color4;
  24684. /**
  24685. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  24686. */
  24687. color2: Color4;
  24688. /**
  24689. * Color the particle will have at the end of its lifetime.
  24690. */
  24691. colorDead: Color4;
  24692. /**
  24693. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  24694. */
  24695. emitRate: number;
  24696. /**
  24697. * You can use gravity if you want to give an orientation to your particles.
  24698. */
  24699. gravity: Vector3;
  24700. /**
  24701. * Minimum power of emitting particles.
  24702. */
  24703. minEmitPower: number;
  24704. /**
  24705. * Maximum power of emitting particles.
  24706. */
  24707. maxEmitPower: number;
  24708. /**
  24709. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  24710. */
  24711. minAngularSpeed: number;
  24712. /**
  24713. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  24714. */
  24715. maxAngularSpeed: number;
  24716. /**
  24717. * The particle emitter type defines the emitter used by the particle system.
  24718. * It can be for example box, sphere, or cone...
  24719. */
  24720. particleEmitterType: Nullable<IParticleEmitterType>;
  24721. /**
  24722. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24723. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24724. */
  24725. direction1: Vector3;
  24726. /**
  24727. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  24728. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24729. */
  24730. direction2: Vector3;
  24731. /**
  24732. * 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.
  24733. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24734. */
  24735. minEmitBox: Vector3;
  24736. /**
  24737. * 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.
  24738. * This only works when particleEmitterTyps is a BoxParticleEmitter
  24739. */
  24740. maxEmitBox: Vector3;
  24741. /**
  24742. * Gets the maximum number of particles active at the same time.
  24743. * @returns The max number of active particles.
  24744. */
  24745. getCapacity(): number;
  24746. /**
  24747. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  24748. * to override the particles.
  24749. */
  24750. forceDepthWrite: boolean;
  24751. /**
  24752. * Gets or set the number of active particles
  24753. */
  24754. activeParticleCount: number;
  24755. private _preWarmDone;
  24756. /** 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 */
  24757. preWarmCycles: number;
  24758. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  24759. preWarmStepOffset: number;
  24760. /**
  24761. * Gets or sets the minimal initial rotation in radians.
  24762. */
  24763. minInitialRotation: number;
  24764. /**
  24765. * Gets or sets the maximal initial rotation in radians.
  24766. */
  24767. maxInitialRotation: number;
  24768. /**
  24769. * 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)
  24770. */
  24771. spriteCellChangeSpeed: number;
  24772. /**
  24773. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  24774. */
  24775. startSpriteCellID: number;
  24776. /**
  24777. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  24778. */
  24779. endSpriteCellID: number;
  24780. /**
  24781. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  24782. */
  24783. spriteCellWidth: number;
  24784. /**
  24785. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  24786. */
  24787. spriteCellHeight: number;
  24788. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  24789. translationPivot: Vector2;
  24790. /**
  24791. * Gets or sets a texture used to add random noise to particle positions
  24792. */
  24793. noiseTexture: Nullable<BaseTexture>;
  24794. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  24795. noiseStrength: Vector3;
  24796. /**
  24797. * Gets or sets the billboard mode to use when isBillboardBased = true.
  24798. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  24799. */
  24800. billboardMode: number;
  24801. private _isAnimationSheetEnabled;
  24802. /**
  24803. * Gets whether an animation sprite sheet is enabled or not on the particle system
  24804. */
  24805. readonly isAnimationSheetEnabled: boolean;
  24806. /**
  24807. * Is this system ready to be used/rendered
  24808. * @return true if the system is ready
  24809. */
  24810. isReady(): boolean;
  24811. /**
  24812. * Gets Wether the system has been started.
  24813. * @returns True if it has been started, otherwise false.
  24814. */
  24815. isStarted(): boolean;
  24816. /**
  24817. * Starts the particle system and begins to emit
  24818. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  24819. */
  24820. start(delay?: number): void;
  24821. /**
  24822. * Stops the particle system.
  24823. */
  24824. stop(): void;
  24825. /**
  24826. * Remove all active particles
  24827. */
  24828. reset(): void;
  24829. /**
  24830. * Returns the string "GPUParticleSystem"
  24831. * @returns a string containing the class name
  24832. */
  24833. getClassName(): string;
  24834. private _isBillboardBased;
  24835. /**
  24836. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  24837. */
  24838. isBillboardBased: boolean;
  24839. private _colorGradients;
  24840. private _colorGradientsTexture;
  24841. /**
  24842. * Gets the current list of color gradients.
  24843. * You must use addColorGradient and removeColorGradient to udpate this list
  24844. * @returns the list of color gradients
  24845. */
  24846. getColorGradients(): Nullable<Array<ColorGradient>>;
  24847. /**
  24848. * Gets the current list of size gradients.
  24849. * You must use addSizeGradient and removeSizeGradient to udpate this list
  24850. * @returns the list of size gradients
  24851. */
  24852. getSizeGradients(): Nullable<Array<FactorGradient>>;
  24853. /**
  24854. * Gets the current list of angular speed gradients.
  24855. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  24856. * @returns the list of angular speed gradients
  24857. */
  24858. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  24859. /**
  24860. * Gets the current list of velocity gradients.
  24861. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  24862. * @returns the list of angular speed gradients
  24863. */
  24864. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  24865. private _removeGradient(gradient, gradients, texture);
  24866. /**
  24867. * Adds a new color gradient
  24868. * @param gradient defines the gradient to use (between 0 and 1)
  24869. * @param color defines the color to affect to the specified gradient
  24870. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  24871. * @returns the current particle system
  24872. */
  24873. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  24874. /**
  24875. * Remove a specific color gradient
  24876. * @param gradient defines the gradient to remove
  24877. * @returns the current particle system
  24878. */
  24879. removeColorGradient(gradient: number): GPUParticleSystem;
  24880. private _angularSpeedGradients;
  24881. private _angularSpeedGradientsTexture;
  24882. private _sizeGradients;
  24883. private _sizeGradientsTexture;
  24884. private _velocityGradients;
  24885. private _velocityGradientsTexture;
  24886. private _addFactorGradient(factorGradients, gradient, factor);
  24887. /**
  24888. * Adds a new size gradient
  24889. * @param gradient defines the gradient to use (between 0 and 1)
  24890. * @param factor defines the size factor to affect to the specified gradient
  24891. * @returns the current particle system
  24892. */
  24893. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  24894. /**
  24895. * Remove a specific size gradient
  24896. * @param gradient defines the gradient to remove
  24897. * @returns the current particle system
  24898. */
  24899. removeSizeGradient(gradient: number): GPUParticleSystem;
  24900. /**
  24901. * Adds a new angular speed gradient
  24902. * @param gradient defines the gradient to use (between 0 and 1)
  24903. * @param factor defines the size factor to affect to the specified gradient
  24904. * @returns the current particle system
  24905. */
  24906. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  24907. /**
  24908. * Remove a specific angular speed gradient
  24909. * @param gradient defines the gradient to remove
  24910. * @returns the current particle system
  24911. */
  24912. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  24913. /**
  24914. * Adds a new velocity gradient
  24915. * @param gradient defines the gradient to use (between 0 and 1)
  24916. * @param factor defines the size factor to affect to the specified gradient
  24917. * @returns the current particle system
  24918. */
  24919. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  24920. /**
  24921. * Remove a specific velocity gradient
  24922. * @param gradient defines the gradient to remove
  24923. * @returns the current particle system
  24924. */
  24925. removeVelocityGradient(gradient: number): GPUParticleSystem;
  24926. /**
  24927. * Instantiates a GPU particle system.
  24928. * 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.
  24929. * @param name The name of the particle system
  24930. * @param options The options used to create the system
  24931. * @param scene The scene the particle system belongs to
  24932. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  24933. */
  24934. constructor(name: string, options: Partial<{
  24935. capacity: number;
  24936. randomTextureSize: number;
  24937. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  24938. private _createUpdateVAO(source);
  24939. private _createRenderVAO(source, spriteSource);
  24940. private _initialize(force?);
  24941. /** @hidden */
  24942. _recreateUpdateEffect(): void;
  24943. /** @hidden */
  24944. _recreateRenderEffect(): void;
  24945. /**
  24946. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  24947. * @param preWarm defines if we are in the pre-warmimg phase
  24948. */
  24949. animate(preWarm?: boolean): void;
  24950. private _createFactorGradientTexture(factorGradients, textureName);
  24951. private _createSizeGradientTexture();
  24952. private _createAngularSpeedGradientTexture();
  24953. private _createVelocityGradientTexture();
  24954. private _createColorGradientTexture();
  24955. /**
  24956. * Renders the particle system in its current state
  24957. * @param preWarm defines if the system should only update the particles but not render them
  24958. * @returns the current number of particles
  24959. */
  24960. render(preWarm?: boolean): number;
  24961. /**
  24962. * Rebuilds the particle system
  24963. */
  24964. rebuild(): void;
  24965. private _releaseBuffers();
  24966. private _releaseVAOs();
  24967. /**
  24968. * Disposes the particle system and free the associated resources
  24969. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  24970. */
  24971. dispose(disposeTexture?: boolean): void;
  24972. /**
  24973. * Clones the particle system.
  24974. * @param name The name of the cloned object
  24975. * @param newEmitter The new emitter to use
  24976. * @returns the cloned particle system
  24977. */
  24978. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  24979. /**
  24980. * Serializes the particle system to a JSON object.
  24981. * @returns the JSON object
  24982. */
  24983. serialize(): any;
  24984. /**
  24985. * Parses a JSON object to create a GPU particle system.
  24986. * @param parsedParticleSystem The JSON object to parse
  24987. * @param scene The scene to create the particle system in
  24988. * @param rootUrl The root url to use to load external dependencies like texture
  24989. * @returns the parsed GPU particle system
  24990. */
  24991. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  24992. }
  24993. }
  24994. declare module BABYLON {
  24995. /**
  24996. * Interface representing a particle system in Babylon.js.
  24997. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  24998. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  24999. */
  25000. interface IParticleSystem {
  25001. /**
  25002. * List of animations used by the particle system.
  25003. */
  25004. animations: Animation[];
  25005. /**
  25006. * The id of the Particle system.
  25007. */
  25008. id: string;
  25009. /**
  25010. * The name of the Particle system.
  25011. */
  25012. name: string;
  25013. /**
  25014. * The emitter represents the Mesh or position we are attaching the particle system to.
  25015. */
  25016. emitter: Nullable<AbstractMesh | Vector3>;
  25017. /**
  25018. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  25019. */
  25020. isBillboardBased: boolean;
  25021. /**
  25022. * The rendering group used by the Particle system to chose when to render.
  25023. */
  25024. renderingGroupId: number;
  25025. /**
  25026. * The layer mask we are rendering the particles through.
  25027. */
  25028. layerMask: number;
  25029. /**
  25030. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  25031. */
  25032. updateSpeed: number;
  25033. /**
  25034. * The amount of time the particle system is running (depends of the overall update speed).
  25035. */
  25036. targetStopDuration: number;
  25037. /**
  25038. * The texture used to render each particle. (this can be a spritesheet)
  25039. */
  25040. particleTexture: Nullable<Texture>;
  25041. /**
  25042. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  25043. */
  25044. blendMode: number;
  25045. /**
  25046. * Minimum life time of emitting particles.
  25047. */
  25048. minLifeTime: number;
  25049. /**
  25050. * Maximum life time of emitting particles.
  25051. */
  25052. maxLifeTime: number;
  25053. /**
  25054. * Minimum Size of emitting particles.
  25055. */
  25056. minSize: number;
  25057. /**
  25058. * Maximum Size of emitting particles.
  25059. */
  25060. maxSize: number;
  25061. /**
  25062. * Minimum scale of emitting particles on X axis.
  25063. */
  25064. minScaleX: number;
  25065. /**
  25066. * Maximum scale of emitting particles on X axis.
  25067. */
  25068. maxScaleX: number;
  25069. /**
  25070. * Minimum scale of emitting particles on Y axis.
  25071. */
  25072. minScaleY: number;
  25073. /**
  25074. * Maximum scale of emitting particles on Y axis.
  25075. */
  25076. maxScaleY: number;
  25077. /**
  25078. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25079. */
  25080. color1: Color4;
  25081. /**
  25082. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  25083. */
  25084. color2: Color4;
  25085. /**
  25086. * Color the particle will have at the end of its lifetime.
  25087. */
  25088. colorDead: Color4;
  25089. /**
  25090. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  25091. */
  25092. emitRate: number;
  25093. /**
  25094. * You can use gravity if you want to give an orientation to your particles.
  25095. */
  25096. gravity: Vector3;
  25097. /**
  25098. * Minimum power of emitting particles.
  25099. */
  25100. minEmitPower: number;
  25101. /**
  25102. * Maximum power of emitting particles.
  25103. */
  25104. maxEmitPower: number;
  25105. /**
  25106. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  25107. */
  25108. minAngularSpeed: number;
  25109. /**
  25110. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  25111. */
  25112. maxAngularSpeed: number;
  25113. /**
  25114. * Gets or sets the minimal initial rotation in radians.
  25115. */
  25116. minInitialRotation: number;
  25117. /**
  25118. * Gets or sets the maximal initial rotation in radians.
  25119. */
  25120. maxInitialRotation: number;
  25121. /**
  25122. * The particle emitter type defines the emitter used by the particle system.
  25123. * It can be for example box, sphere, or cone...
  25124. */
  25125. particleEmitterType: Nullable<IParticleEmitterType>;
  25126. /**
  25127. * 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
  25128. */
  25129. preWarmCycles: number;
  25130. /**
  25131. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  25132. */
  25133. preWarmStepOffset: number;
  25134. /**
  25135. * 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)
  25136. */
  25137. spriteCellChangeSpeed: number;
  25138. /**
  25139. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  25140. */
  25141. startSpriteCellID: number;
  25142. /**
  25143. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  25144. */
  25145. endSpriteCellID: number;
  25146. /**
  25147. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  25148. */
  25149. spriteCellWidth: number;
  25150. /**
  25151. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  25152. */
  25153. spriteCellHeight: number;
  25154. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  25155. translationPivot: Vector2;
  25156. /**
  25157. * Gets or sets a texture used to add random noise to particle positions
  25158. */
  25159. noiseTexture: Nullable<BaseTexture>;
  25160. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  25161. noiseStrength: Vector3;
  25162. /**
  25163. * Gets or sets the billboard mode to use when isBillboardBased = true.
  25164. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  25165. */
  25166. billboardMode: number;
  25167. /**
  25168. * Gets the maximum number of particles active at the same time.
  25169. * @returns The max number of active particles.
  25170. */
  25171. getCapacity(): number;
  25172. /**
  25173. * Gets Wether the system has been started.
  25174. * @returns True if it has been started, otherwise false.
  25175. */
  25176. isStarted(): boolean;
  25177. /**
  25178. * Gets if the particle system has been started.
  25179. * @return true if the system has been started, otherwise false.
  25180. */
  25181. isStarted(): boolean;
  25182. /**
  25183. * Animates the particle system for this frame.
  25184. */
  25185. animate(): void;
  25186. /**
  25187. * Renders the particle system in its current state.
  25188. * @returns the current number of particles
  25189. */
  25190. render(): number;
  25191. /**
  25192. * Dispose the particle system and frees its associated resources.
  25193. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25194. */
  25195. dispose(disposeTexture?: boolean): void;
  25196. /**
  25197. * Clones the particle system.
  25198. * @param name The name of the cloned object
  25199. * @param newEmitter The new emitter to use
  25200. * @returns the cloned particle system
  25201. */
  25202. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  25203. /**
  25204. * Serializes the particle system to a JSON object.
  25205. * @returns the JSON object
  25206. */
  25207. serialize(): any;
  25208. /**
  25209. * Rebuild the particle system
  25210. */
  25211. rebuild(): void;
  25212. /**
  25213. * Starts the particle system and begins to emit
  25214. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  25215. */
  25216. start(delay?: number): void;
  25217. /**
  25218. * Stops the particle system.
  25219. */
  25220. stop(): void;
  25221. /**
  25222. * Remove all active particles
  25223. */
  25224. reset(): void;
  25225. /**
  25226. * Is this system ready to be used/rendered
  25227. * @return true if the system is ready
  25228. */
  25229. isReady(): boolean;
  25230. /**
  25231. * Adds a new color gradient
  25232. * @param gradient defines the gradient to use (between 0 and 1)
  25233. * @param color defines the color to affect to the specified gradient
  25234. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25235. * @returns the current particle system
  25236. */
  25237. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  25238. /**
  25239. * Remove a specific color gradient
  25240. * @param gradient defines the gradient to remove
  25241. * @returns the current particle system
  25242. */
  25243. removeColorGradient(gradient: number): IParticleSystem;
  25244. /**
  25245. * Adds a new size gradient
  25246. * @param gradient defines the gradient to use (between 0 and 1)
  25247. * @param factor defines the size factor to affect to the specified gradient
  25248. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25249. * @returns the current particle system
  25250. */
  25251. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25252. /**
  25253. * Remove a specific size gradient
  25254. * @param gradient defines the gradient to remove
  25255. * @returns the current particle system
  25256. */
  25257. removeSizeGradient(gradient: number): IParticleSystem;
  25258. /**
  25259. * Gets the current list of color gradients.
  25260. * You must use addColorGradient and removeColorGradient to udpate this list
  25261. * @returns the list of color gradients
  25262. */
  25263. getColorGradients(): Nullable<Array<ColorGradient>>;
  25264. /**
  25265. * Gets the current list of size gradients.
  25266. * You must use addSizeGradient and removeSizeGradient to udpate this list
  25267. * @returns the list of size gradients
  25268. */
  25269. getSizeGradients(): Nullable<Array<FactorGradient>>;
  25270. /**
  25271. * Gets the current list of angular speed gradients.
  25272. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  25273. * @returns the list of angular speed gradients
  25274. */
  25275. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  25276. /**
  25277. * Adds a new angular speed gradient
  25278. * @param gradient defines the gradient to use (between 0 and 1)
  25279. * @param factor defines the size factor to affect to the specified gradient
  25280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25281. * @returns the current particle system
  25282. */
  25283. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25284. /**
  25285. * Remove a specific angular speed gradient
  25286. * @param gradient defines the gradient to remove
  25287. * @returns the current particle system
  25288. */
  25289. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  25290. /**
  25291. * Gets the current list of velocity gradients.
  25292. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  25293. * @returns the list of velocity gradients
  25294. */
  25295. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  25296. /**
  25297. * Adds a new velocity gradient
  25298. * @param gradient defines the gradient to use (between 0 and 1)
  25299. * @param factor defines the size factor to affect to the specified gradient
  25300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25301. * @returns the current particle system
  25302. */
  25303. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  25304. /**
  25305. * Remove a specific velocity gradient
  25306. * @param gradient defines the gradient to remove
  25307. * @returns the current particle system
  25308. */
  25309. removeVelocityGradient(gradient: number): IParticleSystem;
  25310. }
  25311. }
  25312. declare module BABYLON {
  25313. /**
  25314. * A particle represents one of the element emitted by a particle system.
  25315. * This is mainly define by its coordinates, direction, velocity and age.
  25316. */
  25317. class Particle {
  25318. /**
  25319. * particleSystem the particle system the particle belongs to.
  25320. */
  25321. particleSystem: ParticleSystem;
  25322. /**
  25323. * The world position of the particle in the scene.
  25324. */
  25325. position: Vector3;
  25326. /**
  25327. * The world direction of the particle in the scene.
  25328. */
  25329. direction: Vector3;
  25330. /**
  25331. * The color of the particle.
  25332. */
  25333. color: Color4;
  25334. /**
  25335. * The color change of the particle per step.
  25336. */
  25337. colorStep: Color4;
  25338. /**
  25339. * Defines how long will the life of the particle be.
  25340. */
  25341. lifeTime: number;
  25342. /**
  25343. * The current age of the particle.
  25344. */
  25345. age: number;
  25346. /**
  25347. * The current size of the particle.
  25348. */
  25349. size: number;
  25350. /**
  25351. * The current scale of the particle.
  25352. */
  25353. scale: Vector2;
  25354. /**
  25355. * The current angle of the particle.
  25356. */
  25357. angle: number;
  25358. /**
  25359. * Defines how fast is the angle changing.
  25360. */
  25361. angularSpeed: number;
  25362. /**
  25363. * Defines the cell index used by the particle to be rendered from a sprite.
  25364. */
  25365. cellIndex: number;
  25366. /** @hidden */
  25367. _initialDirection: Nullable<Vector3>;
  25368. /** @hidden */
  25369. _initialStartSpriteCellID: number;
  25370. _initialEndSpriteCellID: number;
  25371. /** @hidden */
  25372. _currentColorGradient: Nullable<ColorGradient>;
  25373. /** @hidden */
  25374. _currentColor1: Color4;
  25375. /** @hidden */
  25376. _currentColor2: Color4;
  25377. /** @hidden */
  25378. _currentSizeGradient: Nullable<FactorGradient>;
  25379. /** @hidden */
  25380. _currentSize1: number;
  25381. /** @hidden */
  25382. _currentSize2: number;
  25383. /** @hidden */
  25384. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  25385. /** @hidden */
  25386. _currentAngularSpeed1: number;
  25387. /** @hidden */
  25388. _currentAngularSpeed2: number;
  25389. /** @hidden */
  25390. _currentVelocityGradient: Nullable<FactorGradient>;
  25391. /** @hidden */
  25392. _currentVelocity1: number;
  25393. /** @hidden */
  25394. _currentVelocity2: number;
  25395. /**
  25396. * Creates a new instance Particle
  25397. * @param particleSystem the particle system the particle belongs to
  25398. */
  25399. constructor(
  25400. /**
  25401. * particleSystem the particle system the particle belongs to.
  25402. */
  25403. particleSystem: ParticleSystem);
  25404. private updateCellInfoFromSystem();
  25405. /**
  25406. * Defines how the sprite cell index is updated for the particle
  25407. */
  25408. updateCellIndex(): void;
  25409. /**
  25410. * Copy the properties of particle to another one.
  25411. * @param other the particle to copy the information to.
  25412. */
  25413. copyTo(other: Particle): void;
  25414. }
  25415. }
  25416. declare module BABYLON {
  25417. /**
  25418. * This class is made for on one-liner static method to help creating particle system set.
  25419. */
  25420. class ParticleHelper {
  25421. /**
  25422. * Gets or sets base Assets URL
  25423. */
  25424. static BaseAssetsUrl: string;
  25425. /**
  25426. * Create a default particle system that you can tweak
  25427. * @param emitter defines the emitter to use
  25428. * @param capacity defines the system capacity (default is 500 particles)
  25429. * @param scene defines the hosting scene
  25430. * @returns the new Particle system
  25431. */
  25432. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene): ParticleSystem;
  25433. /**
  25434. * This is the main static method (one-liner) of this helper to create different particle systems
  25435. * @param type This string represents the type to the particle system to create
  25436. * @param scene The scene where the particle system should live
  25437. * @param gpu If the system will use gpu
  25438. * @returns the ParticleSystemSet created
  25439. */
  25440. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  25441. /**
  25442. * Static function used to export a particle system to a ParticleSystemSet variable.
  25443. * Please note that the emitter shape is not exported
  25444. * @param system defines the particle systems to export
  25445. */
  25446. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  25447. }
  25448. }
  25449. declare module BABYLON {
  25450. /**
  25451. * This represents a particle system in Babylon.
  25452. * 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.
  25453. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  25454. * @example https://doc.babylonjs.com/babylon101/particles
  25455. */
  25456. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  25457. /**
  25458. * Source color is added to the destination color without alpha affecting the result.
  25459. */
  25460. static BLENDMODE_ONEONE: number;
  25461. /**
  25462. * Blend current color and particle color using particle’s alpha.
  25463. */
  25464. static BLENDMODE_STANDARD: number;
  25465. /**
  25466. * Add current color and particle color multiplied by particle’s alpha.
  25467. */
  25468. static BLENDMODE_ADD: number;
  25469. /**
  25470. * List of animations used by the particle system.
  25471. */
  25472. animations: Animation[];
  25473. /**
  25474. * The id of the Particle system.
  25475. */
  25476. id: string;
  25477. /**
  25478. * The friendly name of the Particle system.
  25479. */
  25480. name: string;
  25481. /**
  25482. * The rendering group used by the Particle system to chose when to render.
  25483. */
  25484. renderingGroupId: number;
  25485. /**
  25486. * The emitter represents the Mesh or position we are attaching the particle system to.
  25487. */
  25488. emitter: Nullable<AbstractMesh | Vector3>;
  25489. /**
  25490. * The maximum number of particles to emit per frame
  25491. */
  25492. emitRate: number;
  25493. /**
  25494. * If you want to launch only a few particles at once, that can be done, as well.
  25495. */
  25496. manualEmitCount: number;
  25497. /**
  25498. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  25499. */
  25500. updateSpeed: number;
  25501. /**
  25502. * The amount of time the particle system is running (depends of the overall update speed).
  25503. */
  25504. targetStopDuration: number;
  25505. /**
  25506. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  25507. */
  25508. disposeOnStop: boolean;
  25509. /**
  25510. * Minimum power of emitting particles.
  25511. */
  25512. minEmitPower: number;
  25513. /**
  25514. * Maximum power of emitting particles.
  25515. */
  25516. maxEmitPower: number;
  25517. /**
  25518. * Minimum life time of emitting particles.
  25519. */
  25520. minLifeTime: number;
  25521. /**
  25522. * Maximum life time of emitting particles.
  25523. */
  25524. maxLifeTime: number;
  25525. /**
  25526. * Minimum Size of emitting particles.
  25527. */
  25528. minSize: number;
  25529. /**
  25530. * Maximum Size of emitting particles.
  25531. */
  25532. maxSize: number;
  25533. /**
  25534. * Minimum scale of emitting particles on X axis.
  25535. */
  25536. minScaleX: number;
  25537. /**
  25538. * Maximum scale of emitting particles on X axis.
  25539. */
  25540. maxScaleX: number;
  25541. /**
  25542. * Minimum scale of emitting particles on Y axis.
  25543. */
  25544. minScaleY: number;
  25545. /**
  25546. * Maximum scale of emitting particles on Y axis.
  25547. */
  25548. maxScaleY: number;
  25549. /**
  25550. * Gets or sets the minimal initial rotation in radians.
  25551. */
  25552. minInitialRotation: number;
  25553. /**
  25554. * Gets or sets the maximal initial rotation in radians.
  25555. */
  25556. maxInitialRotation: number;
  25557. /**
  25558. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  25559. */
  25560. minAngularSpeed: number;
  25561. /**
  25562. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  25563. */
  25564. maxAngularSpeed: number;
  25565. /**
  25566. * The texture used to render each particle. (this can be a spritesheet)
  25567. */
  25568. particleTexture: Nullable<Texture>;
  25569. /**
  25570. * The layer mask we are rendering the particles through.
  25571. */
  25572. layerMask: number;
  25573. /**
  25574. * This can help using your own shader to render the particle system.
  25575. * The according effect will be created
  25576. */
  25577. customShader: any;
  25578. /**
  25579. * By default particle system starts as soon as they are created. This prevents the
  25580. * automatic start to happen and let you decide when to start emitting particles.
  25581. */
  25582. preventAutoStart: boolean;
  25583. /**
  25584. * Gets or sets a texture used to add random noise to particle positions
  25585. */
  25586. noiseTexture: Nullable<BaseTexture>;
  25587. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  25588. noiseStrength: Vector3;
  25589. /**
  25590. * This function can be defined to provide custom update for active particles.
  25591. * This function will be called instead of regular update (age, position, color, etc.).
  25592. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  25593. */
  25594. updateFunction: (particles: Particle[]) => void;
  25595. /**
  25596. * Callback triggered when the particle animation is ending.
  25597. */
  25598. onAnimationEnd: Nullable<() => void>;
  25599. /**
  25600. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  25601. */
  25602. blendMode: number;
  25603. /**
  25604. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  25605. * to override the particles.
  25606. */
  25607. forceDepthWrite: boolean;
  25608. /**
  25609. * You can use gravity if you want to give an orientation to your particles.
  25610. */
  25611. gravity: Vector3;
  25612. private _emitterWorldMatrix;
  25613. private _colorGradients;
  25614. private _sizeGradients;
  25615. private _lifeTimeGradients;
  25616. private _angularSpeedGradients;
  25617. private _velocityGradients;
  25618. /**
  25619. * Gets the current list of color gradients.
  25620. * You must use addColorGradient and removeColorGradient to udpate this list
  25621. * @returns the list of color gradients
  25622. */
  25623. getColorGradients(): Nullable<Array<ColorGradient>>;
  25624. /**
  25625. * Gets the current list of size gradients.
  25626. * You must use addSizeGradient and removeSizeGradient to udpate this list
  25627. * @returns the list of size gradients
  25628. */
  25629. getSizeGradients(): Nullable<Array<FactorGradient>>;
  25630. /**
  25631. * Gets the current list of life time gradients.
  25632. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  25633. * @returns the list of life time gradients
  25634. */
  25635. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  25636. /**
  25637. * Gets the current list of angular speed gradients.
  25638. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  25639. * @returns the list of angular speed gradients
  25640. */
  25641. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  25642. /**
  25643. * Gets the current list of velocity gradients.
  25644. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  25645. * @returns the list of velocity gradients
  25646. */
  25647. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  25648. /**
  25649. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  25650. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25651. */
  25652. direction1: Vector3;
  25653. /**
  25654. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  25655. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25656. */
  25657. direction2: Vector3;
  25658. /**
  25659. * 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.
  25660. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25661. */
  25662. minEmitBox: Vector3;
  25663. /**
  25664. * 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.
  25665. * This only works when particleEmitterTyps is a BoxParticleEmitter
  25666. */
  25667. maxEmitBox: Vector3;
  25668. /**
  25669. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  25670. */
  25671. color1: Color4;
  25672. /**
  25673. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  25674. */
  25675. color2: Color4;
  25676. /**
  25677. * Color the particle will have at the end of its lifetime
  25678. */
  25679. colorDead: Color4;
  25680. /**
  25681. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  25682. */
  25683. textureMask: Color4;
  25684. /**
  25685. * The particle emitter type defines the emitter used by the particle system.
  25686. * It can be for example box, sphere, or cone...
  25687. */
  25688. particleEmitterType: IParticleEmitterType;
  25689. /**
  25690. * This function can be defined to specify initial direction for every new particle.
  25691. * It by default use the emitterType defined function
  25692. */
  25693. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  25694. /**
  25695. * This function can be defined to specify initial position for every new particle.
  25696. * It by default use the emitterType defined function
  25697. */
  25698. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  25699. /**
  25700. * 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)
  25701. */
  25702. spriteCellChangeSpeed: number;
  25703. /**
  25704. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  25705. */
  25706. startSpriteCellID: number;
  25707. /**
  25708. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  25709. */
  25710. endSpriteCellID: number;
  25711. /**
  25712. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  25713. */
  25714. spriteCellWidth: number;
  25715. /**
  25716. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  25717. */
  25718. spriteCellHeight: number;
  25719. /** 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 */
  25720. preWarmCycles: number;
  25721. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  25722. preWarmStepOffset: number;
  25723. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  25724. translationPivot: Vector2;
  25725. /**
  25726. * An event triggered when the system is disposed
  25727. */
  25728. onDisposeObservable: Observable<ParticleSystem>;
  25729. private _onDisposeObserver;
  25730. /**
  25731. * Sets a callback that will be triggered when the system is disposed
  25732. */
  25733. onDispose: () => void;
  25734. /**
  25735. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  25736. */
  25737. isAnimationSheetEnabled: boolean;
  25738. /**
  25739. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  25740. */
  25741. isBillboardBased: boolean;
  25742. /**
  25743. * Get hosting scene
  25744. * @returns the scene
  25745. */
  25746. getScene(): Scene;
  25747. /**
  25748. * Gets or sets the billboard mode to use when isBillboardBased = true.
  25749. * Only BABYLON.AbstractMesh.BILLBOARDMODE_ALL and AbstractMesh.BILLBOARDMODE_Y are supported so far
  25750. */
  25751. billboardMode: number;
  25752. private _particles;
  25753. private _epsilon;
  25754. private _capacity;
  25755. private _scene;
  25756. private _stockParticles;
  25757. private _newPartsExcess;
  25758. private _vertexData;
  25759. private _vertexBuffer;
  25760. private _vertexBuffers;
  25761. private _spriteBuffer;
  25762. private _indexBuffer;
  25763. private _effect;
  25764. private _customEffect;
  25765. private _cachedDefines;
  25766. private _scaledColorStep;
  25767. private _colorDiff;
  25768. private _scaledDirection;
  25769. private _scaledGravity;
  25770. private _currentRenderId;
  25771. private _alive;
  25772. private _useInstancing;
  25773. private _started;
  25774. private _stopped;
  25775. private _actualFrame;
  25776. private _scaledUpdateSpeed;
  25777. private _vertexBufferSize;
  25778. private _isAnimationSheetEnabled;
  25779. private _isBillboardBased;
  25780. /**
  25781. * 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.
  25782. */
  25783. subEmitters: ParticleSystem[];
  25784. /**
  25785. * The current active Sub-systems, this property is used by the root particle system only.
  25786. */
  25787. activeSubSystems: Array<ParticleSystem>;
  25788. private _rootParticleSystem;
  25789. /**
  25790. * Gets the current list of active particles
  25791. */
  25792. readonly particles: Particle[];
  25793. /**
  25794. * Returns the string "ParticleSystem"
  25795. * @returns a string containing the class name
  25796. */
  25797. getClassName(): string;
  25798. /**
  25799. * Instantiates a particle system.
  25800. * 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.
  25801. * @param name The name of the particle system
  25802. * @param capacity The max number of particles alive at the same time
  25803. * @param scene The scene the particle system belongs to
  25804. * @param customEffect a custom effect used to change the way particles are rendered by default
  25805. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  25806. * @param epsilon Offset used to render the particles
  25807. */
  25808. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  25809. private _fetchR(u, v, width, height, pixels);
  25810. private _addFactorGradient(factorGradients, gradient, factor, factor2?);
  25811. private _removeFactorGradient(factorGradients, gradient);
  25812. /**
  25813. * Adds a new life time gradient
  25814. * @param gradient defines the gradient to use (between 0 and 1)
  25815. * @param factor defines the life time factor to affect to the specified gradient
  25816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25817. * @returns the current particle system
  25818. */
  25819. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  25820. /**
  25821. * Remove a specific life time gradient
  25822. * @param gradient defines the gradient to remove
  25823. * @returns the current particle system
  25824. */
  25825. removeLifeTimeGradient(gradient: number): ParticleSystem;
  25826. /**
  25827. * Adds a new size gradient
  25828. * @param gradient defines the gradient to use (between 0 and 1)
  25829. * @param factor defines the size factor to affect to the specified gradient
  25830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25831. * @returns the current particle system
  25832. */
  25833. addSizeGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  25834. /**
  25835. * Remove a specific size gradient
  25836. * @param gradient defines the gradient to remove
  25837. * @returns the current particle system
  25838. */
  25839. removeSizeGradient(gradient: number): ParticleSystem;
  25840. /**
  25841. * Adds a new angular speed gradient
  25842. * @param gradient defines the gradient to use (between 0 and 1)
  25843. * @param factor defines the size factor to affect to the specified gradient
  25844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25845. * @returns the current particle system
  25846. */
  25847. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  25848. /**
  25849. * Remove a specific angular speed gradient
  25850. * @param gradient defines the gradient to remove
  25851. * @returns the current particle system
  25852. */
  25853. removeAngularSpeedGradient(gradient: number): ParticleSystem;
  25854. /**
  25855. * Adds a new velocity gradient
  25856. * @param gradient defines the gradient to use (between 0 and 1)
  25857. * @param factor defines the size factor to affect to the specified gradient
  25858. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  25859. * @returns the current particle system
  25860. */
  25861. addVelocityGradient(gradient: number, factor: number, factor2?: number): ParticleSystem;
  25862. /**
  25863. * Remove a specific velocity gradient
  25864. * @param gradient defines the gradient to remove
  25865. * @returns the current particle system
  25866. */
  25867. removeVelocityGradient(gradient: number): ParticleSystem;
  25868. /**
  25869. * Adds a new color gradient
  25870. * @param gradient defines the gradient to use (between 0 and 1)
  25871. * @param color defines the color to affect to the specified gradient
  25872. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  25873. */
  25874. addColorGradient(gradient: number, color: Color4, color2?: Color4): ParticleSystem;
  25875. /**
  25876. * Remove a specific color gradient
  25877. * @param gradient defines the gradient to remove
  25878. */
  25879. removeColorGradient(gradient: number): ParticleSystem;
  25880. private _resetEffect();
  25881. private _createVertexBuffers();
  25882. private _createIndexBuffer();
  25883. /**
  25884. * Gets the maximum number of particles active at the same time.
  25885. * @returns The max number of active particles.
  25886. */
  25887. getCapacity(): number;
  25888. /**
  25889. * Gets Wether there are still active particles in the system.
  25890. * @returns True if it is alive, otherwise false.
  25891. */
  25892. isAlive(): boolean;
  25893. /**
  25894. * Gets Wether the system has been started.
  25895. * @returns True if it has been started, otherwise false.
  25896. */
  25897. isStarted(): boolean;
  25898. /**
  25899. * Starts the particle system and begins to emit
  25900. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  25901. */
  25902. start(delay?: number): void;
  25903. /**
  25904. * Stops the particle system.
  25905. * @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.
  25906. */
  25907. stop(stopSubEmitters?: boolean): void;
  25908. /**
  25909. * Remove all active particles
  25910. */
  25911. reset(): void;
  25912. /**
  25913. * @hidden (for internal use only)
  25914. */
  25915. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  25916. /**
  25917. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  25918. * Its lifetime will start back at 0.
  25919. */
  25920. recycleParticle: (particle: Particle) => void;
  25921. private _stopSubEmitters();
  25922. private _createParticle;
  25923. private _removeFromRoot();
  25924. private _emitFromParticle;
  25925. private _update(newParticles);
  25926. /** @hidden */
  25927. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean): string[];
  25928. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  25929. private _getEffect();
  25930. /**
  25931. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  25932. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  25933. */
  25934. animate(preWarmOnly?: boolean): void;
  25935. private _appendParticleVertices(offset, particle);
  25936. /**
  25937. * Rebuilds the particle system.
  25938. */
  25939. rebuild(): void;
  25940. /**
  25941. * Is this system ready to be used/rendered
  25942. * @return true if the system is ready
  25943. */
  25944. isReady(): boolean;
  25945. /**
  25946. * Renders the particle system in its current state.
  25947. * @returns the current number of particles
  25948. */
  25949. render(): number;
  25950. /**
  25951. * Disposes the particle system and free the associated resources
  25952. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  25953. */
  25954. dispose(disposeTexture?: boolean): void;
  25955. /**
  25956. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  25957. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25958. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25959. * @returns the emitter
  25960. */
  25961. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  25962. /**
  25963. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  25964. * @param radius The radius of the hemisphere to emit from
  25965. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  25966. * @returns the emitter
  25967. */
  25968. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  25969. /**
  25970. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  25971. * @param radius The radius of the sphere to emit from
  25972. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  25973. * @returns the emitter
  25974. */
  25975. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  25976. /**
  25977. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  25978. * @param radius The radius of the sphere to emit from
  25979. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  25980. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  25981. * @returns the emitter
  25982. */
  25983. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  25984. /**
  25985. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  25986. * @param radius The radius of the cone to emit from
  25987. * @param angle The base angle of the cone
  25988. * @returns the emitter
  25989. */
  25990. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  25991. /**
  25992. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  25993. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  25994. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  25995. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25996. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  25997. * @returns the emitter
  25998. */
  25999. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  26000. /**
  26001. * Clones the particle system.
  26002. * @param name The name of the cloned object
  26003. * @param newEmitter The new emitter to use
  26004. * @returns the cloned particle system
  26005. */
  26006. clone(name: string, newEmitter: any): ParticleSystem;
  26007. /**
  26008. * Serializes the particle system to a JSON object.
  26009. * @returns the JSON object
  26010. */
  26011. serialize(): any;
  26012. /** @hidden */
  26013. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  26014. /** @hidden */
  26015. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  26016. /**
  26017. * Parses a JSON object to create a particle system.
  26018. * @param parsedParticleSystem The JSON object to parse
  26019. * @param scene The scene to create the particle system in
  26020. * @param rootUrl The root url to use to load external dependencies like texture
  26021. * @returns the Parsed particle system
  26022. */
  26023. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  26024. }
  26025. }
  26026. declare module BABYLON {
  26027. interface Engine {
  26028. /**
  26029. * Create an effect to use with particle systems.
  26030. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  26031. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  26032. * @param uniformsNames defines a list of attribute names
  26033. * @param samplers defines an array of string used to represent textures
  26034. * @param defines defines the string containing the defines to use to compile the shaders
  26035. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  26036. * @param onCompiled defines a function to call when the effect creation is successful
  26037. * @param onError defines a function to call when the effect creation has failed
  26038. * @returns the new Effect
  26039. */
  26040. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  26041. }
  26042. }
  26043. declare module BABYLON {
  26044. /**
  26045. * Represents a set of particle systems working together to create a specific effect
  26046. */
  26047. class ParticleSystemSet implements IDisposable {
  26048. private _emitterCreationOptions;
  26049. private _emitterNode;
  26050. /**
  26051. * Gets the particle system list
  26052. */
  26053. systems: IParticleSystem[];
  26054. /**
  26055. * Gets the emitter node used with this set
  26056. */
  26057. readonly emitterNode: Nullable<TransformNode>;
  26058. /**
  26059. * Creates a new emitter mesh as a sphere
  26060. * @param options defines the options used to create the sphere
  26061. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  26062. * @param scene defines the hosting scene
  26063. */
  26064. setEmitterAsSphere(options: {
  26065. diameter: number;
  26066. segments: number;
  26067. color: Color3;
  26068. }, renderingGroupId: number, scene: Scene): void;
  26069. /**
  26070. * Starts all particle systems of the set
  26071. * @param emitter defines an optional mesh to use as emitter for the particle systems
  26072. */
  26073. start(emitter?: AbstractMesh): void;
  26074. /**
  26075. * Release all associated resources
  26076. */
  26077. dispose(): void;
  26078. /**
  26079. * Serialize the set into a JSON compatible object
  26080. * @returns a JSON compatible representation of the set
  26081. */
  26082. serialize(): any;
  26083. /**
  26084. * Parse a new ParticleSystemSet from a serialized source
  26085. * @param data defines a JSON compatible representation of the set
  26086. * @param scene defines the hosting scene
  26087. * @param gpu defines if we want GPU particles or CPU particles
  26088. * @returns a new ParticleSystemSet
  26089. */
  26090. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  26091. }
  26092. }
  26093. declare module BABYLON {
  26094. /**
  26095. * Represents one particle of a solid particle system.
  26096. */
  26097. class SolidParticle {
  26098. /**
  26099. * particle global index
  26100. */
  26101. idx: number;
  26102. /**
  26103. * The color of the particle
  26104. */
  26105. color: Nullable<Color4>;
  26106. /**
  26107. * The world space position of the particle.
  26108. */
  26109. position: Vector3;
  26110. /**
  26111. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26112. */
  26113. rotation: Vector3;
  26114. /**
  26115. * The world space rotation quaternion of the particle.
  26116. */
  26117. rotationQuaternion: Nullable<Quaternion>;
  26118. /**
  26119. * The scaling of the particle.
  26120. */
  26121. scaling: Vector3;
  26122. /**
  26123. * The uvs of the particle.
  26124. */
  26125. uvs: Vector4;
  26126. /**
  26127. * The current speed of the particle.
  26128. */
  26129. velocity: Vector3;
  26130. /**
  26131. * The pivot point in the particle local space.
  26132. */
  26133. pivot: Vector3;
  26134. /**
  26135. * Must the particle be translated from its pivot point in its local space ?
  26136. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26137. * Default : false
  26138. */
  26139. translateFromPivot: boolean;
  26140. /**
  26141. * Is the particle active or not ?
  26142. */
  26143. alive: boolean;
  26144. /**
  26145. * Is the particle visible or not ?
  26146. */
  26147. isVisible: boolean;
  26148. /**
  26149. * Index of this particle in the global "positions" array (Internal use)
  26150. */
  26151. _pos: number;
  26152. /**
  26153. * Index of this particle in the global "indices" array (Internal use)
  26154. */
  26155. _ind: number;
  26156. /**
  26157. * ModelShape of this particle (Internal use)
  26158. */
  26159. _model: ModelShape;
  26160. /**
  26161. * ModelShape id of this particle
  26162. */
  26163. shapeId: number;
  26164. /**
  26165. * Index of the particle in its shape id (Internal use)
  26166. */
  26167. idxInShape: number;
  26168. /**
  26169. * Reference to the shape model BoundingInfo object (Internal use)
  26170. */
  26171. _modelBoundingInfo: BoundingInfo;
  26172. /**
  26173. * Particle BoundingInfo object (Internal use)
  26174. */
  26175. _boundingInfo: BoundingInfo;
  26176. /**
  26177. * Reference to the SPS what the particle belongs to (Internal use)
  26178. */
  26179. _sps: SolidParticleSystem;
  26180. /**
  26181. * Still set as invisible in order to skip useless computations (Internal use)
  26182. */
  26183. _stillInvisible: boolean;
  26184. /**
  26185. * Last computed particle rotation matrix
  26186. */
  26187. _rotationMatrix: number[];
  26188. /**
  26189. * Parent particle Id, if any.
  26190. * Default null.
  26191. */
  26192. parentId: Nullable<number>;
  26193. /**
  26194. * Internal global position in the SPS.
  26195. */
  26196. _globalPosition: Vector3;
  26197. /**
  26198. * Creates a Solid Particle object.
  26199. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26200. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26201. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26202. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26203. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26204. * @param shapeId (integer) is the model shape identifier in the SPS.
  26205. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26206. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26207. */
  26208. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26209. /**
  26210. * Legacy support, changed scale to scaling
  26211. */
  26212. /**
  26213. * Legacy support, changed scale to scaling
  26214. */
  26215. scale: Vector3;
  26216. /**
  26217. * Legacy support, changed quaternion to rotationQuaternion
  26218. */
  26219. /**
  26220. * Legacy support, changed quaternion to rotationQuaternion
  26221. */
  26222. quaternion: Nullable<Quaternion>;
  26223. /**
  26224. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26225. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26226. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26227. * @returns true if it intersects
  26228. */
  26229. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26230. }
  26231. /**
  26232. * Represents the shape of the model used by one particle of a solid particle system.
  26233. * SPS internal tool, don't use it manually.
  26234. */
  26235. class ModelShape {
  26236. /**
  26237. * The shape id.
  26238. */
  26239. shapeID: number;
  26240. /**
  26241. * flat array of model positions (internal use)
  26242. */
  26243. _shape: Vector3[];
  26244. /**
  26245. * flat array of model UVs (internal use)
  26246. */
  26247. _shapeUV: number[];
  26248. /**
  26249. * length of the shape in the model indices array (internal use)
  26250. */
  26251. _indicesLength: number;
  26252. /**
  26253. * Custom position function (internal use)
  26254. */
  26255. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26256. /**
  26257. * Custom vertex function (internal use)
  26258. */
  26259. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26260. /**
  26261. * 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.
  26262. * SPS internal tool, don't use it manually.
  26263. * @hidden
  26264. */
  26265. 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>);
  26266. }
  26267. /**
  26268. * Represents a Depth Sorted Particle in the solid particle system.
  26269. */
  26270. class DepthSortedParticle {
  26271. /**
  26272. * Index of the particle in the "indices" array
  26273. */
  26274. ind: number;
  26275. /**
  26276. * Length of the particle shape in the "indices" array
  26277. */
  26278. indicesLength: number;
  26279. /**
  26280. * Squared distance from the particle to the camera
  26281. */
  26282. sqDistance: number;
  26283. }
  26284. }
  26285. declare module BABYLON {
  26286. /**
  26287. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26288. *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.
  26289. * The SPS is also a particle system. It provides some methods to manage the particles.
  26290. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26291. *
  26292. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  26293. */
  26294. class SolidParticleSystem implements IDisposable {
  26295. /**
  26296. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26297. * Example : var p = SPS.particles[i];
  26298. */
  26299. particles: SolidParticle[];
  26300. /**
  26301. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26302. */
  26303. nbParticles: number;
  26304. /**
  26305. * If the particles must ever face the camera (default false). Useful for planar particles.
  26306. */
  26307. billboard: boolean;
  26308. /**
  26309. * Recompute normals when adding a shape
  26310. */
  26311. recomputeNormals: boolean;
  26312. /**
  26313. * This a counter ofr your own usage. It's not set by any SPS functions.
  26314. */
  26315. counter: number;
  26316. /**
  26317. * The SPS name. This name is also given to the underlying mesh.
  26318. */
  26319. name: string;
  26320. /**
  26321. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26322. */
  26323. mesh: Mesh;
  26324. /**
  26325. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26326. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  26327. */
  26328. vars: any;
  26329. /**
  26330. * This array is populated when the SPS is set as 'pickable'.
  26331. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26332. * Each element of this array is an object `{idx: int, faceId: int}`.
  26333. * `idx` is the picked particle index in the `SPS.particles` array
  26334. * `faceId` is the picked face index counted within this particle.
  26335. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  26336. */
  26337. pickedParticles: {
  26338. idx: number;
  26339. faceId: number;
  26340. }[];
  26341. /**
  26342. * This array is populated when `enableDepthSort` is set to true.
  26343. * Each element of this array is an instance of the class DepthSortedParticle.
  26344. */
  26345. depthSortedParticles: DepthSortedParticle[];
  26346. /**
  26347. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26348. */
  26349. _bSphereOnly: boolean;
  26350. /**
  26351. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26352. */
  26353. _bSphereRadiusFactor: number;
  26354. private _scene;
  26355. private _positions;
  26356. private _indices;
  26357. private _normals;
  26358. private _colors;
  26359. private _uvs;
  26360. private _indices32;
  26361. private _positions32;
  26362. private _normals32;
  26363. private _fixedNormal32;
  26364. private _colors32;
  26365. private _uvs32;
  26366. private _index;
  26367. private _updatable;
  26368. private _pickable;
  26369. private _isVisibilityBoxLocked;
  26370. private _alwaysVisible;
  26371. private _depthSort;
  26372. private _shapeCounter;
  26373. private _copy;
  26374. private _shape;
  26375. private _shapeUV;
  26376. private _color;
  26377. private _computeParticleColor;
  26378. private _computeParticleTexture;
  26379. private _computeParticleRotation;
  26380. private _computeParticleVertex;
  26381. private _computeBoundingBox;
  26382. private _depthSortParticles;
  26383. private _cam_axisZ;
  26384. private _cam_axisY;
  26385. private _cam_axisX;
  26386. private _axisZ;
  26387. private _camera;
  26388. private _particle;
  26389. private _camDir;
  26390. private _camInvertedPosition;
  26391. private _rotMatrix;
  26392. private _invertMatrix;
  26393. private _rotated;
  26394. private _quaternion;
  26395. private _vertex;
  26396. private _normal;
  26397. private _yaw;
  26398. private _pitch;
  26399. private _roll;
  26400. private _halfroll;
  26401. private _halfpitch;
  26402. private _halfyaw;
  26403. private _sinRoll;
  26404. private _cosRoll;
  26405. private _sinPitch;
  26406. private _cosPitch;
  26407. private _sinYaw;
  26408. private _cosYaw;
  26409. private _mustUnrotateFixedNormals;
  26410. private _minimum;
  26411. private _maximum;
  26412. private _minBbox;
  26413. private _maxBbox;
  26414. private _particlesIntersect;
  26415. private _depthSortFunction;
  26416. private _needs32Bits;
  26417. private _pivotBackTranslation;
  26418. private _scaledPivot;
  26419. private _particleHasParent;
  26420. private _parent;
  26421. /**
  26422. * Creates a SPS (Solid Particle System) object.
  26423. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26424. * @param scene (Scene) is the scene in which the SPS is added.
  26425. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26426. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26427. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26428. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26429. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26430. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26431. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26432. */
  26433. constructor(name: string, scene: Scene, options?: {
  26434. updatable?: boolean;
  26435. isPickable?: boolean;
  26436. enableDepthSort?: boolean;
  26437. particleIntersection?: boolean;
  26438. boundingSphereOnly?: boolean;
  26439. bSphereRadiusFactor?: number;
  26440. });
  26441. /**
  26442. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26443. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26444. * @returns the created mesh
  26445. */
  26446. buildMesh(): Mesh;
  26447. /**
  26448. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26449. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26450. * Thus the particles generated from `digest()` have their property `position` set yet.
  26451. * @param mesh ( Mesh ) is the mesh to be digested
  26452. * @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
  26453. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26454. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26455. * @returns the current SPS
  26456. */
  26457. digest(mesh: Mesh, options?: {
  26458. facetNb?: number;
  26459. number?: number;
  26460. delta?: number;
  26461. }): SolidParticleSystem;
  26462. private _unrotateFixedNormals();
  26463. private _resetCopy();
  26464. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  26465. private _posToShape(positions);
  26466. private _uvsToShapeUV(uvs);
  26467. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  26468. /**
  26469. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26470. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  26471. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26472. * @param nb (positive integer) the number of particles to be created from this model
  26473. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26474. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26475. * @returns the number of shapes in the system
  26476. */
  26477. addShape(mesh: Mesh, nb: number, options?: {
  26478. positionFunction?: any;
  26479. vertexFunction?: any;
  26480. }): number;
  26481. private _rebuildParticle(particle);
  26482. /**
  26483. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26484. * @returns the SPS.
  26485. */
  26486. rebuildMesh(): SolidParticleSystem;
  26487. /**
  26488. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26489. * This method calls `updateParticle()` for each particle of the SPS.
  26490. * For an animated SPS, it is usually called within the render loop.
  26491. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26492. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26493. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26494. * @returns the SPS.
  26495. */
  26496. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26497. private _quaternionRotationYPR();
  26498. private _quaternionToRotationMatrix();
  26499. /**
  26500. * Disposes the SPS.
  26501. */
  26502. dispose(): void;
  26503. /**
  26504. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26505. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26506. * @returns the SPS.
  26507. */
  26508. refreshVisibleSize(): SolidParticleSystem;
  26509. /**
  26510. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26511. * @param size the size (float) of the visibility box
  26512. * note : this doesn't lock the SPS mesh bounding box.
  26513. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26514. */
  26515. setVisibilityBox(size: number): void;
  26516. /**
  26517. * Gets whether the SPS as always visible or not
  26518. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26519. */
  26520. /**
  26521. * Sets the SPS as always visible or not
  26522. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26523. */
  26524. isAlwaysVisible: boolean;
  26525. /**
  26526. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26527. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26528. */
  26529. /**
  26530. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26531. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  26532. */
  26533. isVisibilityBoxLocked: boolean;
  26534. /**
  26535. * Gets if `setParticles()` computes the particle rotations or not.
  26536. * Default value : true. The SPS is faster when it's set to false.
  26537. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26538. */
  26539. /**
  26540. * Tells to `setParticles()` to compute the particle rotations or not.
  26541. * Default value : true. The SPS is faster when it's set to false.
  26542. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26543. */
  26544. computeParticleRotation: boolean;
  26545. /**
  26546. * Gets if `setParticles()` computes the particle colors or not.
  26547. * Default value : true. The SPS is faster when it's set to false.
  26548. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26549. */
  26550. /**
  26551. * Tells to `setParticles()` to compute the particle colors or not.
  26552. * Default value : true. The SPS is faster when it's set to false.
  26553. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26554. */
  26555. computeParticleColor: boolean;
  26556. /**
  26557. * Gets if `setParticles()` computes the particle textures or not.
  26558. * Default value : true. The SPS is faster when it's set to false.
  26559. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26560. */
  26561. computeParticleTexture: boolean;
  26562. /**
  26563. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26564. * Default value : false. The SPS is faster when it's set to false.
  26565. * Note : the particle custom vertex positions aren't stored values.
  26566. */
  26567. /**
  26568. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26569. * Default value : false. The SPS is faster when it's set to false.
  26570. * Note : the particle custom vertex positions aren't stored values.
  26571. */
  26572. computeParticleVertex: boolean;
  26573. /**
  26574. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26575. */
  26576. /**
  26577. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26578. */
  26579. computeBoundingBox: boolean;
  26580. /**
  26581. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26582. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26583. * Default : `true`
  26584. */
  26585. /**
  26586. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26587. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26588. * Default : `true`
  26589. */
  26590. depthSortParticles: boolean;
  26591. /**
  26592. * This function does nothing. It may be overwritten to set all the particle first values.
  26593. * The SPS doesn't call this function, you may have to call it by your own.
  26594. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26595. */
  26596. initParticles(): void;
  26597. /**
  26598. * This function does nothing. It may be overwritten to recycle a particle.
  26599. * The SPS doesn't call this function, you may have to call it by your own.
  26600. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26601. * @param particle The particle to recycle
  26602. * @returns the recycled particle
  26603. */
  26604. recycleParticle(particle: SolidParticle): SolidParticle;
  26605. /**
  26606. * Updates a particle : this function should be overwritten by the user.
  26607. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26608. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  26609. * @example : just set a particle position or velocity and recycle conditions
  26610. * @param particle The particle to update
  26611. * @returns the updated particle
  26612. */
  26613. updateParticle(particle: SolidParticle): SolidParticle;
  26614. /**
  26615. * Updates a vertex of a particle : it can be overwritten by the user.
  26616. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26617. * @param particle the current particle
  26618. * @param vertex the current index of the current particle
  26619. * @param pt the index of the current vertex in the particle shape
  26620. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  26621. * @example : just set a vertex particle position
  26622. * @returns the updated vertex
  26623. */
  26624. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26625. /**
  26626. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26627. * This does nothing and may be overwritten by the user.
  26628. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26629. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26630. * @param update the boolean update value actually passed to setParticles()
  26631. */
  26632. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26633. /**
  26634. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26635. * This will be passed three parameters.
  26636. * This does nothing and may be overwritten by the user.
  26637. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26638. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26639. * @param update the boolean update value actually passed to setParticles()
  26640. */
  26641. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26642. }
  26643. }
  26644. declare module BABYLON {
  26645. class ReflectionProbe {
  26646. name: string;
  26647. private _scene;
  26648. private _renderTargetTexture;
  26649. private _projectionMatrix;
  26650. private _viewMatrix;
  26651. private _target;
  26652. private _add;
  26653. private _attachedMesh;
  26654. private _invertYAxis;
  26655. position: Vector3;
  26656. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  26657. samples: number;
  26658. refreshRate: number;
  26659. getScene(): Scene;
  26660. readonly cubeTexture: RenderTargetTexture;
  26661. readonly renderList: Nullable<AbstractMesh[]>;
  26662. attachToMesh(mesh: AbstractMesh): void;
  26663. /**
  26664. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26665. *
  26666. * @param renderingGroupId The rendering group id corresponding to its index
  26667. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26668. */
  26669. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  26670. dispose(): void;
  26671. }
  26672. }
  26673. declare module BABYLON {
  26674. interface Scene {
  26675. /** @hidden (Backing field) */
  26676. _boundingBoxRenderer: BoundingBoxRenderer;
  26677. /** @hidden (Backing field) */
  26678. _forceShowBoundingBoxes: boolean;
  26679. /**
  26680. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  26681. */
  26682. forceShowBoundingBoxes: boolean;
  26683. /**
  26684. * Gets the bounding box renderer associated with the scene
  26685. * @returns a BoundingBoxRenderer
  26686. */
  26687. getBoundingBoxRenderer(): BoundingBoxRenderer;
  26688. }
  26689. interface AbstractMesh {
  26690. /** @hidden (Backing field) */
  26691. _showBoundingBox: boolean;
  26692. /**
  26693. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  26694. */
  26695. showBoundingBox: boolean;
  26696. }
  26697. class BoundingBoxRenderer implements ISceneComponent {
  26698. /**
  26699. * The component name helpfull to identify the component in the list of scene components.
  26700. */
  26701. readonly name: string;
  26702. /**
  26703. * The scene the component belongs to.
  26704. */
  26705. scene: Scene;
  26706. frontColor: Color3;
  26707. backColor: Color3;
  26708. showBackLines: boolean;
  26709. renderList: SmartArray<BoundingBox>;
  26710. private _colorShader;
  26711. private _vertexBuffers;
  26712. private _indexBuffer;
  26713. constructor(scene: Scene);
  26714. /**
  26715. * Registers the component in a given scene
  26716. */
  26717. register(): void;
  26718. private _evaluateSubMesh(mesh, subMesh);
  26719. private _activeMesh(sourceMesh, mesh);
  26720. private _prepareRessources();
  26721. private _createIndexBuffer();
  26722. /**
  26723. * Rebuilds the elements related to this component in case of
  26724. * context lost for instance.
  26725. */
  26726. rebuild(): void;
  26727. reset(): void;
  26728. render(): void;
  26729. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  26730. dispose(): void;
  26731. }
  26732. }
  26733. declare module BABYLON {
  26734. /**
  26735. * This represents a depth renderer in Babylon.
  26736. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  26737. */
  26738. class DepthRenderer {
  26739. private _scene;
  26740. private _depthMap;
  26741. private _effect;
  26742. private _cachedDefines;
  26743. private _camera;
  26744. /**
  26745. * Instantiates a depth renderer
  26746. * @param scene The scene the renderer belongs to
  26747. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  26748. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  26749. */
  26750. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  26751. /**
  26752. * Creates the depth rendering effect and checks if the effect is ready.
  26753. * @param subMesh The submesh to be used to render the depth map of
  26754. * @param useInstances If multiple world instances should be used
  26755. * @returns if the depth renderer is ready to render the depth map
  26756. */
  26757. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26758. /**
  26759. * Gets the texture which the depth map will be written to.
  26760. * @returns The depth map texture
  26761. */
  26762. getDepthMap(): RenderTargetTexture;
  26763. /**
  26764. * Disposes of the depth renderer.
  26765. */
  26766. dispose(): void;
  26767. }
  26768. }
  26769. declare module BABYLON {
  26770. class EdgesRenderer {
  26771. edgesWidthScalerForOrthographic: number;
  26772. edgesWidthScalerForPerspective: number;
  26773. private _source;
  26774. private _linesPositions;
  26775. private _linesNormals;
  26776. private _linesIndices;
  26777. private _epsilon;
  26778. private _indicesCount;
  26779. private _lineShader;
  26780. private _ib;
  26781. private _buffers;
  26782. private _checkVerticesInsteadOfIndices;
  26783. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  26784. isEnabled: boolean;
  26785. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  26786. private _prepareRessources();
  26787. _rebuild(): void;
  26788. dispose(): void;
  26789. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  26790. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  26791. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  26792. _generateEdgesLines(): void;
  26793. render(): void;
  26794. }
  26795. }
  26796. declare module BABYLON {
  26797. /**
  26798. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  26799. */
  26800. class GeometryBufferRenderer {
  26801. private _scene;
  26802. private _multiRenderTarget;
  26803. private _ratio;
  26804. private _enablePosition;
  26805. protected _effect: Effect;
  26806. protected _cachedDefines: string;
  26807. /**
  26808. * Set the render list (meshes to be rendered) used in the G buffer.
  26809. */
  26810. renderList: Mesh[];
  26811. /**
  26812. * Gets wether or not G buffer are supported by the running hardware.
  26813. * This requires draw buffer supports
  26814. */
  26815. readonly isSupported: boolean;
  26816. /**
  26817. * Gets wether or not position are enabled for the G buffer.
  26818. */
  26819. /**
  26820. * Sets wether or not position are enabled for the G buffer.
  26821. */
  26822. enablePosition: boolean;
  26823. /**
  26824. * Gets the scene associated with the buffer.
  26825. */
  26826. readonly scene: Scene;
  26827. /**
  26828. * Gets the ratio used by the buffer during its creation.
  26829. * How big is the buffer related to the main canvas.
  26830. */
  26831. readonly ratio: number;
  26832. /**
  26833. * Creates a new G Buffer for the scene
  26834. * @param scene The scene the buffer belongs to
  26835. * @param ratio How big is the buffer related to the main canvas.
  26836. */
  26837. constructor(scene: Scene, ratio?: number);
  26838. /**
  26839. * Checks wether everything is ready to render a submesh to the G buffer.
  26840. * @param subMesh the submesh to check readiness for
  26841. * @param useInstances is the mesh drawn using instance or not
  26842. * @returns true if ready otherwise false
  26843. */
  26844. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26845. /**
  26846. * Gets the current underlying G Buffer.
  26847. * @returns the buffer
  26848. */
  26849. getGBuffer(): MultiRenderTarget;
  26850. /**
  26851. * Gets the number of samples used to render the buffer (anti aliasing).
  26852. */
  26853. /**
  26854. * Sets the number of samples used to render the buffer (anti aliasing).
  26855. */
  26856. samples: number;
  26857. /**
  26858. * Disposes the renderer and frees up associated resources.
  26859. */
  26860. dispose(): void;
  26861. protected _createRenderTargets(): void;
  26862. }
  26863. }
  26864. declare module BABYLON {
  26865. class OutlineRenderer {
  26866. private _scene;
  26867. private _effect;
  26868. private _cachedDefines;
  26869. zOffset: number;
  26870. constructor(scene: Scene);
  26871. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  26872. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26873. }
  26874. }
  26875. declare module BABYLON {
  26876. class RenderingGroup {
  26877. index: number;
  26878. private _scene;
  26879. private _opaqueSubMeshes;
  26880. private _transparentSubMeshes;
  26881. private _alphaTestSubMeshes;
  26882. private _depthOnlySubMeshes;
  26883. private _particleSystems;
  26884. private _spriteManagers;
  26885. private _opaqueSortCompareFn;
  26886. private _alphaTestSortCompareFn;
  26887. private _transparentSortCompareFn;
  26888. private _renderOpaque;
  26889. private _renderAlphaTest;
  26890. private _renderTransparent;
  26891. private _edgesRenderers;
  26892. onBeforeTransparentRendering: () => void;
  26893. /**
  26894. * Set the opaque sort comparison function.
  26895. * If null the sub meshes will be render in the order they were created
  26896. */
  26897. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26898. /**
  26899. * Set the alpha test sort comparison function.
  26900. * If null the sub meshes will be render in the order they were created
  26901. */
  26902. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26903. /**
  26904. * Set the transparent sort comparison function.
  26905. * If null the sub meshes will be render in the order they were created
  26906. */
  26907. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26908. /**
  26909. * Creates a new rendering group.
  26910. * @param index The rendering group index
  26911. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  26912. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  26913. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  26914. */
  26915. 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>);
  26916. /**
  26917. * Render all the sub meshes contained in the group.
  26918. * @param customRenderFunction Used to override the default render behaviour of the group.
  26919. * @returns true if rendered some submeshes.
  26920. */
  26921. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  26922. /**
  26923. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  26924. * @param subMeshes The submeshes to render
  26925. */
  26926. private renderOpaqueSorted(subMeshes);
  26927. /**
  26928. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  26929. * @param subMeshes The submeshes to render
  26930. */
  26931. private renderAlphaTestSorted(subMeshes);
  26932. /**
  26933. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  26934. * @param subMeshes The submeshes to render
  26935. */
  26936. private renderTransparentSorted(subMeshes);
  26937. /**
  26938. * Renders the submeshes in a specified order.
  26939. * @param subMeshes The submeshes to sort before render
  26940. * @param sortCompareFn The comparison function use to sort
  26941. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  26942. * @param transparent Specifies to activate blending if true
  26943. */
  26944. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  26945. /**
  26946. * Renders the submeshes in the order they were dispatched (no sort applied).
  26947. * @param subMeshes The submeshes to render
  26948. */
  26949. private static renderUnsorted(subMeshes);
  26950. /**
  26951. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26952. * are rendered back to front if in the same alpha index.
  26953. *
  26954. * @param a The first submesh
  26955. * @param b The second submesh
  26956. * @returns The result of the comparison
  26957. */
  26958. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  26959. /**
  26960. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26961. * are rendered back to front.
  26962. *
  26963. * @param a The first submesh
  26964. * @param b The second submesh
  26965. * @returns The result of the comparison
  26966. */
  26967. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  26968. /**
  26969. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26970. * are rendered front to back (prevent overdraw).
  26971. *
  26972. * @param a The first submesh
  26973. * @param b The second submesh
  26974. * @returns The result of the comparison
  26975. */
  26976. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  26977. /**
  26978. * Resets the different lists of submeshes to prepare a new frame.
  26979. */
  26980. prepare(): void;
  26981. dispose(): void;
  26982. /**
  26983. * Inserts the submesh in its correct queue depending on its material.
  26984. * @param subMesh The submesh to dispatch
  26985. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26986. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26987. */
  26988. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26989. dispatchSprites(spriteManager: SpriteManager): void;
  26990. dispatchParticles(particleSystem: IParticleSystem): void;
  26991. private _renderParticles(activeMeshes);
  26992. private _renderSprites();
  26993. }
  26994. }
  26995. declare module BABYLON {
  26996. /**
  26997. * Interface describing the different options available in the rendering manager
  26998. * regarding Auto Clear between groups.
  26999. */
  27000. interface IRenderingManagerAutoClearSetup {
  27001. /**
  27002. * Defines whether or not autoclear is enable.
  27003. */
  27004. autoClear: boolean;
  27005. /**
  27006. * Defines whether or not to autoclear the depth buffer.
  27007. */
  27008. depth: boolean;
  27009. /**
  27010. * Defines whether or not to autoclear the stencil buffer.
  27011. */
  27012. stencil: boolean;
  27013. }
  27014. class RenderingManager {
  27015. /**
  27016. * The max id used for rendering groups (not included)
  27017. */
  27018. static MAX_RENDERINGGROUPS: number;
  27019. /**
  27020. * The min id used for rendering groups (included)
  27021. */
  27022. static MIN_RENDERINGGROUPS: number;
  27023. /**
  27024. * Used to globally prevent autoclearing scenes.
  27025. */
  27026. static AUTOCLEAR: boolean;
  27027. /**
  27028. * Hidden
  27029. */
  27030. _useSceneAutoClearSetup: boolean;
  27031. private _scene;
  27032. private _renderingGroups;
  27033. private _depthStencilBufferAlreadyCleaned;
  27034. private _autoClearDepthStencil;
  27035. private _customOpaqueSortCompareFn;
  27036. private _customAlphaTestSortCompareFn;
  27037. private _customTransparentSortCompareFn;
  27038. private _renderingGroupInfo;
  27039. constructor(scene: Scene);
  27040. private _clearDepthStencilBuffer(depth?, stencil?);
  27041. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  27042. reset(): void;
  27043. dispose(): void;
  27044. /**
  27045. * Clear the info related to rendering groups preventing retention points during dispose.
  27046. */
  27047. freeRenderingGroups(): void;
  27048. private _prepareRenderingGroup(renderingGroupId);
  27049. dispatchSprites(spriteManager: SpriteManager): void;
  27050. dispatchParticles(particleSystem: IParticleSystem): void;
  27051. /**
  27052. * @param subMesh The submesh to dispatch
  27053. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  27054. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  27055. */
  27056. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  27057. /**
  27058. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  27059. * This allowed control for front to back rendering or reversly depending of the special needs.
  27060. *
  27061. * @param renderingGroupId The rendering group id corresponding to its index
  27062. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  27063. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  27064. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  27065. */
  27066. 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;
  27067. /**
  27068. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  27069. *
  27070. * @param renderingGroupId The rendering group id corresponding to its index
  27071. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  27072. * @param depth Automatically clears depth between groups if true and autoClear is true.
  27073. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  27074. */
  27075. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  27076. /**
  27077. * Gets the current auto clear configuration for one rendering group of the rendering
  27078. * manager.
  27079. * @param index the rendering group index to get the information for
  27080. * @returns The auto clear setup for the requested rendering group
  27081. */
  27082. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  27083. }
  27084. }
  27085. declare module BABYLON {
  27086. /**
  27087. * Renders a layer on top of an existing scene
  27088. */
  27089. class UtilityLayerRenderer implements IDisposable {
  27090. /** the original scene that will be rendered on top of */
  27091. originalScene: Scene;
  27092. private _pointerCaptures;
  27093. private _lastPointerEvents;
  27094. private static _DefaultUtilityLayer;
  27095. private static _DefaultKeepDepthUtilityLayer;
  27096. /**
  27097. * 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)
  27098. */
  27099. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  27100. /**
  27101. * 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)
  27102. */
  27103. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  27104. /**
  27105. * The scene that is rendered on top of the original scene
  27106. */
  27107. utilityLayerScene: Scene;
  27108. /**
  27109. * If the utility layer should automatically be rendered on top of existing scene
  27110. */
  27111. shouldRender: boolean;
  27112. /**
  27113. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  27114. */
  27115. onlyCheckPointerDownEvents: boolean;
  27116. /**
  27117. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  27118. */
  27119. processAllEvents: boolean;
  27120. /**
  27121. * Observable raised when the pointer move from the utility layer scene to the main scene
  27122. */
  27123. onPointerOutObservable: Observable<number>;
  27124. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  27125. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  27126. private _afterRenderObserver;
  27127. private _sceneDisposeObserver;
  27128. private _originalPointerObserver;
  27129. /**
  27130. * Instantiates a UtilityLayerRenderer
  27131. * @param originalScene the original scene that will be rendered on top of
  27132. */
  27133. constructor(
  27134. /** the original scene that will be rendered on top of */
  27135. originalScene: Scene);
  27136. private _notifyObservers(prePointerInfo, pickInfo, pointerEvent);
  27137. /**
  27138. * Renders the utility layers scene on top of the original scene
  27139. */
  27140. render(): void;
  27141. /**
  27142. * Disposes of the renderer
  27143. */
  27144. dispose(): void;
  27145. private _updateCamera();
  27146. }
  27147. }
  27148. declare module BABYLON {
  27149. /**
  27150. * Postprocess used to generate anaglyphic rendering
  27151. */
  27152. class AnaglyphPostProcess extends PostProcess {
  27153. private _passedProcess;
  27154. /**
  27155. * Creates a new AnaglyphPostProcess
  27156. * @param name defines postprocess name
  27157. * @param options defines creation options or target ratio scale
  27158. * @param rigCameras defines cameras using this postprocess
  27159. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  27160. * @param engine defines hosting engine
  27161. * @param reusable defines if the postprocess will be reused multiple times per frame
  27162. */
  27163. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  27164. }
  27165. }
  27166. declare module BABYLON {
  27167. class BlackAndWhitePostProcess extends PostProcess {
  27168. degree: number;
  27169. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27170. }
  27171. }
  27172. declare module BABYLON {
  27173. /**
  27174. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  27175. */
  27176. class BloomEffect extends PostProcessRenderEffect {
  27177. private bloomScale;
  27178. /**
  27179. * Internal
  27180. */
  27181. _effects: Array<PostProcess>;
  27182. /**
  27183. * Internal
  27184. */
  27185. _downscale: ExtractHighlightsPostProcess;
  27186. private _blurX;
  27187. private _blurY;
  27188. private _merge;
  27189. /**
  27190. * The luminance threshold to find bright areas of the image to bloom.
  27191. */
  27192. threshold: number;
  27193. /**
  27194. * The strength of the bloom.
  27195. */
  27196. weight: number;
  27197. /**
  27198. * Specifies the size of the bloom blur kernel, relative to the final output size
  27199. */
  27200. kernel: number;
  27201. /**
  27202. * Creates a new instance of @see BloomEffect
  27203. * @param scene The scene the effect belongs to.
  27204. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  27205. * @param bloomKernel The size of the kernel to be used when applying the blur.
  27206. * @param bloomWeight The the strength of bloom.
  27207. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27208. * @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)
  27209. */
  27210. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  27211. /**
  27212. * Disposes each of the internal effects for a given camera.
  27213. * @param camera The camera to dispose the effect on.
  27214. */
  27215. disposeEffects(camera: Camera): void;
  27216. /**
  27217. * Internal
  27218. */
  27219. _updateEffects(): void;
  27220. /**
  27221. * Internal
  27222. * @returns if all the contained post processes are ready.
  27223. */
  27224. _isReady(): boolean;
  27225. }
  27226. }
  27227. declare module BABYLON {
  27228. /**
  27229. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27230. */
  27231. class BloomMergePostProcess extends PostProcess {
  27232. /** Weight of the bloom to be added to the original input. */
  27233. weight: number;
  27234. /**
  27235. * Creates a new instance of @see BloomMergePostProcess
  27236. * @param name The name of the effect.
  27237. * @param originalFromInput Post process which's input will be used for the merge.
  27238. * @param blurred Blurred highlights post process which's output will be used.
  27239. * @param weight Weight of the bloom to be added to the original input.
  27240. * @param options The required width/height ratio to downsize to before computing the render pass.
  27241. * @param camera The camera to apply the render pass to.
  27242. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27243. * @param engine The engine which the post process will be applied. (default: current engine)
  27244. * @param reusable If the post process can be reused on the same frame. (default: false)
  27245. * @param textureType Type of textures used when performing the post process. (default: 0)
  27246. * @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)
  27247. */
  27248. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  27249. /** Weight of the bloom to be added to the original input. */
  27250. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27251. }
  27252. }
  27253. declare module BABYLON {
  27254. /**
  27255. * The Blur Post Process which blurs an image based on a kernel and direction.
  27256. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27257. */
  27258. class BlurPostProcess extends PostProcess {
  27259. /** The direction in which to blur the image. */
  27260. direction: Vector2;
  27261. private blockCompilation;
  27262. protected _kernel: number;
  27263. protected _idealKernel: number;
  27264. protected _packedFloat: boolean;
  27265. private _staticDefines;
  27266. /**
  27267. * Gets the length in pixels of the blur sample region
  27268. */
  27269. /**
  27270. * Sets the length in pixels of the blur sample region
  27271. */
  27272. kernel: number;
  27273. /**
  27274. * Gets wether or not the blur is unpacking/repacking floats
  27275. */
  27276. /**
  27277. * Sets wether or not the blur needs to unpack/repack floats
  27278. */
  27279. packedFloat: boolean;
  27280. /**
  27281. * Creates a new instance BlurPostProcess
  27282. * @param name The name of the effect.
  27283. * @param direction The direction in which to blur the image.
  27284. * @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.
  27285. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27286. * @param camera The camera to apply the render pass to.
  27287. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27288. * @param engine The engine which the post process will be applied. (default: current engine)
  27289. * @param reusable If the post process can be reused on the same frame. (default: false)
  27290. * @param textureType Type of textures used when performing the post process. (default: 0)
  27291. * @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)
  27292. */
  27293. constructor(name: string,
  27294. /** The direction in which to blur the image. */
  27295. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  27296. /**
  27297. * Updates the effect with the current post process compile time values and recompiles the shader.
  27298. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27299. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27300. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27301. * @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
  27302. * @param onCompiled Called when the shader has been compiled.
  27303. * @param onError Called if there is an error when compiling a shader.
  27304. */
  27305. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27306. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27307. /**
  27308. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27309. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27310. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27311. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27312. * The gaps between physical kernels are compensated for in the weighting of the samples
  27313. * @param idealKernel Ideal blur kernel.
  27314. * @return Nearest best kernel.
  27315. */
  27316. protected _nearestBestKernel(idealKernel: number): number;
  27317. /**
  27318. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27319. * @param x The point on the Gaussian distribution to sample.
  27320. * @return the value of the Gaussian function at x.
  27321. */
  27322. protected _gaussianWeight(x: number): number;
  27323. /**
  27324. * Generates a string that can be used as a floating point number in GLSL.
  27325. * @param x Value to print.
  27326. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27327. * @return GLSL float string.
  27328. */
  27329. protected _glslFloat(x: number, decimalFigures?: number): string;
  27330. }
  27331. }
  27332. declare module BABYLON {
  27333. /**
  27334. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  27335. */
  27336. class ChromaticAberrationPostProcess extends PostProcess {
  27337. /**
  27338. * The amount of seperation of rgb channels (default: 30)
  27339. */
  27340. aberrationAmount: number;
  27341. /**
  27342. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  27343. */
  27344. radialIntensity: number;
  27345. /**
  27346. * 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))
  27347. */
  27348. direction: Vector2;
  27349. /**
  27350. * 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))
  27351. */
  27352. centerPosition: Vector2;
  27353. /**
  27354. * Creates a new instance ChromaticAberrationPostProcess
  27355. * @param name The name of the effect.
  27356. * @param screenWidth The width of the screen to apply the effect on.
  27357. * @param screenHeight The height of the screen to apply the effect on.
  27358. * @param options The required width/height ratio to downsize to before computing the render pass.
  27359. * @param camera The camera to apply the render pass to.
  27360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27361. * @param engine The engine which the post process will be applied. (default: current engine)
  27362. * @param reusable If the post process can be reused on the same frame. (default: false)
  27363. * @param textureType Type of textures used when performing the post process. (default: 0)
  27364. * @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)
  27365. */
  27366. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27367. }
  27368. }
  27369. declare module BABYLON {
  27370. /**
  27371. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  27372. */
  27373. class CircleOfConfusionPostProcess extends PostProcess {
  27374. /**
  27375. * 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.
  27376. */
  27377. lensSize: number;
  27378. /**
  27379. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27380. */
  27381. fStop: number;
  27382. /**
  27383. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27384. */
  27385. focusDistance: number;
  27386. /**
  27387. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  27388. */
  27389. focalLength: number;
  27390. private _depthTexture;
  27391. /**
  27392. * Creates a new instance CircleOfConfusionPostProcess
  27393. * @param name The name of the effect.
  27394. * @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.
  27395. * @param options The required width/height ratio to downsize to before computing the render pass.
  27396. * @param camera The camera to apply the render pass to.
  27397. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27398. * @param engine The engine which the post process will be applied. (default: current engine)
  27399. * @param reusable If the post process can be reused on the same frame. (default: false)
  27400. * @param textureType Type of textures used when performing the post process. (default: 0)
  27401. * @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)
  27402. */
  27403. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27404. /**
  27405. * 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.
  27406. */
  27407. depthTexture: RenderTargetTexture;
  27408. }
  27409. }
  27410. declare module BABYLON {
  27411. class ColorCorrectionPostProcess extends PostProcess {
  27412. private _colorTableTexture;
  27413. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27414. }
  27415. }
  27416. declare module BABYLON {
  27417. /**
  27418. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  27419. * input texture to perform effects such as edge detection or sharpening
  27420. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  27421. */
  27422. class ConvolutionPostProcess extends PostProcess {
  27423. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27424. kernel: number[];
  27425. /**
  27426. * Creates a new instance ConvolutionPostProcess
  27427. * @param name The name of the effect.
  27428. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  27429. * @param options The required width/height ratio to downsize to before computing the render pass.
  27430. * @param camera The camera to apply the render pass to.
  27431. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27432. * @param engine The engine which the post process will be applied. (default: current engine)
  27433. * @param reusable If the post process can be reused on the same frame. (default: false)
  27434. * @param textureType Type of textures used when performing the post process. (default: 0)
  27435. */
  27436. constructor(name: string,
  27437. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  27438. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27439. /**
  27440. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27441. */
  27442. static EdgeDetect0Kernel: number[];
  27443. /**
  27444. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27445. */
  27446. static EdgeDetect1Kernel: number[];
  27447. /**
  27448. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27449. */
  27450. static EdgeDetect2Kernel: number[];
  27451. /**
  27452. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27453. */
  27454. static SharpenKernel: number[];
  27455. /**
  27456. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27457. */
  27458. static EmbossKernel: number[];
  27459. /**
  27460. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  27461. */
  27462. static GaussianKernel: number[];
  27463. }
  27464. }
  27465. declare module BABYLON {
  27466. /**
  27467. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  27468. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  27469. * based on samples that have a large difference in distance than the center pixel.
  27470. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  27471. */
  27472. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  27473. direction: Vector2;
  27474. /**
  27475. * Creates a new instance CircleOfConfusionPostProcess
  27476. * @param name The name of the effect.
  27477. * @param scene The scene the effect belongs to.
  27478. * @param direction The direction the blur should be applied.
  27479. * @param kernel The size of the kernel used to blur.
  27480. * @param options The required width/height ratio to downsize to before computing the render pass.
  27481. * @param camera The camera to apply the render pass to.
  27482. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  27483. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  27484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27485. * @param engine The engine which the post process will be applied. (default: current engine)
  27486. * @param reusable If the post process can be reused on the same frame. (default: false)
  27487. * @param textureType Type of textures used when performing the post process. (default: 0)
  27488. * @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)
  27489. */
  27490. 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);
  27491. }
  27492. }
  27493. declare module BABYLON {
  27494. /**
  27495. * Specifies the level of max blur that should be applied when using the depth of field effect
  27496. */
  27497. enum DepthOfFieldEffectBlurLevel {
  27498. /**
  27499. * Subtle blur
  27500. */
  27501. Low = 0,
  27502. /**
  27503. * Medium blur
  27504. */
  27505. Medium = 1,
  27506. /**
  27507. * Large blur
  27508. */
  27509. High = 2,
  27510. }
  27511. /**
  27512. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  27513. */
  27514. class DepthOfFieldEffect extends PostProcessRenderEffect {
  27515. private _circleOfConfusion;
  27516. /**
  27517. * Internal, blurs from high to low
  27518. */
  27519. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  27520. private _depthOfFieldBlurY;
  27521. private _dofMerge;
  27522. /**
  27523. * Internal post processes in depth of field effect
  27524. */
  27525. _effects: Array<PostProcess>;
  27526. /**
  27527. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  27528. */
  27529. focalLength: number;
  27530. /**
  27531. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  27532. */
  27533. fStop: number;
  27534. /**
  27535. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  27536. */
  27537. focusDistance: number;
  27538. /**
  27539. * 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.
  27540. */
  27541. lensSize: number;
  27542. /**
  27543. * Creates a new instance DepthOfFieldEffect
  27544. * @param scene The scene the effect belongs to.
  27545. * @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.
  27546. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  27547. * @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)
  27548. */
  27549. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  27550. /**
  27551. * 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.
  27552. */
  27553. depthTexture: RenderTargetTexture;
  27554. /**
  27555. * Disposes each of the internal effects for a given camera.
  27556. * @param camera The camera to dispose the effect on.
  27557. */
  27558. disposeEffects(camera: Camera): void;
  27559. /**
  27560. * Internal
  27561. */
  27562. _updateEffects(): void;
  27563. /**
  27564. * Internal
  27565. * @returns if all the contained post processes are ready.
  27566. */
  27567. _isReady(): boolean;
  27568. }
  27569. }
  27570. declare module BABYLON {
  27571. /**
  27572. * Options to be set when merging outputs from the default pipeline.
  27573. */
  27574. class DepthOfFieldMergePostProcessOptions {
  27575. /**
  27576. * The original image to merge on top of
  27577. */
  27578. originalFromInput: PostProcess;
  27579. /**
  27580. * Parameters to perform the merge of the depth of field effect
  27581. */
  27582. depthOfField?: {
  27583. circleOfConfusion: PostProcess;
  27584. blurSteps: Array<PostProcess>;
  27585. };
  27586. /**
  27587. * Parameters to perform the merge of bloom effect
  27588. */
  27589. bloom?: {
  27590. blurred: PostProcess;
  27591. weight: number;
  27592. };
  27593. }
  27594. /**
  27595. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  27596. */
  27597. class DepthOfFieldMergePostProcess extends PostProcess {
  27598. private blurSteps;
  27599. /**
  27600. * Creates a new instance of DepthOfFieldMergePostProcess
  27601. * @param name The name of the effect.
  27602. * @param originalFromInput Post process which's input will be used for the merge.
  27603. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  27604. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  27605. * @param options The required width/height ratio to downsize to before computing the render pass.
  27606. * @param camera The camera to apply the render pass to.
  27607. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27608. * @param engine The engine which the post process will be applied. (default: current engine)
  27609. * @param reusable If the post process can be reused on the same frame. (default: false)
  27610. * @param textureType Type of textures used when performing the post process. (default: 0)
  27611. * @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)
  27612. */
  27613. 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);
  27614. /**
  27615. * Updates the effect with the current post process compile time values and recompiles the shader.
  27616. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27617. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27618. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27619. * @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
  27620. * @param onCompiled Called when the shader has been compiled.
  27621. * @param onError Called if there is an error when compiling a shader.
  27622. */
  27623. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27624. }
  27625. }
  27626. declare module BABYLON {
  27627. class DisplayPassPostProcess extends PostProcess {
  27628. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27629. }
  27630. }
  27631. declare module BABYLON {
  27632. /**
  27633. * 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.
  27634. */
  27635. class ExtractHighlightsPostProcess extends PostProcess {
  27636. /**
  27637. * The luminance threshold, pixels below this value will be set to black.
  27638. */
  27639. threshold: number;
  27640. /**
  27641. * Internal
  27642. */
  27643. _exposure: number;
  27644. /**
  27645. * Post process which has the input texture to be used when performing highlight extraction
  27646. */
  27647. _inputPostProcess: Nullable<PostProcess>;
  27648. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27649. }
  27650. }
  27651. declare module BABYLON {
  27652. class FilterPostProcess extends PostProcess {
  27653. kernelMatrix: Matrix;
  27654. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  27655. }
  27656. }
  27657. declare module BABYLON {
  27658. class FxaaPostProcess extends PostProcess {
  27659. texelWidth: number;
  27660. texelHeight: number;
  27661. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27662. private _getDefines();
  27663. }
  27664. }
  27665. declare module BABYLON {
  27666. /**
  27667. * The GrainPostProcess adds noise to the image at mid luminance levels
  27668. */
  27669. class GrainPostProcess extends PostProcess {
  27670. /**
  27671. * The intensity of the grain added (default: 30)
  27672. */
  27673. intensity: number;
  27674. /**
  27675. * If the grain should be randomized on every frame
  27676. */
  27677. animated: boolean;
  27678. /**
  27679. * Creates a new instance of @see GrainPostProcess
  27680. * @param name The name of the effect.
  27681. * @param options The required width/height ratio to downsize to before computing the render pass.
  27682. * @param camera The camera to apply the render pass to.
  27683. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27684. * @param engine The engine which the post process will be applied. (default: current engine)
  27685. * @param reusable If the post process can be reused on the same frame. (default: false)
  27686. * @param textureType Type of textures used when performing the post process. (default: 0)
  27687. * @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)
  27688. */
  27689. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27690. }
  27691. }
  27692. declare module BABYLON {
  27693. class HighlightsPostProcess extends PostProcess {
  27694. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  27695. }
  27696. }
  27697. declare module BABYLON {
  27698. class ImageProcessingPostProcess extends PostProcess {
  27699. /**
  27700. * Default configuration related to image processing available in the PBR Material.
  27701. */
  27702. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27703. /**
  27704. * Gets the image processing configuration used either in this material.
  27705. */
  27706. /**
  27707. * Sets the Default image processing configuration used either in the this material.
  27708. *
  27709. * If sets to null, the scene one is in use.
  27710. */
  27711. imageProcessingConfiguration: ImageProcessingConfiguration;
  27712. /**
  27713. * Keep track of the image processing observer to allow dispose and replace.
  27714. */
  27715. private _imageProcessingObserver;
  27716. /**
  27717. * Attaches a new image processing configuration to the PBR Material.
  27718. * @param configuration
  27719. */
  27720. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  27721. /**
  27722. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27723. */
  27724. /**
  27725. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  27726. */
  27727. colorCurves: Nullable<ColorCurves>;
  27728. /**
  27729. * Gets wether the color curves effect is enabled.
  27730. */
  27731. /**
  27732. * Sets wether the color curves effect is enabled.
  27733. */
  27734. colorCurvesEnabled: boolean;
  27735. /**
  27736. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27737. */
  27738. /**
  27739. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  27740. */
  27741. colorGradingTexture: Nullable<BaseTexture>;
  27742. /**
  27743. * Gets wether the color grading effect is enabled.
  27744. */
  27745. /**
  27746. * Gets wether the color grading effect is enabled.
  27747. */
  27748. colorGradingEnabled: boolean;
  27749. /**
  27750. * Gets exposure used in the effect.
  27751. */
  27752. /**
  27753. * Sets exposure used in the effect.
  27754. */
  27755. exposure: number;
  27756. /**
  27757. * Gets wether tonemapping is enabled or not.
  27758. */
  27759. /**
  27760. * Sets wether tonemapping is enabled or not
  27761. */
  27762. toneMappingEnabled: boolean;
  27763. /**
  27764. * Gets contrast used in the effect.
  27765. */
  27766. /**
  27767. * Sets contrast used in the effect.
  27768. */
  27769. contrast: number;
  27770. /**
  27771. * Gets Vignette stretch size.
  27772. */
  27773. /**
  27774. * Sets Vignette stretch size.
  27775. */
  27776. vignetteStretch: number;
  27777. /**
  27778. * Gets Vignette centre X Offset.
  27779. */
  27780. /**
  27781. * Sets Vignette centre X Offset.
  27782. */
  27783. vignetteCentreX: number;
  27784. /**
  27785. * Gets Vignette centre Y Offset.
  27786. */
  27787. /**
  27788. * Sets Vignette centre Y Offset.
  27789. */
  27790. vignetteCentreY: number;
  27791. /**
  27792. * Gets Vignette weight or intensity of the vignette effect.
  27793. */
  27794. /**
  27795. * Sets Vignette weight or intensity of the vignette effect.
  27796. */
  27797. vignetteWeight: number;
  27798. /**
  27799. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27800. * if vignetteEnabled is set to true.
  27801. */
  27802. /**
  27803. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  27804. * if vignetteEnabled is set to true.
  27805. */
  27806. vignetteColor: Color4;
  27807. /**
  27808. * Gets Camera field of view used by the Vignette effect.
  27809. */
  27810. /**
  27811. * Sets Camera field of view used by the Vignette effect.
  27812. */
  27813. vignetteCameraFov: number;
  27814. /**
  27815. * Gets the vignette blend mode allowing different kind of effect.
  27816. */
  27817. /**
  27818. * Sets the vignette blend mode allowing different kind of effect.
  27819. */
  27820. vignetteBlendMode: number;
  27821. /**
  27822. * Gets wether the vignette effect is enabled.
  27823. */
  27824. /**
  27825. * Sets wether the vignette effect is enabled.
  27826. */
  27827. vignetteEnabled: boolean;
  27828. private _fromLinearSpace;
  27829. /**
  27830. * Gets wether the input of the processing is in Gamma or Linear Space.
  27831. */
  27832. /**
  27833. * Sets wether the input of the processing is in Gamma or Linear Space.
  27834. */
  27835. fromLinearSpace: boolean;
  27836. /**
  27837. * Defines cache preventing GC.
  27838. */
  27839. private _defines;
  27840. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  27841. getClassName(): string;
  27842. protected _updateParameters(): void;
  27843. dispose(camera?: Camera): void;
  27844. }
  27845. }
  27846. declare module BABYLON {
  27847. class PassPostProcess extends PostProcess {
  27848. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  27849. }
  27850. }
  27851. declare module BABYLON {
  27852. type PostProcessOptions = {
  27853. width: number;
  27854. height: number;
  27855. };
  27856. /**
  27857. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27858. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27859. */
  27860. class PostProcess {
  27861. /** Name of the PostProcess. */
  27862. name: string;
  27863. /**
  27864. * Width of the texture to apply the post process on
  27865. */
  27866. width: number;
  27867. /**
  27868. * Height of the texture to apply the post process on
  27869. */
  27870. height: number;
  27871. /**
  27872. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27873. */
  27874. _outputTexture: Nullable<InternalTexture>;
  27875. /**
  27876. * Sampling mode used by the shader
  27877. * See https://doc.babylonjs.com/classes/3.1/texture
  27878. */
  27879. renderTargetSamplingMode: number;
  27880. /**
  27881. * Clear color to use when screen clearing
  27882. */
  27883. clearColor: Color4;
  27884. /**
  27885. * If the buffer needs to be cleared before applying the post process. (default: true)
  27886. * Should be set to false if shader will overwrite all previous pixels.
  27887. */
  27888. autoClear: boolean;
  27889. /**
  27890. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27891. */
  27892. alphaMode: number;
  27893. /**
  27894. * Sets the setAlphaBlendConstants of the babylon engine
  27895. */
  27896. alphaConstants: Color4;
  27897. /**
  27898. * Animations to be used for the post processing
  27899. */
  27900. animations: Animation[];
  27901. /**
  27902. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27903. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27904. */
  27905. enablePixelPerfectMode: boolean;
  27906. /**
  27907. * Force the postprocess to be applied without taking in account viewport
  27908. */
  27909. forceFullscreenViewport: boolean;
  27910. /**
  27911. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27912. *
  27913. * | Value | Type | Description |
  27914. * | ----- | ----------------------------------- | ----------- |
  27915. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27916. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27917. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27918. *
  27919. */
  27920. scaleMode: number;
  27921. /**
  27922. * Force textures to be a power of two (default: false)
  27923. */
  27924. alwaysForcePOT: boolean;
  27925. /**
  27926. * Number of sample textures (default: 1)
  27927. */
  27928. samples: number;
  27929. /**
  27930. * Modify the scale of the post process to be the same as the viewport (default: false)
  27931. */
  27932. adaptScaleToCurrentViewport: boolean;
  27933. private _camera;
  27934. private _scene;
  27935. private _engine;
  27936. private _options;
  27937. private _reusable;
  27938. private _textureType;
  27939. /**
  27940. * Smart array of input and output textures for the post process.
  27941. */
  27942. _textures: SmartArray<InternalTexture>;
  27943. /**
  27944. * The index in _textures that corresponds to the output texture.
  27945. */
  27946. _currentRenderTextureInd: number;
  27947. private _effect;
  27948. private _samplers;
  27949. private _fragmentUrl;
  27950. private _vertexUrl;
  27951. private _parameters;
  27952. private _scaleRatio;
  27953. protected _indexParameters: any;
  27954. private _shareOutputWithPostProcess;
  27955. private _texelSize;
  27956. private _forcedOutputTexture;
  27957. /**
  27958. * An event triggered when the postprocess is activated.
  27959. */
  27960. onActivateObservable: Observable<Camera>;
  27961. private _onActivateObserver;
  27962. /**
  27963. * A function that is added to the onActivateObservable
  27964. */
  27965. onActivate: Nullable<(camera: Camera) => void>;
  27966. /**
  27967. * An event triggered when the postprocess changes its size.
  27968. */
  27969. onSizeChangedObservable: Observable<PostProcess>;
  27970. private _onSizeChangedObserver;
  27971. /**
  27972. * A function that is added to the onSizeChangedObservable
  27973. */
  27974. onSizeChanged: (postProcess: PostProcess) => void;
  27975. /**
  27976. * An event triggered when the postprocess applies its effect.
  27977. */
  27978. onApplyObservable: Observable<Effect>;
  27979. private _onApplyObserver;
  27980. /**
  27981. * A function that is added to the onApplyObservable
  27982. */
  27983. onApply: (effect: Effect) => void;
  27984. /**
  27985. * An event triggered before rendering the postprocess
  27986. */
  27987. onBeforeRenderObservable: Observable<Effect>;
  27988. private _onBeforeRenderObserver;
  27989. /**
  27990. * A function that is added to the onBeforeRenderObservable
  27991. */
  27992. onBeforeRender: (effect: Effect) => void;
  27993. /**
  27994. * An event triggered after rendering the postprocess
  27995. */
  27996. onAfterRenderObservable: Observable<Effect>;
  27997. private _onAfterRenderObserver;
  27998. /**
  27999. * A function that is added to the onAfterRenderObservable
  28000. */
  28001. onAfterRender: (efect: Effect) => void;
  28002. /**
  28003. * 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
  28004. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28005. */
  28006. inputTexture: InternalTexture;
  28007. /**
  28008. * Gets the camera which post process is applied to.
  28009. * @returns The camera the post process is applied to.
  28010. */
  28011. getCamera(): Camera;
  28012. /**
  28013. * Gets the texel size of the postprocess.
  28014. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28015. */
  28016. readonly texelSize: Vector2;
  28017. /**
  28018. * Creates a new instance PostProcess
  28019. * @param name The name of the PostProcess.
  28020. * @param fragmentUrl The url of the fragment shader to be used.
  28021. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28022. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28023. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28024. * @param camera The camera to apply the render pass to.
  28025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28026. * @param engine The engine which the post process will be applied. (default: current engine)
  28027. * @param reusable If the post process can be reused on the same frame. (default: false)
  28028. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28029. * @param textureType Type of textures used when performing the post process. (default: 0)
  28030. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28031. * @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
  28032. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  28033. */
  28034. constructor(
  28035. /** Name of the PostProcess. */
  28036. 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);
  28037. /**
  28038. * Gets the engine which this post process belongs to.
  28039. * @returns The engine the post process was enabled with.
  28040. */
  28041. getEngine(): Engine;
  28042. /**
  28043. * The effect that is created when initializing the post process.
  28044. * @returns The created effect corrisponding the the postprocess.
  28045. */
  28046. getEffect(): Effect;
  28047. /**
  28048. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28049. * @param postProcess The post process to share the output with.
  28050. * @returns This post process.
  28051. */
  28052. shareOutputWith(postProcess: PostProcess): PostProcess;
  28053. /**
  28054. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28055. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28056. */
  28057. useOwnOutput(): void;
  28058. /**
  28059. * Updates the effect with the current post process compile time values and recompiles the shader.
  28060. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28061. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28062. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28063. * @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
  28064. * @param onCompiled Called when the shader has been compiled.
  28065. * @param onError Called if there is an error when compiling a shader.
  28066. */
  28067. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28068. /**
  28069. * The post process is reusable if it can be used multiple times within one frame.
  28070. * @returns If the post process is reusable
  28071. */
  28072. isReusable(): boolean;
  28073. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28074. markTextureDirty(): void;
  28075. /**
  28076. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28077. * 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.
  28078. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28079. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28080. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28081. * @returns The target texture that was bound to be written to.
  28082. */
  28083. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28084. /**
  28085. * If the post process is supported.
  28086. */
  28087. readonly isSupported: boolean;
  28088. /**
  28089. * The aspect ratio of the output texture.
  28090. */
  28091. readonly aspectRatio: number;
  28092. /**
  28093. * Get a value indicating if the post-process is ready to be used
  28094. * @returns true if the post-process is ready (shader is compiled)
  28095. */
  28096. isReady(): boolean;
  28097. /**
  28098. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28099. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  28100. */
  28101. apply(): Nullable<Effect>;
  28102. private _disposeTextures();
  28103. /**
  28104. * Disposes the post process.
  28105. * @param camera The camera to dispose the post process on.
  28106. */
  28107. dispose(camera?: Camera): void;
  28108. }
  28109. }
  28110. declare module BABYLON {
  28111. /**
  28112. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28113. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28114. */
  28115. class PostProcessManager {
  28116. private _scene;
  28117. private _indexBuffer;
  28118. private _vertexBuffers;
  28119. /**
  28120. * Creates a new instance PostProcess
  28121. * @param scene The scene that the post process is associated with.
  28122. */
  28123. constructor(scene: Scene);
  28124. private _prepareBuffers();
  28125. private _buildIndexBuffer();
  28126. /**
  28127. * Rebuilds the vertex buffers of the manager.
  28128. */
  28129. _rebuild(): void;
  28130. /**
  28131. * Prepares a frame to be run through a post process.
  28132. * @param sourceTexture The input texture to the post procesess. (default: null)
  28133. * @param postProcesses An array of post processes to be run. (default: null)
  28134. * @returns True if the post processes were able to be run.
  28135. */
  28136. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28137. /**
  28138. * Manually render a set of post processes to a texture.
  28139. * @param postProcesses An array of post processes to be run.
  28140. * @param targetTexture The target texture to render to.
  28141. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28142. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28143. * @param lodLevel defines which lod of the texture to render to
  28144. */
  28145. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  28146. /**
  28147. * Finalize the result of the output of the postprocesses.
  28148. * @param doNotPresent If true the result will not be displayed to the screen.
  28149. * @param targetTexture The target texture to render to.
  28150. * @param faceIndex The index of the face to bind the target texture to.
  28151. * @param postProcesses The array of post processes to render.
  28152. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28153. */
  28154. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28155. /**
  28156. * Disposes of the post process manager.
  28157. */
  28158. dispose(): void;
  28159. }
  28160. }
  28161. declare module BABYLON {
  28162. class RefractionPostProcess extends PostProcess {
  28163. color: Color3;
  28164. depth: number;
  28165. colorLevel: number;
  28166. private _refTexture;
  28167. private _ownRefractionTexture;
  28168. /**
  28169. * Gets or sets the refraction texture
  28170. * Please note that you are responsible for disposing the texture if you set it manually
  28171. */
  28172. refractionTexture: Texture;
  28173. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28174. dispose(camera: Camera): void;
  28175. }
  28176. }
  28177. declare module BABYLON {
  28178. /**
  28179. * The SharpenPostProcess applies a sharpen kernel to every pixel
  28180. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  28181. */
  28182. class SharpenPostProcess extends PostProcess {
  28183. /**
  28184. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  28185. */
  28186. colorAmount: number;
  28187. /**
  28188. * How much sharpness should be applied (default: 0.3)
  28189. */
  28190. edgeAmount: number;
  28191. /**
  28192. * Creates a new instance ConvolutionPostProcess
  28193. * @param name The name of the effect.
  28194. * @param options The required width/height ratio to downsize to before computing the render pass.
  28195. * @param camera The camera to apply the render pass to.
  28196. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28197. * @param engine The engine which the post process will be applied. (default: current engine)
  28198. * @param reusable If the post process can be reused on the same frame. (default: false)
  28199. * @param textureType Type of textures used when performing the post process. (default: 0)
  28200. * @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)
  28201. */
  28202. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  28203. }
  28204. }
  28205. declare module BABYLON {
  28206. class StereoscopicInterlacePostProcess extends PostProcess {
  28207. private _stepSize;
  28208. private _passedProcess;
  28209. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  28210. }
  28211. }
  28212. declare module BABYLON {
  28213. /** Defines operator used for tonemapping */
  28214. enum TonemappingOperator {
  28215. /** Hable */
  28216. Hable = 0,
  28217. /** Reinhard */
  28218. Reinhard = 1,
  28219. /** HejiDawson */
  28220. HejiDawson = 2,
  28221. /** Photographic */
  28222. Photographic = 3,
  28223. }
  28224. /**
  28225. * Defines a post process to apply tone mapping
  28226. */
  28227. class TonemapPostProcess extends PostProcess {
  28228. private _operator;
  28229. /** Defines the required exposure adjustement */
  28230. exposureAdjustment: number;
  28231. /**
  28232. * Creates a new TonemapPostProcess
  28233. * @param name defines the name of the postprocess
  28234. * @param _operator defines the operator to use
  28235. * @param exposureAdjustment defines the required exposure adjustement
  28236. * @param camera defines the camera to use (can be null)
  28237. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  28238. * @param engine defines the hosting engine (can be ignore if camera is set)
  28239. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28240. */
  28241. constructor(name: string, _operator: TonemappingOperator,
  28242. /** Defines the required exposure adjustement */
  28243. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  28244. }
  28245. }
  28246. declare module BABYLON {
  28247. class VolumetricLightScatteringPostProcess extends PostProcess {
  28248. private _volumetricLightScatteringPass;
  28249. private _volumetricLightScatteringRTT;
  28250. private _viewPort;
  28251. private _screenCoordinates;
  28252. private _cachedDefines;
  28253. /**
  28254. * If not undefined, the mesh position is computed from the attached node position
  28255. */
  28256. attachedNode: {
  28257. position: Vector3;
  28258. };
  28259. /**
  28260. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  28261. */
  28262. customMeshPosition: Vector3;
  28263. /**
  28264. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  28265. */
  28266. useCustomMeshPosition: boolean;
  28267. /**
  28268. * If the post-process should inverse the light scattering direction
  28269. */
  28270. invert: boolean;
  28271. /**
  28272. * The internal mesh used by the post-process
  28273. */
  28274. mesh: Mesh;
  28275. useDiffuseColor: boolean;
  28276. /**
  28277. * Array containing the excluded meshes not rendered in the internal pass
  28278. */
  28279. excludedMeshes: AbstractMesh[];
  28280. /**
  28281. * Controls the overall intensity of the post-process
  28282. */
  28283. exposure: number;
  28284. /**
  28285. * Dissipates each sample's contribution in range [0, 1]
  28286. */
  28287. decay: number;
  28288. /**
  28289. * Controls the overall intensity of each sample
  28290. */
  28291. weight: number;
  28292. /**
  28293. * Controls the density of each sample
  28294. */
  28295. density: number;
  28296. /**
  28297. * @constructor
  28298. * @param {string} name - The post-process name
  28299. * @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)
  28300. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  28301. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  28302. * @param {number} samples - The post-process quality, default 100
  28303. * @param {number} samplingMode - The post-process filtering mode
  28304. * @param {BABYLON.Engine} engine - The babylon engine
  28305. * @param {boolean} reusable - If the post-process is reusable
  28306. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  28307. */
  28308. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  28309. getClassName(): string;
  28310. private _isReady(subMesh, useInstances);
  28311. /**
  28312. * Sets the new light position for light scattering effect
  28313. * @param {BABYLON.Vector3} The new custom light position
  28314. */
  28315. setCustomMeshPosition(position: Vector3): void;
  28316. /**
  28317. * Returns the light position for light scattering effect
  28318. * @return {BABYLON.Vector3} The custom light position
  28319. */
  28320. getCustomMeshPosition(): Vector3;
  28321. /**
  28322. * Disposes the internal assets and detaches the post-process from the camera
  28323. */
  28324. dispose(camera: Camera): void;
  28325. /**
  28326. * Returns the render target texture used by the post-process
  28327. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  28328. */
  28329. getPass(): RenderTargetTexture;
  28330. private _meshExcluded(mesh);
  28331. private _createPass(scene, ratio);
  28332. private _updateMeshScreenCoordinates(scene);
  28333. /**
  28334. * Creates a default mesh for the Volumeric Light Scattering post-process
  28335. * @param {string} The mesh name
  28336. * @param {BABYLON.Scene} The scene where to create the mesh
  28337. * @return {BABYLON.Mesh} the default mesh
  28338. */
  28339. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  28340. }
  28341. }
  28342. declare module BABYLON {
  28343. class VRDistortionCorrectionPostProcess extends PostProcess {
  28344. private _isRightEye;
  28345. private _distortionFactors;
  28346. private _postProcessScaleFactor;
  28347. private _lensCenterOffset;
  28348. private _scaleIn;
  28349. private _scaleFactor;
  28350. private _lensCenter;
  28351. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  28352. }
  28353. }
  28354. declare module BABYLON {
  28355. /**
  28356. * @hidden
  28357. **/
  28358. class _AlphaState {
  28359. private _isAlphaBlendDirty;
  28360. private _isBlendFunctionParametersDirty;
  28361. private _isBlendEquationParametersDirty;
  28362. private _isBlendConstantsDirty;
  28363. private _alphaBlend;
  28364. private _blendFunctionParameters;
  28365. private _blendEquationParameters;
  28366. private _blendConstants;
  28367. /**
  28368. * Initializes the state.
  28369. */
  28370. constructor();
  28371. readonly isDirty: boolean;
  28372. alphaBlend: boolean;
  28373. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28374. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28375. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28376. reset(): void;
  28377. apply(gl: WebGLRenderingContext): void;
  28378. }
  28379. }
  28380. declare module BABYLON {
  28381. /**
  28382. * @hidden
  28383. **/
  28384. class _DepthCullingState {
  28385. private _isDepthTestDirty;
  28386. private _isDepthMaskDirty;
  28387. private _isDepthFuncDirty;
  28388. private _isCullFaceDirty;
  28389. private _isCullDirty;
  28390. private _isZOffsetDirty;
  28391. private _isFrontFaceDirty;
  28392. private _depthTest;
  28393. private _depthMask;
  28394. private _depthFunc;
  28395. private _cull;
  28396. private _cullFace;
  28397. private _zOffset;
  28398. private _frontFace;
  28399. /**
  28400. * Initializes the state.
  28401. */
  28402. constructor();
  28403. readonly isDirty: boolean;
  28404. zOffset: number;
  28405. cullFace: Nullable<number>;
  28406. cull: Nullable<boolean>;
  28407. depthFunc: Nullable<number>;
  28408. depthMask: boolean;
  28409. depthTest: boolean;
  28410. frontFace: Nullable<number>;
  28411. reset(): void;
  28412. apply(gl: WebGLRenderingContext): void;
  28413. }
  28414. }
  28415. declare module BABYLON {
  28416. /**
  28417. * @hidden
  28418. **/
  28419. class _StencilState {
  28420. private _isStencilTestDirty;
  28421. private _isStencilMaskDirty;
  28422. private _isStencilFuncDirty;
  28423. private _isStencilOpDirty;
  28424. private _stencilTest;
  28425. private _stencilMask;
  28426. private _stencilFunc;
  28427. private _stencilFuncRef;
  28428. private _stencilFuncMask;
  28429. private _stencilOpStencilFail;
  28430. private _stencilOpDepthFail;
  28431. private _stencilOpStencilDepthPass;
  28432. readonly isDirty: boolean;
  28433. stencilFunc: number;
  28434. stencilFuncRef: number;
  28435. stencilFuncMask: number;
  28436. stencilOpStencilFail: number;
  28437. stencilOpDepthFail: number;
  28438. stencilOpStencilDepthPass: number;
  28439. stencilMask: number;
  28440. stencilTest: boolean;
  28441. constructor();
  28442. reset(): void;
  28443. apply(gl: WebGLRenderingContext): void;
  28444. }
  28445. }
  28446. declare module BABYLON {
  28447. class Sprite {
  28448. name: string;
  28449. position: Vector3;
  28450. color: Color4;
  28451. width: number;
  28452. height: number;
  28453. angle: number;
  28454. cellIndex: number;
  28455. invertU: number;
  28456. invertV: number;
  28457. disposeWhenFinishedAnimating: boolean;
  28458. animations: Animation[];
  28459. isPickable: boolean;
  28460. actionManager: ActionManager;
  28461. private _animationStarted;
  28462. private _loopAnimation;
  28463. private _fromIndex;
  28464. private _toIndex;
  28465. private _delay;
  28466. private _direction;
  28467. private _manager;
  28468. private _time;
  28469. private _onAnimationEnd;
  28470. /**
  28471. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  28472. */
  28473. isVisible: boolean;
  28474. size: number;
  28475. constructor(name: string, manager: SpriteManager);
  28476. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  28477. stopAnimation(): void;
  28478. _animate(deltaTime: number): void;
  28479. dispose(): void;
  28480. }
  28481. }
  28482. declare module BABYLON {
  28483. class SpriteManager {
  28484. name: string;
  28485. sprites: Sprite[];
  28486. renderingGroupId: number;
  28487. layerMask: number;
  28488. fogEnabled: boolean;
  28489. isPickable: boolean;
  28490. cellWidth: number;
  28491. cellHeight: number;
  28492. /**
  28493. * An event triggered when the manager is disposed.
  28494. */
  28495. onDisposeObservable: Observable<SpriteManager>;
  28496. private _onDisposeObserver;
  28497. onDispose: () => void;
  28498. private _capacity;
  28499. private _spriteTexture;
  28500. private _epsilon;
  28501. private _scene;
  28502. private _vertexData;
  28503. private _buffer;
  28504. private _vertexBuffers;
  28505. private _indexBuffer;
  28506. private _effectBase;
  28507. private _effectFog;
  28508. texture: Texture;
  28509. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  28510. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  28511. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  28512. render(): void;
  28513. dispose(): void;
  28514. }
  28515. }
  28516. declare module BABYLON {
  28517. /**
  28518. * Class used to evalaute queries containing `and` and `or` operators
  28519. */
  28520. class AndOrNotEvaluator {
  28521. /**
  28522. * Evaluate a query
  28523. * @param query defines the query to evaluate
  28524. * @param evaluateCallback defines the callback used to filter result
  28525. * @returns true if the query matches
  28526. */
  28527. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  28528. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  28529. private static _SimplifyNegation(booleanString);
  28530. }
  28531. }
  28532. declare module BABYLON {
  28533. /**
  28534. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  28535. */
  28536. enum AssetTaskState {
  28537. /**
  28538. * Initialization
  28539. */
  28540. INIT = 0,
  28541. /**
  28542. * Running
  28543. */
  28544. RUNNING = 1,
  28545. /**
  28546. * Done
  28547. */
  28548. DONE = 2,
  28549. /**
  28550. * Error
  28551. */
  28552. ERROR = 3,
  28553. }
  28554. /**
  28555. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  28556. */
  28557. abstract class AbstractAssetTask {
  28558. /**
  28559. * Task name
  28560. */ name: string;
  28561. /**
  28562. * Callback called when the task is successful
  28563. */
  28564. onSuccess: (task: any) => void;
  28565. /**
  28566. * Callback called when the task is not successful
  28567. */
  28568. onError: (task: any, message?: string, exception?: any) => void;
  28569. /**
  28570. * Creates a new {BABYLON.AssetsManager}
  28571. * @param name defines the name of the task
  28572. */
  28573. constructor(
  28574. /**
  28575. * Task name
  28576. */ name: string);
  28577. private _isCompleted;
  28578. private _taskState;
  28579. private _errorObject;
  28580. /**
  28581. * Get if the task is completed
  28582. */
  28583. readonly isCompleted: boolean;
  28584. /**
  28585. * Gets the current state of the task
  28586. */
  28587. readonly taskState: AssetTaskState;
  28588. /**
  28589. * Gets the current error object (if task is in error)
  28590. */
  28591. readonly errorObject: {
  28592. message?: string;
  28593. exception?: any;
  28594. };
  28595. /**
  28596. * Internal only
  28597. * @hidden
  28598. */
  28599. _setErrorObject(message?: string, exception?: any): void;
  28600. /**
  28601. * Execute the current task
  28602. * @param scene defines the scene where you want your assets to be loaded
  28603. * @param onSuccess is a callback called when the task is successfully executed
  28604. * @param onError is a callback called if an error occurs
  28605. */
  28606. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28607. /**
  28608. * Execute the current task
  28609. * @param scene defines the scene where you want your assets to be loaded
  28610. * @param onSuccess is a callback called when the task is successfully executed
  28611. * @param onError is a callback called if an error occurs
  28612. */
  28613. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28614. /**
  28615. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  28616. * This can be used with failed tasks that have the reason for failure fixed.
  28617. */
  28618. reset(): void;
  28619. private onErrorCallback(onError, message?, exception?);
  28620. private onDoneCallback(onSuccess, onError);
  28621. }
  28622. /**
  28623. * Define the interface used by progress events raised during assets loading
  28624. */
  28625. interface IAssetsProgressEvent {
  28626. /**
  28627. * Defines the number of remaining tasks to process
  28628. */
  28629. remainingCount: number;
  28630. /**
  28631. * Defines the total number of tasks
  28632. */
  28633. totalCount: number;
  28634. /**
  28635. * Defines the task that was just processed
  28636. */
  28637. task: AbstractAssetTask;
  28638. }
  28639. /**
  28640. * Class used to share progress information about assets loading
  28641. */
  28642. class AssetsProgressEvent implements IAssetsProgressEvent {
  28643. /**
  28644. * Defines the number of remaining tasks to process
  28645. */
  28646. remainingCount: number;
  28647. /**
  28648. * Defines the total number of tasks
  28649. */
  28650. totalCount: number;
  28651. /**
  28652. * Defines the task that was just processed
  28653. */
  28654. task: AbstractAssetTask;
  28655. /**
  28656. * Creates a {BABYLON.AssetsProgressEvent}
  28657. * @param remainingCount defines the number of remaining tasks to process
  28658. * @param totalCount defines the total number of tasks
  28659. * @param task defines the task that was just processed
  28660. */
  28661. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  28662. }
  28663. /**
  28664. * Define a task used by {BABYLON.AssetsManager} to load meshes
  28665. */
  28666. class MeshAssetTask extends AbstractAssetTask {
  28667. /**
  28668. * Defines the name of the task
  28669. */
  28670. name: string;
  28671. /**
  28672. * Defines the list of mesh's names you want to load
  28673. */
  28674. meshesNames: any;
  28675. /**
  28676. * Defines the root url to use as a base to load your meshes and associated resources
  28677. */
  28678. rootUrl: string;
  28679. /**
  28680. * Defines the filename of the scene to load from
  28681. */
  28682. sceneFilename: string;
  28683. /**
  28684. * Gets the list of loaded meshes
  28685. */
  28686. loadedMeshes: Array<AbstractMesh>;
  28687. /**
  28688. * Gets the list of loaded particle systems
  28689. */
  28690. loadedParticleSystems: Array<IParticleSystem>;
  28691. /**
  28692. * Gets the list of loaded skeletons
  28693. */
  28694. loadedSkeletons: Array<Skeleton>;
  28695. /**
  28696. * Callback called when the task is successful
  28697. */
  28698. onSuccess: (task: MeshAssetTask) => void;
  28699. /**
  28700. * Callback called when the task is successful
  28701. */
  28702. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  28703. /**
  28704. * Creates a new {BABYLON.MeshAssetTask}
  28705. * @param name defines the name of the task
  28706. * @param meshesNames defines the list of mesh's names you want to load
  28707. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  28708. * @param sceneFilename defines the filename of the scene to load from
  28709. */
  28710. constructor(
  28711. /**
  28712. * Defines the name of the task
  28713. */
  28714. name: string,
  28715. /**
  28716. * Defines the list of mesh's names you want to load
  28717. */
  28718. meshesNames: any,
  28719. /**
  28720. * Defines the root url to use as a base to load your meshes and associated resources
  28721. */
  28722. rootUrl: string,
  28723. /**
  28724. * Defines the filename of the scene to load from
  28725. */
  28726. sceneFilename: string);
  28727. /**
  28728. * Execute the current task
  28729. * @param scene defines the scene where you want your assets to be loaded
  28730. * @param onSuccess is a callback called when the task is successfully executed
  28731. * @param onError is a callback called if an error occurs
  28732. */
  28733. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28734. }
  28735. /**
  28736. * Define a task used by {BABYLON.AssetsManager} to load text content
  28737. */
  28738. class TextFileAssetTask extends AbstractAssetTask {
  28739. /**
  28740. * Defines the name of the task
  28741. */
  28742. name: string;
  28743. /**
  28744. * Defines the location of the file to load
  28745. */
  28746. url: string;
  28747. /**
  28748. * Gets the loaded text string
  28749. */
  28750. text: string;
  28751. /**
  28752. * Callback called when the task is successful
  28753. */
  28754. onSuccess: (task: TextFileAssetTask) => void;
  28755. /**
  28756. * Callback called when the task is successful
  28757. */
  28758. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  28759. /**
  28760. * Creates a new TextFileAssetTask object
  28761. * @param name defines the name of the task
  28762. * @param url defines the location of the file to load
  28763. */
  28764. constructor(
  28765. /**
  28766. * Defines the name of the task
  28767. */
  28768. name: string,
  28769. /**
  28770. * Defines the location of the file to load
  28771. */
  28772. url: string);
  28773. /**
  28774. * Execute the current task
  28775. * @param scene defines the scene where you want your assets to be loaded
  28776. * @param onSuccess is a callback called when the task is successfully executed
  28777. * @param onError is a callback called if an error occurs
  28778. */
  28779. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28780. }
  28781. /**
  28782. * Define a task used by {BABYLON.AssetsManager} to load binary data
  28783. */
  28784. class BinaryFileAssetTask extends AbstractAssetTask {
  28785. /**
  28786. * Defines the name of the task
  28787. */
  28788. name: string;
  28789. /**
  28790. * Defines the location of the file to load
  28791. */
  28792. url: string;
  28793. /**
  28794. * Gets the lodaded data (as an array buffer)
  28795. */
  28796. data: ArrayBuffer;
  28797. /**
  28798. * Callback called when the task is successful
  28799. */
  28800. onSuccess: (task: BinaryFileAssetTask) => void;
  28801. /**
  28802. * Callback called when the task is successful
  28803. */
  28804. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  28805. /**
  28806. * Creates a new BinaryFileAssetTask object
  28807. * @param name defines the name of the new task
  28808. * @param url defines the location of the file to load
  28809. */
  28810. constructor(
  28811. /**
  28812. * Defines the name of the task
  28813. */
  28814. name: string,
  28815. /**
  28816. * Defines the location of the file to load
  28817. */
  28818. url: string);
  28819. /**
  28820. * Execute the current task
  28821. * @param scene defines the scene where you want your assets to be loaded
  28822. * @param onSuccess is a callback called when the task is successfully executed
  28823. * @param onError is a callback called if an error occurs
  28824. */
  28825. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28826. }
  28827. /**
  28828. * Define a task used by {BABYLON.AssetsManager} to load images
  28829. */
  28830. class ImageAssetTask extends AbstractAssetTask {
  28831. /**
  28832. * Defines the name of the task
  28833. */
  28834. name: string;
  28835. /**
  28836. * Defines the location of the image to load
  28837. */
  28838. url: string;
  28839. /**
  28840. * Gets the loaded images
  28841. */
  28842. image: HTMLImageElement;
  28843. /**
  28844. * Callback called when the task is successful
  28845. */
  28846. onSuccess: (task: ImageAssetTask) => void;
  28847. /**
  28848. * Callback called when the task is successful
  28849. */
  28850. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  28851. /**
  28852. * Creates a new ImageAssetTask
  28853. * @param name defines the name of the task
  28854. * @param url defines the location of the image to load
  28855. */
  28856. constructor(
  28857. /**
  28858. * Defines the name of the task
  28859. */
  28860. name: string,
  28861. /**
  28862. * Defines the location of the image to load
  28863. */
  28864. url: string);
  28865. /**
  28866. * Execute the current task
  28867. * @param scene defines the scene where you want your assets to be loaded
  28868. * @param onSuccess is a callback called when the task is successfully executed
  28869. * @param onError is a callback called if an error occurs
  28870. */
  28871. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28872. }
  28873. /**
  28874. * Defines the interface used by texture loading tasks
  28875. */
  28876. interface ITextureAssetTask<TEX extends BaseTexture> {
  28877. /**
  28878. * Gets the loaded texture
  28879. */
  28880. texture: TEX;
  28881. }
  28882. /**
  28883. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  28884. */
  28885. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  28886. /**
  28887. * Defines the name of the task
  28888. */
  28889. name: string;
  28890. /**
  28891. * Defines the location of the file to load
  28892. */
  28893. url: string;
  28894. /**
  28895. * Defines if mipmap should not be generated (default is false)
  28896. */
  28897. noMipmap: boolean | undefined;
  28898. /**
  28899. * Defines if texture must be inverted on Y axis (default is false)
  28900. */
  28901. invertY: boolean | undefined;
  28902. /**
  28903. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28904. */
  28905. samplingMode: number;
  28906. /**
  28907. * Gets the loaded texture
  28908. */
  28909. texture: Texture;
  28910. /**
  28911. * Callback called when the task is successful
  28912. */
  28913. onSuccess: (task: TextureAssetTask) => void;
  28914. /**
  28915. * Callback called when the task is successful
  28916. */
  28917. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  28918. /**
  28919. * Creates a new TextureAssetTask object
  28920. * @param name defines the name of the task
  28921. * @param url defines the location of the file to load
  28922. * @param noMipmap defines if mipmap should not be generated (default is false)
  28923. * @param invertY defines if texture must be inverted on Y axis (default is false)
  28924. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28925. */
  28926. constructor(
  28927. /**
  28928. * Defines the name of the task
  28929. */
  28930. name: string,
  28931. /**
  28932. * Defines the location of the file to load
  28933. */
  28934. url: string,
  28935. /**
  28936. * Defines if mipmap should not be generated (default is false)
  28937. */
  28938. noMipmap?: boolean | undefined,
  28939. /**
  28940. * Defines if texture must be inverted on Y axis (default is false)
  28941. */
  28942. invertY?: boolean | undefined,
  28943. /**
  28944. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  28945. */
  28946. samplingMode?: number);
  28947. /**
  28948. * Execute the current task
  28949. * @param scene defines the scene where you want your assets to be loaded
  28950. * @param onSuccess is a callback called when the task is successfully executed
  28951. * @param onError is a callback called if an error occurs
  28952. */
  28953. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  28954. }
  28955. /**
  28956. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  28957. */
  28958. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  28959. /**
  28960. * Defines the name of the task
  28961. */
  28962. name: string;
  28963. /**
  28964. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  28965. */
  28966. url: string;
  28967. /**
  28968. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  28969. */
  28970. extensions: string[] | undefined;
  28971. /**
  28972. * Defines if mipmaps should not be generated (default is false)
  28973. */
  28974. noMipmap: boolean | undefined;
  28975. /**
  28976. * Defines the explicit list of files (undefined by default)
  28977. */
  28978. files: string[] | undefined;
  28979. /**
  28980. * Gets the loaded texture
  28981. */
  28982. texture: CubeTexture;
  28983. /**
  28984. * Callback called when the task is successful
  28985. */
  28986. onSuccess: (task: CubeTextureAssetTask) => void;
  28987. /**
  28988. * Callback called when the task is successful
  28989. */
  28990. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  28991. /**
  28992. * Creates a new CubeTextureAssetTask
  28993. * @param name defines the name of the task
  28994. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  28995. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  28996. * @param noMipmap defines if mipmaps should not be generated (default is false)
  28997. * @param files defines the explicit list of files (undefined by default)
  28998. */
  28999. constructor(
  29000. /**
  29001. * Defines the name of the task
  29002. */
  29003. name: string,
  29004. /**
  29005. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  29006. */
  29007. url: string,
  29008. /**
  29009. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  29010. */
  29011. extensions?: string[] | undefined,
  29012. /**
  29013. * Defines if mipmaps should not be generated (default is false)
  29014. */
  29015. noMipmap?: boolean | undefined,
  29016. /**
  29017. * Defines the explicit list of files (undefined by default)
  29018. */
  29019. files?: string[] | undefined);
  29020. /**
  29021. * Execute the current task
  29022. * @param scene defines the scene where you want your assets to be loaded
  29023. * @param onSuccess is a callback called when the task is successfully executed
  29024. * @param onError is a callback called if an error occurs
  29025. */
  29026. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29027. }
  29028. /**
  29029. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  29030. */
  29031. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  29032. /**
  29033. * Defines the name of the task
  29034. */
  29035. name: string;
  29036. /**
  29037. * Defines the location of the file to load
  29038. */
  29039. url: string;
  29040. /**
  29041. * Defines the desired size (the more it increases the longer the generation will be)
  29042. */
  29043. size: number;
  29044. /**
  29045. * Defines if mipmaps should not be generated (default is false)
  29046. */
  29047. noMipmap: boolean;
  29048. /**
  29049. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  29050. */
  29051. generateHarmonics: boolean;
  29052. /**
  29053. * 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)
  29054. */
  29055. gammaSpace: boolean;
  29056. /**
  29057. * Internal Use Only
  29058. */
  29059. reserved: boolean;
  29060. /**
  29061. * Gets the loaded texture
  29062. */
  29063. texture: HDRCubeTexture;
  29064. /**
  29065. * Callback called when the task is successful
  29066. */
  29067. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  29068. /**
  29069. * Callback called when the task is successful
  29070. */
  29071. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  29072. /**
  29073. * Creates a new HDRCubeTextureAssetTask object
  29074. * @param name defines the name of the task
  29075. * @param url defines the location of the file to load
  29076. * @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.
  29077. * @param noMipmap defines if mipmaps should not be generated (default is false)
  29078. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  29079. * @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)
  29080. * @param reserved Internal use only
  29081. */
  29082. constructor(
  29083. /**
  29084. * Defines the name of the task
  29085. */
  29086. name: string,
  29087. /**
  29088. * Defines the location of the file to load
  29089. */
  29090. url: string,
  29091. /**
  29092. * Defines the desired size (the more it increases the longer the generation will be)
  29093. */
  29094. size: number,
  29095. /**
  29096. * Defines if mipmaps should not be generated (default is false)
  29097. */
  29098. noMipmap?: boolean,
  29099. /**
  29100. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  29101. */
  29102. generateHarmonics?: boolean,
  29103. /**
  29104. * 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)
  29105. */
  29106. gammaSpace?: boolean,
  29107. /**
  29108. * Internal Use Only
  29109. */
  29110. reserved?: boolean);
  29111. /**
  29112. * Execute the current task
  29113. * @param scene defines the scene where you want your assets to be loaded
  29114. * @param onSuccess is a callback called when the task is successfully executed
  29115. * @param onError is a callback called if an error occurs
  29116. */
  29117. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  29118. }
  29119. /**
  29120. * This class can be used to easily import assets into a scene
  29121. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  29122. */
  29123. class AssetsManager {
  29124. private _scene;
  29125. private _isLoading;
  29126. protected _tasks: AbstractAssetTask[];
  29127. protected _waitingTasksCount: number;
  29128. protected _totalTasksCount: number;
  29129. /**
  29130. * Callback called when all tasks are processed
  29131. */
  29132. onFinish: (tasks: AbstractAssetTask[]) => void;
  29133. /**
  29134. * Callback called when a task is successful
  29135. */
  29136. onTaskSuccess: (task: AbstractAssetTask) => void;
  29137. /**
  29138. * Callback called when a task had an error
  29139. */
  29140. onTaskError: (task: AbstractAssetTask) => void;
  29141. /**
  29142. * Callback called when a task is done (whatever the result is)
  29143. */
  29144. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  29145. /**
  29146. * Observable called when all tasks are processed
  29147. */
  29148. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  29149. /**
  29150. * Observable called when a task had an error
  29151. */
  29152. onTaskErrorObservable: Observable<AbstractAssetTask>;
  29153. /**
  29154. * Observable called when a task is successful
  29155. */
  29156. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  29157. /**
  29158. * Observable called when a task is done (whatever the result is)
  29159. */
  29160. onProgressObservable: Observable<IAssetsProgressEvent>;
  29161. /**
  29162. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  29163. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29164. */
  29165. useDefaultLoadingScreen: boolean;
  29166. /**
  29167. * Creates a new AssetsManager
  29168. * @param scene defines the scene to work on
  29169. */
  29170. constructor(scene: Scene);
  29171. /**
  29172. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  29173. * @param taskName defines the name of the new task
  29174. * @param meshesNames defines the name of meshes to load
  29175. * @param rootUrl defines the root url to use to locate files
  29176. * @param sceneFilename defines the filename of the scene file
  29177. * @returns a new {BABYLON.MeshAssetTask} object
  29178. */
  29179. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  29180. /**
  29181. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  29182. * @param taskName defines the name of the new task
  29183. * @param url defines the url of the file to load
  29184. * @returns a new {BABYLON.TextFileAssetTask} object
  29185. */
  29186. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  29187. /**
  29188. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  29189. * @param taskName defines the name of the new task
  29190. * @param url defines the url of the file to load
  29191. * @returns a new {BABYLON.BinaryFileAssetTask} object
  29192. */
  29193. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  29194. /**
  29195. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  29196. * @param taskName defines the name of the new task
  29197. * @param url defines the url of the file to load
  29198. * @returns a new {BABYLON.ImageAssetTask} object
  29199. */
  29200. addImageTask(taskName: string, url: string): ImageAssetTask;
  29201. /**
  29202. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  29203. * @param taskName defines the name of the new task
  29204. * @param url defines the url of the file to load
  29205. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29206. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  29207. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  29208. * @returns a new {BABYLON.TextureAssetTask} object
  29209. */
  29210. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  29211. /**
  29212. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  29213. * @param taskName defines the name of the new task
  29214. * @param url defines the url of the file to load
  29215. * @param extensions defines the extension to use to load the cube map (can be null)
  29216. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29217. * @param files defines the list of files to load (can be null)
  29218. * @returns a new {BABYLON.CubeTextureAssetTask} object
  29219. */
  29220. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  29221. /**
  29222. *
  29223. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  29224. * @param taskName defines the name of the new task
  29225. * @param url defines the url of the file to load
  29226. * @param size defines the size you want for the cubemap (can be null)
  29227. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  29228. * @param generateHarmonics defines if you want to automatically generate (true by default)
  29229. * @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)
  29230. * @param reserved Internal use only
  29231. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  29232. */
  29233. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  29234. /**
  29235. * Remove a task from the assets manager.
  29236. * @param task the task to remove
  29237. */
  29238. removeTask(task: AbstractAssetTask): void;
  29239. private _decreaseWaitingTasksCount(task);
  29240. private _runTask(task);
  29241. /**
  29242. * Reset the {BABYLON.AssetsManager} and remove all tasks
  29243. * @return the current instance of the {BABYLON.AssetsManager}
  29244. */
  29245. reset(): AssetsManager;
  29246. /**
  29247. * Start the loading process
  29248. * @return the current instance of the {BABYLON.AssetsManager}
  29249. */
  29250. load(): AssetsManager;
  29251. }
  29252. }
  29253. declare module BABYLON {
  29254. /**
  29255. * Class used to enable access to IndexedDB
  29256. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  29257. */
  29258. class Database {
  29259. private callbackManifestChecked;
  29260. private currentSceneUrl;
  29261. private db;
  29262. private _enableSceneOffline;
  29263. private _enableTexturesOffline;
  29264. private manifestVersionFound;
  29265. private mustUpdateRessources;
  29266. private hasReachedQuota;
  29267. private isSupported;
  29268. private idbFactory;
  29269. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  29270. static IsUASupportingBlobStorage: boolean;
  29271. /** Gets a boolean indicating if Database storate is enabled */
  29272. static IDBStorageEnabled: boolean;
  29273. /**
  29274. * Gets a boolean indicating if scene must be saved in the database
  29275. */
  29276. readonly enableSceneOffline: boolean;
  29277. /**
  29278. * Gets a boolean indicating if textures must be saved in the database
  29279. */
  29280. readonly enableTexturesOffline: boolean;
  29281. /**
  29282. * Creates a new Database
  29283. * @param urlToScene defines the url to load the scene
  29284. * @param callbackManifestChecked defines the callback to use when manifest is checked
  29285. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  29286. */
  29287. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  29288. private static _ParseURL;
  29289. private static _ReturnFullUrlLocation;
  29290. private _checkManifestFile();
  29291. /**
  29292. * Open the database and make it available
  29293. * @param successCallback defines the callback to call on success
  29294. * @param errorCallback defines the callback to call on error
  29295. */
  29296. openAsync(successCallback: () => void, errorCallback: () => void): void;
  29297. /**
  29298. * Loads an image from the database
  29299. * @param url defines the url to load from
  29300. * @param image defines the target DOM image
  29301. */
  29302. loadImageFromDB(url: string, image: HTMLImageElement): void;
  29303. private _loadImageFromDBAsync(url, image, notInDBCallback);
  29304. private _saveImageIntoDBAsync(url, image);
  29305. private _checkVersionFromDB(url, versionLoaded);
  29306. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  29307. private _saveVersionIntoDBAsync(url, callback);
  29308. /**
  29309. * Loads a file from database
  29310. * @param url defines the URL to load from
  29311. * @param sceneLoaded defines a callback to call on success
  29312. * @param progressCallBack defines a callback to call when progress changed
  29313. * @param errorCallback defines a callback to call on error
  29314. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  29315. */
  29316. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  29317. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  29318. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?, errorCallback?);
  29319. }
  29320. }
  29321. declare module BABYLON {
  29322. interface DDSInfo {
  29323. width: number;
  29324. height: number;
  29325. mipmapCount: number;
  29326. isFourCC: boolean;
  29327. isRGB: boolean;
  29328. isLuminance: boolean;
  29329. isCube: boolean;
  29330. isCompressed: boolean;
  29331. dxgiFormat: number;
  29332. textureType: number;
  29333. /** Sphericle polynomial created for the dds texture */
  29334. sphericalPolynomial?: SphericalPolynomial;
  29335. }
  29336. class DDSTools {
  29337. static StoreLODInAlphaChannel: boolean;
  29338. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  29339. private static _FloatView;
  29340. private static _Int32View;
  29341. private static _ToHalfFloat(value);
  29342. private static _FromHalfFloat(value);
  29343. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29344. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29345. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29346. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29347. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  29348. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  29349. private static _ExtractLongWordOrder(value);
  29350. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  29351. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  29352. /**
  29353. * Uploads DDS Levels to a Babylon Texture
  29354. * @hidden
  29355. */
  29356. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  29357. }
  29358. }
  29359. declare module BABYLON {
  29360. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29361. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29362. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29363. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29364. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29365. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29366. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29367. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29368. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29369. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29370. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29371. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29372. /**
  29373. * Decorator used to define property that can be serialized as reference to a camera
  29374. * @param sourceName defines the name of the property to decorate
  29375. */
  29376. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29377. class SerializationHelper {
  29378. static Serialize<T>(entity: T, serializationObject?: any): any;
  29379. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29380. static Clone<T>(creationFunction: () => T, source: T): T;
  29381. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29382. }
  29383. }
  29384. declare module BABYLON {
  29385. /**
  29386. * Wrapper class for promise with external resolve and reject.
  29387. */
  29388. class Deferred<T> {
  29389. /**
  29390. * The promise associated with this deferred object.
  29391. */
  29392. readonly promise: Promise<T>;
  29393. private _resolve;
  29394. private _reject;
  29395. /**
  29396. * The resolve method of the promise associated with this deferred object.
  29397. */
  29398. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  29399. /**
  29400. * The reject method of the promise associated with this deferred object.
  29401. */
  29402. readonly reject: (reason?: any) => void;
  29403. /**
  29404. * Constructor for this deferred object.
  29405. */
  29406. constructor();
  29407. }
  29408. }
  29409. declare module BABYLON {
  29410. /**
  29411. * Raw texture data and descriptor sufficient for WebGL texture upload
  29412. */
  29413. interface EnvironmentTextureInfo {
  29414. /**
  29415. * Version of the environment map
  29416. */
  29417. version: number;
  29418. /**
  29419. * Width of image
  29420. */
  29421. width: number;
  29422. /**
  29423. * Irradiance information stored in the file.
  29424. */
  29425. irradiance: any;
  29426. /**
  29427. * Specular information stored in the file.
  29428. */
  29429. specular: any;
  29430. }
  29431. /**
  29432. * Sets of helpers addressing the serialization and deserialization of environment texture
  29433. * stored in a BabylonJS env file.
  29434. * Those files are usually stored as .env files.
  29435. */
  29436. class EnvironmentTextureTools {
  29437. /**
  29438. * Magic number identifying the env file.
  29439. */
  29440. private static _MagicBytes;
  29441. /**
  29442. * Gets the environment info from an env file.
  29443. * @param data The array buffer containing the .env bytes.
  29444. * @returns the environment file info (the json header) if successfully parsed.
  29445. */
  29446. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  29447. /**
  29448. * Creates an environment texture from a loaded cube texture.
  29449. * @param texture defines the cube texture to convert in env file
  29450. * @return a promise containing the environment data if succesfull.
  29451. */
  29452. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  29453. /**
  29454. * Creates a JSON representation of the spherical data.
  29455. * @param texture defines the texture containing the polynomials
  29456. * @return the JSON representation of the spherical info
  29457. */
  29458. private static _CreateEnvTextureIrradiance(texture);
  29459. /**
  29460. * Uploads the texture info contained in the env file to the GPU.
  29461. * @param texture defines the internal texture to upload to
  29462. * @param arrayBuffer defines the buffer cotaining the data to load
  29463. * @param info defines the texture info retrieved through the GetEnvInfo method
  29464. * @returns a promise
  29465. */
  29466. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  29467. /**
  29468. * Uploads the levels of image data to the GPU.
  29469. * @param texture defines the internal texture to upload to
  29470. * @param imageData defines the array buffer views of image data [mipmap][face]
  29471. * @returns a promise
  29472. */
  29473. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  29474. /**
  29475. * Uploads spherical polynomials information to the texture.
  29476. * @param texture defines the texture we are trying to upload the information to
  29477. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  29478. */
  29479. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  29480. }
  29481. }
  29482. declare module BABYLON {
  29483. class FilesInput {
  29484. static FilesToLoad: {
  29485. [key: string]: File;
  29486. };
  29487. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  29488. private _engine;
  29489. private _currentScene;
  29490. private _sceneLoadedCallback;
  29491. private _progressCallback;
  29492. private _additionalRenderLoopLogicCallback;
  29493. private _textureLoadingCallback;
  29494. private _startingProcessingFilesCallback;
  29495. private _onReloadCallback;
  29496. private _errorCallback;
  29497. private _elementToMonitor;
  29498. private _sceneFileToLoad;
  29499. private _filesToLoad;
  29500. 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);
  29501. private _dragEnterHandler;
  29502. private _dragOverHandler;
  29503. private _dropHandler;
  29504. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  29505. dispose(): void;
  29506. private renderFunction();
  29507. private drag(e);
  29508. private drop(eventDrop);
  29509. private _traverseFolder(folder, files, remaining, callback);
  29510. private _processFiles(files);
  29511. loadFiles(event: any): void;
  29512. private _processReload();
  29513. reload(): void;
  29514. }
  29515. }
  29516. declare module BABYLON {
  29517. /**
  29518. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29519. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29520. */
  29521. class KhronosTextureContainer {
  29522. arrayBuffer: any;
  29523. static HEADER_LEN: number;
  29524. static COMPRESSED_2D: number;
  29525. static COMPRESSED_3D: number;
  29526. static TEX_2D: number;
  29527. static TEX_3D: number;
  29528. glType: number;
  29529. glTypeSize: number;
  29530. glFormat: number;
  29531. glInternalFormat: number;
  29532. glBaseInternalFormat: number;
  29533. pixelWidth: number;
  29534. pixelHeight: number;
  29535. pixelDepth: number;
  29536. numberOfArrayElements: number;
  29537. numberOfFaces: number;
  29538. numberOfMipmapLevels: number;
  29539. bytesOfKeyValueData: number;
  29540. loadType: number;
  29541. /**
  29542. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  29543. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  29544. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  29545. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  29546. */
  29547. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  29548. switchEndainness(val: number): number;
  29549. /**
  29550. * Uploads KTX content to a Babylon Texture.
  29551. * It is assumed that the texture has already been created & is currently bound
  29552. * @hidden
  29553. */
  29554. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  29555. private _upload2DCompressedLevels(texture, loadMipmaps);
  29556. }
  29557. }
  29558. declare module BABYLON {
  29559. /**
  29560. * A class serves as a medium between the observable and its observers
  29561. */
  29562. class EventState {
  29563. /**
  29564. * Create a new EventState
  29565. * @param mask defines the mask associated with this state
  29566. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  29567. * @param target defines the original target of the state
  29568. * @param currentTarget defines the current target of the state
  29569. */
  29570. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  29571. /**
  29572. * Initialize the current event state
  29573. * @param mask defines the mask associated with this state
  29574. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  29575. * @param target defines the original target of the state
  29576. * @param currentTarget defines the current target of the state
  29577. * @returns the current event state
  29578. */
  29579. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  29580. /**
  29581. * An Observer can set this property to true to prevent subsequent observers of being notified
  29582. */
  29583. skipNextObservers: boolean;
  29584. /**
  29585. * Get the mask value that were used to trigger the event corresponding to this EventState object
  29586. */
  29587. mask: number;
  29588. /**
  29589. * The object that originally notified the event
  29590. */
  29591. target?: any;
  29592. /**
  29593. * The current object in the bubbling phase
  29594. */
  29595. currentTarget?: any;
  29596. /**
  29597. * This will be populated with the return value of the last function that was executed.
  29598. * If it is the first function in the callback chain it will be the event data.
  29599. */
  29600. lastReturnValue?: any;
  29601. }
  29602. /**
  29603. * Represent an Observer registered to a given Observable object.
  29604. */
  29605. class Observer<T> {
  29606. /**
  29607. * Defines the callback to call when the observer is notified
  29608. */
  29609. callback: (eventData: T, eventState: EventState) => void;
  29610. /**
  29611. * Defines the mask of the observer (used to filter notifications)
  29612. */
  29613. mask: number;
  29614. /**
  29615. * Defines the current scope used to restore the JS context
  29616. */
  29617. scope: any;
  29618. /** @hidden */
  29619. _willBeUnregistered: boolean;
  29620. /**
  29621. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  29622. */
  29623. unregisterOnNextCall: boolean;
  29624. /**
  29625. * Creates a new observer
  29626. * @param callback defines the callback to call when the observer is notified
  29627. * @param mask defines the mask of the observer (used to filter notifications)
  29628. * @param scope defines the current scope used to restore the JS context
  29629. */
  29630. constructor(
  29631. /**
  29632. * Defines the callback to call when the observer is notified
  29633. */
  29634. callback: (eventData: T, eventState: EventState) => void,
  29635. /**
  29636. * Defines the mask of the observer (used to filter notifications)
  29637. */
  29638. mask: number,
  29639. /**
  29640. * Defines the current scope used to restore the JS context
  29641. */
  29642. scope?: any);
  29643. }
  29644. /**
  29645. * Represent a list of observers registered to multiple Observables object.
  29646. */
  29647. class MultiObserver<T> {
  29648. private _observers;
  29649. private _observables;
  29650. /**
  29651. * Release associated resources
  29652. */
  29653. dispose(): void;
  29654. /**
  29655. * Raise a callback when one of the observable will notify
  29656. * @param observables defines a list of observables to watch
  29657. * @param callback defines the callback to call on notification
  29658. * @param mask defines the mask used to filter notifications
  29659. * @param scope defines the current scope used to restore the JS context
  29660. * @returns the new MultiObserver
  29661. */
  29662. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  29663. }
  29664. /**
  29665. * The Observable class is a simple implementation of the Observable pattern.
  29666. *
  29667. * 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.
  29668. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  29669. * 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).
  29670. * 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.
  29671. */
  29672. class Observable<T> {
  29673. private _observers;
  29674. private _eventState;
  29675. private _onObserverAdded;
  29676. /**
  29677. * Creates a new observable
  29678. * @param onObserverAdded defines a callback to call when a new observer is added
  29679. */
  29680. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  29681. /**
  29682. * Create a new Observer with the specified callback
  29683. * @param callback the callback that will be executed for that Observer
  29684. * @param mask the mask used to filter observers
  29685. * @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.
  29686. * @param scope optional scope for the callback to be called from
  29687. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  29688. * @returns the new observer created for the callback
  29689. */
  29690. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  29691. /**
  29692. * Create a new Observer with the specified callback and unregisters after the next notification
  29693. * @param callback the callback that will be executed for that Observer
  29694. * @returns the new observer created for the callback
  29695. */
  29696. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  29697. /**
  29698. * Remove an Observer from the Observable object
  29699. * @param observer the instance of the Observer to remove
  29700. * @returns false if it doesn't belong to this Observable
  29701. */
  29702. remove(observer: Nullable<Observer<T>>): boolean;
  29703. /**
  29704. * Remove a callback from the Observable object
  29705. * @param callback the callback to remove
  29706. * @param scope optional scope. If used only the callbacks with this scope will be removed
  29707. * @returns false if it doesn't belong to this Observable
  29708. */
  29709. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  29710. private _deferUnregister(observer);
  29711. private _remove(observer);
  29712. /**
  29713. * Notify all Observers by calling their respective callback with the given data
  29714. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  29715. * @param eventData defines the data to send to all observers
  29716. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  29717. * @param target defines the original target of the state
  29718. * @param currentTarget defines the current target of the state
  29719. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  29720. */
  29721. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  29722. /**
  29723. * Calling this will execute each callback, expecting it to be a promise or return a value.
  29724. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  29725. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  29726. * and it is crucial that all callbacks will be executed.
  29727. * The order of the callbacks is kept, callbacks are not executed parallel.
  29728. *
  29729. * @param eventData The data to be sent to each callback
  29730. * @param mask is used to filter observers defaults to -1
  29731. * @param target defines the callback target (see EventState)
  29732. * @param currentTarget defines he current object in the bubbling phase
  29733. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  29734. */
  29735. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  29736. /**
  29737. * Notify a specific observer
  29738. * @param observer defines the observer to notify
  29739. * @param eventData defines the data to be sent to each callback
  29740. * @param mask is used to filter observers defaults to -1
  29741. */
  29742. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  29743. /**
  29744. * Gets a boolean indicating if the observable has at least one observer
  29745. * @returns true is the Observable has at least one Observer registered
  29746. */
  29747. hasObservers(): boolean;
  29748. /**
  29749. * Clear the list of observers
  29750. */
  29751. clear(): void;
  29752. /**
  29753. * Clone the current observable
  29754. * @returns a new observable
  29755. */
  29756. clone(): Observable<T>;
  29757. /**
  29758. * Does this observable handles observer registered with a given mask
  29759. * @param mask defines the mask to be tested
  29760. * @return whether or not one observer registered with the given mask is handeled
  29761. **/
  29762. hasSpecificMask(mask?: number): boolean;
  29763. }
  29764. }
  29765. declare module BABYLON {
  29766. /**
  29767. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  29768. */
  29769. class PerformanceMonitor {
  29770. private _enabled;
  29771. private _rollingFrameTime;
  29772. private _lastFrameTimeMs;
  29773. /**
  29774. * constructor
  29775. * @param frameSampleSize The number of samples required to saturate the sliding window
  29776. */
  29777. constructor(frameSampleSize?: number);
  29778. /**
  29779. * Samples current frame
  29780. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  29781. */
  29782. sampleFrame(timeMs?: number): void;
  29783. /**
  29784. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  29785. * @return Average frame time in milliseconds
  29786. */
  29787. readonly averageFrameTime: number;
  29788. /**
  29789. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  29790. * @return Frame time variance in milliseconds squared
  29791. */
  29792. readonly averageFrameTimeVariance: number;
  29793. /**
  29794. * Returns the frame time of the most recent frame
  29795. * @return Frame time in milliseconds
  29796. */
  29797. readonly instantaneousFrameTime: number;
  29798. /**
  29799. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  29800. * @return Framerate in frames per second
  29801. */
  29802. readonly averageFPS: number;
  29803. /**
  29804. * Returns the average framerate in frames per second using the most recent frame time
  29805. * @return Framerate in frames per second
  29806. */
  29807. readonly instantaneousFPS: number;
  29808. /**
  29809. * Returns true if enough samples have been taken to completely fill the sliding window
  29810. * @return true if saturated
  29811. */
  29812. readonly isSaturated: boolean;
  29813. /**
  29814. * Enables contributions to the sliding window sample set
  29815. */
  29816. enable(): void;
  29817. /**
  29818. * Disables contributions to the sliding window sample set
  29819. * Samples will not be interpolated over the disabled period
  29820. */
  29821. disable(): void;
  29822. /**
  29823. * Returns true if sampling is enabled
  29824. * @return true if enabled
  29825. */
  29826. readonly isEnabled: boolean;
  29827. /**
  29828. * Resets performance monitor
  29829. */
  29830. reset(): void;
  29831. }
  29832. /**
  29833. * RollingAverage
  29834. *
  29835. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  29836. */
  29837. class RollingAverage {
  29838. /**
  29839. * Current average
  29840. */
  29841. average: number;
  29842. /**
  29843. * Current variance
  29844. */
  29845. variance: number;
  29846. protected _samples: Array<number>;
  29847. protected _sampleCount: number;
  29848. protected _pos: number;
  29849. protected _m2: number;
  29850. /**
  29851. * constructor
  29852. * @param length The number of samples required to saturate the sliding window
  29853. */
  29854. constructor(length: number);
  29855. /**
  29856. * Adds a sample to the sample set
  29857. * @param v The sample value
  29858. */
  29859. add(v: number): void;
  29860. /**
  29861. * Returns previously added values or null if outside of history or outside the sliding window domain
  29862. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  29863. * @return Value previously recorded with add() or null if outside of range
  29864. */
  29865. history(i: number): number;
  29866. /**
  29867. * Returns true if enough samples have been taken to completely fill the sliding window
  29868. * @return true if sample-set saturated
  29869. */
  29870. isSaturated(): boolean;
  29871. /**
  29872. * Resets the rolling average (equivalent to 0 samples taken so far)
  29873. */
  29874. reset(): void;
  29875. /**
  29876. * Wraps a value around the sample range boundaries
  29877. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  29878. * @return Wrapped position in sample range
  29879. */
  29880. protected _wrapPosition(i: number): number;
  29881. }
  29882. }
  29883. declare module BABYLON {
  29884. /**
  29885. * Helper class that provides a small promise polyfill
  29886. */
  29887. class PromisePolyfill {
  29888. /**
  29889. * Static function used to check if the polyfill is required
  29890. * If this is the case then the function will inject the polyfill to window.Promise
  29891. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  29892. */
  29893. static Apply(force?: boolean): void;
  29894. }
  29895. }
  29896. declare module BABYLON {
  29897. /**
  29898. * Defines the root class used to create scene optimization to use with SceneOptimizer
  29899. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29900. */
  29901. class SceneOptimization {
  29902. /**
  29903. * Defines the priority of this optimization (0 by default which means first in the list)
  29904. */
  29905. priority: number;
  29906. /**
  29907. * Gets a string describing the action executed by the current optimization
  29908. * @returns description string
  29909. */
  29910. getDescription(): string;
  29911. /**
  29912. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29913. * @param scene defines the current scene where to apply this optimization
  29914. * @param optimizer defines the current optimizer
  29915. * @returns true if everything that can be done was applied
  29916. */
  29917. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29918. /**
  29919. * Creates the SceneOptimization object
  29920. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29921. * @param desc defines the description associated with the optimization
  29922. */
  29923. constructor(
  29924. /**
  29925. * Defines the priority of this optimization (0 by default which means first in the list)
  29926. */
  29927. priority?: number);
  29928. }
  29929. /**
  29930. * Defines an optimization used to reduce the size of render target textures
  29931. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29932. */
  29933. class TextureOptimization extends SceneOptimization {
  29934. /**
  29935. * Defines the priority of this optimization (0 by default which means first in the list)
  29936. */
  29937. priority: number;
  29938. /**
  29939. * 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
  29940. */
  29941. maximumSize: number;
  29942. /**
  29943. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29944. */
  29945. step: number;
  29946. /**
  29947. * Gets a string describing the action executed by the current optimization
  29948. * @returns description string
  29949. */
  29950. getDescription(): string;
  29951. /**
  29952. * Creates the TextureOptimization object
  29953. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  29954. * @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
  29955. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29956. */
  29957. constructor(
  29958. /**
  29959. * Defines the priority of this optimization (0 by default which means first in the list)
  29960. */
  29961. priority?: number,
  29962. /**
  29963. * 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
  29964. */
  29965. maximumSize?: number,
  29966. /**
  29967. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  29968. */
  29969. step?: number);
  29970. /**
  29971. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  29972. * @param scene defines the current scene where to apply this optimization
  29973. * @param optimizer defines the current optimizer
  29974. * @returns true if everything that can be done was applied
  29975. */
  29976. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  29977. }
  29978. /**
  29979. * Defines an optimization used to increase or decrease the rendering resolution
  29980. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  29981. */
  29982. class HardwareScalingOptimization extends SceneOptimization {
  29983. /**
  29984. * Defines the priority of this optimization (0 by default which means first in the list)
  29985. */
  29986. priority: number;
  29987. /**
  29988. * Defines the maximum scale to use (2 by default)
  29989. */
  29990. maximumScale: number;
  29991. /**
  29992. * Defines the step to use between two passes (0.5 by default)
  29993. */
  29994. step: number;
  29995. private _currentScale;
  29996. private _directionOffset;
  29997. /**
  29998. * Gets a string describing the action executed by the current optimization
  29999. * @return description string
  30000. */
  30001. getDescription(): string;
  30002. /**
  30003. * Creates the HardwareScalingOptimization object
  30004. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30005. * @param maximumScale defines the maximum scale to use (2 by default)
  30006. * @param step defines the step to use between two passes (0.5 by default)
  30007. */
  30008. constructor(
  30009. /**
  30010. * Defines the priority of this optimization (0 by default which means first in the list)
  30011. */
  30012. priority?: number,
  30013. /**
  30014. * Defines the maximum scale to use (2 by default)
  30015. */
  30016. maximumScale?: number,
  30017. /**
  30018. * Defines the step to use between two passes (0.5 by default)
  30019. */
  30020. step?: number);
  30021. /**
  30022. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30023. * @param scene defines the current scene where to apply this optimization
  30024. * @param optimizer defines the current optimizer
  30025. * @returns true if everything that can be done was applied
  30026. */
  30027. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30028. }
  30029. /**
  30030. * Defines an optimization used to remove shadows
  30031. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30032. */
  30033. class ShadowsOptimization extends SceneOptimization {
  30034. /**
  30035. * Gets a string describing the action executed by the current optimization
  30036. * @return description string
  30037. */
  30038. getDescription(): string;
  30039. /**
  30040. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30041. * @param scene defines the current scene where to apply this optimization
  30042. * @param optimizer defines the current optimizer
  30043. * @returns true if everything that can be done was applied
  30044. */
  30045. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30046. }
  30047. /**
  30048. * Defines an optimization used to turn post-processes off
  30049. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30050. */
  30051. class PostProcessesOptimization extends SceneOptimization {
  30052. /**
  30053. * Gets a string describing the action executed by the current optimization
  30054. * @return description string
  30055. */
  30056. getDescription(): string;
  30057. /**
  30058. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30059. * @param scene defines the current scene where to apply this optimization
  30060. * @param optimizer defines the current optimizer
  30061. * @returns true if everything that can be done was applied
  30062. */
  30063. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30064. }
  30065. /**
  30066. * Defines an optimization used to turn lens flares off
  30067. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30068. */
  30069. class LensFlaresOptimization extends SceneOptimization {
  30070. /**
  30071. * Gets a string describing the action executed by the current optimization
  30072. * @return description string
  30073. */
  30074. getDescription(): string;
  30075. /**
  30076. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30077. * @param scene defines the current scene where to apply this optimization
  30078. * @param optimizer defines the current optimizer
  30079. * @returns true if everything that can be done was applied
  30080. */
  30081. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30082. }
  30083. /**
  30084. * Defines an optimization based on user defined callback.
  30085. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30086. */
  30087. class CustomOptimization extends SceneOptimization {
  30088. /**
  30089. * Callback called to apply the custom optimization.
  30090. */
  30091. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  30092. /**
  30093. * Callback called to get custom description
  30094. */
  30095. onGetDescription: () => string;
  30096. /**
  30097. * Gets a string describing the action executed by the current optimization
  30098. * @returns description string
  30099. */
  30100. getDescription(): string;
  30101. /**
  30102. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30103. * @param scene defines the current scene where to apply this optimization
  30104. * @param optimizer defines the current optimizer
  30105. * @returns true if everything that can be done was applied
  30106. */
  30107. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30108. }
  30109. /**
  30110. * Defines an optimization used to turn particles off
  30111. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30112. */
  30113. class ParticlesOptimization extends SceneOptimization {
  30114. /**
  30115. * Gets a string describing the action executed by the current optimization
  30116. * @return description string
  30117. */
  30118. getDescription(): string;
  30119. /**
  30120. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30121. * @param scene defines the current scene where to apply this optimization
  30122. * @param optimizer defines the current optimizer
  30123. * @returns true if everything that can be done was applied
  30124. */
  30125. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30126. }
  30127. /**
  30128. * Defines an optimization used to turn render targets off
  30129. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30130. */
  30131. class RenderTargetsOptimization extends SceneOptimization {
  30132. /**
  30133. * Gets a string describing the action executed by the current optimization
  30134. * @return description string
  30135. */
  30136. getDescription(): string;
  30137. /**
  30138. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30139. * @param scene defines the current scene where to apply this optimization
  30140. * @param optimizer defines the current optimizer
  30141. * @returns true if everything that can be done was applied
  30142. */
  30143. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  30144. }
  30145. /**
  30146. * Defines an optimization used to merge meshes with compatible materials
  30147. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30148. */
  30149. class MergeMeshesOptimization extends SceneOptimization {
  30150. private static _UpdateSelectionTree;
  30151. /**
  30152. * Gets or sets a boolean which defines if optimization octree has to be updated
  30153. */
  30154. /**
  30155. * Gets or sets a boolean which defines if optimization octree has to be updated
  30156. */
  30157. static UpdateSelectionTree: boolean;
  30158. /**
  30159. * Gets a string describing the action executed by the current optimization
  30160. * @return description string
  30161. */
  30162. getDescription(): string;
  30163. private _canBeMerged;
  30164. /**
  30165. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  30166. * @param scene defines the current scene where to apply this optimization
  30167. * @param optimizer defines the current optimizer
  30168. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  30169. * @returns true if everything that can be done was applied
  30170. */
  30171. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  30172. }
  30173. /**
  30174. * Defines a list of options used by SceneOptimizer
  30175. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30176. */
  30177. class SceneOptimizerOptions {
  30178. /**
  30179. * Defines the target frame rate to reach (60 by default)
  30180. */
  30181. targetFrameRate: number;
  30182. /**
  30183. * Defines the interval between two checkes (2000ms by default)
  30184. */
  30185. trackerDuration: number;
  30186. /**
  30187. * Gets the list of optimizations to apply
  30188. */
  30189. optimizations: SceneOptimization[];
  30190. /**
  30191. * Creates a new list of options used by SceneOptimizer
  30192. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  30193. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  30194. */
  30195. constructor(
  30196. /**
  30197. * Defines the target frame rate to reach (60 by default)
  30198. */
  30199. targetFrameRate?: number,
  30200. /**
  30201. * Defines the interval between two checkes (2000ms by default)
  30202. */
  30203. trackerDuration?: number);
  30204. /**
  30205. * Add a new optimization
  30206. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  30207. * @returns the current SceneOptimizerOptions
  30208. */
  30209. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  30210. /**
  30211. * Add a new custom optimization
  30212. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  30213. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  30214. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  30215. * @returns the current SceneOptimizerOptions
  30216. */
  30217. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  30218. /**
  30219. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  30220. * @param targetFrameRate defines the target frame rate (60 by default)
  30221. * @returns a SceneOptimizerOptions object
  30222. */
  30223. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30224. /**
  30225. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  30226. * @param targetFrameRate defines the target frame rate (60 by default)
  30227. * @returns a SceneOptimizerOptions object
  30228. */
  30229. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30230. /**
  30231. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  30232. * @param targetFrameRate defines the target frame rate (60 by default)
  30233. * @returns a SceneOptimizerOptions object
  30234. */
  30235. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  30236. }
  30237. /**
  30238. * Class used to run optimizations in order to reach a target frame rate
  30239. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  30240. */
  30241. class SceneOptimizer implements IDisposable {
  30242. private _isRunning;
  30243. private _options;
  30244. private _scene;
  30245. private _currentPriorityLevel;
  30246. private _targetFrameRate;
  30247. private _trackerDuration;
  30248. private _currentFrameRate;
  30249. private _sceneDisposeObserver;
  30250. private _improvementMode;
  30251. /**
  30252. * Defines an observable called when the optimizer reaches the target frame rate
  30253. */
  30254. onSuccessObservable: Observable<SceneOptimizer>;
  30255. /**
  30256. * Defines an observable called when the optimizer enables an optimization
  30257. */
  30258. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  30259. /**
  30260. * Defines an observable called when the optimizer is not able to reach the target frame rate
  30261. */
  30262. onFailureObservable: Observable<SceneOptimizer>;
  30263. /**
  30264. * Gets a boolean indicating if the optimizer is in improvement mode
  30265. */
  30266. readonly isInImprovementMode: boolean;
  30267. /**
  30268. * Gets the current priority level (0 at start)
  30269. */
  30270. readonly currentPriorityLevel: number;
  30271. /**
  30272. * Gets the current frame rate checked by the SceneOptimizer
  30273. */
  30274. readonly currentFrameRate: number;
  30275. /**
  30276. * Gets or sets the current target frame rate (60 by default)
  30277. */
  30278. /**
  30279. * Gets or sets the current target frame rate (60 by default)
  30280. */
  30281. targetFrameRate: number;
  30282. /**
  30283. * Gets or sets the current interval between two checks (every 2000ms by default)
  30284. */
  30285. /**
  30286. * Gets or sets the current interval between two checks (every 2000ms by default)
  30287. */
  30288. trackerDuration: number;
  30289. /**
  30290. * Gets the list of active optimizations
  30291. */
  30292. readonly optimizations: SceneOptimization[];
  30293. /**
  30294. * Creates a new SceneOptimizer
  30295. * @param scene defines the scene to work on
  30296. * @param options defines the options to use with the SceneOptimizer
  30297. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  30298. * @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)
  30299. */
  30300. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  30301. /**
  30302. * Stops the current optimizer
  30303. */
  30304. stop(): void;
  30305. /**
  30306. * Reset the optimizer to initial step (current priority level = 0)
  30307. */
  30308. reset(): void;
  30309. /**
  30310. * Start the optimizer. By default it will try to reach a specific framerate
  30311. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  30312. */
  30313. start(): void;
  30314. private _checkCurrentState();
  30315. /**
  30316. * Release all resources
  30317. */
  30318. dispose(): void;
  30319. /**
  30320. * Helper function to create a SceneOptimizer with one single line of code
  30321. * @param scene defines the scene to work on
  30322. * @param options defines the options to use with the SceneOptimizer
  30323. * @param onSuccess defines a callback to call on success
  30324. * @param onFailure defines a callback to call on failure
  30325. * @returns the new SceneOptimizer object
  30326. */
  30327. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  30328. }
  30329. }
  30330. declare module BABYLON {
  30331. class SceneSerializer {
  30332. static ClearCache(): void;
  30333. static Serialize(scene: Scene): any;
  30334. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  30335. }
  30336. }
  30337. declare module BABYLON {
  30338. class SmartArray<T> {
  30339. data: Array<T>;
  30340. length: number;
  30341. protected _id: number;
  30342. [index: number]: T;
  30343. constructor(capacity: number);
  30344. push(value: T): void;
  30345. forEach(func: (content: T) => void): void;
  30346. sort(compareFn: (a: T, b: T) => number): void;
  30347. reset(): void;
  30348. dispose(): void;
  30349. concat(array: any): void;
  30350. indexOf(value: T): number;
  30351. contains(value: T): boolean;
  30352. private static _GlobalId;
  30353. }
  30354. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  30355. private _duplicateId;
  30356. [index: number]: T;
  30357. push(value: T): void;
  30358. pushNoDuplicate(value: T): boolean;
  30359. reset(): void;
  30360. concatWithNoDuplicate(array: any): void;
  30361. }
  30362. }
  30363. declare module BABYLON {
  30364. /**
  30365. * This class implement a typical dictionary using a string as key and the generic type T as value.
  30366. * The underlying implementation relies on an associative array to ensure the best performances.
  30367. * The value can be anything including 'null' but except 'undefined'
  30368. */
  30369. class StringDictionary<T> {
  30370. /**
  30371. * This will clear this dictionary and copy the content from the 'source' one.
  30372. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  30373. * @param source the dictionary to take the content from and copy to this dictionary
  30374. */
  30375. copyFrom(source: StringDictionary<T>): void;
  30376. /**
  30377. * Get a value based from its key
  30378. * @param key the given key to get the matching value from
  30379. * @return the value if found, otherwise undefined is returned
  30380. */
  30381. get(key: string): T | undefined;
  30382. /**
  30383. * Get a value from its key or add it if it doesn't exist.
  30384. * This method will ensure you that a given key/data will be present in the dictionary.
  30385. * @param key the given key to get the matching value from
  30386. * @param factory the factory that will create the value if the key is not present in the dictionary.
  30387. * The factory will only be invoked if there's no data for the given key.
  30388. * @return the value corresponding to the key.
  30389. */
  30390. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  30391. /**
  30392. * Get a value from its key if present in the dictionary otherwise add it
  30393. * @param key the key to get the value from
  30394. * @param val if there's no such key/value pair in the dictionary add it with this value
  30395. * @return the value corresponding to the key
  30396. */
  30397. getOrAdd(key: string, val: T): T;
  30398. /**
  30399. * Check if there's a given key in the dictionary
  30400. * @param key the key to check for
  30401. * @return true if the key is present, false otherwise
  30402. */
  30403. contains(key: string): boolean;
  30404. /**
  30405. * Add a new key and its corresponding value
  30406. * @param key the key to add
  30407. * @param value the value corresponding to the key
  30408. * @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
  30409. */
  30410. add(key: string, value: T): boolean;
  30411. set(key: string, value: T): boolean;
  30412. /**
  30413. * Get the element of the given key and remove it from the dictionary
  30414. * @param key
  30415. */
  30416. getAndRemove(key: string): Nullable<T>;
  30417. /**
  30418. * Remove a key/value from the dictionary.
  30419. * @param key the key to remove
  30420. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  30421. */
  30422. remove(key: string): boolean;
  30423. /**
  30424. * Clear the whole content of the dictionary
  30425. */
  30426. clear(): void;
  30427. readonly count: number;
  30428. /**
  30429. * Execute a callback on each key/val of the dictionary.
  30430. * Note that you can remove any element in this dictionary in the callback implementation
  30431. * @param callback the callback to execute on a given key/value pair
  30432. */
  30433. forEach(callback: (key: string, val: T) => void): void;
  30434. /**
  30435. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  30436. * If the callback returns null or undefined the method will iterate to the next key/value pair
  30437. * Note that you can remove any element in this dictionary in the callback implementation
  30438. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  30439. */
  30440. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  30441. private _count;
  30442. private _data;
  30443. }
  30444. }
  30445. declare module BABYLON {
  30446. class Tags {
  30447. static EnableFor(obj: any): void;
  30448. static DisableFor(obj: any): void;
  30449. static HasTags(obj: any): boolean;
  30450. static GetTags(obj: any, asString?: boolean): any;
  30451. static AddTagsTo(obj: any, tagsString: string): void;
  30452. static _AddTagTo(obj: any, tag: string): void;
  30453. static RemoveTagsFrom(obj: any, tagsString: string): void;
  30454. static _RemoveTagFrom(obj: any, tag: string): void;
  30455. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  30456. }
  30457. }
  30458. declare module BABYLON {
  30459. class TextureTools {
  30460. /**
  30461. * Uses the GPU to create a copy texture rescaled at a given size
  30462. * @param texture Texture to copy from
  30463. * @param width Desired width
  30464. * @param height Desired height
  30465. * @return Generated texture
  30466. */
  30467. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  30468. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  30469. private static _environmentBRDFBase64Texture;
  30470. }
  30471. }
  30472. declare module BABYLON {
  30473. class TGATools {
  30474. private static _TYPE_INDEXED;
  30475. private static _TYPE_RGB;
  30476. private static _TYPE_GREY;
  30477. private static _TYPE_RLE_INDEXED;
  30478. private static _TYPE_RLE_RGB;
  30479. private static _TYPE_RLE_GREY;
  30480. private static _ORIGIN_MASK;
  30481. private static _ORIGIN_SHIFT;
  30482. private static _ORIGIN_BL;
  30483. private static _ORIGIN_BR;
  30484. private static _ORIGIN_UL;
  30485. private static _ORIGIN_UR;
  30486. static GetTGAHeader(data: Uint8Array): any;
  30487. /**
  30488. * Uploads TGA content to a Babylon Texture
  30489. * @hidden
  30490. */
  30491. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  30492. 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;
  30493. 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;
  30494. 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;
  30495. 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;
  30496. 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;
  30497. 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;
  30498. }
  30499. }
  30500. declare module BABYLON {
  30501. interface IAnimatable {
  30502. animations: Array<Animation>;
  30503. }
  30504. /** Interface used by value gradients (color, factor, ...) */
  30505. interface IValueGradient {
  30506. /**
  30507. * Gets or sets the gradient value (between 0 and 1)
  30508. */
  30509. gradient: number;
  30510. }
  30511. /** Class used to store color gradient */
  30512. class ColorGradient implements IValueGradient {
  30513. /**
  30514. * Gets or sets the gradient value (between 0 and 1)
  30515. */
  30516. gradient: number;
  30517. /**
  30518. * Gets or sets first associated color
  30519. */
  30520. color1: Color4;
  30521. /**
  30522. * Gets or sets second associated color
  30523. */
  30524. color2?: Color4;
  30525. /**
  30526. * Will get a color picked randomly between color1 and color2.
  30527. * If color2 is undefined then color1 will be used
  30528. * @param result defines the target Color4 to store the result in
  30529. */
  30530. getColorToRef(result: Color4): void;
  30531. }
  30532. /** Class used to store factor gradient */
  30533. class FactorGradient implements IValueGradient {
  30534. /**
  30535. * Gets or sets the gradient value (between 0 and 1)
  30536. */
  30537. gradient: number;
  30538. /**
  30539. * Gets or sets first associated factor
  30540. */
  30541. factor1: number;
  30542. /**
  30543. * Gets or sets second associated factor
  30544. */
  30545. factor2?: number;
  30546. /**
  30547. * Will get a number picked randomly between factor1 and factor2.
  30548. * If factor2 is undefined then factor1 will be used
  30549. * @returns the picked number
  30550. */
  30551. getFactor(): number;
  30552. }
  30553. class LoadFileError extends Error {
  30554. request: XMLHttpRequest | undefined;
  30555. private static _setPrototypeOf;
  30556. constructor(message: string, request?: XMLHttpRequest | undefined);
  30557. }
  30558. class RetryStrategy {
  30559. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30560. }
  30561. interface IFileRequest {
  30562. /**
  30563. * Raised when the request is complete (success or error).
  30564. */
  30565. onCompleteObservable: Observable<IFileRequest>;
  30566. /**
  30567. * Aborts the request for a file.
  30568. */
  30569. abort: () => void;
  30570. }
  30571. class Tools {
  30572. static BaseUrl: string;
  30573. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30574. /**
  30575. * Default behaviour for cors in the application.
  30576. * It can be a string if the expected behavior is identical in the entire app.
  30577. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30578. */
  30579. static CorsBehavior: string | ((url: string | string[]) => string);
  30580. static UseFallbackTexture: boolean;
  30581. /**
  30582. * Use this object to register external classes like custom textures or material
  30583. * to allow the laoders to instantiate them
  30584. */
  30585. static RegisteredExternalClasses: {
  30586. [key: string]: Object;
  30587. };
  30588. static fallbackTexture: string;
  30589. /**
  30590. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30591. * @param u defines the coordinate on X axis
  30592. * @param v defines the coordinate on Y axis
  30593. * @param width defines the width of the source data
  30594. * @param height defines the height of the source data
  30595. * @param pixels defines the source byte array
  30596. * @param color defines the output color
  30597. */
  30598. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30599. /**
  30600. * Interpolates between a and b via alpha
  30601. * @param a The lower value (returned when alpha = 0)
  30602. * @param b The upper value (returned when alpha = 1)
  30603. * @param alpha The interpolation-factor
  30604. * @return The mixed value
  30605. */
  30606. static Mix(a: number, b: number, alpha: number): number;
  30607. static Instantiate(className: string): any;
  30608. /**
  30609. * Provides a slice function that will work even on IE
  30610. * @param data defines the array to slice
  30611. * @param start defines the start of the data (optional)
  30612. * @param end defines the end of the data (optional)
  30613. * @returns the new sliced array
  30614. */
  30615. static Slice<T>(data: T, start?: number, end?: number): T;
  30616. static SetImmediate(action: () => void): void;
  30617. static IsExponentOfTwo(value: number): boolean;
  30618. private static _tmpFloatArray;
  30619. /**
  30620. * Returns the nearest 32-bit single precision float representation of a Number
  30621. * @param value A Number. If the parameter is of a different type, it will get converted
  30622. * to a number or to NaN if it cannot be converted
  30623. * @returns number
  30624. */
  30625. static FloatRound(value: number): number;
  30626. /**
  30627. * Find the next highest power of two.
  30628. * @param x Number to start search from.
  30629. * @return Next highest power of two.
  30630. */
  30631. static CeilingPOT(x: number): number;
  30632. /**
  30633. * Find the next lowest power of two.
  30634. * @param x Number to start search from.
  30635. * @return Next lowest power of two.
  30636. */
  30637. static FloorPOT(x: number): number;
  30638. /**
  30639. * Find the nearest power of two.
  30640. * @param x Number to start search from.
  30641. * @return Next nearest power of two.
  30642. */
  30643. static NearestPOT(x: number): number;
  30644. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30645. static GetFilename(path: string): string;
  30646. /**
  30647. * Extracts the "folder" part of a path (everything before the filename).
  30648. * @param uri The URI to extract the info from
  30649. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30650. * @returns The "folder" part of the path
  30651. */
  30652. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30653. static GetDOMTextContent(element: HTMLElement): string;
  30654. static ToDegrees(angle: number): number;
  30655. static ToRadians(angle: number): number;
  30656. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30657. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30658. minimum: Vector3;
  30659. maximum: Vector3;
  30660. };
  30661. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30662. minimum: Vector3;
  30663. maximum: Vector3;
  30664. };
  30665. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  30666. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  30667. minimum: Vector2;
  30668. maximum: Vector2;
  30669. };
  30670. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30671. static GetPointerPrefix(): string;
  30672. /**
  30673. * @param func - the function to be called
  30674. * @param requester - the object that will request the next frame. Falls back to window.
  30675. */
  30676. static QueueNewFrame(func: () => void, requester?: any): number;
  30677. static RequestFullscreen(element: HTMLElement): void;
  30678. static ExitFullscreen(): void;
  30679. static SetCorsBehavior(url: string | string[], element: {
  30680. crossOrigin: string | null;
  30681. }): void;
  30682. static CleanUrl(url: string): string;
  30683. static PreprocessUrl: (url: string) => string;
  30684. /**
  30685. * Loads an image as an HTMLImageElement.
  30686. * @param input url string, ArrayBuffer, or Blob to load
  30687. * @param onLoad callback called when the image successfully loads
  30688. * @param onError callback called when the image fails to load
  30689. * @param database database for caching
  30690. * @returns the HTMLImageElement of the loaded image
  30691. */
  30692. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  30693. 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;
  30694. /**
  30695. * Load a script (identified by an url). When the url returns, the
  30696. * content of this file is added into a new script element, attached to the DOM (body element)
  30697. */
  30698. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30699. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30700. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30701. static FileAsURL(content: string): string;
  30702. static Format(value: number, decimals?: number): string;
  30703. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30704. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30705. static IsEmpty(obj: any): boolean;
  30706. static RegisterTopRootEvents(events: {
  30707. name: string;
  30708. handler: Nullable<(e: FocusEvent) => any>;
  30709. }[]): void;
  30710. static UnregisterTopRootEvents(events: {
  30711. name: string;
  30712. handler: Nullable<(e: FocusEvent) => any>;
  30713. }[]): void;
  30714. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30715. /**
  30716. * Converts the canvas data to blob.
  30717. * This acts as a polyfill for browsers not supporting the to blob function.
  30718. * @param canvas Defines the canvas to extract the data from
  30719. * @param successCallback Defines the callback triggered once the data are available
  30720. * @param mimeType Defines the mime type of the result
  30721. */
  30722. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30723. /**
  30724. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30725. * @param successCallback Defines the callback triggered once the data are available
  30726. * @param mimeType Defines the mime type of the result
  30727. * @param fileName The filename to download. If present, the result will automatically be downloaded
  30728. */
  30729. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30730. /**
  30731. * Downloads a blob in the browser
  30732. * @param blob defines the blob to download
  30733. * @param fileName defines the name of the downloaded file
  30734. */
  30735. static Download(blob: Blob, fileName: string): void;
  30736. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30737. /**
  30738. * Generates an image screenshot from the specified camera.
  30739. *
  30740. * @param engine The engine to use for rendering
  30741. * @param camera The camera to use for rendering
  30742. * @param size This parameter can be set to a single number or to an object with the
  30743. * following (optional) properties: precision, width, height. If a single number is passed,
  30744. * it will be used for both width and height. If an object is passed, the screenshot size
  30745. * will be derived from the parameters. The precision property is a multiplier allowing
  30746. * rendering at a higher or lower resolution.
  30747. * @param successCallback The callback receives a single parameter which contains the
  30748. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30749. * src parameter of an <img> to display it.
  30750. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30751. * Check your browser for supported MIME types.
  30752. * @param samples Texture samples (default: 1)
  30753. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30754. * @param fileName A name for for the downloaded file.
  30755. * @constructor
  30756. */
  30757. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30758. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  30759. /**
  30760. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30761. * Be aware Math.random() could cause collisions, but:
  30762. * "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"
  30763. */
  30764. static RandomId(): string;
  30765. /**
  30766. * Test if the given uri is a base64 string.
  30767. * @param uri The uri to test
  30768. * @return True if the uri is a base64 string or false otherwise.
  30769. */
  30770. static IsBase64(uri: string): boolean;
  30771. /**
  30772. * Decode the given base64 uri.
  30773. * @param uri The uri to decode
  30774. * @return The decoded base64 data.
  30775. */
  30776. static DecodeBase64(uri: string): ArrayBuffer;
  30777. private static _NoneLogLevel;
  30778. private static _MessageLogLevel;
  30779. private static _WarningLogLevel;
  30780. private static _ErrorLogLevel;
  30781. private static _LogCache;
  30782. static errorsCount: number;
  30783. static OnNewCacheEntry: (entry: string) => void;
  30784. static readonly NoneLogLevel: number;
  30785. static readonly MessageLogLevel: number;
  30786. static readonly WarningLogLevel: number;
  30787. static readonly ErrorLogLevel: number;
  30788. static readonly AllLogLevel: number;
  30789. private static _AddLogEntry(entry);
  30790. private static _FormatMessage(message);
  30791. private static _LogDisabled(message);
  30792. private static _LogEnabled(message);
  30793. private static _WarnDisabled(message);
  30794. private static _WarnEnabled(message);
  30795. private static _ErrorDisabled(message);
  30796. private static _ErrorEnabled(message);
  30797. static Log: (message: string) => void;
  30798. static Warn: (message: string) => void;
  30799. static Error: (message: string) => void;
  30800. static readonly LogCache: string;
  30801. static ClearLogCache(): void;
  30802. static LogLevels: number;
  30803. static IsWindowObjectExist(): boolean;
  30804. private static _PerformanceNoneLogLevel;
  30805. private static _PerformanceUserMarkLogLevel;
  30806. private static _PerformanceConsoleLogLevel;
  30807. private static _performance;
  30808. static readonly PerformanceNoneLogLevel: number;
  30809. static readonly PerformanceUserMarkLogLevel: number;
  30810. static readonly PerformanceConsoleLogLevel: number;
  30811. static PerformanceLogLevel: number;
  30812. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  30813. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  30814. static _StartUserMark(counterName: string, condition?: boolean): void;
  30815. static _EndUserMark(counterName: string, condition?: boolean): void;
  30816. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  30817. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  30818. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30819. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30820. static readonly Now: number;
  30821. /**
  30822. * This method will return the name of the class used to create the instance of the given object.
  30823. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30824. * @param object the object to get the class name from
  30825. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  30826. */
  30827. static GetClassName(object: any, isType?: boolean): string;
  30828. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30829. /**
  30830. * This method will return the name of the full name of the class, including its owning module (if any).
  30831. * 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).
  30832. * @param object the object to get the class name from
  30833. * @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.
  30834. */
  30835. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30836. /**
  30837. * 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.
  30838. * @param array
  30839. */
  30840. static arrayOrStringFeeder(array: any): (i: number) => number;
  30841. /**
  30842. * Compute the hashCode of a stream of number
  30843. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  30844. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  30845. * @return the hash code computed
  30846. */
  30847. static hashCodeFromStream(feeder: (index: number) => number): number;
  30848. /**
  30849. * Returns a promise that resolves after the given amount of time.
  30850. * @param delay Number of milliseconds to delay
  30851. * @returns Promise that resolves after the given amount of time
  30852. */
  30853. static DelayAsync(delay: number): Promise<void>;
  30854. /**
  30855. * Gets the current gradient from an array of IValueGradient
  30856. * @param ratio defines the current ratio to get
  30857. * @param gradients defines the array of IValueGradient
  30858. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30859. */
  30860. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30861. }
  30862. /**
  30863. * This class is used to track a performance counter which is number based.
  30864. * The user has access to many properties which give statistics of different nature
  30865. *
  30866. * The implementer can track two kinds of Performance Counter: time and count
  30867. * 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.
  30868. * 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.
  30869. */
  30870. class PerfCounter {
  30871. static Enabled: boolean;
  30872. /**
  30873. * Returns the smallest value ever
  30874. */
  30875. readonly min: number;
  30876. /**
  30877. * Returns the biggest value ever
  30878. */
  30879. readonly max: number;
  30880. /**
  30881. * Returns the average value since the performance counter is running
  30882. */
  30883. readonly average: number;
  30884. /**
  30885. * Returns the average value of the last second the counter was monitored
  30886. */
  30887. readonly lastSecAverage: number;
  30888. /**
  30889. * Returns the current value
  30890. */
  30891. readonly current: number;
  30892. readonly total: number;
  30893. readonly count: number;
  30894. constructor();
  30895. /**
  30896. * Call this method to start monitoring a new frame.
  30897. * 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.
  30898. */
  30899. fetchNewFrame(): void;
  30900. /**
  30901. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30902. * @param newCount the count value to add to the monitored count
  30903. * @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.
  30904. */
  30905. addCount(newCount: number, fetchResult: boolean): void;
  30906. /**
  30907. * Start monitoring this performance counter
  30908. */
  30909. beginMonitoring(): void;
  30910. /**
  30911. * Compute the time lapsed since the previous beginMonitoring() call.
  30912. * @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
  30913. */
  30914. endMonitoring(newFrame?: boolean): void;
  30915. private _fetchResult();
  30916. private _startMonitoringTime;
  30917. private _min;
  30918. private _max;
  30919. private _average;
  30920. private _current;
  30921. private _totalValueCount;
  30922. private _totalAccumulated;
  30923. private _lastSecAverage;
  30924. private _lastSecAccumulated;
  30925. private _lastSecTime;
  30926. private _lastSecValueCount;
  30927. }
  30928. /**
  30929. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30930. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30931. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30932. * @param name The name of the class, case should be preserved
  30933. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30934. */
  30935. function className(name: string, module?: string): (target: Object) => void;
  30936. /**
  30937. * An implementation of a loop for asynchronous functions.
  30938. */
  30939. class AsyncLoop {
  30940. iterations: number;
  30941. private _fn;
  30942. private _successCallback;
  30943. index: number;
  30944. private _done;
  30945. /**
  30946. * Constroctor.
  30947. * @param iterations the number of iterations.
  30948. * @param _fn the function to run each iteration
  30949. * @param _successCallback the callback that will be called upon succesful execution
  30950. * @param offset starting offset.
  30951. */
  30952. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  30953. /**
  30954. * Execute the next iteration. Must be called after the last iteration was finished.
  30955. */
  30956. executeNext(): void;
  30957. /**
  30958. * Break the loop and run the success callback.
  30959. */
  30960. breakLoop(): void;
  30961. /**
  30962. * Helper function
  30963. */
  30964. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  30965. /**
  30966. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30967. * @param iterations total number of iterations
  30968. * @param syncedIterations number of synchronous iterations in each async iteration.
  30969. * @param fn the function to call each iteration.
  30970. * @param callback a success call back that will be called when iterating stops.
  30971. * @param breakFunction a break condition (optional)
  30972. * @param timeout timeout settings for the setTimeout function. default - 0.
  30973. * @constructor
  30974. */
  30975. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  30976. }
  30977. }
  30978. declare module BABYLON {
  30979. /**
  30980. * Defines the potential axis of a Joystick
  30981. */
  30982. enum JoystickAxis {
  30983. /** X axis */
  30984. X = 0,
  30985. /** Y axis */
  30986. Y = 1,
  30987. /** Z axis */
  30988. Z = 2,
  30989. }
  30990. /**
  30991. * Class used to define virtual joystick (used in touch mode)
  30992. */
  30993. class VirtualJoystick {
  30994. /**
  30995. * Gets or sets a boolean indicating that left and right values must be inverted
  30996. */
  30997. reverseLeftRight: boolean;
  30998. /**
  30999. * Gets or sets a boolean indicating that up and down values must be inverted
  31000. */
  31001. reverseUpDown: boolean;
  31002. /**
  31003. * Gets the offset value for the position (ie. the change of the position value)
  31004. */
  31005. deltaPosition: Vector3;
  31006. /**
  31007. * Gets a boolean indicating if the virtual joystick was pressed
  31008. */
  31009. pressed: boolean;
  31010. private static _globalJoystickIndex;
  31011. private static vjCanvas;
  31012. private static vjCanvasContext;
  31013. private static vjCanvasWidth;
  31014. private static vjCanvasHeight;
  31015. private static halfWidth;
  31016. private _action;
  31017. private _axisTargetedByLeftAndRight;
  31018. private _axisTargetedByUpAndDown;
  31019. private _joystickSensibility;
  31020. private _inversedSensibility;
  31021. private _joystickPointerID;
  31022. private _joystickColor;
  31023. private _joystickPointerPos;
  31024. private _joystickPreviousPointerPos;
  31025. private _joystickPointerStartPos;
  31026. private _deltaJoystickVector;
  31027. private _leftJoystick;
  31028. private _touches;
  31029. private _onPointerDownHandlerRef;
  31030. private _onPointerMoveHandlerRef;
  31031. private _onPointerUpHandlerRef;
  31032. private _onResize;
  31033. /**
  31034. * Creates a new virtual joystick
  31035. * @param leftJoystick defines that the joystick is for left hand (false by default)
  31036. */
  31037. constructor(leftJoystick?: boolean);
  31038. /**
  31039. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  31040. * @param newJoystickSensibility defines the new sensibility
  31041. */
  31042. setJoystickSensibility(newJoystickSensibility: number): void;
  31043. private _onPointerDown(e);
  31044. private _onPointerMove(e);
  31045. private _onPointerUp(e);
  31046. /**
  31047. * Change the color of the virtual joystick
  31048. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  31049. */
  31050. setJoystickColor(newColor: string): void;
  31051. /**
  31052. * Defines a callback to call when the joystick is touched
  31053. * @param action defines the callback
  31054. */
  31055. setActionOnTouch(action: () => any): void;
  31056. /**
  31057. * Defines which axis you'd like to control for left & right
  31058. * @param axis defines the axis to use
  31059. */
  31060. setAxisForLeftRight(axis: JoystickAxis): void;
  31061. /**
  31062. * Defines which axis you'd like to control for up & down
  31063. * @param axis defines the axis to use
  31064. */
  31065. setAxisForUpDown(axis: JoystickAxis): void;
  31066. private _drawVirtualJoystick();
  31067. /**
  31068. * Release internal HTML canvas
  31069. */
  31070. releaseCanvas(): void;
  31071. }
  31072. }
  31073. declare module BABYLON {
  31074. /**
  31075. * Helper class to push actions to a pool of workers.
  31076. */
  31077. class WorkerPool implements IDisposable {
  31078. private _workerInfos;
  31079. private _pendingActions;
  31080. /**
  31081. * Constructor
  31082. * @param workers Array of workers to use for actions
  31083. */
  31084. constructor(workers: Array<Worker>);
  31085. /**
  31086. * Terminates all workers and clears any pending actions.
  31087. */
  31088. dispose(): void;
  31089. /**
  31090. * Pushes an action to the worker pool. If all the workers are active, the action will be
  31091. * pended until a worker has completed its action.
  31092. * @param action The action to perform. Call onComplete when the action is complete.
  31093. */
  31094. push(action: (worker: Worker, onComplete: () => void) => void): void;
  31095. private _execute(workerInfo, action);
  31096. }
  31097. }
  31098. declare module BABYLON {
  31099. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  31100. readonly name: string;
  31101. private _zoomStopsAnimation;
  31102. private _idleRotationSpeed;
  31103. private _idleRotationWaitTime;
  31104. private _idleRotationSpinupTime;
  31105. /**
  31106. * Gets the flag that indicates if user zooming should stop animation.
  31107. */
  31108. /**
  31109. * Sets the flag that indicates if user zooming should stop animation.
  31110. */
  31111. zoomStopsAnimation: boolean;
  31112. /**
  31113. * Gets the default speed at which the camera rotates around the model.
  31114. */
  31115. /**
  31116. * Sets the default speed at which the camera rotates around the model.
  31117. */
  31118. idleRotationSpeed: number;
  31119. /**
  31120. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  31121. */
  31122. /**
  31123. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  31124. */
  31125. idleRotationWaitTime: number;
  31126. /**
  31127. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  31128. */
  31129. /**
  31130. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  31131. */
  31132. idleRotationSpinupTime: number;
  31133. /**
  31134. * Gets a value indicating if the camera is currently rotating because of this behavior
  31135. */
  31136. readonly rotationInProgress: boolean;
  31137. private _onPrePointerObservableObserver;
  31138. private _onAfterCheckInputsObserver;
  31139. private _attachedCamera;
  31140. private _isPointerDown;
  31141. private _lastFrameTime;
  31142. private _lastInteractionTime;
  31143. private _cameraRotationSpeed;
  31144. init(): void;
  31145. attach(camera: ArcRotateCamera): void;
  31146. detach(): void;
  31147. /**
  31148. * Returns true if user is scrolling.
  31149. * @return true if user is scrolling.
  31150. */
  31151. private _userIsZooming();
  31152. private _lastFrameRadius;
  31153. private _shouldAnimationStopForInteraction();
  31154. /**
  31155. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  31156. */
  31157. private _applyUserInteraction();
  31158. private _userIsMoving();
  31159. }
  31160. }
  31161. declare module BABYLON {
  31162. /**
  31163. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  31164. */
  31165. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  31166. readonly name: string;
  31167. /**
  31168. * The easing function used by animations
  31169. */
  31170. static EasingFunction: BackEase;
  31171. /**
  31172. * The easing mode used by animations
  31173. */
  31174. static EasingMode: number;
  31175. /**
  31176. * The duration of the animation, in milliseconds
  31177. */
  31178. transitionDuration: number;
  31179. /**
  31180. * Length of the distance animated by the transition when lower radius is reached
  31181. */
  31182. lowerRadiusTransitionRange: number;
  31183. /**
  31184. * Length of the distance animated by the transition when upper radius is reached
  31185. */
  31186. upperRadiusTransitionRange: number;
  31187. private _autoTransitionRange;
  31188. /**
  31189. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  31190. */
  31191. /**
  31192. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  31193. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  31194. */
  31195. autoTransitionRange: boolean;
  31196. private _attachedCamera;
  31197. private _onAfterCheckInputsObserver;
  31198. private _onMeshTargetChangedObserver;
  31199. init(): void;
  31200. attach(camera: ArcRotateCamera): void;
  31201. detach(): void;
  31202. private _radiusIsAnimating;
  31203. private _radiusBounceTransition;
  31204. private _animatables;
  31205. private _cachedWheelPrecision;
  31206. /**
  31207. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  31208. * @param radiusLimit The limit to check against.
  31209. * @return Bool to indicate if at limit.
  31210. */
  31211. private _isRadiusAtLimit(radiusLimit);
  31212. /**
  31213. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  31214. * @param radiusDelta The delta by which to animate to. Can be negative.
  31215. */
  31216. private _applyBoundRadiusAnimation(radiusDelta);
  31217. /**
  31218. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  31219. */
  31220. protected _clearAnimationLocks(): void;
  31221. /**
  31222. * Stops and removes all animations that have been applied to the camera
  31223. */
  31224. stopAllAnimations(): void;
  31225. }
  31226. }
  31227. declare module BABYLON {
  31228. class FramingBehavior implements Behavior<ArcRotateCamera> {
  31229. readonly name: string;
  31230. private _mode;
  31231. private _radiusScale;
  31232. private _positionScale;
  31233. private _defaultElevation;
  31234. private _elevationReturnTime;
  31235. private _elevationReturnWaitTime;
  31236. private _zoomStopsAnimation;
  31237. private _framingTime;
  31238. /**
  31239. * The easing function used by animations
  31240. */
  31241. static EasingFunction: ExponentialEase;
  31242. /**
  31243. * The easing mode used by animations
  31244. */
  31245. static EasingMode: number;
  31246. /**
  31247. * Gets current mode used by the behavior.
  31248. */
  31249. /**
  31250. * Sets the current mode used by the behavior
  31251. */
  31252. mode: number;
  31253. /**
  31254. * Gets the scale applied to the radius
  31255. */
  31256. /**
  31257. * Sets the scale applied to the radius (1 by default)
  31258. */
  31259. radiusScale: number;
  31260. /**
  31261. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  31262. */
  31263. /**
  31264. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  31265. */
  31266. positionScale: number;
  31267. /**
  31268. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  31269. * behaviour is triggered, in radians.
  31270. */
  31271. /**
  31272. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  31273. * behaviour is triggered, in radians.
  31274. */
  31275. defaultElevation: number;
  31276. /**
  31277. * Gets the time (in milliseconds) taken to return to the default beta position.
  31278. * Negative value indicates camera should not return to default.
  31279. */
  31280. /**
  31281. * Sets the time (in milliseconds) taken to return to the default beta position.
  31282. * Negative value indicates camera should not return to default.
  31283. */
  31284. elevationReturnTime: number;
  31285. /**
  31286. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  31287. */
  31288. /**
  31289. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  31290. */
  31291. elevationReturnWaitTime: number;
  31292. /**
  31293. * Gets the flag that indicates if user zooming should stop animation.
  31294. */
  31295. /**
  31296. * Sets the flag that indicates if user zooming should stop animation.
  31297. */
  31298. zoomStopsAnimation: boolean;
  31299. /**
  31300. * Gets the transition time when framing the mesh, in milliseconds
  31301. */
  31302. /**
  31303. * Sets the transition time when framing the mesh, in milliseconds
  31304. */
  31305. framingTime: number;
  31306. private _onPrePointerObservableObserver;
  31307. private _onAfterCheckInputsObserver;
  31308. private _onMeshTargetChangedObserver;
  31309. private _attachedCamera;
  31310. private _isPointerDown;
  31311. private _lastInteractionTime;
  31312. init(): void;
  31313. attach(camera: ArcRotateCamera): void;
  31314. detach(): void;
  31315. private _animatables;
  31316. private _betaIsAnimating;
  31317. private _betaTransition;
  31318. private _radiusTransition;
  31319. private _vectorTransition;
  31320. /**
  31321. * Targets the given mesh and updates zoom level accordingly.
  31322. * @param mesh The mesh to target.
  31323. * @param radius Optional. If a cached radius position already exists, overrides default.
  31324. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31325. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31326. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31327. */
  31328. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31329. /**
  31330. * Targets the given mesh with its children and updates zoom level accordingly.
  31331. * @param mesh The mesh to target.
  31332. * @param radius Optional. If a cached radius position already exists, overrides default.
  31333. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31334. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31335. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31336. */
  31337. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31338. /**
  31339. * Targets the given meshes with their children and updates zoom level accordingly.
  31340. * @param meshes The mesh to target.
  31341. * @param radius Optional. If a cached radius position already exists, overrides default.
  31342. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31343. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31344. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31345. */
  31346. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31347. /**
  31348. * Targets the given mesh and updates zoom level accordingly.
  31349. * @param mesh The mesh to target.
  31350. * @param radius Optional. If a cached radius position already exists, overrides default.
  31351. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  31352. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  31353. * @param onAnimationEnd Callback triggered at the end of the framing animation
  31354. */
  31355. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  31356. /**
  31357. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  31358. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  31359. * frustum width.
  31360. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  31361. * to fully enclose the mesh in the viewing frustum.
  31362. */
  31363. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  31364. /**
  31365. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  31366. * is automatically returned to its default position (expected to be above ground plane).
  31367. */
  31368. private _maintainCameraAboveGround();
  31369. /**
  31370. * Returns the frustum slope based on the canvas ratio and camera FOV
  31371. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  31372. */
  31373. private _getFrustumSlope();
  31374. /**
  31375. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  31376. */
  31377. private _clearAnimationLocks();
  31378. /**
  31379. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  31380. */
  31381. private _applyUserInteraction();
  31382. /**
  31383. * Stops and removes all animations that have been applied to the camera
  31384. */
  31385. stopAllAnimations(): void;
  31386. /**
  31387. * Gets a value indicating if the user is moving the camera
  31388. */
  31389. readonly isUserIsMoving: boolean;
  31390. /**
  31391. * The camera can move all the way towards the mesh.
  31392. */
  31393. static IgnoreBoundsSizeMode: number;
  31394. /**
  31395. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  31396. */
  31397. static FitFrustumSidesMode: number;
  31398. }
  31399. }
  31400. declare module BABYLON {
  31401. /**
  31402. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  31403. */
  31404. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  31405. private ui;
  31406. /**
  31407. * The name of the behavior
  31408. */
  31409. name: string;
  31410. /**
  31411. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  31412. */
  31413. distanceAwayFromFace: number;
  31414. /**
  31415. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  31416. */
  31417. distanceAwayFromBottomOfFace: number;
  31418. private _faceVectors;
  31419. private _target;
  31420. private _scene;
  31421. private _onRenderObserver;
  31422. private _tmpMatrix;
  31423. private _tmpVector;
  31424. /**
  31425. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  31426. * @param ui The transform node that should be attched to the mesh
  31427. */
  31428. constructor(ui: BABYLON.TransformNode);
  31429. /**
  31430. * Initializes the behavior
  31431. */
  31432. init(): void;
  31433. private _closestFace(targetDirection);
  31434. private _zeroVector;
  31435. private _lookAtTmpMatrix;
  31436. private _lookAtToRef(pos, up, ref);
  31437. /**
  31438. * Attaches the AttachToBoxBehavior to the passed in mesh
  31439. * @param target The mesh that the specified node will be attached to
  31440. */
  31441. attach(target: BABYLON.Mesh): void;
  31442. /**
  31443. * Detaches the behavior from the mesh
  31444. */
  31445. detach(): void;
  31446. }
  31447. }
  31448. declare module BABYLON {
  31449. /**
  31450. * A behavior that when attached to a mesh will allow the mesh to be scaled
  31451. */
  31452. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  31453. private _dragBehaviorA;
  31454. private _dragBehaviorB;
  31455. private _startDistance;
  31456. private _initialScale;
  31457. private _targetScale;
  31458. private _ownerNode;
  31459. private _sceneRenderObserver;
  31460. constructor();
  31461. /**
  31462. * The name of the behavior
  31463. */
  31464. readonly name: string;
  31465. /**
  31466. * Initializes the behavior
  31467. */
  31468. init(): void;
  31469. private _getCurrentDistance();
  31470. /**
  31471. * Attaches the scale behavior the passed in mesh
  31472. * @param ownerNode The mesh that will be scaled around once attached
  31473. */
  31474. attach(ownerNode: Mesh): void;
  31475. /**
  31476. * Detaches the behavior from the mesh
  31477. */
  31478. detach(): void;
  31479. }
  31480. }
  31481. declare module BABYLON {
  31482. /**
  31483. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  31484. */
  31485. class PointerDragBehavior implements Behavior<Mesh> {
  31486. private _attachedNode;
  31487. private _dragPlane;
  31488. private _scene;
  31489. private _pointerObserver;
  31490. private _beforeRenderObserver;
  31491. private static _planeScene;
  31492. /**
  31493. * 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)
  31494. */
  31495. maxDragAngle: number;
  31496. /**
  31497. * @hidden
  31498. */
  31499. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  31500. /**
  31501. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  31502. */
  31503. currentDraggingPointerID: number;
  31504. /**
  31505. * The last position where the pointer hit the drag plane in world space
  31506. */
  31507. lastDragPosition: Vector3;
  31508. /**
  31509. * If the behavior is currently in a dragging state
  31510. */
  31511. dragging: boolean;
  31512. /**
  31513. * 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)
  31514. */
  31515. dragDeltaRatio: number;
  31516. /**
  31517. * If the drag plane orientation should be updated during the dragging (Default: true)
  31518. */
  31519. updateDragPlane: boolean;
  31520. private _debugMode;
  31521. private _moving;
  31522. /**
  31523. * Fires each time the attached mesh is dragged with the pointer
  31524. * * delta between last drag position and current drag position in world space
  31525. * * dragDistance along the drag axis
  31526. * * dragPlaneNormal normal of the current drag plane used during the drag
  31527. * * dragPlanePoint in world space where the drag intersects the drag plane
  31528. */
  31529. onDragObservable: Observable<{
  31530. delta: Vector3;
  31531. dragPlanePoint: Vector3;
  31532. dragPlaneNormal: Vector3;
  31533. dragDistance: number;
  31534. pointerId: number;
  31535. }>;
  31536. /**
  31537. * Fires each time a drag begins (eg. mouse down on mesh)
  31538. */
  31539. onDragStartObservable: Observable<{
  31540. dragPlanePoint: Vector3;
  31541. pointerId: number;
  31542. }>;
  31543. /**
  31544. * Fires each time a drag ends (eg. mouse release after drag)
  31545. */
  31546. onDragEndObservable: Observable<{
  31547. dragPlanePoint: Vector3;
  31548. pointerId: number;
  31549. }>;
  31550. /**
  31551. * If the attached mesh should be moved when dragged
  31552. */
  31553. moveAttached: boolean;
  31554. /**
  31555. * If the drag behavior will react to drag events (Default: true)
  31556. */
  31557. enabled: boolean;
  31558. /**
  31559. * If camera controls should be detached during the drag
  31560. */
  31561. detachCameraControls: boolean;
  31562. /**
  31563. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  31564. */
  31565. useObjectOrienationForDragging: boolean;
  31566. private _options;
  31567. /**
  31568. * Creates a pointer drag behavior that can be attached to a mesh
  31569. * @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)
  31570. */
  31571. constructor(options?: {
  31572. dragAxis?: Vector3;
  31573. dragPlaneNormal?: Vector3;
  31574. });
  31575. /**
  31576. * The name of the behavior
  31577. */
  31578. readonly name: string;
  31579. /**
  31580. * Initializes the behavior
  31581. */
  31582. init(): void;
  31583. private _tmpVector;
  31584. private _alternatePickedPoint;
  31585. private _worldDragAxis;
  31586. /**
  31587. * Attaches the drag behavior the passed in mesh
  31588. * @param ownerNode The mesh that will be dragged around once attached
  31589. */
  31590. attach(ownerNode: Mesh): void;
  31591. releaseDrag(): void;
  31592. private _pickWithRayOnDragPlane(ray);
  31593. private _pointA;
  31594. private _pointB;
  31595. private _pointC;
  31596. private _lineA;
  31597. private _lineB;
  31598. private _localAxis;
  31599. private _lookAt;
  31600. private _updateDragPlanePosition(ray, dragPlanePosition);
  31601. /**
  31602. * Detaches the behavior from the mesh
  31603. */
  31604. detach(): void;
  31605. }
  31606. }
  31607. declare module BABYLON {
  31608. /**
  31609. * 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
  31610. */
  31611. class SixDofDragBehavior implements Behavior<Mesh> {
  31612. private static _virtualScene;
  31613. private _ownerNode;
  31614. private _sceneRenderObserver;
  31615. private _scene;
  31616. private _targetPosition;
  31617. private _virtualOriginMesh;
  31618. private _virtualDragMesh;
  31619. private _pointerObserver;
  31620. private _moving;
  31621. private _startingOrientation;
  31622. /**
  31623. * 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)
  31624. */
  31625. private zDragFactor;
  31626. /**
  31627. * If the behavior is currently in a dragging state
  31628. */
  31629. dragging: boolean;
  31630. /**
  31631. * 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)
  31632. */
  31633. dragDeltaRatio: number;
  31634. /**
  31635. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  31636. */
  31637. currentDraggingPointerID: number;
  31638. /**
  31639. * If camera controls should be detached during the drag
  31640. */
  31641. detachCameraControls: boolean;
  31642. constructor();
  31643. /**
  31644. * The name of the behavior
  31645. */
  31646. readonly name: string;
  31647. /**
  31648. * Initializes the behavior
  31649. */
  31650. init(): void;
  31651. /**
  31652. * Attaches the scale behavior the passed in mesh
  31653. * @param ownerNode The mesh that will be scaled around once attached
  31654. */
  31655. attach(ownerNode: Mesh): void;
  31656. /**
  31657. * Detaches the behavior from the mesh
  31658. */
  31659. detach(): void;
  31660. }
  31661. }
  31662. declare module BABYLON {
  31663. interface IOctreeContainer<T> {
  31664. blocks: Array<OctreeBlock<T>>;
  31665. }
  31666. class Octree<T> {
  31667. maxDepth: number;
  31668. blocks: Array<OctreeBlock<T>>;
  31669. dynamicContent: T[];
  31670. private _maxBlockCapacity;
  31671. private _selectionContent;
  31672. private _creationFunc;
  31673. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  31674. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  31675. addMesh(entry: T): void;
  31676. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  31677. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  31678. intersectsRay(ray: Ray): SmartArray<T>;
  31679. 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;
  31680. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  31681. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  31682. }
  31683. }
  31684. declare module BABYLON {
  31685. class OctreeBlock<T> {
  31686. entries: T[];
  31687. blocks: Array<OctreeBlock<T>>;
  31688. private _depth;
  31689. private _maxDepth;
  31690. private _capacity;
  31691. private _minPoint;
  31692. private _maxPoint;
  31693. private _boundingVectors;
  31694. private _creationFunc;
  31695. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  31696. readonly capacity: number;
  31697. readonly minPoint: Vector3;
  31698. readonly maxPoint: Vector3;
  31699. addEntry(entry: T): void;
  31700. addEntries(entries: T[]): void;
  31701. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  31702. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  31703. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  31704. createInnerBlocks(): void;
  31705. }
  31706. }
  31707. declare module BABYLON {
  31708. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  31709. camera: ArcRotateCamera;
  31710. gamepad: Nullable<Gamepad>;
  31711. private _onGamepadConnectedObserver;
  31712. private _onGamepadDisconnectedObserver;
  31713. gamepadRotationSensibility: number;
  31714. gamepadMoveSensibility: number;
  31715. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31716. detachControl(element: Nullable<HTMLElement>): void;
  31717. checkInputs(): void;
  31718. getClassName(): string;
  31719. getSimpleName(): string;
  31720. }
  31721. }
  31722. declare module BABYLON {
  31723. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  31724. camera: ArcRotateCamera;
  31725. private _keys;
  31726. keysUp: number[];
  31727. keysDown: number[];
  31728. keysLeft: number[];
  31729. keysRight: number[];
  31730. keysReset: number[];
  31731. panningSensibility: number;
  31732. zoomingSensibility: number;
  31733. useAltToZoom: boolean;
  31734. private _ctrlPressed;
  31735. private _altPressed;
  31736. private _onCanvasBlurObserver;
  31737. private _onKeyboardObserver;
  31738. private _engine;
  31739. private _scene;
  31740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31741. detachControl(element: Nullable<HTMLElement>): void;
  31742. checkInputs(): void;
  31743. getClassName(): string;
  31744. getSimpleName(): string;
  31745. }
  31746. }
  31747. declare module BABYLON {
  31748. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  31749. camera: ArcRotateCamera;
  31750. private _wheel;
  31751. private _observer;
  31752. wheelPrecision: number;
  31753. /**
  31754. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  31755. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  31756. */
  31757. wheelDeltaPercentage: number;
  31758. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31759. detachControl(element: Nullable<HTMLElement>): void;
  31760. getClassName(): string;
  31761. getSimpleName(): string;
  31762. }
  31763. }
  31764. declare module BABYLON {
  31765. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  31766. camera: ArcRotateCamera;
  31767. buttons: number[];
  31768. angularSensibilityX: number;
  31769. angularSensibilityY: number;
  31770. pinchPrecision: number;
  31771. /**
  31772. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  31773. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  31774. */
  31775. pinchDeltaPercentage: number;
  31776. panningSensibility: number;
  31777. multiTouchPanning: boolean;
  31778. multiTouchPanAndZoom: boolean;
  31779. private _isPanClick;
  31780. pinchInwards: boolean;
  31781. private _pointerInput;
  31782. private _observer;
  31783. private _onMouseMove;
  31784. private _onGestureStart;
  31785. private _onGesture;
  31786. private _MSGestureHandler;
  31787. private _onLostFocus;
  31788. private _onContextMenu;
  31789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31790. detachControl(element: Nullable<HTMLElement>): void;
  31791. getClassName(): string;
  31792. getSimpleName(): string;
  31793. }
  31794. }
  31795. declare module BABYLON {
  31796. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  31797. camera: ArcRotateCamera;
  31798. alphaCorrection: number;
  31799. betaCorrection: number;
  31800. gammaCorrection: number;
  31801. private _alpha;
  31802. private _gamma;
  31803. private _dirty;
  31804. private _deviceOrientationHandler;
  31805. constructor();
  31806. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31807. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  31808. checkInputs(): void;
  31809. detachControl(element: Nullable<HTMLElement>): void;
  31810. getClassName(): string;
  31811. getSimpleName(): string;
  31812. }
  31813. }
  31814. declare module BABYLON {
  31815. /**
  31816. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  31817. * Screen rotation is taken into account.
  31818. */
  31819. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  31820. private _camera;
  31821. private _screenOrientationAngle;
  31822. private _constantTranform;
  31823. private _screenQuaternion;
  31824. private _alpha;
  31825. private _beta;
  31826. private _gamma;
  31827. constructor();
  31828. camera: FreeCamera;
  31829. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31830. private _orientationChanged;
  31831. private _deviceOrientation;
  31832. detachControl(element: Nullable<HTMLElement>): void;
  31833. checkInputs(): void;
  31834. getClassName(): string;
  31835. getSimpleName(): string;
  31836. }
  31837. }
  31838. declare module BABYLON {
  31839. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  31840. camera: FreeCamera;
  31841. gamepad: Nullable<Gamepad>;
  31842. private _onGamepadConnectedObserver;
  31843. private _onGamepadDisconnectedObserver;
  31844. gamepadAngularSensibility: number;
  31845. gamepadMoveSensibility: number;
  31846. private _cameraTransform;
  31847. private _deltaTransform;
  31848. private _vector3;
  31849. private _vector2;
  31850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31851. detachControl(element: Nullable<HTMLElement>): void;
  31852. checkInputs(): void;
  31853. getClassName(): string;
  31854. getSimpleName(): string;
  31855. }
  31856. }
  31857. declare module BABYLON {
  31858. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  31859. camera: FreeCamera;
  31860. private _keys;
  31861. private _onCanvasBlurObserver;
  31862. private _onKeyboardObserver;
  31863. private _engine;
  31864. private _scene;
  31865. keysUp: number[];
  31866. keysDown: number[];
  31867. keysLeft: number[];
  31868. keysRight: number[];
  31869. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31870. detachControl(element: Nullable<HTMLElement>): void;
  31871. checkInputs(): void;
  31872. getClassName(): string;
  31873. _onLostFocus(e: FocusEvent): void;
  31874. getSimpleName(): string;
  31875. }
  31876. }
  31877. declare module BABYLON {
  31878. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  31879. touchEnabled: boolean;
  31880. camera: FreeCamera;
  31881. buttons: number[];
  31882. angularSensibility: number;
  31883. private _pointerInput;
  31884. private _onMouseMove;
  31885. private _observer;
  31886. private previousPosition;
  31887. constructor(touchEnabled?: boolean);
  31888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31889. detachControl(element: Nullable<HTMLElement>): void;
  31890. getClassName(): string;
  31891. getSimpleName(): string;
  31892. }
  31893. }
  31894. declare module BABYLON {
  31895. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  31896. camera: FreeCamera;
  31897. private _offsetX;
  31898. private _offsetY;
  31899. private _pointerPressed;
  31900. private _pointerInput;
  31901. private _observer;
  31902. private _onLostFocus;
  31903. touchAngularSensibility: number;
  31904. touchMoveSensibility: number;
  31905. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31906. detachControl(element: Nullable<HTMLElement>): void;
  31907. checkInputs(): void;
  31908. getClassName(): string;
  31909. getSimpleName(): string;
  31910. }
  31911. }
  31912. declare module BABYLON {
  31913. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  31914. camera: FreeCamera;
  31915. private _leftjoystick;
  31916. private _rightjoystick;
  31917. getLeftJoystick(): VirtualJoystick;
  31918. getRightJoystick(): VirtualJoystick;
  31919. checkInputs(): void;
  31920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31921. detachControl(element: Nullable<HTMLElement>): void;
  31922. getClassName(): string;
  31923. getSimpleName(): string;
  31924. }
  31925. }
  31926. declare module BABYLON {
  31927. /**
  31928. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  31929. */
  31930. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  31931. /**
  31932. * Creates a new AnaglyphArcRotateCamera
  31933. * @param name defines camera name
  31934. * @param alpha defines alpha angle (in radians)
  31935. * @param beta defines beta angle (in radians)
  31936. * @param radius defines radius
  31937. * @param target defines camera target
  31938. * @param interaxialDistance defines distance between each color axis
  31939. * @param scene defines the hosting scene
  31940. */
  31941. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  31942. /**
  31943. * Gets camera class name
  31944. * @returns AnaglyphArcRotateCamera
  31945. */
  31946. getClassName(): string;
  31947. }
  31948. }
  31949. declare module BABYLON {
  31950. /**
  31951. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  31952. */
  31953. class AnaglyphFreeCamera extends FreeCamera {
  31954. /**
  31955. * Creates a new AnaglyphFreeCamera
  31956. * @param name defines camera name
  31957. * @param position defines initial position
  31958. * @param interaxialDistance defines distance between each color axis
  31959. * @param scene defines the hosting scene
  31960. */
  31961. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  31962. /**
  31963. * Gets camera class name
  31964. * @returns AnaglyphFreeCamera
  31965. */
  31966. getClassName(): string;
  31967. }
  31968. }
  31969. declare module BABYLON {
  31970. /**
  31971. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  31972. */
  31973. class AnaglyphGamepadCamera extends GamepadCamera {
  31974. /**
  31975. * Creates a new AnaglyphGamepadCamera
  31976. * @param name defines camera name
  31977. * @param position defines initial position
  31978. * @param interaxialDistance defines distance between each color axis
  31979. * @param scene defines the hosting scene
  31980. */
  31981. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  31982. /**
  31983. * Gets camera class name
  31984. * @returns AnaglyphGamepadCamera
  31985. */
  31986. getClassName(): string;
  31987. }
  31988. }
  31989. declare module BABYLON {
  31990. /**
  31991. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  31992. */
  31993. class AnaglyphUniversalCamera extends UniversalCamera {
  31994. /**
  31995. * Creates a new AnaglyphUniversalCamera
  31996. * @param name defines camera name
  31997. * @param position defines initial position
  31998. * @param interaxialDistance defines distance between each color axis
  31999. * @param scene defines the hosting scene
  32000. */
  32001. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  32002. /**
  32003. * Gets camera class name
  32004. * @returns AnaglyphUniversalCamera
  32005. */
  32006. getClassName(): string;
  32007. }
  32008. }
  32009. declare module BABYLON {
  32010. /**
  32011. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  32012. */
  32013. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  32014. /**
  32015. * Creates a new StereoscopicArcRotateCamera
  32016. * @param name defines camera name
  32017. * @param alpha defines alpha angle (in radians)
  32018. * @param beta defines beta angle (in radians)
  32019. * @param radius defines radius
  32020. * @param target defines camera target
  32021. * @param interaxialDistance defines distance between each color axis
  32022. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32023. * @param scene defines the hosting scene
  32024. */
  32025. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32026. /**
  32027. * Gets camera class name
  32028. * @returns StereoscopicArcRotateCamera
  32029. */
  32030. getClassName(): string;
  32031. }
  32032. }
  32033. declare module BABYLON {
  32034. /**
  32035. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  32036. */
  32037. class StereoscopicFreeCamera extends FreeCamera {
  32038. /**
  32039. * Creates a new StereoscopicFreeCamera
  32040. * @param name defines camera name
  32041. * @param position defines initial position
  32042. * @param interaxialDistance defines distance between each color axis
  32043. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32044. * @param scene defines the hosting scene
  32045. */
  32046. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32047. /**
  32048. * Gets camera class name
  32049. * @returns StereoscopicFreeCamera
  32050. */
  32051. getClassName(): string;
  32052. }
  32053. }
  32054. declare module BABYLON {
  32055. /**
  32056. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  32057. */
  32058. class StereoscopicGamepadCamera extends GamepadCamera {
  32059. /**
  32060. * Creates a new StereoscopicGamepadCamera
  32061. * @param name defines camera name
  32062. * @param position defines initial position
  32063. * @param interaxialDistance defines distance between each color axis
  32064. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32065. * @param scene defines the hosting scene
  32066. */
  32067. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32068. /**
  32069. * Gets camera class name
  32070. * @returns StereoscopicGamepadCamera
  32071. */
  32072. getClassName(): string;
  32073. }
  32074. }
  32075. declare module BABYLON {
  32076. /**
  32077. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  32078. */
  32079. class StereoscopicUniversalCamera extends UniversalCamera {
  32080. /**
  32081. * Creates a new StereoscopicUniversalCamera
  32082. * @param name defines camera name
  32083. * @param position defines initial position
  32084. * @param interaxialDistance defines distance between each color axis
  32085. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  32086. * @param scene defines the hosting scene
  32087. */
  32088. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  32089. /**
  32090. * Gets camera class name
  32091. * @returns StereoscopicUniversalCamera
  32092. */
  32093. getClassName(): string;
  32094. }
  32095. }
  32096. declare module BABYLON {
  32097. class VRCameraMetrics {
  32098. hResolution: number;
  32099. vResolution: number;
  32100. hScreenSize: number;
  32101. vScreenSize: number;
  32102. vScreenCenter: number;
  32103. eyeToScreenDistance: number;
  32104. lensSeparationDistance: number;
  32105. interpupillaryDistance: number;
  32106. distortionK: number[];
  32107. chromaAbCorrection: number[];
  32108. postProcessScaleFactor: number;
  32109. lensCenterOffset: number;
  32110. compensateDistortion: boolean;
  32111. readonly aspectRatio: number;
  32112. readonly aspectRatioFov: number;
  32113. readonly leftHMatrix: Matrix;
  32114. readonly rightHMatrix: Matrix;
  32115. readonly leftPreViewMatrix: Matrix;
  32116. readonly rightPreViewMatrix: Matrix;
  32117. static GetDefault(): VRCameraMetrics;
  32118. }
  32119. }
  32120. declare module BABYLON {
  32121. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  32122. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  32123. getClassName(): string;
  32124. }
  32125. }
  32126. declare module BABYLON {
  32127. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  32128. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  32129. getClassName(): string;
  32130. }
  32131. }
  32132. declare module BABYLON {
  32133. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  32134. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  32135. getClassName(): string;
  32136. }
  32137. }
  32138. declare module BABYLON {
  32139. /**
  32140. * Options to modify the vr teleportation behavior.
  32141. */
  32142. interface VRTeleportationOptions {
  32143. /**
  32144. * The name of the mesh which should be used as the teleportation floor. (default: null)
  32145. */
  32146. floorMeshName?: string;
  32147. /**
  32148. * A list of meshes to be used as the teleportation floor. (default: empty)
  32149. */
  32150. floorMeshes?: Mesh[];
  32151. }
  32152. /**
  32153. * Options to modify the vr experience helper's behavior.
  32154. */
  32155. interface VRExperienceHelperOptions extends WebVROptions {
  32156. /**
  32157. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  32158. */
  32159. createDeviceOrientationCamera?: boolean;
  32160. /**
  32161. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  32162. */
  32163. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  32164. /**
  32165. * Uses the main button on the controller to toggle the laser casted. (default: true)
  32166. */
  32167. laserToggle?: boolean;
  32168. /**
  32169. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  32170. */
  32171. floorMeshes?: Mesh[];
  32172. }
  32173. /**
  32174. * Helps to quickly add VR support to an existing scene.
  32175. * See http://doc.babylonjs.com/how_to/webvr_helper
  32176. */
  32177. class VRExperienceHelper {
  32178. /** Options to modify the vr experience helper's behavior. */
  32179. webVROptions: VRExperienceHelperOptions;
  32180. private _scene;
  32181. private _position;
  32182. private _btnVR;
  32183. private _btnVRDisplayed;
  32184. private _webVRsupported;
  32185. private _webVRready;
  32186. private _webVRrequesting;
  32187. private _webVRpresenting;
  32188. private _fullscreenVRpresenting;
  32189. private _canvas;
  32190. private _webVRCamera;
  32191. private _vrDeviceOrientationCamera;
  32192. private _deviceOrientationCamera;
  32193. private _existingCamera;
  32194. private _onKeyDown;
  32195. private _onVrDisplayPresentChange;
  32196. private _onVRDisplayChanged;
  32197. private _onVRRequestPresentStart;
  32198. private _onVRRequestPresentComplete;
  32199. /**
  32200. * Observable raised when entering VR.
  32201. */
  32202. onEnteringVRObservable: Observable<VRExperienceHelper>;
  32203. /**
  32204. * Observable raised when exiting VR.
  32205. */
  32206. onExitingVRObservable: Observable<VRExperienceHelper>;
  32207. /**
  32208. * Observable raised when controller mesh is loaded.
  32209. */
  32210. onControllerMeshLoadedObservable: Observable<WebVRController>;
  32211. /** Return this.onEnteringVRObservable
  32212. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  32213. */
  32214. readonly onEnteringVR: Observable<VRExperienceHelper>;
  32215. /** Return this.onExitingVRObservable
  32216. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  32217. */
  32218. readonly onExitingVR: Observable<VRExperienceHelper>;
  32219. /** Return this.onControllerMeshLoadedObservable
  32220. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  32221. */
  32222. readonly onControllerMeshLoaded: Observable<WebVRController>;
  32223. private _rayLength;
  32224. private _useCustomVRButton;
  32225. private _teleportationRequested;
  32226. private _teleportActive;
  32227. private _floorMeshName;
  32228. private _floorMeshesCollection;
  32229. private _rotationAllowed;
  32230. private _teleportBackwardsVector;
  32231. private _teleportationTarget;
  32232. private _isDefaultTeleportationTarget;
  32233. private _postProcessMove;
  32234. private _teleportationFillColor;
  32235. private _teleportationBorderColor;
  32236. private _rotationAngle;
  32237. private _haloCenter;
  32238. private _cameraGazer;
  32239. private _padSensibilityUp;
  32240. private _padSensibilityDown;
  32241. private leftController;
  32242. private rightController;
  32243. /**
  32244. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  32245. */
  32246. onNewMeshSelected: Observable<AbstractMesh>;
  32247. /**
  32248. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  32249. */
  32250. onNewMeshPicked: Observable<PickingInfo>;
  32251. private _circleEase;
  32252. /**
  32253. * Observable raised before camera teleportation
  32254. */
  32255. onBeforeCameraTeleport: Observable<Vector3>;
  32256. /**
  32257. * Observable raised after camera teleportation
  32258. */
  32259. onAfterCameraTeleport: Observable<Vector3>;
  32260. /**
  32261. * Observable raised when current selected mesh gets unselected
  32262. */
  32263. onSelectedMeshUnselected: Observable<AbstractMesh>;
  32264. private _raySelectionPredicate;
  32265. /**
  32266. * To be optionaly changed by user to define custom ray selection
  32267. */
  32268. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  32269. /**
  32270. * To be optionaly changed by user to define custom selection logic (after ray selection)
  32271. */
  32272. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  32273. /**
  32274. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  32275. */
  32276. teleportationEnabled: boolean;
  32277. private _defaultHeight;
  32278. private _teleportationInitialized;
  32279. private _interactionsEnabled;
  32280. private _interactionsRequested;
  32281. private _displayGaze;
  32282. private _displayLaserPointer;
  32283. /**
  32284. * The mesh used to display where the user is going to teleport.
  32285. */
  32286. /**
  32287. * Sets the mesh to be used to display where the user is going to teleport.
  32288. */
  32289. teleportationTarget: Mesh;
  32290. /**
  32291. * The mesh used to display where the user is selecting,
  32292. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  32293. * See http://doc.babylonjs.com/resources/baking_transformations
  32294. */
  32295. gazeTrackerMesh: Mesh;
  32296. /**
  32297. * If the ray of the gaze should be displayed.
  32298. */
  32299. /**
  32300. * Sets if the ray of the gaze should be displayed.
  32301. */
  32302. displayGaze: boolean;
  32303. /**
  32304. * If the ray of the LaserPointer should be displayed.
  32305. */
  32306. /**
  32307. * Sets if the ray of the LaserPointer should be displayed.
  32308. */
  32309. displayLaserPointer: boolean;
  32310. /**
  32311. * The deviceOrientationCamera used as the camera when not in VR.
  32312. */
  32313. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  32314. /**
  32315. * Based on the current WebVR support, returns the current VR camera used.
  32316. */
  32317. readonly currentVRCamera: Nullable<Camera>;
  32318. /**
  32319. * The webVRCamera which is used when in VR.
  32320. */
  32321. readonly webVRCamera: WebVRFreeCamera;
  32322. /**
  32323. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  32324. */
  32325. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  32326. private readonly _teleportationRequestInitiated;
  32327. /**
  32328. * Instantiates a VRExperienceHelper.
  32329. * Helps to quickly add VR support to an existing scene.
  32330. * @param scene The scene the VRExperienceHelper belongs to.
  32331. * @param webVROptions Options to modify the vr experience helper's behavior.
  32332. */
  32333. constructor(scene: Scene,
  32334. /** Options to modify the vr experience helper's behavior. */
  32335. webVROptions?: VRExperienceHelperOptions);
  32336. private _onDefaultMeshLoaded(webVRController);
  32337. private _onResize;
  32338. private _onFullscreenChange;
  32339. /**
  32340. * Gets a value indicating if we are currently in VR mode.
  32341. */
  32342. readonly isInVRMode: boolean;
  32343. private onVrDisplayPresentChange();
  32344. private onVRDisplayChanged(eventArgs);
  32345. private moveButtonToBottomRight();
  32346. private displayVRButton();
  32347. private updateButtonVisibility();
  32348. /**
  32349. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  32350. * Otherwise, will use the fullscreen API.
  32351. */
  32352. enterVR(): void;
  32353. /**
  32354. * Attempt to exit VR, or fullscreen.
  32355. */
  32356. exitVR(): void;
  32357. /**
  32358. * The position of the vr experience helper.
  32359. */
  32360. /**
  32361. * Sets the position of the vr experience helper.
  32362. */
  32363. position: Vector3;
  32364. /**
  32365. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  32366. */
  32367. enableInteractions(): void;
  32368. private readonly _noControllerIsActive;
  32369. private beforeRender;
  32370. private _isTeleportationFloor(mesh);
  32371. /**
  32372. * Adds a floor mesh to be used for teleportation.
  32373. * @param floorMesh the mesh to be used for teleportation.
  32374. */
  32375. addFloorMesh(floorMesh: Mesh): void;
  32376. /**
  32377. * Removes a floor mesh from being used for teleportation.
  32378. * @param floorMesh the mesh to be removed.
  32379. */
  32380. removeFloorMesh(floorMesh: Mesh): void;
  32381. /**
  32382. * Enables interactions and teleportation using the VR controllers and gaze.
  32383. * @param vrTeleportationOptions options to modify teleportation behavior.
  32384. */
  32385. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  32386. private _onNewGamepadConnected;
  32387. private _tryEnableInteractionOnController;
  32388. private _onNewGamepadDisconnected;
  32389. private _enableInteractionOnController(controller);
  32390. private _checkTeleportWithRay(stateObject, gazer);
  32391. private _checkRotate(stateObject, gazer);
  32392. private _checkTeleportBackwards(stateObject, gazer);
  32393. private _enableTeleportationOnController(controller);
  32394. private _createTeleportationCircles();
  32395. private _displayTeleportationTarget();
  32396. private _hideTeleportationTarget();
  32397. private _rotateCamera(right);
  32398. private _moveTeleportationSelectorTo(hit, gazer, ray);
  32399. private _workingVector;
  32400. private _workingQuaternion;
  32401. private _workingMatrix;
  32402. private _teleportCamera(location);
  32403. private _convertNormalToDirectionOfRay(normal, ray);
  32404. private _castRayAndSelectObject(gazer);
  32405. private _notifySelectedMeshUnselected(mesh);
  32406. /**
  32407. * Sets the color of the laser ray from the vr controllers.
  32408. * @param color new color for the ray.
  32409. */
  32410. changeLaserColor(color: Color3): void;
  32411. /**
  32412. * Sets the color of the ray from the vr headsets gaze.
  32413. * @param color new color for the ray.
  32414. */
  32415. changeGazeColor(color: Color3): void;
  32416. /**
  32417. * Exits VR and disposes of the vr experience helper
  32418. */
  32419. dispose(): void;
  32420. /**
  32421. * Gets the name of the VRExperienceHelper class
  32422. * @returns "VRExperienceHelper"
  32423. */
  32424. getClassName(): string;
  32425. }
  32426. }
  32427. declare module BABYLON {
  32428. /**
  32429. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  32430. * IMPORTANT!! The data is right-hand data.
  32431. * @export
  32432. * @interface DevicePose
  32433. */
  32434. interface DevicePose {
  32435. /**
  32436. * The position of the device, values in array are [x,y,z].
  32437. */
  32438. readonly position: Nullable<Float32Array>;
  32439. /**
  32440. * The linearVelocity of the device, values in array are [x,y,z].
  32441. */
  32442. readonly linearVelocity: Nullable<Float32Array>;
  32443. /**
  32444. * The linearAcceleration of the device, values in array are [x,y,z].
  32445. */
  32446. readonly linearAcceleration: Nullable<Float32Array>;
  32447. /**
  32448. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  32449. */
  32450. readonly orientation: Nullable<Float32Array>;
  32451. /**
  32452. * The angularVelocity of the device, values in array are [x,y,z].
  32453. */
  32454. readonly angularVelocity: Nullable<Float32Array>;
  32455. /**
  32456. * The angularAcceleration of the device, values in array are [x,y,z].
  32457. */
  32458. readonly angularAcceleration: Nullable<Float32Array>;
  32459. }
  32460. /**
  32461. * Interface representing a pose controlled object in Babylon.
  32462. * A pose controlled object has both regular pose values as well as pose values
  32463. * from an external device such as a VR head mounted display
  32464. */
  32465. interface PoseControlled {
  32466. /**
  32467. * The position of the object in babylon space.
  32468. */
  32469. position: Vector3;
  32470. /**
  32471. * The rotation quaternion of the object in babylon space.
  32472. */
  32473. rotationQuaternion: Quaternion;
  32474. /**
  32475. * The position of the device in babylon space.
  32476. */
  32477. devicePosition?: Vector3;
  32478. /**
  32479. * The rotation quaternion of the device in babylon space.
  32480. */
  32481. deviceRotationQuaternion: Quaternion;
  32482. /**
  32483. * The raw pose coming from the device.
  32484. */
  32485. rawPose: Nullable<DevicePose>;
  32486. /**
  32487. * The scale of the device to be used when translating from device space to babylon space.
  32488. */
  32489. deviceScaleFactor: number;
  32490. /**
  32491. * Updates the poseControlled values based on the input device pose.
  32492. * @param poseData the pose data to update the object with
  32493. */
  32494. updateFromDevice(poseData: DevicePose): void;
  32495. }
  32496. /**
  32497. * Set of options to customize the webVRCamera
  32498. */
  32499. interface WebVROptions {
  32500. /**
  32501. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  32502. */
  32503. trackPosition?: boolean;
  32504. /**
  32505. * Sets the scale of the vrDevice in babylon space. (default: 1)
  32506. */
  32507. positionScale?: number;
  32508. /**
  32509. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  32510. */
  32511. displayName?: string;
  32512. /**
  32513. * Should the native controller meshes be initialized. (default: true)
  32514. */
  32515. controllerMeshes?: boolean;
  32516. /**
  32517. * Creating a default HemiLight only on controllers. (default: true)
  32518. */
  32519. defaultLightingOnControllers?: boolean;
  32520. /**
  32521. * If you don't want to use the default VR button of the helper. (default: false)
  32522. */
  32523. useCustomVRButton?: boolean;
  32524. /**
  32525. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  32526. */
  32527. customVRButton?: HTMLButtonElement;
  32528. /**
  32529. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  32530. */
  32531. rayLength?: number;
  32532. /**
  32533. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  32534. */
  32535. defaultHeight?: number;
  32536. }
  32537. /**
  32538. * This represents a WebVR camera.
  32539. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  32540. * @example http://doc.babylonjs.com/how_to/webvr_camera
  32541. */
  32542. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  32543. private webVROptions;
  32544. /**
  32545. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  32546. */
  32547. _vrDevice: any;
  32548. /**
  32549. * The rawPose of the vrDevice.
  32550. */
  32551. rawPose: Nullable<DevicePose>;
  32552. private _onVREnabled;
  32553. private _specsVersion;
  32554. private _attached;
  32555. private _frameData;
  32556. protected _descendants: Array<Node>;
  32557. private _deviceRoomPosition;
  32558. /** @hidden */
  32559. _deviceRoomRotationQuaternion: Quaternion;
  32560. private _standingMatrix;
  32561. /**
  32562. * Represents device position in babylon space.
  32563. */
  32564. devicePosition: Vector3;
  32565. /**
  32566. * Represents device rotation in babylon space.
  32567. */
  32568. deviceRotationQuaternion: Quaternion;
  32569. /**
  32570. * The scale of the device to be used when translating from device space to babylon space.
  32571. */
  32572. deviceScaleFactor: number;
  32573. private _deviceToWorld;
  32574. private _worldToDevice;
  32575. /**
  32576. * References to the webVR controllers for the vrDevice.
  32577. */
  32578. controllers: Array<WebVRController>;
  32579. /**
  32580. * Emits an event when a controller is attached.
  32581. */
  32582. onControllersAttachedObservable: Observable<WebVRController[]>;
  32583. /**
  32584. * Emits an event when a controller's mesh has been loaded;
  32585. */
  32586. onControllerMeshLoadedObservable: Observable<WebVRController>;
  32587. /**
  32588. * Emits an event when the HMD's pose has been updated.
  32589. */
  32590. onPoseUpdatedFromDeviceObservable: Observable<any>;
  32591. private _poseSet;
  32592. /**
  32593. * If the rig cameras be used as parent instead of this camera.
  32594. */
  32595. rigParenting: boolean;
  32596. private _lightOnControllers;
  32597. private _defaultHeight?;
  32598. /**
  32599. * Instantiates a WebVRFreeCamera.
  32600. * @param name The name of the WebVRFreeCamera
  32601. * @param position The starting anchor position for the camera
  32602. * @param scene The scene the camera belongs to
  32603. * @param webVROptions a set of customizable options for the webVRCamera
  32604. */
  32605. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  32606. /**
  32607. * Gets the device distance from the ground in meters.
  32608. * @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.
  32609. */
  32610. deviceDistanceToRoomGround(): number;
  32611. /**
  32612. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  32613. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  32614. */
  32615. useStandingMatrix(callback?: (bool: boolean) => void): void;
  32616. /**
  32617. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  32618. * @returns A promise with a boolean set to if the standing matrix is supported.
  32619. */
  32620. useStandingMatrixAsync(): Promise<boolean>;
  32621. /**
  32622. * Disposes the camera
  32623. */
  32624. dispose(): void;
  32625. /**
  32626. * Gets a vrController by name.
  32627. * @param name The name of the controller to retreive
  32628. * @returns the controller matching the name specified or null if not found
  32629. */
  32630. getControllerByName(name: string): Nullable<WebVRController>;
  32631. private _leftController;
  32632. /**
  32633. * The controller corrisponding to the users left hand.
  32634. */
  32635. readonly leftController: Nullable<WebVRController>;
  32636. private _rightController;
  32637. /**
  32638. * The controller corrisponding to the users right hand.
  32639. */
  32640. readonly rightController: Nullable<WebVRController>;
  32641. /**
  32642. * Casts a ray forward from the vrCamera's gaze.
  32643. * @param length Length of the ray (default: 100)
  32644. * @returns the ray corrisponding to the gaze
  32645. */
  32646. getForwardRay(length?: number): Ray;
  32647. /**
  32648. * Updates the camera based on device's frame data
  32649. */
  32650. _checkInputs(): void;
  32651. /**
  32652. * Updates the poseControlled values based on the input device pose.
  32653. * @param poseData Pose coming from the device
  32654. */
  32655. updateFromDevice(poseData: DevicePose): void;
  32656. /**
  32657. * WebVR's attach control will start broadcasting frames to the device.
  32658. * Note that in certain browsers (chrome for example) this function must be called
  32659. * within a user-interaction callback. Example:
  32660. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  32661. *
  32662. * @param element html element to attach the vrDevice to
  32663. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  32664. */
  32665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  32666. /**
  32667. * Detaches the camera from the html element and disables VR
  32668. *
  32669. * @param element html element to detach from
  32670. */
  32671. detachControl(element: HTMLElement): void;
  32672. /**
  32673. * @returns the name of this class
  32674. */
  32675. getClassName(): string;
  32676. /**
  32677. * Calls resetPose on the vrDisplay
  32678. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  32679. */
  32680. resetToCurrentRotation(): void;
  32681. /**
  32682. * Updates the rig cameras (left and right eye)
  32683. */
  32684. _updateRigCameras(): void;
  32685. private _workingVector;
  32686. private _oneVector;
  32687. private _workingMatrix;
  32688. private updateCacheCalled;
  32689. /**
  32690. * Updates the cached values of the camera
  32691. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  32692. */
  32693. _updateCache(ignoreParentClass?: boolean): void;
  32694. /**
  32695. * Updates the current device position and rotation in the babylon world
  32696. */
  32697. update(): void;
  32698. /**
  32699. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  32700. * @returns an identity matrix
  32701. */
  32702. _getViewMatrix(): Matrix;
  32703. /**
  32704. * This function is called by the two RIG cameras.
  32705. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  32706. */
  32707. protected _getWebVRViewMatrix(): Matrix;
  32708. protected _getWebVRProjectionMatrix(): Matrix;
  32709. private _onGamepadConnectedObserver;
  32710. private _onGamepadDisconnectedObserver;
  32711. /**
  32712. * Initializes the controllers and their meshes
  32713. */
  32714. initControllers(): void;
  32715. }
  32716. }
  32717. declare module BABYLON {
  32718. interface Engine {
  32719. /**
  32720. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  32721. * @return the new query
  32722. */
  32723. createQuery(): WebGLQuery;
  32724. /**
  32725. * Delete and release a webGL query
  32726. * @param query defines the query to delete
  32727. * @return the current engine
  32728. */
  32729. deleteQuery(query: WebGLQuery): Engine;
  32730. /**
  32731. * Check if a given query has resolved and got its value
  32732. * @param query defines the query to check
  32733. * @returns true if the query got its value
  32734. */
  32735. isQueryResultAvailable(query: WebGLQuery): boolean;
  32736. /**
  32737. * Gets the value of a given query
  32738. * @param query defines the query to check
  32739. * @returns the value of the query
  32740. */
  32741. getQueryResult(query: WebGLQuery): number;
  32742. /**
  32743. * Initiates an occlusion query
  32744. * @param algorithmType defines the algorithm to use
  32745. * @param query defines the query to use
  32746. * @returns the current engine
  32747. * @see http://doc.babylonjs.com/features/occlusionquery
  32748. */
  32749. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  32750. /**
  32751. * Ends an occlusion query
  32752. * @see http://doc.babylonjs.com/features/occlusionquery
  32753. * @param algorithmType defines the algorithm to use
  32754. * @returns the current engine
  32755. */
  32756. endOcclusionQuery(algorithmType: number): Engine;
  32757. /**
  32758. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  32759. * Please note that only one query can be issued at a time
  32760. * @returns a time token used to track the time span
  32761. */
  32762. startTimeQuery(): Nullable<_TimeToken>;
  32763. /**
  32764. * Ends a time query
  32765. * @param token defines the token used to measure the time span
  32766. * @returns the time spent (in ns)
  32767. */
  32768. endTimeQuery(token: _TimeToken): int;
  32769. /** @hidden */
  32770. _currentNonTimestampToken: Nullable<_TimeToken>;
  32771. /** @hidden */
  32772. _createTimeQuery(): WebGLQuery;
  32773. /** @hidden */
  32774. _deleteTimeQuery(query: WebGLQuery): void;
  32775. /** @hidden */
  32776. _getGlAlgorithmType(algorithmType: number): number;
  32777. /** @hidden */
  32778. _getTimeQueryResult(query: WebGLQuery): any;
  32779. /** @hidden */
  32780. _getTimeQueryAvailability(query: WebGLQuery): any;
  32781. }
  32782. }
  32783. declare module BABYLON {
  32784. interface Engine {
  32785. /**
  32786. * Creates a webGL transform feedback object
  32787. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  32788. * @returns the webGL transform feedback object
  32789. */
  32790. createTransformFeedback(): WebGLTransformFeedback;
  32791. /**
  32792. * Delete a webGL transform feedback object
  32793. * @param value defines the webGL transform feedback object to delete
  32794. */
  32795. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  32796. /**
  32797. * Bind a webGL transform feedback object to the webgl context
  32798. * @param value defines the webGL transform feedback object to bind
  32799. */
  32800. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  32801. /**
  32802. * Begins a transform feedback operation
  32803. * @param usePoints defines if points or triangles must be used
  32804. */
  32805. beginTransformFeedback(usePoints: boolean): void;
  32806. /**
  32807. * Ends a transform feedback operation
  32808. */
  32809. endTransformFeedback(): void;
  32810. /**
  32811. * Specify the varyings to use with transform feedback
  32812. * @param program defines the associated webGL program
  32813. * @param value defines the list of strings representing the varying names
  32814. */
  32815. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  32816. /**
  32817. * Bind a webGL buffer for a transform feedback operation
  32818. * @param value defines the webGL buffer to bind
  32819. */
  32820. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  32821. }
  32822. }
  32823. declare module BABYLON {
  32824. /**
  32825. * Google Daydream controller
  32826. */
  32827. class DaydreamController extends WebVRController {
  32828. /**
  32829. * Base Url for the controller model.
  32830. */
  32831. static MODEL_BASE_URL: string;
  32832. /**
  32833. * File name for the controller model.
  32834. */
  32835. static MODEL_FILENAME: string;
  32836. /**
  32837. * Gamepad Id prefix used to identify Daydream Controller.
  32838. */
  32839. static readonly GAMEPAD_ID_PREFIX: string;
  32840. /**
  32841. * Creates a new DaydreamController from a gamepad
  32842. * @param vrGamepad the gamepad that the controller should be created from
  32843. */
  32844. constructor(vrGamepad: any);
  32845. /**
  32846. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32847. * @param scene scene in which to add meshes
  32848. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32849. */
  32850. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32851. /**
  32852. * Called once for each button that changed state since the last frame
  32853. * @param buttonIdx Which button index changed
  32854. * @param state New state of the button
  32855. * @param changes Which properties on the state changed since last frame
  32856. */
  32857. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32858. }
  32859. }
  32860. declare module BABYLON {
  32861. /**
  32862. * Gear VR Controller
  32863. */
  32864. class GearVRController extends WebVRController {
  32865. /**
  32866. * Base Url for the controller model.
  32867. */
  32868. static MODEL_BASE_URL: string;
  32869. /**
  32870. * File name for the controller model.
  32871. */
  32872. static MODEL_FILENAME: string;
  32873. private _maxRotationDistFromHeadset;
  32874. private _draggedRoomRotation;
  32875. private _tmpVector;
  32876. /**
  32877. * Gamepad Id prefix used to identify this controller.
  32878. */
  32879. static readonly GAMEPAD_ID_PREFIX: string;
  32880. private readonly _buttonIndexToObservableNameMap;
  32881. /**
  32882. * Creates a new GearVRController from a gamepad
  32883. * @param vrGamepad the gamepad that the controller should be created from
  32884. */
  32885. constructor(vrGamepad: any);
  32886. /**
  32887. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  32888. * @param poseData raw pose fromthe device
  32889. */
  32890. updateFromDevice(poseData: DevicePose): void;
  32891. /**
  32892. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32893. * @param scene scene in which to add meshes
  32894. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32895. */
  32896. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32897. /**
  32898. * Called once for each button that changed state since the last frame
  32899. * @param buttonIdx Which button index changed
  32900. * @param state New state of the button
  32901. * @param changes Which properties on the state changed since last frame
  32902. */
  32903. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32904. }
  32905. }
  32906. declare module BABYLON {
  32907. /**
  32908. * Generic Controller
  32909. */
  32910. class GenericController extends WebVRController {
  32911. /**
  32912. * Base Url for the controller model.
  32913. */
  32914. static readonly MODEL_BASE_URL: string;
  32915. /**
  32916. * File name for the controller model.
  32917. */
  32918. static readonly MODEL_FILENAME: string;
  32919. /**
  32920. * Creates a new GenericController from a gamepad
  32921. * @param vrGamepad the gamepad that the controller should be created from
  32922. */
  32923. constructor(vrGamepad: any);
  32924. /**
  32925. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32926. * @param scene scene in which to add meshes
  32927. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32928. */
  32929. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32930. /**
  32931. * Called once for each button that changed state since the last frame
  32932. * @param buttonIdx Which button index changed
  32933. * @param state New state of the button
  32934. * @param changes Which properties on the state changed since last frame
  32935. */
  32936. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  32937. }
  32938. }
  32939. declare module BABYLON {
  32940. /**
  32941. * Oculus Touch Controller
  32942. */
  32943. class OculusTouchController extends WebVRController {
  32944. /**
  32945. * Base Url for the controller model.
  32946. */
  32947. static MODEL_BASE_URL: string;
  32948. /**
  32949. * File name for the left controller model.
  32950. */
  32951. static MODEL_LEFT_FILENAME: string;
  32952. /**
  32953. * File name for the right controller model.
  32954. */
  32955. static MODEL_RIGHT_FILENAME: string;
  32956. /**
  32957. * Fired when the secondary trigger on this controller is modified
  32958. */
  32959. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  32960. /**
  32961. * Fired when the thumb rest on this controller is modified
  32962. */
  32963. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  32964. /**
  32965. * Creates a new OculusTouchController from a gamepad
  32966. * @param vrGamepad the gamepad that the controller should be created from
  32967. */
  32968. constructor(vrGamepad: any);
  32969. /**
  32970. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  32971. * @param scene scene in which to add meshes
  32972. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  32973. */
  32974. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  32975. /**
  32976. * Fired when the A button on this controller is modified
  32977. */
  32978. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32979. /**
  32980. * Fired when the B button on this controller is modified
  32981. */
  32982. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32983. /**
  32984. * Fired when the X button on this controller is modified
  32985. */
  32986. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32987. /**
  32988. * Fired when the Y button on this controller is modified
  32989. */
  32990. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  32991. /**
  32992. * Called once for each button that changed state since the last frame
  32993. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  32994. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  32995. * 2) secondary trigger (same)
  32996. * 3) A (right) X (left), touch, pressed = value
  32997. * 4) B / Y
  32998. * 5) thumb rest
  32999. * @param buttonIdx Which button index changed
  33000. * @param state New state of the button
  33001. * @param changes Which properties on the state changed since last frame
  33002. */
  33003. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33004. }
  33005. }
  33006. declare module BABYLON {
  33007. /**
  33008. * Defines the types of pose enabled controllers that are supported
  33009. */
  33010. enum PoseEnabledControllerType {
  33011. /**
  33012. * HTC Vive
  33013. */
  33014. VIVE = 0,
  33015. /**
  33016. * Oculus Rift
  33017. */
  33018. OCULUS = 1,
  33019. /**
  33020. * Windows mixed reality
  33021. */
  33022. WINDOWS = 2,
  33023. /**
  33024. * Samsung gear VR
  33025. */
  33026. GEAR_VR = 3,
  33027. /**
  33028. * Google Daydream
  33029. */
  33030. DAYDREAM = 4,
  33031. /**
  33032. * Generic
  33033. */
  33034. GENERIC = 5,
  33035. }
  33036. /**
  33037. * Defines the MutableGamepadButton interface for the state of a gamepad button
  33038. */
  33039. interface MutableGamepadButton {
  33040. /**
  33041. * Value of the button/trigger
  33042. */
  33043. value: number;
  33044. /**
  33045. * If the button/trigger is currently touched
  33046. */
  33047. touched: boolean;
  33048. /**
  33049. * If the button/trigger is currently pressed
  33050. */
  33051. pressed: boolean;
  33052. }
  33053. /**
  33054. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  33055. * @hidden
  33056. */
  33057. interface ExtendedGamepadButton extends GamepadButton {
  33058. /**
  33059. * If the button/trigger is currently pressed
  33060. */
  33061. readonly pressed: boolean;
  33062. /**
  33063. * If the button/trigger is currently touched
  33064. */
  33065. readonly touched: boolean;
  33066. /**
  33067. * Value of the button/trigger
  33068. */
  33069. readonly value: number;
  33070. }
  33071. /**
  33072. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  33073. */
  33074. class PoseEnabledControllerHelper {
  33075. /**
  33076. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  33077. * @param vrGamepad the gamepad to initialized
  33078. * @returns a vr controller of the type the gamepad identified as
  33079. */
  33080. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  33081. }
  33082. /**
  33083. * Defines the PoseEnabledController object that contains state of a vr capable controller
  33084. */
  33085. class PoseEnabledController extends Gamepad implements PoseControlled {
  33086. private _deviceRoomPosition;
  33087. private _deviceRoomRotationQuaternion;
  33088. /**
  33089. * The device position in babylon space
  33090. */
  33091. devicePosition: Vector3;
  33092. /**
  33093. * The device rotation in babylon space
  33094. */
  33095. deviceRotationQuaternion: Quaternion;
  33096. /**
  33097. * The scale factor of the device in babylon space
  33098. */
  33099. deviceScaleFactor: number;
  33100. /**
  33101. * (Likely devicePosition should be used instead) The device position in its room space
  33102. */
  33103. position: Vector3;
  33104. /**
  33105. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  33106. */
  33107. rotationQuaternion: Quaternion;
  33108. /**
  33109. * The type of controller (Eg. Windows mixed reality)
  33110. */
  33111. controllerType: PoseEnabledControllerType;
  33112. protected _calculatedPosition: Vector3;
  33113. private _calculatedRotation;
  33114. /**
  33115. * The raw pose from the device
  33116. */
  33117. rawPose: DevicePose;
  33118. /**
  33119. * Internal, the mesh attached to the controller
  33120. */
  33121. _mesh: Nullable<AbstractMesh>;
  33122. private _poseControlledCamera;
  33123. private _leftHandSystemQuaternion;
  33124. /**
  33125. * Internal, matrix used to convert room space to babylon space
  33126. */
  33127. _deviceToWorld: Matrix;
  33128. /**
  33129. * Node to be used when casting a ray from the controller
  33130. */
  33131. _pointingPoseNode: Nullable<AbstractMesh>;
  33132. /**
  33133. * Name of the child mesh that can be used to cast a ray from the controller
  33134. */
  33135. static readonly POINTING_POSE: string;
  33136. /**
  33137. * Creates a new PoseEnabledController from a gamepad
  33138. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  33139. */
  33140. constructor(browserGamepad: any);
  33141. private _workingMatrix;
  33142. /**
  33143. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  33144. */
  33145. update(): void;
  33146. /**
  33147. * Updates only the pose device and mesh without doing any button event checking
  33148. */
  33149. protected _updatePoseAndMesh(): void;
  33150. /**
  33151. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  33152. * @param poseData raw pose fromthe device
  33153. */
  33154. updateFromDevice(poseData: DevicePose): void;
  33155. /**
  33156. * @hidden
  33157. */
  33158. _meshAttachedObservable: Observable<AbstractMesh>;
  33159. /**
  33160. * Attaches a mesh to the controller
  33161. * @param mesh the mesh to be attached
  33162. */
  33163. attachToMesh(mesh: AbstractMesh): void;
  33164. /**
  33165. * Attaches the controllers mesh to a camera
  33166. * @param camera the camera the mesh should be attached to
  33167. */
  33168. attachToPoseControlledCamera(camera: TargetCamera): void;
  33169. /**
  33170. * Disposes of the controller
  33171. */
  33172. dispose(): void;
  33173. /**
  33174. * The mesh that is attached to the controller
  33175. */
  33176. readonly mesh: Nullable<AbstractMesh>;
  33177. /**
  33178. * Gets the ray of the controller in the direction the controller is pointing
  33179. * @param length the length the resulting ray should be
  33180. * @returns a ray in the direction the controller is pointing
  33181. */
  33182. getForwardRay(length?: number): Ray;
  33183. }
  33184. }
  33185. declare module BABYLON {
  33186. /**
  33187. * Vive Controller
  33188. */
  33189. class ViveController extends WebVRController {
  33190. /**
  33191. * Base Url for the controller model.
  33192. */
  33193. static MODEL_BASE_URL: string;
  33194. /**
  33195. * File name for the controller model.
  33196. */
  33197. static MODEL_FILENAME: string;
  33198. /**
  33199. * Creates a new ViveController from a gamepad
  33200. * @param vrGamepad the gamepad that the controller should be created from
  33201. */
  33202. constructor(vrGamepad: any);
  33203. /**
  33204. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33205. * @param scene scene in which to add meshes
  33206. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33207. */
  33208. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33209. /**
  33210. * Fired when the left button on this controller is modified
  33211. */
  33212. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33213. /**
  33214. * Fired when the right button on this controller is modified
  33215. */
  33216. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33217. /**
  33218. * Fired when the menu button on this controller is modified
  33219. */
  33220. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33221. /**
  33222. * Called once for each button that changed state since the last frame
  33223. * Vive mapping:
  33224. * 0: touchpad
  33225. * 1: trigger
  33226. * 2: left AND right buttons
  33227. * 3: menu button
  33228. * @param buttonIdx Which button index changed
  33229. * @param state New state of the button
  33230. * @param changes Which properties on the state changed since last frame
  33231. */
  33232. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33233. }
  33234. }
  33235. declare module BABYLON {
  33236. /**
  33237. * Defines the WebVRController object that represents controllers tracked in 3D space
  33238. */
  33239. abstract class WebVRController extends PoseEnabledController {
  33240. /**
  33241. * Internal, the default controller model for the controller
  33242. */
  33243. protected _defaultModel: AbstractMesh;
  33244. /**
  33245. * Fired when the trigger state has changed
  33246. */
  33247. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  33248. /**
  33249. * Fired when the main button state has changed
  33250. */
  33251. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33252. /**
  33253. * Fired when the secondary button state has changed
  33254. */
  33255. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33256. /**
  33257. * Fired when the pad state has changed
  33258. */
  33259. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  33260. /**
  33261. * Fired when controllers stick values have changed
  33262. */
  33263. onPadValuesChangedObservable: Observable<StickValues>;
  33264. /**
  33265. * Array of button availible on the controller
  33266. */
  33267. protected _buttons: Array<MutableGamepadButton>;
  33268. private _onButtonStateChange;
  33269. /**
  33270. * Fired when a controller button's state has changed
  33271. * @param callback the callback containing the button that was modified
  33272. */
  33273. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  33274. /**
  33275. * X and Y axis corrisponding to the controllers joystick
  33276. */
  33277. pad: StickValues;
  33278. /**
  33279. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  33280. */
  33281. hand: string;
  33282. /**
  33283. * The default controller model for the controller
  33284. */
  33285. readonly defaultModel: AbstractMesh;
  33286. /**
  33287. * Creates a new WebVRController from a gamepad
  33288. * @param vrGamepad the gamepad that the WebVRController should be created from
  33289. */
  33290. constructor(vrGamepad: any);
  33291. /**
  33292. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  33293. */
  33294. update(): void;
  33295. /**
  33296. * Function to be called when a button is modified
  33297. */
  33298. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33299. /**
  33300. * Loads a mesh and attaches it to the controller
  33301. * @param scene the scene the mesh should be added to
  33302. * @param meshLoaded callback for when the mesh has been loaded
  33303. */
  33304. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  33305. private _setButtonValue(newState, currentState, buttonIndex);
  33306. private _changes;
  33307. private _checkChanges(newState, currentState);
  33308. /**
  33309. * Disposes of th webVRCOntroller
  33310. */
  33311. dispose(): void;
  33312. }
  33313. }
  33314. declare module BABYLON {
  33315. /**
  33316. * Defines the WindowsMotionController object that the state of the windows motion controller
  33317. */
  33318. class WindowsMotionController extends WebVRController {
  33319. /**
  33320. * The base url used to load the left and right controller models
  33321. */
  33322. static MODEL_BASE_URL: string;
  33323. /**
  33324. * The name of the left controller model file
  33325. */
  33326. static MODEL_LEFT_FILENAME: string;
  33327. /**
  33328. * The name of the right controller model file
  33329. */
  33330. static MODEL_RIGHT_FILENAME: string;
  33331. /**
  33332. * The controller name prefix for this controller type
  33333. */
  33334. static readonly GAMEPAD_ID_PREFIX: string;
  33335. /**
  33336. * The controller id pattern for this controller type
  33337. */
  33338. private static readonly GAMEPAD_ID_PATTERN;
  33339. private _loadedMeshInfo;
  33340. private readonly _mapping;
  33341. /**
  33342. * Fired when the trackpad on this controller is clicked
  33343. */
  33344. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  33345. /**
  33346. * Fired when the trackpad on this controller is modified
  33347. */
  33348. onTrackpadValuesChangedObservable: Observable<StickValues>;
  33349. /**
  33350. * The current x and y values of this controller's trackpad
  33351. */
  33352. trackpad: StickValues;
  33353. /**
  33354. * Creates a new WindowsMotionController from a gamepad
  33355. * @param vrGamepad the gamepad that the controller should be created from
  33356. */
  33357. constructor(vrGamepad: any);
  33358. /**
  33359. * Fired when the trigger on this controller is modified
  33360. */
  33361. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33362. /**
  33363. * Fired when the menu button on this controller is modified
  33364. */
  33365. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33366. /**
  33367. * Fired when the grip button on this controller is modified
  33368. */
  33369. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33370. /**
  33371. * Fired when the thumbstick button on this controller is modified
  33372. */
  33373. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33374. /**
  33375. * Fired when the touchpad button on this controller is modified
  33376. */
  33377. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  33378. /**
  33379. * Fired when the touchpad values on this controller are modified
  33380. */
  33381. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  33382. private _updateTrackpad();
  33383. /**
  33384. * Called once per frame by the engine.
  33385. */
  33386. update(): void;
  33387. /**
  33388. * Called once for each button that changed state since the last frame
  33389. * @param buttonIdx Which button index changed
  33390. * @param state New state of the button
  33391. * @param changes Which properties on the state changed since last frame
  33392. */
  33393. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  33394. /**
  33395. * Moves the buttons on the controller mesh based on their current state
  33396. * @param buttonName the name of the button to move
  33397. * @param buttonValue the value of the button which determines the buttons new position
  33398. */
  33399. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  33400. /**
  33401. * Moves the axis on the controller mesh based on its current state
  33402. * @param axis the index of the axis
  33403. * @param axisValue the value of the axis which determines the meshes new position
  33404. * @hidden
  33405. */
  33406. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  33407. /**
  33408. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  33409. * @param scene scene in which to add meshes
  33410. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  33411. */
  33412. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  33413. /**
  33414. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  33415. * can be transformed by button presses and axes values, based on this._mapping.
  33416. *
  33417. * @param scene scene in which the meshes exist
  33418. * @param meshes list of meshes that make up the controller model to process
  33419. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  33420. */
  33421. private processModel(scene, meshes);
  33422. private createMeshInfo(rootNode);
  33423. /**
  33424. * Gets the ray of the controller in the direction the controller is pointing
  33425. * @param length the length the resulting ray should be
  33426. * @returns a ray in the direction the controller is pointing
  33427. */
  33428. getForwardRay(length?: number): Ray;
  33429. /**
  33430. * Disposes of the controller
  33431. */
  33432. dispose(): void;
  33433. }
  33434. }
  33435. declare module BABYLON {
  33436. /**
  33437. * Interface to implement to create a shadow generator compatible with BJS.
  33438. */
  33439. interface IShadowGenerator {
  33440. /**
  33441. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  33442. * @returns The render target texture if present otherwise, null
  33443. */
  33444. getShadowMap(): Nullable<RenderTargetTexture>;
  33445. /**
  33446. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  33447. * @returns The render target texture if the shadow map is present otherwise, null
  33448. */
  33449. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  33450. /**
  33451. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  33452. * @param subMesh The submesh we want to render in the shadow map
  33453. * @param useInstances Defines wether will draw in the map using instances
  33454. * @returns true if ready otherwise, false
  33455. */
  33456. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  33457. /**
  33458. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  33459. * @param defines Defines of the material we want to update
  33460. * @param lightIndex Index of the light in the enabled light list of the material
  33461. */
  33462. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  33463. /**
  33464. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  33465. * defined in the generator but impacting the effect).
  33466. * It implies the unifroms available on the materials are the standard BJS ones.
  33467. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  33468. * @param effect The effect we are binfing the information for
  33469. */
  33470. bindShadowLight(lightIndex: string, effect: Effect): void;
  33471. /**
  33472. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  33473. * (eq to shadow prjection matrix * light transform matrix)
  33474. * @returns The transform matrix used to create the shadow map
  33475. */
  33476. getTransformMatrix(): Matrix;
  33477. /**
  33478. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  33479. * Cube and 2D textures for instance.
  33480. */
  33481. recreateShadowMap(): void;
  33482. /**
  33483. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33484. * @param onCompiled Callback triggered at the and of the effects compilation
  33485. * @param options Sets of optional options forcing the compilation with different modes
  33486. */
  33487. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  33488. useInstances: boolean;
  33489. }>): void;
  33490. /**
  33491. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33492. * @param options Sets of optional options forcing the compilation with different modes
  33493. * @returns A promise that resolves when the compilation completes
  33494. */
  33495. forceCompilationAsync(options?: Partial<{
  33496. useInstances: boolean;
  33497. }>): Promise<void>;
  33498. /**
  33499. * Serializes the shadow generator setup to a json object.
  33500. * @returns The serialized JSON object
  33501. */
  33502. serialize(): any;
  33503. /**
  33504. * Disposes the Shadow map and related Textures and effects.
  33505. */
  33506. dispose(): void;
  33507. }
  33508. /**
  33509. * Default implementation IShadowGenerator.
  33510. * This is the main object responsible of generating shadows in the framework.
  33511. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  33512. */
  33513. class ShadowGenerator implements IShadowGenerator {
  33514. /**
  33515. * Shadow generator mode None: no filtering applied.
  33516. */
  33517. static readonly FILTER_NONE: number;
  33518. /**
  33519. * Shadow generator mode ESM: Exponential Shadow Mapping.
  33520. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33521. */
  33522. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  33523. /**
  33524. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  33525. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  33526. */
  33527. static readonly FILTER_POISSONSAMPLING: number;
  33528. /**
  33529. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  33530. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33531. */
  33532. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  33533. /**
  33534. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  33535. * edge artifacts on steep falloff.
  33536. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33537. */
  33538. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  33539. /**
  33540. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  33541. * edge artifacts on steep falloff.
  33542. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  33543. */
  33544. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  33545. /**
  33546. * Shadow generator mode PCF: Percentage Closer Filtering
  33547. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  33548. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  33549. */
  33550. static readonly FILTER_PCF: number;
  33551. /**
  33552. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  33553. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  33554. * Contact Hardening
  33555. */
  33556. static readonly FILTER_PCSS: number;
  33557. /**
  33558. * Reserved for PCF and PCSS
  33559. * Highest Quality.
  33560. *
  33561. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  33562. *
  33563. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  33564. */
  33565. static readonly QUALITY_HIGH: number;
  33566. /**
  33567. * Reserved for PCF and PCSS
  33568. * Good tradeoff for quality/perf cross devices
  33569. *
  33570. * Execute PCF on a 3*3 kernel.
  33571. *
  33572. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  33573. */
  33574. static readonly QUALITY_MEDIUM: number;
  33575. /**
  33576. * Reserved for PCF and PCSS
  33577. * The lowest quality but the fastest.
  33578. *
  33579. * Execute PCF on a 1*1 kernel.
  33580. *
  33581. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  33582. */
  33583. static readonly QUALITY_LOW: number;
  33584. private _bias;
  33585. /**
  33586. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  33587. */
  33588. /**
  33589. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  33590. */
  33591. bias: number;
  33592. private _normalBias;
  33593. /**
  33594. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  33595. */
  33596. /**
  33597. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  33598. */
  33599. normalBias: number;
  33600. private _blurBoxOffset;
  33601. /**
  33602. * Gets the blur box offset: offset applied during the blur pass.
  33603. * Only usefull if useKernelBlur = false
  33604. */
  33605. /**
  33606. * Sets the blur box offset: offset applied during the blur pass.
  33607. * Only usefull if useKernelBlur = false
  33608. */
  33609. blurBoxOffset: number;
  33610. private _blurScale;
  33611. /**
  33612. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  33613. * 2 means half of the size.
  33614. */
  33615. /**
  33616. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  33617. * 2 means half of the size.
  33618. */
  33619. blurScale: number;
  33620. private _blurKernel;
  33621. /**
  33622. * Gets the blur kernel: kernel size of the blur pass.
  33623. * Only usefull if useKernelBlur = true
  33624. */
  33625. /**
  33626. * Sets the blur kernel: kernel size of the blur pass.
  33627. * Only usefull if useKernelBlur = true
  33628. */
  33629. blurKernel: number;
  33630. private _useKernelBlur;
  33631. /**
  33632. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  33633. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  33634. */
  33635. /**
  33636. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  33637. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  33638. */
  33639. useKernelBlur: boolean;
  33640. private _depthScale;
  33641. /**
  33642. * Gets the depth scale used in ESM mode.
  33643. */
  33644. /**
  33645. * Sets the depth scale used in ESM mode.
  33646. * This can override the scale stored on the light.
  33647. */
  33648. depthScale: number;
  33649. private _filter;
  33650. /**
  33651. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  33652. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  33653. */
  33654. /**
  33655. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  33656. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  33657. */
  33658. filter: number;
  33659. /**
  33660. * Gets if the current filter is set to Poisson Sampling.
  33661. */
  33662. /**
  33663. * Sets the current filter to Poisson Sampling.
  33664. */
  33665. usePoissonSampling: boolean;
  33666. /**
  33667. * Gets if the current filter is set to VSM.
  33668. * DEPRECATED. Should use useExponentialShadowMap instead.
  33669. */
  33670. /**
  33671. * Sets the current filter is to VSM.
  33672. * DEPRECATED. Should use useExponentialShadowMap instead.
  33673. */
  33674. useVarianceShadowMap: boolean;
  33675. /**
  33676. * Gets if the current filter is set to blurred VSM.
  33677. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  33678. */
  33679. /**
  33680. * Sets the current filter is to blurred VSM.
  33681. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  33682. */
  33683. useBlurVarianceShadowMap: boolean;
  33684. /**
  33685. * Gets if the current filter is set to ESM.
  33686. */
  33687. /**
  33688. * Sets the current filter is to ESM.
  33689. */
  33690. useExponentialShadowMap: boolean;
  33691. /**
  33692. * Gets if the current filter is set to filtered ESM.
  33693. */
  33694. /**
  33695. * Gets if the current filter is set to filtered ESM.
  33696. */
  33697. useBlurExponentialShadowMap: boolean;
  33698. /**
  33699. * Gets if the current filter is set to "close ESM" (using the inverse of the
  33700. * exponential to prevent steep falloff artifacts).
  33701. */
  33702. /**
  33703. * Sets the current filter to "close ESM" (using the inverse of the
  33704. * exponential to prevent steep falloff artifacts).
  33705. */
  33706. useCloseExponentialShadowMap: boolean;
  33707. /**
  33708. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  33709. * exponential to prevent steep falloff artifacts).
  33710. */
  33711. /**
  33712. * Sets the current filter to filtered "close ESM" (using the inverse of the
  33713. * exponential to prevent steep falloff artifacts).
  33714. */
  33715. useBlurCloseExponentialShadowMap: boolean;
  33716. /**
  33717. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  33718. */
  33719. /**
  33720. * Sets the current filter to "PCF" (percentage closer filtering).
  33721. */
  33722. usePercentageCloserFiltering: boolean;
  33723. private _filteringQuality;
  33724. /**
  33725. * Gets the PCF or PCSS Quality.
  33726. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  33727. */
  33728. /**
  33729. * Sets the PCF or PCSS Quality.
  33730. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  33731. */
  33732. filteringQuality: number;
  33733. /**
  33734. * Gets if the current filter is set to "PCSS" (contact hardening).
  33735. */
  33736. /**
  33737. * Sets the current filter to "PCSS" (contact hardening).
  33738. */
  33739. useContactHardeningShadow: boolean;
  33740. private _contactHardeningLightSizeUVRatio;
  33741. /**
  33742. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  33743. * Using a ratio helps keeping shape stability independently of the map size.
  33744. *
  33745. * It does not account for the light projection as it was having too much
  33746. * instability during the light setup or during light position changes.
  33747. *
  33748. * Only valid if useContactHardeningShadow is true.
  33749. */
  33750. /**
  33751. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  33752. * Using a ratio helps keeping shape stability independently of the map size.
  33753. *
  33754. * It does not account for the light projection as it was having too much
  33755. * instability during the light setup or during light position changes.
  33756. *
  33757. * Only valid if useContactHardeningShadow is true.
  33758. */
  33759. contactHardeningLightSizeUVRatio: number;
  33760. private _darkness;
  33761. /**
  33762. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  33763. * 0 means strongest and 1 would means no shadow.
  33764. * @returns the darkness.
  33765. */
  33766. getDarkness(): number;
  33767. /**
  33768. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  33769. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  33770. * @returns the shadow generator allowing fluent coding.
  33771. */
  33772. setDarkness(darkness: number): ShadowGenerator;
  33773. private _transparencyShadow;
  33774. /**
  33775. * Sets the ability to have transparent shadow (boolean).
  33776. * @param transparent True if transparent else False
  33777. * @returns the shadow generator allowing fluent coding
  33778. */
  33779. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  33780. private _shadowMap;
  33781. private _shadowMap2;
  33782. /**
  33783. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  33784. * @returns The render target texture if present otherwise, null
  33785. */
  33786. getShadowMap(): Nullable<RenderTargetTexture>;
  33787. /**
  33788. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  33789. * @returns The render target texture if the shadow map is present otherwise, null
  33790. */
  33791. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  33792. /**
  33793. * Helper function to add a mesh and its descendants to the list of shadow casters.
  33794. * @param mesh Mesh to add
  33795. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  33796. * @returns the Shadow Generator itself
  33797. */
  33798. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  33799. /**
  33800. * Helper function to remove a mesh and its descendants from the list of shadow casters
  33801. * @param mesh Mesh to remove
  33802. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  33803. * @returns the Shadow Generator itself
  33804. */
  33805. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  33806. /**
  33807. * Controls the extent to which the shadows fade out at the edge of the frustum
  33808. * Used only by directionals and spots
  33809. */
  33810. frustumEdgeFalloff: number;
  33811. private _light;
  33812. /**
  33813. * Returns the associated light object.
  33814. * @returns the light generating the shadow
  33815. */
  33816. getLight(): IShadowLight;
  33817. /**
  33818. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  33819. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  33820. * It might on the other hand introduce peter panning.
  33821. */
  33822. forceBackFacesOnly: boolean;
  33823. private _scene;
  33824. private _lightDirection;
  33825. private _effect;
  33826. private _viewMatrix;
  33827. private _projectionMatrix;
  33828. private _transformMatrix;
  33829. private _cachedPosition;
  33830. private _cachedDirection;
  33831. private _cachedDefines;
  33832. private _currentRenderID;
  33833. private _boxBlurPostprocess;
  33834. private _kernelBlurXPostprocess;
  33835. private _kernelBlurYPostprocess;
  33836. private _blurPostProcesses;
  33837. private _mapSize;
  33838. private _currentFaceIndex;
  33839. private _currentFaceIndexCache;
  33840. private _textureType;
  33841. private _defaultTextureMatrix;
  33842. /**
  33843. * Creates a ShadowGenerator object.
  33844. * A ShadowGenerator is the required tool to use the shadows.
  33845. * Each light casting shadows needs to use its own ShadowGenerator.
  33846. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  33847. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  33848. * @param light The light object generating the shadows.
  33849. * @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.
  33850. */
  33851. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  33852. private _initializeGenerator();
  33853. private _initializeShadowMap();
  33854. private _initializeBlurRTTAndPostProcesses();
  33855. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  33856. private _renderSubMeshForShadowMap(subMesh);
  33857. private _applyFilterValues();
  33858. /**
  33859. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33860. * @param onCompiled Callback triggered at the and of the effects compilation
  33861. * @param options Sets of optional options forcing the compilation with different modes
  33862. */
  33863. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  33864. useInstances: boolean;
  33865. }>): void;
  33866. /**
  33867. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  33868. * @param options Sets of optional options forcing the compilation with different modes
  33869. * @returns A promise that resolves when the compilation completes
  33870. */
  33871. forceCompilationAsync(options?: Partial<{
  33872. useInstances: boolean;
  33873. }>): Promise<void>;
  33874. /**
  33875. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  33876. * @param subMesh The submesh we want to render in the shadow map
  33877. * @param useInstances Defines wether will draw in the map using instances
  33878. * @returns true if ready otherwise, false
  33879. */
  33880. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  33881. /**
  33882. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  33883. * @param defines Defines of the material we want to update
  33884. * @param lightIndex Index of the light in the enabled light list of the material
  33885. */
  33886. prepareDefines(defines: any, lightIndex: number): void;
  33887. /**
  33888. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  33889. * defined in the generator but impacting the effect).
  33890. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  33891. * @param effect The effect we are binfing the information for
  33892. */
  33893. bindShadowLight(lightIndex: string, effect: Effect): void;
  33894. /**
  33895. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  33896. * (eq to shadow prjection matrix * light transform matrix)
  33897. * @returns The transform matrix used to create the shadow map
  33898. */
  33899. getTransformMatrix(): Matrix;
  33900. /**
  33901. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  33902. * Cube and 2D textures for instance.
  33903. */
  33904. recreateShadowMap(): void;
  33905. private _disposeBlurPostProcesses();
  33906. private _disposeRTTandPostProcesses();
  33907. /**
  33908. * Disposes the ShadowGenerator.
  33909. * Returns nothing.
  33910. */
  33911. dispose(): void;
  33912. /**
  33913. * Serializes the shadow generator setup to a json object.
  33914. * @returns The serialized JSON object
  33915. */
  33916. serialize(): any;
  33917. /**
  33918. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  33919. * @param parsedShadowGenerator The JSON object to parse
  33920. * @param scene The scene to create the shadow map for
  33921. * @returns The parsed shadow generator
  33922. */
  33923. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  33924. }
  33925. }
  33926. declare module BABYLON {
  33927. }
  33928. declare module BABYLON {
  33929. /**
  33930. * Background material used to create an efficient environement around your scene.
  33931. */
  33932. class BackgroundMaterial extends PushMaterial {
  33933. /**
  33934. * Standard reflectance value at parallel view angle.
  33935. */
  33936. static StandardReflectance0: number;
  33937. /**
  33938. * Standard reflectance value at grazing angle.
  33939. */
  33940. static StandardReflectance90: number;
  33941. protected _primaryColor: Color3;
  33942. /**
  33943. * Key light Color (multiply against the environement texture)
  33944. */
  33945. primaryColor: Color3;
  33946. protected __perceptualColor: Nullable<Color3>;
  33947. /**
  33948. * Experimental Internal Use Only.
  33949. *
  33950. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  33951. * This acts as a helper to set the primary color to a more "human friendly" value.
  33952. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  33953. * output color as close as possible from the chosen value.
  33954. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  33955. * part of lighting setup.)
  33956. */
  33957. _perceptualColor: Nullable<Color3>;
  33958. protected _primaryColorShadowLevel: float;
  33959. /**
  33960. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  33961. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  33962. */
  33963. primaryColorShadowLevel: float;
  33964. protected _primaryColorHighlightLevel: float;
  33965. /**
  33966. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  33967. * The primary color is used at the level chosen to define what the white area would look.
  33968. */
  33969. primaryColorHighlightLevel: float;
  33970. protected _reflectionTexture: Nullable<BaseTexture>;
  33971. /**
  33972. * Reflection Texture used in the material.
  33973. * Should be author in a specific way for the best result (refer to the documentation).
  33974. */
  33975. reflectionTexture: Nullable<BaseTexture>;
  33976. protected _reflectionBlur: float;
  33977. /**
  33978. * Reflection Texture level of blur.
  33979. *
  33980. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  33981. * texture twice.
  33982. */
  33983. reflectionBlur: float;
  33984. protected _diffuseTexture: Nullable<BaseTexture>;
  33985. /**
  33986. * Diffuse Texture used in the material.
  33987. * Should be author in a specific way for the best result (refer to the documentation).
  33988. */
  33989. diffuseTexture: Nullable<BaseTexture>;
  33990. protected _shadowLights: Nullable<IShadowLight[]>;
  33991. /**
  33992. * Specify the list of lights casting shadow on the material.
  33993. * All scene shadow lights will be included if null.
  33994. */
  33995. shadowLights: Nullable<IShadowLight[]>;
  33996. protected _shadowLevel: float;
  33997. /**
  33998. * Helps adjusting the shadow to a softer level if required.
  33999. * 0 means black shadows and 1 means no shadows.
  34000. */
  34001. shadowLevel: float;
  34002. protected _sceneCenter: Vector3;
  34003. /**
  34004. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  34005. * It is usually zero but might be interesting to modify according to your setup.
  34006. */
  34007. sceneCenter: Vector3;
  34008. protected _opacityFresnel: boolean;
  34009. /**
  34010. * This helps specifying that the material is falling off to the sky box at grazing angle.
  34011. * This helps ensuring a nice transition when the camera goes under the ground.
  34012. */
  34013. opacityFresnel: boolean;
  34014. protected _reflectionFresnel: boolean;
  34015. /**
  34016. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  34017. * This helps adding a mirror texture on the ground.
  34018. */
  34019. reflectionFresnel: boolean;
  34020. protected _reflectionFalloffDistance: number;
  34021. /**
  34022. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  34023. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  34024. */
  34025. reflectionFalloffDistance: number;
  34026. protected _reflectionAmount: number;
  34027. /**
  34028. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  34029. */
  34030. reflectionAmount: number;
  34031. protected _reflectionReflectance0: number;
  34032. /**
  34033. * This specifies the weight of the reflection at grazing angle.
  34034. */
  34035. reflectionReflectance0: number;
  34036. protected _reflectionReflectance90: number;
  34037. /**
  34038. * This specifies the weight of the reflection at a perpendicular point of view.
  34039. */
  34040. reflectionReflectance90: number;
  34041. /**
  34042. * Sets the reflection reflectance fresnel values according to the default standard
  34043. * empirically know to work well :-)
  34044. */
  34045. reflectionStandardFresnelWeight: number;
  34046. protected _useRGBColor: boolean;
  34047. /**
  34048. * Helps to directly use the maps channels instead of their level.
  34049. */
  34050. useRGBColor: boolean;
  34051. protected _enableNoise: boolean;
  34052. /**
  34053. * This helps reducing the banding effect that could occur on the background.
  34054. */
  34055. enableNoise: boolean;
  34056. /**
  34057. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  34058. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  34059. * Recommended to be keep at 1.0 except for special cases.
  34060. */
  34061. fovMultiplier: number;
  34062. private _fovMultiplier;
  34063. /**
  34064. * Enable the FOV adjustment feature controlled by fovMultiplier.
  34065. */
  34066. useEquirectangularFOV: boolean;
  34067. private _maxSimultaneousLights;
  34068. /**
  34069. * Number of Simultaneous lights allowed on the material.
  34070. */
  34071. maxSimultaneousLights: int;
  34072. /**
  34073. * Default configuration related to image processing available in the Background Material.
  34074. */
  34075. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34076. /**
  34077. * Keep track of the image processing observer to allow dispose and replace.
  34078. */
  34079. private _imageProcessingObserver;
  34080. /**
  34081. * Attaches a new image processing configuration to the PBR Material.
  34082. * @param configuration (if null the scene configuration will be use)
  34083. */
  34084. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  34085. /**
  34086. * Gets the image processing configuration used either in this material.
  34087. */
  34088. /**
  34089. * Sets the Default image processing configuration used either in the this material.
  34090. *
  34091. * If sets to null, the scene one is in use.
  34092. */
  34093. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  34094. /**
  34095. * Gets wether the color curves effect is enabled.
  34096. */
  34097. /**
  34098. * Sets wether the color curves effect is enabled.
  34099. */
  34100. cameraColorCurvesEnabled: boolean;
  34101. /**
  34102. * Gets wether the color grading effect is enabled.
  34103. */
  34104. /**
  34105. * Gets wether the color grading effect is enabled.
  34106. */
  34107. cameraColorGradingEnabled: boolean;
  34108. /**
  34109. * Gets wether tonemapping is enabled or not.
  34110. */
  34111. /**
  34112. * Sets wether tonemapping is enabled or not
  34113. */
  34114. cameraToneMappingEnabled: boolean;
  34115. /**
  34116. * The camera exposure used on this material.
  34117. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  34118. * This corresponds to a photographic exposure.
  34119. */
  34120. /**
  34121. * The camera exposure used on this material.
  34122. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  34123. * This corresponds to a photographic exposure.
  34124. */
  34125. cameraExposure: float;
  34126. /**
  34127. * Gets The camera contrast used on this material.
  34128. */
  34129. /**
  34130. * Sets The camera contrast used on this material.
  34131. */
  34132. cameraContrast: float;
  34133. /**
  34134. * Gets the Color Grading 2D Lookup Texture.
  34135. */
  34136. /**
  34137. * Sets the Color Grading 2D Lookup Texture.
  34138. */
  34139. cameraColorGradingTexture: Nullable<BaseTexture>;
  34140. /**
  34141. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  34142. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  34143. * 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;
  34144. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  34145. */
  34146. /**
  34147. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  34148. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  34149. * 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;
  34150. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  34151. */
  34152. cameraColorCurves: Nullable<ColorCurves>;
  34153. /**
  34154. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  34155. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  34156. */
  34157. switchToBGR: boolean;
  34158. private _renderTargets;
  34159. private _reflectionControls;
  34160. private _white;
  34161. private _primaryShadowColor;
  34162. private _primaryHighlightColor;
  34163. /**
  34164. * Instantiates a Background Material in the given scene
  34165. * @param name The friendly name of the material
  34166. * @param scene The scene to add the material to
  34167. */
  34168. constructor(name: string, scene: Scene);
  34169. /**
  34170. * The entire material has been created in order to prevent overdraw.
  34171. * @returns false
  34172. */
  34173. needAlphaTesting(): boolean;
  34174. /**
  34175. * The entire material has been created in order to prevent overdraw.
  34176. * @returns true if blending is enable
  34177. */
  34178. needAlphaBlending(): boolean;
  34179. /**
  34180. * Checks wether the material is ready to be rendered for a given mesh.
  34181. * @param mesh The mesh to render
  34182. * @param subMesh The submesh to check against
  34183. * @param useInstances Specify wether or not the material is used with instances
  34184. * @returns true if all the dependencies are ready (Textures, Effects...)
  34185. */
  34186. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  34187. /**
  34188. * Compute the primary color according to the chosen perceptual color.
  34189. */
  34190. private _computePrimaryColorFromPerceptualColor();
  34191. /**
  34192. * Compute the highlights and shadow colors according to their chosen levels.
  34193. */
  34194. private _computePrimaryColors();
  34195. /**
  34196. * Build the uniform buffer used in the material.
  34197. */
  34198. buildUniformLayout(): void;
  34199. /**
  34200. * Unbind the material.
  34201. */
  34202. unbind(): void;
  34203. /**
  34204. * Bind only the world matrix to the material.
  34205. * @param world The world matrix to bind.
  34206. */
  34207. bindOnlyWorldMatrix(world: Matrix): void;
  34208. /**
  34209. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  34210. * @param world The world matrix to bind.
  34211. * @param subMesh The submesh to bind for.
  34212. */
  34213. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  34214. /**
  34215. * Dispose the material.
  34216. * @param forceDisposeEffect Force disposal of the associated effect.
  34217. * @param forceDisposeTextures Force disposal of the associated textures.
  34218. */
  34219. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  34220. /**
  34221. * Clones the material.
  34222. * @param name The cloned name.
  34223. * @returns The cloned material.
  34224. */
  34225. clone(name: string): BackgroundMaterial;
  34226. /**
  34227. * Serializes the current material to its JSON representation.
  34228. * @returns The JSON representation.
  34229. */
  34230. serialize(): any;
  34231. /**
  34232. * Gets the class name of the material
  34233. * @returns "BackgroundMaterial"
  34234. */
  34235. getClassName(): string;
  34236. /**
  34237. * Parse a JSON input to create back a background material.
  34238. * @param source The JSON data to parse
  34239. * @param scene The scene to create the parsed material in
  34240. * @param rootUrl The root url of the assets the material depends upon
  34241. * @returns the instantiated BackgroundMaterial.
  34242. */
  34243. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  34244. }
  34245. }
  34246. declare module BABYLON {
  34247. /**
  34248. * The Physically based material base class of BJS.
  34249. *
  34250. * This offers the main features of a standard PBR material.
  34251. * For more information, please refer to the documentation :
  34252. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  34253. */
  34254. abstract class PBRBaseMaterial extends PushMaterial {
  34255. /**
  34256. * Intensity of the direct lights e.g. the four lights available in your scene.
  34257. * This impacts both the direct diffuse and specular highlights.
  34258. */
  34259. protected _directIntensity: number;
  34260. /**
  34261. * Intensity of the emissive part of the material.
  34262. * This helps controlling the emissive effect without modifying the emissive color.
  34263. */
  34264. protected _emissiveIntensity: number;
  34265. /**
  34266. * Intensity of the environment e.g. how much the environment will light the object
  34267. * either through harmonics for rough material or through the refelction for shiny ones.
  34268. */
  34269. protected _environmentIntensity: number;
  34270. /**
  34271. * This is a special control allowing the reduction of the specular highlights coming from the
  34272. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  34273. */
  34274. protected _specularIntensity: number;
  34275. /**
  34276. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  34277. */
  34278. private _lightingInfos;
  34279. /**
  34280. * Debug Control allowing disabling the bump map on this material.
  34281. */
  34282. protected _disableBumpMap: boolean;
  34283. /**
  34284. * AKA Diffuse Texture in standard nomenclature.
  34285. */
  34286. protected _albedoTexture: BaseTexture;
  34287. /**
  34288. * AKA Occlusion Texture in other nomenclature.
  34289. */
  34290. protected _ambientTexture: BaseTexture;
  34291. /**
  34292. * AKA Occlusion Texture Intensity in other nomenclature.
  34293. */
  34294. protected _ambientTextureStrength: number;
  34295. /**
  34296. * Stores the alpha values in a texture.
  34297. */
  34298. protected _opacityTexture: BaseTexture;
  34299. /**
  34300. * Stores the reflection values in a texture.
  34301. */
  34302. protected _reflectionTexture: BaseTexture;
  34303. /**
  34304. * Stores the refraction values in a texture.
  34305. */
  34306. protected _refractionTexture: BaseTexture;
  34307. /**
  34308. * Stores the emissive values in a texture.
  34309. */
  34310. protected _emissiveTexture: BaseTexture;
  34311. /**
  34312. * AKA Specular texture in other nomenclature.
  34313. */
  34314. protected _reflectivityTexture: BaseTexture;
  34315. /**
  34316. * Used to switch from specular/glossiness to metallic/roughness workflow.
  34317. */
  34318. protected _metallicTexture: BaseTexture;
  34319. /**
  34320. * Specifies the metallic scalar of the metallic/roughness workflow.
  34321. * Can also be used to scale the metalness values of the metallic texture.
  34322. */
  34323. protected _metallic: number;
  34324. /**
  34325. * Specifies the roughness scalar of the metallic/roughness workflow.
  34326. * Can also be used to scale the roughness values of the metallic texture.
  34327. */
  34328. protected _roughness: number;
  34329. /**
  34330. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  34331. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  34332. */
  34333. protected _microSurfaceTexture: BaseTexture;
  34334. /**
  34335. * Stores surface normal data used to displace a mesh in a texture.
  34336. */
  34337. protected _bumpTexture: BaseTexture;
  34338. /**
  34339. * Stores the pre-calculated light information of a mesh in a texture.
  34340. */
  34341. protected _lightmapTexture: BaseTexture;
  34342. /**
  34343. * The color of a material in ambient lighting.
  34344. */
  34345. protected _ambientColor: Color3;
  34346. /**
  34347. * AKA Diffuse Color in other nomenclature.
  34348. */
  34349. protected _albedoColor: Color3;
  34350. /**
  34351. * AKA Specular Color in other nomenclature.
  34352. */
  34353. protected _reflectivityColor: Color3;
  34354. /**
  34355. * The color applied when light is reflected from a material.
  34356. */
  34357. protected _reflectionColor: Color3;
  34358. /**
  34359. * The color applied when light is emitted from a material.
  34360. */
  34361. protected _emissiveColor: Color3;
  34362. /**
  34363. * AKA Glossiness in other nomenclature.
  34364. */
  34365. protected _microSurface: number;
  34366. /**
  34367. * source material index of refraction (IOR)' / 'destination material IOR.
  34368. */
  34369. protected _indexOfRefraction: number;
  34370. /**
  34371. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  34372. */
  34373. protected _invertRefractionY: boolean;
  34374. /**
  34375. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  34376. * Materials half opaque for instance using refraction could benefit from this control.
  34377. */
  34378. protected _linkRefractionWithTransparency: boolean;
  34379. /**
  34380. * Specifies that the material will use the light map as a show map.
  34381. */
  34382. protected _useLightmapAsShadowmap: boolean;
  34383. /**
  34384. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  34385. * makes the reflect vector face the model (under horizon).
  34386. */
  34387. protected _useHorizonOcclusion: boolean;
  34388. /**
  34389. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  34390. * too much the area relying on ambient texture to define their ambient occlusion.
  34391. */
  34392. protected _useRadianceOcclusion: boolean;
  34393. /**
  34394. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  34395. */
  34396. protected _useAlphaFromAlbedoTexture: boolean;
  34397. /**
  34398. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  34399. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  34400. */
  34401. protected _useSpecularOverAlpha: boolean;
  34402. /**
  34403. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  34404. */
  34405. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  34406. /**
  34407. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  34408. */
  34409. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  34410. /**
  34411. * Specifies if the metallic texture contains the roughness information in its green channel.
  34412. */
  34413. protected _useRoughnessFromMetallicTextureGreen: boolean;
  34414. /**
  34415. * Specifies if the metallic texture contains the metallness information in its blue channel.
  34416. */
  34417. protected _useMetallnessFromMetallicTextureBlue: boolean;
  34418. /**
  34419. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  34420. */
  34421. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  34422. /**
  34423. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  34424. */
  34425. protected _useAmbientInGrayScale: boolean;
  34426. /**
  34427. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  34428. * The material will try to infer what glossiness each pixel should be.
  34429. */
  34430. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  34431. /**
  34432. * BJS is using an harcoded light falloff based on a manually sets up range.
  34433. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  34434. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  34435. */
  34436. protected _usePhysicalLightFalloff: boolean;
  34437. /**
  34438. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  34439. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  34440. */
  34441. protected _useRadianceOverAlpha: boolean;
  34442. /**
  34443. * Allows using an object space normal map (instead of tangent space).
  34444. */
  34445. protected _useObjectSpaceNormalMap: boolean;
  34446. /**
  34447. * Allows using the bump map in parallax mode.
  34448. */
  34449. protected _useParallax: boolean;
  34450. /**
  34451. * Allows using the bump map in parallax occlusion mode.
  34452. */
  34453. protected _useParallaxOcclusion: boolean;
  34454. /**
  34455. * Controls the scale bias of the parallax mode.
  34456. */
  34457. protected _parallaxScaleBias: number;
  34458. /**
  34459. * If sets to true, disables all the lights affecting the material.
  34460. */
  34461. protected _disableLighting: boolean;
  34462. /**
  34463. * Number of Simultaneous lights allowed on the material.
  34464. */
  34465. protected _maxSimultaneousLights: number;
  34466. /**
  34467. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  34468. */
  34469. protected _invertNormalMapX: boolean;
  34470. /**
  34471. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  34472. */
  34473. protected _invertNormalMapY: boolean;
  34474. /**
  34475. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  34476. */
  34477. protected _twoSidedLighting: boolean;
  34478. /**
  34479. * Defines the alpha limits in alpha test mode.
  34480. */
  34481. protected _alphaCutOff: number;
  34482. /**
  34483. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  34484. */
  34485. protected _forceAlphaTest: boolean;
  34486. /**
  34487. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34488. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  34489. */
  34490. protected _useAlphaFresnel: boolean;
  34491. /**
  34492. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  34493. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  34494. */
  34495. protected _useLinearAlphaFresnel: boolean;
  34496. /**
  34497. * The transparency mode of the material.
  34498. */
  34499. protected _transparencyMode: Nullable<number>;
  34500. /**
  34501. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  34502. * from cos thetav and roughness:
  34503. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  34504. */
  34505. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  34506. /**
  34507. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  34508. */
  34509. protected _forceIrradianceInFragment: boolean;
  34510. /**
  34511. * Force normal to face away from face.
  34512. */
  34513. protected _forceNormalForward: boolean;
  34514. /**
  34515. * Enables specular anti aliasing in the PBR shader.
  34516. * It will both interacts on the Geometry for analytical and IBL lighting.
  34517. * It also prefilter the roughness map based on the bump values.
  34518. */
  34519. protected _enableSpecularAntiAliasing: boolean;
  34520. /**
  34521. * Default configuration related to image processing available in the PBR Material.
  34522. */
  34523. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34524. /**
  34525. * Keep track of the image processing observer to allow dispose and replace.
  34526. */
  34527. private _imageProcessingObserver;
  34528. /**
  34529. * Attaches a new image processing configuration to the PBR Material.
  34530. * @param configuration
  34531. */
  34532. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  34533. /**
  34534. * Stores the available render targets.
  34535. */
  34536. private _renderTargets;
  34537. /**
  34538. * Sets the global ambient color for the material used in lighting calculations.
  34539. */
  34540. private _globalAmbientColor;
  34541. /**
  34542. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  34543. */
  34544. private _useLogarithmicDepth;
  34545. /**
  34546. * If set to true, no lighting calculations will be applied.
  34547. */
  34548. private _unlit;
  34549. /**
  34550. * Instantiates a new PBRMaterial instance.
  34551. *
  34552. * @param name The material name
  34553. * @param scene The scene the material will be use in.
  34554. */
  34555. constructor(name: string, scene: Scene);
  34556. /**
  34557. * Gets the name of the material class.
  34558. */
  34559. getClassName(): string;
  34560. /**
  34561. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  34562. */
  34563. /**
  34564. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  34565. */
  34566. useLogarithmicDepth: boolean;
  34567. /**
  34568. * Gets the current transparency mode.
  34569. */
  34570. /**
  34571. * Sets the transparency mode of the material.
  34572. *
  34573. * | Value | Type | Description |
  34574. * | ----- | ----------------------------------- | ----------- |
  34575. * | 0 | OPAQUE | |
  34576. * | 1 | ALPHATEST | |
  34577. * | 2 | ALPHABLEND | |
  34578. * | 3 | ALPHATESTANDBLEND | |
  34579. *
  34580. */
  34581. transparencyMode: Nullable<number>;
  34582. /**
  34583. * Returns true if alpha blending should be disabled.
  34584. */
  34585. private readonly _disableAlphaBlending;
  34586. /**
  34587. * Specifies whether or not this material should be rendered in alpha blend mode.
  34588. */
  34589. needAlphaBlending(): boolean;
  34590. /**
  34591. * Specifies if the mesh will require alpha blending.
  34592. * @param mesh - BJS mesh.
  34593. */
  34594. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  34595. /**
  34596. * Specifies whether or not this material should be rendered in alpha test mode.
  34597. */
  34598. needAlphaTesting(): boolean;
  34599. /**
  34600. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  34601. */
  34602. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  34603. /**
  34604. * Gets the texture used for the alpha test.
  34605. */
  34606. getAlphaTestTexture(): BaseTexture;
  34607. /**
  34608. * Stores the reflectivity values based on metallic roughness workflow.
  34609. */
  34610. private static _scaledReflectivity;
  34611. /**
  34612. * Specifies that the submesh is ready to be used.
  34613. * @param mesh - BJS mesh.
  34614. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  34615. * @param useInstances - Specifies that instances should be used.
  34616. * @returns - boolean indicating that the submesh is ready or not.
  34617. */
  34618. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  34619. /**
  34620. * Specifies if the material uses metallic roughness workflow.
  34621. * @returns boolean specifiying if the material uses metallic roughness workflow.
  34622. */
  34623. isMetallicWorkflow(): boolean;
  34624. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  34625. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  34626. /**
  34627. * Force shader compilation
  34628. */
  34629. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  34630. clipPlane: boolean;
  34631. }>): void;
  34632. /**
  34633. * Initializes the uniform buffer layout for the shader.
  34634. */
  34635. buildUniformLayout(): void;
  34636. /**
  34637. * Unbinds the textures.
  34638. */
  34639. unbind(): void;
  34640. /**
  34641. * Binds the submesh data.
  34642. * @param world - The world matrix.
  34643. * @param mesh - The BJS mesh.
  34644. * @param subMesh - A submesh of the BJS mesh.
  34645. */
  34646. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  34647. /**
  34648. * Returns the animatable textures.
  34649. * @returns - Array of animatable textures.
  34650. */
  34651. getAnimatables(): IAnimatable[];
  34652. /**
  34653. * Returns the texture used for reflections.
  34654. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  34655. */
  34656. private _getReflectionTexture();
  34657. /**
  34658. * Returns the texture used for refraction or null if none is used.
  34659. * @returns - Refection texture if present. If no refraction texture and refraction
  34660. * is linked with transparency, returns environment texture. Otherwise, returns null.
  34661. */
  34662. private _getRefractionTexture();
  34663. /**
  34664. * Disposes the resources of the material.
  34665. * @param forceDisposeEffect - Forces the disposal of effects.
  34666. * @param forceDisposeTextures - Forces the disposal of all textures.
  34667. */
  34668. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  34669. }
  34670. }
  34671. declare module BABYLON {
  34672. /**
  34673. * The Physically based simple base material of BJS.
  34674. *
  34675. * This enables better naming and convention enforcements on top of the pbrMaterial.
  34676. * It is used as the base class for both the specGloss and metalRough conventions.
  34677. */
  34678. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  34679. /**
  34680. * Number of Simultaneous lights allowed on the material.
  34681. */
  34682. maxSimultaneousLights: number;
  34683. /**
  34684. * If sets to true, disables all the lights affecting the material.
  34685. */
  34686. disableLighting: boolean;
  34687. /**
  34688. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  34689. */
  34690. environmentTexture: BaseTexture;
  34691. /**
  34692. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  34693. */
  34694. invertNormalMapX: boolean;
  34695. /**
  34696. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  34697. */
  34698. invertNormalMapY: boolean;
  34699. /**
  34700. * Normal map used in the model.
  34701. */
  34702. normalTexture: BaseTexture;
  34703. /**
  34704. * Emissivie color used to self-illuminate the model.
  34705. */
  34706. emissiveColor: Color3;
  34707. /**
  34708. * Emissivie texture used to self-illuminate the model.
  34709. */
  34710. emissiveTexture: BaseTexture;
  34711. /**
  34712. * Occlusion Channel Strenght.
  34713. */
  34714. occlusionStrength: number;
  34715. /**
  34716. * Occlusion Texture of the material (adding extra occlusion effects).
  34717. */
  34718. occlusionTexture: BaseTexture;
  34719. /**
  34720. * Defines the alpha limits in alpha test mode.
  34721. */
  34722. alphaCutOff: number;
  34723. /**
  34724. * Gets the current double sided mode.
  34725. */
  34726. /**
  34727. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  34728. */
  34729. doubleSided: boolean;
  34730. lightmapTexture: BaseTexture;
  34731. useLightmapAsShadowmap: boolean;
  34732. /**
  34733. * Return the active textures of the material.
  34734. */
  34735. getActiveTextures(): BaseTexture[];
  34736. hasTexture(texture: BaseTexture): boolean;
  34737. /**
  34738. * Instantiates a new PBRMaterial instance.
  34739. *
  34740. * @param name The material name
  34741. * @param scene The scene the material will be use in.
  34742. */
  34743. constructor(name: string, scene: Scene);
  34744. getClassName(): string;
  34745. }
  34746. }
  34747. declare module BABYLON {
  34748. /**
  34749. * The Physically based material of BJS.
  34750. *
  34751. * This offers the main features of a standard PBR material.
  34752. * For more information, please refer to the documentation :
  34753. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  34754. */
  34755. class PBRMaterial extends PBRBaseMaterial {
  34756. private static _PBRMATERIAL_OPAQUE;
  34757. /**
  34758. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  34759. */
  34760. static readonly PBRMATERIAL_OPAQUE: number;
  34761. /**
  34762. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  34763. */
  34764. private static _PBRMATERIAL_ALPHATEST;
  34765. /**
  34766. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  34767. */
  34768. static readonly PBRMATERIAL_ALPHATEST: number;
  34769. /**
  34770. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  34771. */
  34772. private static _PBRMATERIAL_ALPHABLEND;
  34773. /**
  34774. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  34775. */
  34776. static readonly PBRMATERIAL_ALPHABLEND: number;
  34777. /**
  34778. * Represents the value for Alpha Test and Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  34779. * They are also discarded below the alpha cutoff threshold to improve performances.
  34780. */
  34781. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  34782. /**
  34783. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  34784. * They are also discarded below the alpha cutoff threshold to improve performances.
  34785. */
  34786. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  34787. /**
  34788. * Intensity of the direct lights e.g. the four lights available in your scene.
  34789. * This impacts both the direct diffuse and specular highlights.
  34790. */
  34791. directIntensity: number;
  34792. /**
  34793. * Intensity of the emissive part of the material.
  34794. * This helps controlling the emissive effect without modifying the emissive color.
  34795. */
  34796. emissiveIntensity: number;
  34797. /**
  34798. * Intensity of the environment e.g. how much the environment will light the object
  34799. * either through harmonics for rough material or through the refelction for shiny ones.
  34800. */
  34801. environmentIntensity: number;
  34802. /**
  34803. * This is a special control allowing the reduction of the specular highlights coming from the
  34804. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  34805. */
  34806. specularIntensity: number;
  34807. /**
  34808. * Debug Control allowing disabling the bump map on this material.
  34809. */
  34810. disableBumpMap: boolean;
  34811. /**
  34812. * AKA Diffuse Texture in standard nomenclature.
  34813. */
  34814. albedoTexture: BaseTexture;
  34815. /**
  34816. * AKA Occlusion Texture in other nomenclature.
  34817. */
  34818. ambientTexture: BaseTexture;
  34819. /**
  34820. * AKA Occlusion Texture Intensity in other nomenclature.
  34821. */
  34822. ambientTextureStrength: number;
  34823. /**
  34824. * Stores the alpha values in a texture.
  34825. */
  34826. opacityTexture: BaseTexture;
  34827. /**
  34828. * Stores the reflection values in a texture.
  34829. */
  34830. reflectionTexture: Nullable<BaseTexture>;
  34831. /**
  34832. * Stores the emissive values in a texture.
  34833. */
  34834. emissiveTexture: BaseTexture;
  34835. /**
  34836. * AKA Specular texture in other nomenclature.
  34837. */
  34838. reflectivityTexture: BaseTexture;
  34839. /**
  34840. * Used to switch from specular/glossiness to metallic/roughness workflow.
  34841. */
  34842. metallicTexture: BaseTexture;
  34843. /**
  34844. * Specifies the metallic scalar of the metallic/roughness workflow.
  34845. * Can also be used to scale the metalness values of the metallic texture.
  34846. */
  34847. metallic: number;
  34848. /**
  34849. * Specifies the roughness scalar of the metallic/roughness workflow.
  34850. * Can also be used to scale the roughness values of the metallic texture.
  34851. */
  34852. roughness: number;
  34853. /**
  34854. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  34855. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  34856. */
  34857. microSurfaceTexture: BaseTexture;
  34858. /**
  34859. * Stores surface normal data used to displace a mesh in a texture.
  34860. */
  34861. bumpTexture: BaseTexture;
  34862. /**
  34863. * Stores the pre-calculated light information of a mesh in a texture.
  34864. */
  34865. lightmapTexture: BaseTexture;
  34866. /**
  34867. * Stores the refracted light information in a texture.
  34868. */
  34869. refractionTexture: BaseTexture;
  34870. /**
  34871. * The color of a material in ambient lighting.
  34872. */
  34873. ambientColor: Color3;
  34874. /**
  34875. * AKA Diffuse Color in other nomenclature.
  34876. */
  34877. albedoColor: Color3;
  34878. /**
  34879. * AKA Specular Color in other nomenclature.
  34880. */
  34881. reflectivityColor: Color3;
  34882. /**
  34883. * The color reflected from the material.
  34884. */
  34885. reflectionColor: Color3;
  34886. /**
  34887. * The color emitted from the material.
  34888. */
  34889. emissiveColor: Color3;
  34890. /**
  34891. * AKA Glossiness in other nomenclature.
  34892. */
  34893. microSurface: number;
  34894. /**
  34895. * source material index of refraction (IOR)' / 'destination material IOR.
  34896. */
  34897. indexOfRefraction: number;
  34898. /**
  34899. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  34900. */
  34901. invertRefractionY: boolean;
  34902. /**
  34903. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  34904. * Materials half opaque for instance using refraction could benefit from this control.
  34905. */
  34906. linkRefractionWithTransparency: boolean;
  34907. useLightmapAsShadowmap: boolean;
  34908. /**
  34909. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  34910. */
  34911. useAlphaFromAlbedoTexture: boolean;
  34912. /**
  34913. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  34914. */
  34915. forceAlphaTest: boolean;
  34916. /**
  34917. * Defines the alpha limits in alpha test mode.
  34918. */
  34919. alphaCutOff: number;
  34920. /**
  34921. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  34922. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  34923. */
  34924. useSpecularOverAlpha: boolean;
  34925. /**
  34926. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  34927. */
  34928. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  34929. /**
  34930. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  34931. */
  34932. useRoughnessFromMetallicTextureAlpha: boolean;
  34933. /**
  34934. * Specifies if the metallic texture contains the roughness information in its green channel.
  34935. */
  34936. useRoughnessFromMetallicTextureGreen: boolean;
  34937. /**
  34938. * Specifies if the metallic texture contains the metallness information in its blue channel.
  34939. */
  34940. useMetallnessFromMetallicTextureBlue: boolean;
  34941. /**
  34942. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  34943. */
  34944. useAmbientOcclusionFromMetallicTextureRed: boolean;
  34945. /**
  34946. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  34947. */
  34948. useAmbientInGrayScale: boolean;
  34949. /**
  34950. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  34951. * The material will try to infer what glossiness each pixel should be.
  34952. */
  34953. useAutoMicroSurfaceFromReflectivityMap: boolean;
  34954. /**
  34955. * BJS is using an harcoded light falloff based on a manually sets up range.
  34956. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  34957. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  34958. */
  34959. usePhysicalLightFalloff: boolean;
  34960. /**
  34961. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  34962. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  34963. */
  34964. useRadianceOverAlpha: boolean;
  34965. /**
  34966. * Allows using an object space normal map (instead of tangent space).
  34967. */
  34968. useObjectSpaceNormalMap: boolean;
  34969. /**
  34970. * Allows using the bump map in parallax mode.
  34971. */
  34972. useParallax: boolean;
  34973. /**
  34974. * Allows using the bump map in parallax occlusion mode.
  34975. */
  34976. useParallaxOcclusion: boolean;
  34977. /**
  34978. * Controls the scale bias of the parallax mode.
  34979. */
  34980. parallaxScaleBias: number;
  34981. /**
  34982. * If sets to true, disables all the lights affecting the material.
  34983. */
  34984. disableLighting: boolean;
  34985. /**
  34986. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  34987. */
  34988. forceIrradianceInFragment: boolean;
  34989. /**
  34990. * Number of Simultaneous lights allowed on the material.
  34991. */
  34992. maxSimultaneousLights: number;
  34993. /**
  34994. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  34995. */
  34996. invertNormalMapX: boolean;
  34997. /**
  34998. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  34999. */
  35000. invertNormalMapY: boolean;
  35001. /**
  35002. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  35003. */
  35004. twoSidedLighting: boolean;
  35005. /**
  35006. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35007. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  35008. */
  35009. useAlphaFresnel: boolean;
  35010. /**
  35011. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35012. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  35013. */
  35014. useLinearAlphaFresnel: boolean;
  35015. /**
  35016. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  35017. * And/Or occlude the blended part.
  35018. */
  35019. environmentBRDFTexture: Nullable<BaseTexture>;
  35020. /**
  35021. * Force normal to face away from face.
  35022. */
  35023. forceNormalForward: boolean;
  35024. /**
  35025. * Enables specular anti aliasing in the PBR shader.
  35026. * It will both interacts on the Geometry for analytical and IBL lighting.
  35027. * It also prefilter the roughness map based on the bump values.
  35028. */
  35029. enableSpecularAntiAliasing: boolean;
  35030. /**
  35031. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  35032. * makes the reflect vector face the model (under horizon).
  35033. */
  35034. useHorizonOcclusion: boolean;
  35035. /**
  35036. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  35037. * too much the area relying on ambient texture to define their ambient occlusion.
  35038. */
  35039. useRadianceOcclusion: boolean;
  35040. /**
  35041. * If set to true, no lighting calculations will be applied.
  35042. */
  35043. unlit: boolean;
  35044. /**
  35045. * Gets the image processing configuration used either in this material.
  35046. */
  35047. /**
  35048. * Sets the Default image processing configuration used either in the this material.
  35049. *
  35050. * If sets to null, the scene one is in use.
  35051. */
  35052. imageProcessingConfiguration: ImageProcessingConfiguration;
  35053. /**
  35054. * Gets wether the color curves effect is enabled.
  35055. */
  35056. /**
  35057. * Sets wether the color curves effect is enabled.
  35058. */
  35059. cameraColorCurvesEnabled: boolean;
  35060. /**
  35061. * Gets wether the color grading effect is enabled.
  35062. */
  35063. /**
  35064. * Gets wether the color grading effect is enabled.
  35065. */
  35066. cameraColorGradingEnabled: boolean;
  35067. /**
  35068. * Gets wether tonemapping is enabled or not.
  35069. */
  35070. /**
  35071. * Sets wether tonemapping is enabled or not
  35072. */
  35073. cameraToneMappingEnabled: boolean;
  35074. /**
  35075. * The camera exposure used on this material.
  35076. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  35077. * This corresponds to a photographic exposure.
  35078. */
  35079. /**
  35080. * The camera exposure used on this material.
  35081. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  35082. * This corresponds to a photographic exposure.
  35083. */
  35084. cameraExposure: number;
  35085. /**
  35086. * Gets The camera contrast used on this material.
  35087. */
  35088. /**
  35089. * Sets The camera contrast used on this material.
  35090. */
  35091. cameraContrast: number;
  35092. /**
  35093. * Gets the Color Grading 2D Lookup Texture.
  35094. */
  35095. /**
  35096. * Sets the Color Grading 2D Lookup Texture.
  35097. */
  35098. cameraColorGradingTexture: Nullable<BaseTexture>;
  35099. /**
  35100. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35101. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35102. * 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;
  35103. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35104. */
  35105. /**
  35106. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  35107. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  35108. * 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;
  35109. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  35110. */
  35111. cameraColorCurves: Nullable<ColorCurves>;
  35112. /**
  35113. * Instantiates a new PBRMaterial instance.
  35114. *
  35115. * @param name The material name
  35116. * @param scene The scene the material will be use in.
  35117. */
  35118. constructor(name: string, scene: Scene);
  35119. /**
  35120. * Returns the name of this material class.
  35121. */
  35122. getClassName(): string;
  35123. /**
  35124. * Returns an array of the actively used textures.
  35125. * @returns - Array of BaseTextures
  35126. */
  35127. getActiveTextures(): BaseTexture[];
  35128. /**
  35129. * Checks to see if a texture is used in the material.
  35130. * @param texture - Base texture to use.
  35131. * @returns - Boolean specifying if a texture is used in the material.
  35132. */
  35133. hasTexture(texture: BaseTexture): boolean;
  35134. /**
  35135. * Makes a duplicate of the current material.
  35136. * @param name - name to use for the new material.
  35137. */
  35138. clone(name: string): PBRMaterial;
  35139. /**
  35140. * Serializes this PBR Material.
  35141. * @returns - An object with the serialized material.
  35142. */
  35143. serialize(): any;
  35144. /**
  35145. * Parses a PBR Material from a serialized object.
  35146. * @param source - Serialized object.
  35147. * @param scene - BJS scene instance.
  35148. * @param rootUrl - url for the scene object
  35149. * @returns - PBRMaterial
  35150. */
  35151. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  35152. }
  35153. }
  35154. declare module BABYLON {
  35155. /**
  35156. * The PBR material of BJS following the metal roughness convention.
  35157. *
  35158. * This fits to the PBR convention in the GLTF definition:
  35159. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  35160. */
  35161. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  35162. /**
  35163. * The base color has two different interpretations depending on the value of metalness.
  35164. * When the material is a metal, the base color is the specific measured reflectance value
  35165. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  35166. * of the material.
  35167. */
  35168. baseColor: Color3;
  35169. /**
  35170. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  35171. * well as opacity information in the alpha channel.
  35172. */
  35173. baseTexture: BaseTexture;
  35174. /**
  35175. * Specifies the metallic scalar value of the material.
  35176. * Can also be used to scale the metalness values of the metallic texture.
  35177. */
  35178. metallic: number;
  35179. /**
  35180. * Specifies the roughness scalar value of the material.
  35181. * Can also be used to scale the roughness values of the metallic texture.
  35182. */
  35183. roughness: number;
  35184. /**
  35185. * Texture containing both the metallic value in the B channel and the
  35186. * roughness value in the G channel to keep better precision.
  35187. */
  35188. metallicRoughnessTexture: BaseTexture;
  35189. /**
  35190. * Instantiates a new PBRMetalRoughnessMaterial instance.
  35191. *
  35192. * @param name The material name
  35193. * @param scene The scene the material will be use in.
  35194. */
  35195. constructor(name: string, scene: Scene);
  35196. /**
  35197. * Return the currrent class name of the material.
  35198. */
  35199. getClassName(): string;
  35200. /**
  35201. * Return the active textures of the material.
  35202. */
  35203. getActiveTextures(): BaseTexture[];
  35204. /**
  35205. * Checks to see if a texture is used in the material.
  35206. * @param texture - Base texture to use.
  35207. * @returns - Boolean specifying if a texture is used in the material.
  35208. */
  35209. hasTexture(texture: BaseTexture): boolean;
  35210. /**
  35211. * Makes a duplicate of the current material.
  35212. * @param name - name to use for the new material.
  35213. */
  35214. clone(name: string): PBRMetallicRoughnessMaterial;
  35215. /**
  35216. * Serialize the material to a parsable JSON object.
  35217. */
  35218. serialize(): any;
  35219. /**
  35220. * Parses a JSON object correponding to the serialize function.
  35221. */
  35222. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  35223. }
  35224. }
  35225. declare module BABYLON {
  35226. /**
  35227. * The PBR material of BJS following the specular glossiness convention.
  35228. *
  35229. * This fits to the PBR convention in the GLTF definition:
  35230. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  35231. */
  35232. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  35233. /**
  35234. * Specifies the diffuse color of the material.
  35235. */
  35236. diffuseColor: Color3;
  35237. /**
  35238. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  35239. * channel.
  35240. */
  35241. diffuseTexture: BaseTexture;
  35242. /**
  35243. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  35244. */
  35245. specularColor: Color3;
  35246. /**
  35247. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  35248. */
  35249. glossiness: number;
  35250. /**
  35251. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  35252. */
  35253. specularGlossinessTexture: BaseTexture;
  35254. /**
  35255. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  35256. *
  35257. * @param name The material name
  35258. * @param scene The scene the material will be use in.
  35259. */
  35260. constructor(name: string, scene: Scene);
  35261. /**
  35262. * Return the currrent class name of the material.
  35263. */
  35264. getClassName(): string;
  35265. /**
  35266. * Return the active textures of the material.
  35267. */
  35268. getActiveTextures(): BaseTexture[];
  35269. /**
  35270. * Checks to see if a texture is used in the material.
  35271. * @param texture - Base texture to use.
  35272. * @returns - Boolean specifying if a texture is used in the material.
  35273. */
  35274. hasTexture(texture: BaseTexture): boolean;
  35275. /**
  35276. * Makes a duplicate of the current material.
  35277. * @param name - name to use for the new material.
  35278. */
  35279. clone(name: string): PBRSpecularGlossinessMaterial;
  35280. /**
  35281. * Serialize the material to a parsable JSON object.
  35282. */
  35283. serialize(): any;
  35284. /**
  35285. * Parses a JSON object correponding to the serialize function.
  35286. */
  35287. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  35288. }
  35289. }
  35290. declare module BABYLON {
  35291. class BaseTexture {
  35292. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35293. name: string;
  35294. private _hasAlpha;
  35295. hasAlpha: boolean;
  35296. getAlphaFromRGB: boolean;
  35297. level: number;
  35298. coordinatesIndex: number;
  35299. private _coordinatesMode;
  35300. /**
  35301. * How a texture is mapped.
  35302. *
  35303. * | Value | Type | Description |
  35304. * | ----- | ----------------------------------- | ----------- |
  35305. * | 0 | EXPLICIT_MODE | |
  35306. * | 1 | SPHERICAL_MODE | |
  35307. * | 2 | PLANAR_MODE | |
  35308. * | 3 | CUBIC_MODE | |
  35309. * | 4 | PROJECTION_MODE | |
  35310. * | 5 | SKYBOX_MODE | |
  35311. * | 6 | INVCUBIC_MODE | |
  35312. * | 7 | EQUIRECTANGULAR_MODE | |
  35313. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35314. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35315. */
  35316. coordinatesMode: number;
  35317. /**
  35318. * | Value | Type | Description |
  35319. * | ----- | ------------------ | ----------- |
  35320. * | 0 | CLAMP_ADDRESSMODE | |
  35321. * | 1 | WRAP_ADDRESSMODE | |
  35322. * | 2 | MIRROR_ADDRESSMODE | |
  35323. */
  35324. wrapU: number;
  35325. /**
  35326. * | Value | Type | Description |
  35327. * | ----- | ------------------ | ----------- |
  35328. * | 0 | CLAMP_ADDRESSMODE | |
  35329. * | 1 | WRAP_ADDRESSMODE | |
  35330. * | 2 | MIRROR_ADDRESSMODE | |
  35331. */
  35332. wrapV: number;
  35333. /**
  35334. * | Value | Type | Description |
  35335. * | ----- | ------------------ | ----------- |
  35336. * | 0 | CLAMP_ADDRESSMODE | |
  35337. * | 1 | WRAP_ADDRESSMODE | |
  35338. * | 2 | MIRROR_ADDRESSMODE | |
  35339. */
  35340. wrapR: number;
  35341. anisotropicFilteringLevel: number;
  35342. isCube: boolean;
  35343. is3D: boolean;
  35344. gammaSpace: boolean;
  35345. /**
  35346. * Gets whether or not the texture contains RGBD data.
  35347. */
  35348. readonly isRGBD: boolean;
  35349. invertZ: boolean;
  35350. lodLevelInAlpha: boolean;
  35351. lodGenerationOffset: number;
  35352. lodGenerationScale: number;
  35353. isRenderTarget: boolean;
  35354. readonly uid: string;
  35355. toString(): string;
  35356. getClassName(): string;
  35357. animations: Animation[];
  35358. /**
  35359. * An event triggered when the texture is disposed.
  35360. */
  35361. onDisposeObservable: Observable<BaseTexture>;
  35362. private _onDisposeObserver;
  35363. onDispose: () => void;
  35364. delayLoadState: number;
  35365. private _scene;
  35366. _texture: Nullable<InternalTexture>;
  35367. private _uid;
  35368. readonly isBlocking: boolean;
  35369. constructor(scene: Nullable<Scene>);
  35370. getScene(): Nullable<Scene>;
  35371. getTextureMatrix(): Matrix;
  35372. getReflectionTextureMatrix(): Matrix;
  35373. getInternalTexture(): Nullable<InternalTexture>;
  35374. isReadyOrNotBlocking(): boolean;
  35375. isReady(): boolean;
  35376. private _cachedSize;
  35377. getSize(): ISize;
  35378. getBaseSize(): ISize;
  35379. scale(ratio: number): void;
  35380. readonly canRescale: boolean;
  35381. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  35382. _rebuild(): void;
  35383. delayLoad(): void;
  35384. clone(): Nullable<BaseTexture>;
  35385. readonly textureType: number;
  35386. readonly textureFormat: number;
  35387. /**
  35388. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35389. * This will returns an RGBA array buffer containing either in values (0-255) or
  35390. * float values (0-1) depending of the underlying buffer type.
  35391. * @param faceIndex The face of the texture to read (in case of cube texture)
  35392. * @param level The LOD level of the texture to read (in case of Mip Maps)
  35393. * @returns The Array buffer containing the pixels data.
  35394. */
  35395. readPixels(faceIndex?: number, level?: number): Nullable<ArrayBufferView>;
  35396. releaseInternalTexture(): void;
  35397. sphericalPolynomial: Nullable<SphericalPolynomial>;
  35398. readonly _lodTextureHigh: Nullable<BaseTexture>;
  35399. readonly _lodTextureMid: Nullable<BaseTexture>;
  35400. readonly _lodTextureLow: Nullable<BaseTexture>;
  35401. dispose(): void;
  35402. serialize(): any;
  35403. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35404. }
  35405. }
  35406. declare module BABYLON {
  35407. /**
  35408. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  35409. * It can help converting any input color in a desired output one. This can then be used to create effects
  35410. * from sepia, black and white to sixties or futuristic rendering...
  35411. *
  35412. * The only supported format is currently 3dl.
  35413. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  35414. */
  35415. class ColorGradingTexture extends BaseTexture {
  35416. /**
  35417. * The current texture matrix. (will always be identity in color grading texture)
  35418. */
  35419. private _textureMatrix;
  35420. /**
  35421. * The texture URL.
  35422. */
  35423. url: string;
  35424. /**
  35425. * Empty line regex stored for GC.
  35426. */
  35427. private static _noneEmptyLineRegex;
  35428. private _engine;
  35429. /**
  35430. * Instantiates a ColorGradingTexture from the following parameters.
  35431. *
  35432. * @param url The location of the color gradind data (currently only supporting 3dl)
  35433. * @param scene The scene the texture will be used in
  35434. */
  35435. constructor(url: string, scene: Scene);
  35436. /**
  35437. * Returns the texture matrix used in most of the material.
  35438. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  35439. */
  35440. getTextureMatrix(): Matrix;
  35441. /**
  35442. * Occurs when the file being loaded is a .3dl LUT file.
  35443. */
  35444. private load3dlTexture();
  35445. /**
  35446. * Starts the loading process of the texture.
  35447. */
  35448. private loadTexture();
  35449. /**
  35450. * Clones the color gradind texture.
  35451. */
  35452. clone(): ColorGradingTexture;
  35453. /**
  35454. * Called during delayed load for textures.
  35455. */
  35456. delayLoad(): void;
  35457. /**
  35458. * Parses a color grading texture serialized by Babylon.
  35459. * @param parsedTexture The texture information being parsedTexture
  35460. * @param scene The scene to load the texture in
  35461. * @param rootUrl The root url of the data assets to load
  35462. * @return A color gradind texture
  35463. */
  35464. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  35465. /**
  35466. * Serializes the LUT texture to json format.
  35467. */
  35468. serialize(): any;
  35469. }
  35470. }
  35471. declare module BABYLON {
  35472. class CubeTexture extends BaseTexture {
  35473. url: string;
  35474. /**
  35475. * Gets or sets the center of the bounding box associated with the cube texture
  35476. * It must define where the camera used to render the texture was set
  35477. */
  35478. boundingBoxPosition: Vector3;
  35479. private _boundingBoxSize;
  35480. /**
  35481. * Gets or sets the size of the bounding box associated with the cube texture
  35482. * When defined, the cubemap will switch to local mode
  35483. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  35484. * @example https://www.babylonjs-playground.com/#RNASML
  35485. */
  35486. boundingBoxSize: Vector3;
  35487. protected _rotationY: number;
  35488. /**
  35489. * Gets texture matrix rotation angle around Y axis radians.
  35490. */
  35491. /**
  35492. * Sets texture matrix rotation angle around Y axis in radians.
  35493. */
  35494. rotationY: number;
  35495. private _noMipmap;
  35496. private _files;
  35497. private _extensions;
  35498. private _textureMatrix;
  35499. private _format;
  35500. private _createPolynomials;
  35501. /** @hidden */
  35502. readonly _prefiltered: boolean;
  35503. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  35504. /**
  35505. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  35506. * @param url defines the url of the prefiltered texture
  35507. * @param scene defines the scene the texture is attached to
  35508. * @param forcedExtension defines the extension of the file if different from the url
  35509. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  35510. * @return the prefiltered texture
  35511. */
  35512. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  35513. /**
  35514. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  35515. * as prefiltered data.
  35516. * @param rootUrl defines the url of the texture or the root name of the six images
  35517. * @param scene defines the scene the texture is attached to
  35518. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  35519. * @param noMipmap defines if mipmaps should be created or not
  35520. * @param files defines the six files to load for the different faces
  35521. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  35522. * @param onError defines a callback triggered in case of error during load
  35523. * @param format defines the internal format to use for the texture once loaded
  35524. * @param prefiltered defines whether or not the texture is created from prefiltered data
  35525. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  35526. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  35527. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  35528. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  35529. * @return the cube texture
  35530. */
  35531. 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);
  35532. delayLoad(): void;
  35533. getReflectionTextureMatrix(): Matrix;
  35534. setReflectionTextureMatrix(value: Matrix): void;
  35535. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  35536. clone(): CubeTexture;
  35537. }
  35538. }
  35539. declare module BABYLON {
  35540. /**
  35541. * A class extending {BABYLON.Texture} allowing drawing on a texture
  35542. * @see http://doc.babylonjs.com/how_to/dynamictexture
  35543. */
  35544. class DynamicTexture extends Texture {
  35545. private _generateMipMaps;
  35546. private _canvas;
  35547. private _context;
  35548. private _engine;
  35549. /**
  35550. * Creates a {BABYLON.DynamicTexture}
  35551. * @param name defines the name of the texture
  35552. * @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
  35553. * @param scene defines the scene where you want the texture
  35554. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  35555. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  35556. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  35557. */
  35558. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  35559. /**
  35560. * Gets the current state of canRescale
  35561. */
  35562. readonly canRescale: boolean;
  35563. private _recreate(textureSize);
  35564. /**
  35565. * Scales the texture
  35566. * @param ratio the scale factor to apply to both width and height
  35567. */
  35568. scale(ratio: number): void;
  35569. /**
  35570. * Resizes the texture
  35571. * @param width the new width
  35572. * @param height the new height
  35573. */
  35574. scaleTo(width: number, height: number): void;
  35575. /**
  35576. * Gets the context of the canvas used by the texture
  35577. * @returns the canvas context of the dynamic texture
  35578. */
  35579. getContext(): CanvasRenderingContext2D;
  35580. /**
  35581. * Clears the texture
  35582. */
  35583. clear(): void;
  35584. /**
  35585. * Updates the texture
  35586. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  35587. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  35588. */
  35589. update(invertY?: boolean, premulAlpha?: boolean): void;
  35590. /**
  35591. * Draws text onto the texture
  35592. * @param text defines the text to be drawn
  35593. * @param x defines the placement of the text from the left
  35594. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  35595. * @param font defines the font to be used with font-style, font-size, font-name
  35596. * @param color defines the color used for the text
  35597. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  35598. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  35599. * @param update defines whether texture is immediately update (default is true)
  35600. */
  35601. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  35602. /**
  35603. * Clones the texture
  35604. * @returns the clone of the texture.
  35605. */
  35606. clone(): DynamicTexture;
  35607. /**
  35608. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  35609. * @returns a serialized dynamic texture object
  35610. */
  35611. serialize(): any;
  35612. /** @hidden */
  35613. _rebuild(): void;
  35614. }
  35615. }
  35616. declare module BABYLON {
  35617. /**
  35618. * This represents a texture coming from an HDR input.
  35619. *
  35620. * The only supported format is currently panorama picture stored in RGBE format.
  35621. * Example of such files can be found on HDRLib: http://hdrlib.com/
  35622. */
  35623. class HDRCubeTexture extends BaseTexture {
  35624. private static _facesMapping;
  35625. private _generateHarmonics;
  35626. private _noMipmap;
  35627. private _textureMatrix;
  35628. private _size;
  35629. private _onLoad;
  35630. private _onError;
  35631. /**
  35632. * The texture URL.
  35633. */
  35634. url: string;
  35635. /**
  35636. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  35637. */
  35638. coordinatesMode: number;
  35639. protected _isBlocking: boolean;
  35640. /**
  35641. * Gets wether or not the texture is blocking during loading.
  35642. */
  35643. /**
  35644. * Sets wether or not the texture is blocking during loading.
  35645. */
  35646. isBlocking: boolean;
  35647. protected _rotationY: number;
  35648. /**
  35649. * Gets texture matrix rotation angle around Y axis radians.
  35650. */
  35651. /**
  35652. * Sets texture matrix rotation angle around Y axis in radians.
  35653. */
  35654. rotationY: number;
  35655. /**
  35656. * Gets or sets the center of the bounding box associated with the cube texture
  35657. * It must define where the camera used to render the texture was set
  35658. */
  35659. boundingBoxPosition: Vector3;
  35660. private _boundingBoxSize;
  35661. /**
  35662. * Gets or sets the size of the bounding box associated with the cube texture
  35663. * When defined, the cubemap will switch to local mode
  35664. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  35665. * @example https://www.babylonjs-playground.com/#RNASML
  35666. */
  35667. boundingBoxSize: Vector3;
  35668. /**
  35669. * Instantiates an HDRTexture from the following parameters.
  35670. *
  35671. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  35672. * @param scene The scene the texture will be used in
  35673. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  35674. * @param noMipmap Forces to not generate the mipmap if true
  35675. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  35676. * @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)
  35677. * @param reserved Reserved flag for internal use.
  35678. */
  35679. 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>);
  35680. /**
  35681. * Occurs when the file is raw .hdr file.
  35682. */
  35683. private loadTexture();
  35684. clone(): HDRCubeTexture;
  35685. delayLoad(): void;
  35686. getReflectionTextureMatrix(): Matrix;
  35687. setReflectionTextureMatrix(value: Matrix): void;
  35688. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  35689. serialize(): any;
  35690. }
  35691. }
  35692. declare module BABYLON {
  35693. /**
  35694. * Class used to store data associated with WebGL texture data for the engine
  35695. * This class should not be used directly
  35696. */
  35697. class InternalTexture implements IInternalTextureTracker {
  35698. /**
  35699. * The source of the texture data is unknown
  35700. */
  35701. static DATASOURCE_UNKNOWN: number;
  35702. /**
  35703. * Texture data comes from an URL
  35704. */
  35705. static DATASOURCE_URL: number;
  35706. /**
  35707. * Texture data is only used for temporary storage
  35708. */
  35709. static DATASOURCE_TEMP: number;
  35710. /**
  35711. * Texture data comes from raw data (ArrayBuffer)
  35712. */
  35713. static DATASOURCE_RAW: number;
  35714. /**
  35715. * Texture content is dynamic (video or dynamic texture)
  35716. */
  35717. static DATASOURCE_DYNAMIC: number;
  35718. /**
  35719. * Texture content is generated by rendering to it
  35720. */
  35721. static DATASOURCE_RENDERTARGET: number;
  35722. /**
  35723. * Texture content is part of a multi render target process
  35724. */
  35725. static DATASOURCE_MULTIRENDERTARGET: number;
  35726. /**
  35727. * Texture data comes from a cube data file
  35728. */
  35729. static DATASOURCE_CUBE: number;
  35730. /**
  35731. * Texture data comes from a raw cube data
  35732. */
  35733. static DATASOURCE_CUBERAW: number;
  35734. /**
  35735. * Texture data come from a prefiltered cube data file
  35736. */
  35737. static DATASOURCE_CUBEPREFILTERED: number;
  35738. /**
  35739. * Texture content is raw 3D data
  35740. */
  35741. static DATASOURCE_RAW3D: number;
  35742. /**
  35743. * Texture content is a depth texture
  35744. */
  35745. static DATASOURCE_DEPTHTEXTURE: number;
  35746. /**
  35747. * Texture data comes from a raw cube data encoded with RGBD
  35748. */
  35749. static DATASOURCE_CUBERAW_RGBD: number;
  35750. /**
  35751. * Defines if the texture is ready
  35752. */
  35753. isReady: boolean;
  35754. /**
  35755. * Defines if the texture is a cube texture
  35756. */
  35757. isCube: boolean;
  35758. /**
  35759. * Defines if the texture contains 3D data
  35760. */
  35761. is3D: boolean;
  35762. /**
  35763. * Gets the URL used to load this texture
  35764. */
  35765. url: string;
  35766. /**
  35767. * Gets the sampling mode of the texture
  35768. */
  35769. samplingMode: number;
  35770. /**
  35771. * Gets a boolean indicating if the texture needs mipmaps generation
  35772. */
  35773. generateMipMaps: boolean;
  35774. /**
  35775. * Gets the number of samples used by the texture (WebGL2+ only)
  35776. */
  35777. samples: number;
  35778. /**
  35779. * Gets the type of the texture
  35780. */
  35781. type: number;
  35782. /**
  35783. * Gets the format of the texture
  35784. */
  35785. format: number;
  35786. /**
  35787. * Observable called when the texture is loaded
  35788. */
  35789. onLoadedObservable: Observable<InternalTexture>;
  35790. /**
  35791. * Gets the width of the texture
  35792. */
  35793. width: number;
  35794. /**
  35795. * Gets the height of the texture
  35796. */
  35797. height: number;
  35798. /**
  35799. * Gets the depth of the texture
  35800. */
  35801. depth: number;
  35802. /**
  35803. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35804. */
  35805. baseWidth: number;
  35806. /**
  35807. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35808. */
  35809. baseHeight: number;
  35810. /**
  35811. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35812. */
  35813. baseDepth: number;
  35814. /**
  35815. * Gets a boolean indicating if the texture is inverted on Y axis
  35816. */
  35817. invertY: boolean;
  35818. /**
  35819. * Gets or set the previous tracker in the list
  35820. */
  35821. previous: Nullable<IInternalTextureTracker>;
  35822. /**
  35823. * Gets or set the next tracker in the list
  35824. */
  35825. next: Nullable<IInternalTextureTracker>;
  35826. /** @hidden */
  35827. _initialSlot: number;
  35828. /** @hidden */
  35829. _designatedSlot: number;
  35830. /** @hidden */
  35831. _dataSource: number;
  35832. /** @hidden */
  35833. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  35834. /** @hidden */
  35835. _bufferView: Nullable<ArrayBufferView>;
  35836. /** @hidden */
  35837. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35838. /** @hidden */
  35839. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35840. /** @hidden */
  35841. _size: number;
  35842. /** @hidden */
  35843. _extension: string;
  35844. /** @hidden */
  35845. _files: Nullable<string[]>;
  35846. /** @hidden */
  35847. _workingCanvas: HTMLCanvasElement;
  35848. /** @hidden */
  35849. _workingContext: CanvasRenderingContext2D;
  35850. /** @hidden */
  35851. _framebuffer: Nullable<WebGLFramebuffer>;
  35852. /** @hidden */
  35853. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35854. /** @hidden */
  35855. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35856. /** @hidden */
  35857. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35858. /** @hidden */
  35859. _attachments: Nullable<number[]>;
  35860. /** @hidden */
  35861. _cachedCoordinatesMode: Nullable<number>;
  35862. /** @hidden */
  35863. _cachedWrapU: Nullable<number>;
  35864. /** @hidden */
  35865. _cachedWrapV: Nullable<number>;
  35866. /** @hidden */
  35867. _cachedWrapR: Nullable<number>;
  35868. /** @hidden */
  35869. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35870. /** @hidden */
  35871. _isDisabled: boolean;
  35872. /** @hidden */
  35873. _compression: Nullable<string>;
  35874. /** @hidden */
  35875. _generateStencilBuffer: boolean;
  35876. /** @hidden */
  35877. _generateDepthBuffer: boolean;
  35878. /** @hidden */
  35879. _comparisonFunction: number;
  35880. /** @hidden */
  35881. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35882. /** @hidden */
  35883. _lodGenerationScale: number;
  35884. /** @hidden */
  35885. _lodGenerationOffset: number;
  35886. /** @hidden */
  35887. _lodTextureHigh: BaseTexture;
  35888. /** @hidden */
  35889. _lodTextureMid: BaseTexture;
  35890. /** @hidden */
  35891. _lodTextureLow: BaseTexture;
  35892. /** @hidden */
  35893. _isRGBD: boolean;
  35894. /** @hidden */
  35895. _webGLTexture: Nullable<WebGLTexture>;
  35896. /** @hidden */
  35897. _references: number;
  35898. private _engine;
  35899. /**
  35900. * Gets the Engine the texture belongs to.
  35901. * @returns The babylon engine
  35902. */
  35903. getEngine(): Engine;
  35904. /**
  35905. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  35906. */
  35907. readonly dataSource: number;
  35908. /**
  35909. * Creates a new InternalTexture
  35910. * @param engine defines the engine to use
  35911. * @param dataSource defines the type of data that will be used
  35912. */
  35913. constructor(engine: Engine, dataSource: number);
  35914. /**
  35915. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  35916. */
  35917. incrementReferences(): void;
  35918. /**
  35919. * Change the size of the texture (not the size of the content)
  35920. * @param width defines the new width
  35921. * @param height defines the new height
  35922. * @param depth defines the new depth (1 by default)
  35923. */
  35924. updateSize(width: int, height: int, depth?: int): void;
  35925. /** @hidden */
  35926. _rebuild(): void;
  35927. _swapAndDie(target: InternalTexture): void;
  35928. /**
  35929. * Dispose the current allocated resources
  35930. */
  35931. dispose(): void;
  35932. }
  35933. }
  35934. declare module BABYLON {
  35935. /**
  35936. * This represents the required contract to create a new type of texture loader.
  35937. */
  35938. interface IInternalTextureLoader {
  35939. /**
  35940. * Defines wether the loader supports cascade loading the different faces.
  35941. */
  35942. supportCascades: boolean;
  35943. /**
  35944. * This returns if the loader support the current file information.
  35945. * @param extension defines the file extension of the file being loaded
  35946. * @param textureFormatInUse defines the current compressed format in use iun the engine
  35947. * @param fallback defines the fallback internal texture if any
  35948. * @param isBase64 defines whether the texture is encoded as a base64
  35949. * @param isBuffer defines whether the texture data are stored as a buffer
  35950. * @returns true if the loader can load the specified file
  35951. */
  35952. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  35953. /**
  35954. * Transform the url before loading if required.
  35955. * @param rootUrl the url of the texture
  35956. * @param textureFormatInUse defines the current compressed format in use iun the engine
  35957. * @returns the transformed texture
  35958. */
  35959. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  35960. /**
  35961. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  35962. * @param rootUrl the url of the texture
  35963. * @param textureFormatInUse defines the current compressed format in use iun the engine
  35964. * @returns the fallback texture
  35965. */
  35966. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  35967. /**
  35968. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  35969. * @param data contains the texture data
  35970. * @param texture defines the BabylonJS internal texture
  35971. * @param createPolynomials will be true if polynomials have been requested
  35972. * @param onLoad defines the callback to trigger once the texture is ready
  35973. * @param onError defines the callback to trigger in case of error
  35974. */
  35975. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  35976. /**
  35977. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  35978. * @param data contains the texture data
  35979. * @param texture defines the BabylonJS internal texture
  35980. * @param callback defines the method to call once ready to upload
  35981. */
  35982. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  35983. }
  35984. }
  35985. declare module BABYLON {
  35986. /**
  35987. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  35988. */
  35989. interface IInternalTextureTracker {
  35990. /**
  35991. * Gets or set the previous tracker in the list
  35992. */
  35993. previous: Nullable<IInternalTextureTracker>;
  35994. /**
  35995. * Gets or set the next tracker in the list
  35996. */
  35997. next: Nullable<IInternalTextureTracker>;
  35998. }
  35999. /**
  36000. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  36001. */
  36002. class DummyInternalTextureTracker {
  36003. /**
  36004. * Gets or set the previous tracker in the list
  36005. */
  36006. previous: Nullable<IInternalTextureTracker>;
  36007. /**
  36008. * Gets or set the next tracker in the list
  36009. */
  36010. next: Nullable<IInternalTextureTracker>;
  36011. }
  36012. }
  36013. declare module BABYLON {
  36014. class MirrorTexture extends RenderTargetTexture {
  36015. private scene;
  36016. mirrorPlane: Plane;
  36017. private _transformMatrix;
  36018. private _mirrorMatrix;
  36019. private _savedViewMatrix;
  36020. private _blurX;
  36021. private _blurY;
  36022. private _adaptiveBlurKernel;
  36023. private _blurKernelX;
  36024. private _blurKernelY;
  36025. private _blurRatio;
  36026. blurRatio: number;
  36027. adaptiveBlurKernel: number;
  36028. blurKernel: number;
  36029. blurKernelX: number;
  36030. blurKernelY: number;
  36031. private _autoComputeBlurKernel();
  36032. protected _onRatioRescale(): void;
  36033. private _updateGammaSpace();
  36034. private _imageProcessingConfigChangeObserver;
  36035. constructor(name: string, size: number | {
  36036. width: number;
  36037. height: number;
  36038. } | {
  36039. ratio: number;
  36040. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  36041. private _preparePostProcesses();
  36042. clone(): MirrorTexture;
  36043. serialize(): any;
  36044. dispose(): void;
  36045. }
  36046. }
  36047. declare module BABYLON {
  36048. interface IMultiRenderTargetOptions {
  36049. generateMipMaps?: boolean;
  36050. types?: number[];
  36051. samplingModes?: number[];
  36052. generateDepthBuffer?: boolean;
  36053. generateStencilBuffer?: boolean;
  36054. generateDepthTexture?: boolean;
  36055. textureCount?: number;
  36056. doNotChangeAspectRatio?: boolean;
  36057. defaultType?: number;
  36058. }
  36059. class MultiRenderTarget extends RenderTargetTexture {
  36060. private _internalTextures;
  36061. private _textures;
  36062. readonly isSupported: boolean;
  36063. private _multiRenderTargetOptions;
  36064. readonly textures: Texture[];
  36065. readonly depthTexture: Texture;
  36066. wrapU: number;
  36067. wrapV: number;
  36068. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  36069. _rebuild(): void;
  36070. private _createInternalTextures();
  36071. private _createTextures();
  36072. samples: number;
  36073. resize(size: any): void;
  36074. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  36075. dispose(): void;
  36076. releaseInternalTextures(): void;
  36077. }
  36078. }
  36079. declare module BABYLON {
  36080. /**
  36081. * Raw cube texture where the raw buffers are passed in
  36082. */
  36083. class RawCubeTexture extends CubeTexture {
  36084. /**
  36085. * Creates a cube texture where the raw buffers are passed in.
  36086. * @param scene defines the scene the texture is attached to
  36087. * @param data defines the array of data to use to create each face
  36088. * @param size defines the size of the textures
  36089. * @param format defines the format of the data
  36090. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  36091. * @param generateMipMaps defines if the engine should generate the mip levels
  36092. * @param invertY defines if data must be stored with Y axis inverted
  36093. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  36094. * @param compression defines the compression used (null by default)
  36095. */
  36096. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  36097. /**
  36098. * Updates the raw cube texture.
  36099. * @param data defines the data to store
  36100. * @param format defines the data format
  36101. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  36102. * @param invertY defines if data must be stored with Y axis inverted
  36103. * @param compression defines the compression used (null by default)
  36104. * @param level defines which level of the texture to update
  36105. */
  36106. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  36107. /**
  36108. * Updates a raw cube texture with RGBD encoded data.
  36109. * @param data defines the array of data [mipmap][face] to use to create each face
  36110. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  36111. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  36112. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  36113. * @returns a promsie that resolves when the operation is complete
  36114. */
  36115. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  36116. /**
  36117. * Clones the raw cube texture.
  36118. * @return a new cube texture
  36119. */
  36120. clone(): CubeTexture;
  36121. /** @hidden */
  36122. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  36123. }
  36124. }
  36125. declare module BABYLON {
  36126. class RawTexture extends Texture {
  36127. format: number;
  36128. private _engine;
  36129. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  36130. update(data: ArrayBufferView): void;
  36131. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  36132. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  36133. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  36134. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  36135. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  36136. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  36137. }
  36138. }
  36139. declare module BABYLON {
  36140. /**
  36141. * Class used to store 3D textures containing user data
  36142. */
  36143. class RawTexture3D extends Texture {
  36144. /** Gets or sets the texture format to use */
  36145. format: number;
  36146. private _engine;
  36147. /**
  36148. * Create a new RawTexture3D
  36149. * @param data defines the data of the texture
  36150. * @param width defines the width of the texture
  36151. * @param height defines the height of the texture
  36152. * @param depth defines the depth of the texture
  36153. * @param format defines the texture format to use
  36154. * @param scene defines the hosting scene
  36155. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  36156. * @param invertY defines if texture must be stored with Y axis inverted
  36157. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  36158. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  36159. */
  36160. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  36161. /** Gets or sets the texture format to use */
  36162. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  36163. /**
  36164. * Update the texture with new data
  36165. * @param data defines the data to store in the texture
  36166. */
  36167. update(data: ArrayBufferView): void;
  36168. }
  36169. }
  36170. declare module BABYLON {
  36171. /**
  36172. * Creates a refraction texture used by refraction channel of the standard material.
  36173. * @param name the texture name
  36174. * @param size size of the underlying texture
  36175. * @param scene root scene
  36176. */
  36177. class RefractionTexture extends RenderTargetTexture {
  36178. refractionPlane: Plane;
  36179. depth: number;
  36180. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  36181. clone(): RefractionTexture;
  36182. serialize(): any;
  36183. }
  36184. }
  36185. declare module BABYLON {
  36186. class RenderTargetTexture extends Texture {
  36187. isCube: boolean;
  36188. static _REFRESHRATE_RENDER_ONCE: number;
  36189. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  36190. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  36191. static readonly REFRESHRATE_RENDER_ONCE: number;
  36192. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  36193. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  36194. /**
  36195. * Use this predicate to dynamically define the list of mesh you want to render.
  36196. * If set, the renderList property will be overwritten.
  36197. */
  36198. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  36199. private _renderList;
  36200. /**
  36201. * Use this list to define the list of mesh you want to render.
  36202. */
  36203. renderList: Nullable<Array<AbstractMesh>>;
  36204. private _hookArray(array);
  36205. renderParticles: boolean;
  36206. renderSprites: boolean;
  36207. coordinatesMode: number;
  36208. activeCamera: Nullable<Camera>;
  36209. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  36210. useCameraPostProcesses: boolean;
  36211. ignoreCameraViewport: boolean;
  36212. private _postProcessManager;
  36213. private _postProcesses;
  36214. private _resizeObserver;
  36215. /**
  36216. * An event triggered when the texture is unbind.
  36217. */
  36218. onBeforeBindObservable: Observable<RenderTargetTexture>;
  36219. /**
  36220. * An event triggered when the texture is unbind.
  36221. */
  36222. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  36223. private _onAfterUnbindObserver;
  36224. onAfterUnbind: () => void;
  36225. /**
  36226. * An event triggered before rendering the texture
  36227. */
  36228. onBeforeRenderObservable: Observable<number>;
  36229. private _onBeforeRenderObserver;
  36230. onBeforeRender: (faceIndex: number) => void;
  36231. /**
  36232. * An event triggered after rendering the texture
  36233. */
  36234. onAfterRenderObservable: Observable<number>;
  36235. private _onAfterRenderObserver;
  36236. onAfterRender: (faceIndex: number) => void;
  36237. /**
  36238. * An event triggered after the texture clear
  36239. */
  36240. onClearObservable: Observable<Engine>;
  36241. private _onClearObserver;
  36242. onClear: (Engine: Engine) => void;
  36243. clearColor: Color4;
  36244. protected _size: number | {
  36245. width: number;
  36246. height: number;
  36247. };
  36248. protected _initialSizeParameter: number | {
  36249. width: number;
  36250. height: number;
  36251. } | {
  36252. ratio: number;
  36253. };
  36254. protected _sizeRatio: Nullable<number>;
  36255. _generateMipMaps: boolean;
  36256. protected _renderingManager: RenderingManager;
  36257. _waitingRenderList: string[];
  36258. protected _doNotChangeAspectRatio: boolean;
  36259. protected _currentRefreshId: number;
  36260. protected _refreshRate: number;
  36261. protected _textureMatrix: Matrix;
  36262. protected _samples: number;
  36263. protected _renderTargetOptions: RenderTargetCreationOptions;
  36264. readonly renderTargetOptions: RenderTargetCreationOptions;
  36265. protected _engine: Engine;
  36266. protected _onRatioRescale(): void;
  36267. /**
  36268. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  36269. * It must define where the camera used to render the texture is set
  36270. */
  36271. boundingBoxPosition: Vector3;
  36272. private _boundingBoxSize;
  36273. /**
  36274. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  36275. * When defined, the cubemap will switch to local mode
  36276. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  36277. * @example https://www.babylonjs-playground.com/#RNASML
  36278. */
  36279. boundingBoxSize: Vector3;
  36280. /**
  36281. * In case the RTT has been created with a depth texture, get the associated
  36282. * depth texture.
  36283. * Otherwise, return null.
  36284. */
  36285. depthStencilTexture: Nullable<InternalTexture>;
  36286. /**
  36287. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  36288. * or used a shadow, depth texture...
  36289. * @param name The friendly name of the texture
  36290. * @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)
  36291. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  36292. * @param generateMipMaps True if mip maps need to be generated after render.
  36293. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  36294. * @param type The type of the buffer in the RTT (int, half float, float...)
  36295. * @param isCube True if a cube texture needs to be created
  36296. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  36297. * @param generateDepthBuffer True to generate a depth buffer
  36298. * @param generateStencilBuffer True to generate a stencil buffer
  36299. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  36300. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  36301. */
  36302. constructor(name: string, size: number | {
  36303. width: number;
  36304. height: number;
  36305. } | {
  36306. ratio: number;
  36307. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  36308. /**
  36309. * Creates a depth stencil texture.
  36310. * This is only available in WebGL 2 or with the depth texture extension available.
  36311. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  36312. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  36313. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  36314. */
  36315. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  36316. private _processSizeParameter(size);
  36317. samples: number;
  36318. resetRefreshCounter(): void;
  36319. refreshRate: number;
  36320. addPostProcess(postProcess: PostProcess): void;
  36321. clearPostProcesses(dispose?: boolean): void;
  36322. removePostProcess(postProcess: PostProcess): void;
  36323. _shouldRender(): boolean;
  36324. getRenderSize(): number;
  36325. getRenderWidth(): number;
  36326. getRenderHeight(): number;
  36327. readonly canRescale: boolean;
  36328. scale(ratio: number): void;
  36329. getReflectionTextureMatrix(): Matrix;
  36330. resize(size: number | {
  36331. width: number;
  36332. height: number;
  36333. } | {
  36334. ratio: number;
  36335. }): void;
  36336. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  36337. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  36338. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  36339. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  36340. /**
  36341. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36342. * This allowed control for front to back rendering or reversly depending of the special needs.
  36343. *
  36344. * @param renderingGroupId The rendering group id corresponding to its index
  36345. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36346. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36347. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36348. */
  36349. 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;
  36350. /**
  36351. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36352. *
  36353. * @param renderingGroupId The rendering group id corresponding to its index
  36354. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36355. */
  36356. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  36357. clone(): RenderTargetTexture;
  36358. serialize(): any;
  36359. disposeFramebufferObjects(): void;
  36360. dispose(): void;
  36361. _rebuild(): void;
  36362. /**
  36363. * Clear the info related to rendering groups preventing retention point in material dispose.
  36364. */
  36365. freeRenderingGroups(): void;
  36366. }
  36367. }
  36368. declare module BABYLON {
  36369. class Texture extends BaseTexture {
  36370. static NEAREST_SAMPLINGMODE: number;
  36371. static NEAREST_NEAREST_MIPLINEAR: number;
  36372. static BILINEAR_SAMPLINGMODE: number;
  36373. static LINEAR_LINEAR_MIPNEAREST: number;
  36374. static TRILINEAR_SAMPLINGMODE: number;
  36375. static LINEAR_LINEAR_MIPLINEAR: number;
  36376. static NEAREST_NEAREST_MIPNEAREST: number;
  36377. static NEAREST_LINEAR_MIPNEAREST: number;
  36378. static NEAREST_LINEAR_MIPLINEAR: number;
  36379. static NEAREST_LINEAR: number;
  36380. static NEAREST_NEAREST: number;
  36381. static LINEAR_NEAREST_MIPNEAREST: number;
  36382. static LINEAR_NEAREST_MIPLINEAR: number;
  36383. static LINEAR_LINEAR: number;
  36384. static LINEAR_NEAREST: number;
  36385. static EXPLICIT_MODE: number;
  36386. static SPHERICAL_MODE: number;
  36387. static PLANAR_MODE: number;
  36388. static CUBIC_MODE: number;
  36389. static PROJECTION_MODE: number;
  36390. static SKYBOX_MODE: number;
  36391. static INVCUBIC_MODE: number;
  36392. static EQUIRECTANGULAR_MODE: number;
  36393. static FIXED_EQUIRECTANGULAR_MODE: number;
  36394. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36395. static readonly CLAMP_ADDRESSMODE: number;
  36396. static readonly WRAP_ADDRESSMODE: number;
  36397. static readonly MIRROR_ADDRESSMODE: number;
  36398. /**
  36399. * 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
  36400. */
  36401. static UseSerializedUrlIfAny: boolean;
  36402. url: Nullable<string>;
  36403. uOffset: number;
  36404. vOffset: number;
  36405. uScale: number;
  36406. vScale: number;
  36407. uAng: number;
  36408. vAng: number;
  36409. wAng: number;
  36410. /**
  36411. * Defines the center of rotation (U)
  36412. */
  36413. uRotationCenter: number;
  36414. /**
  36415. * Defines the center of rotation (V)
  36416. */
  36417. vRotationCenter: number;
  36418. /**
  36419. * Defines the center of rotation (W)
  36420. */
  36421. wRotationCenter: number;
  36422. readonly noMipmap: boolean;
  36423. private _noMipmap;
  36424. _invertY: boolean;
  36425. private _rowGenerationMatrix;
  36426. private _cachedTextureMatrix;
  36427. private _projectionModeMatrix;
  36428. private _t0;
  36429. private _t1;
  36430. private _t2;
  36431. private _cachedUOffset;
  36432. private _cachedVOffset;
  36433. private _cachedUScale;
  36434. private _cachedVScale;
  36435. private _cachedUAng;
  36436. private _cachedVAng;
  36437. private _cachedWAng;
  36438. private _cachedProjectionMatrixId;
  36439. private _cachedCoordinatesMode;
  36440. _samplingMode: number;
  36441. /** @hidden */
  36442. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  36443. private _deleteBuffer;
  36444. protected _format: Nullable<number>;
  36445. private _delayedOnLoad;
  36446. private _delayedOnError;
  36447. protected _onLoadObservable: Nullable<Observable<Texture>>;
  36448. protected _isBlocking: boolean;
  36449. isBlocking: boolean;
  36450. readonly samplingMode: number;
  36451. 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);
  36452. /**
  36453. * Update the url (and optional buffer) of this texture if url was null during construction.
  36454. * @param url the url of the texture
  36455. * @param buffer the buffer of the texture (defaults to null)
  36456. */
  36457. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  36458. delayLoad(): void;
  36459. updateSamplingMode(samplingMode: number): void;
  36460. private _prepareRowForTextureGeneration(x, y, z, t);
  36461. getTextureMatrix(): Matrix;
  36462. getReflectionTextureMatrix(): Matrix;
  36463. clone(): Texture;
  36464. readonly onLoadObservable: Observable<Texture>;
  36465. serialize(): any;
  36466. getClassName(): string;
  36467. dispose(): void;
  36468. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  36469. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  36470. 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;
  36471. }
  36472. }
  36473. declare module BABYLON {
  36474. /**
  36475. * Settings for finer control over video usage
  36476. */
  36477. interface VideoTextureSettings {
  36478. /**
  36479. * Applies `autoplay` to video, if specified
  36480. */
  36481. autoPlay?: boolean;
  36482. /**
  36483. * Applies `loop` to video, if specified
  36484. */
  36485. loop?: boolean;
  36486. /**
  36487. * Automatically updates internal texture from video at every frame in the render loop
  36488. */
  36489. autoUpdateTexture: boolean;
  36490. /**
  36491. * Image src displayed during the video loading or until the user interacts with the video.
  36492. */
  36493. poster?: string;
  36494. }
  36495. class VideoTexture extends Texture {
  36496. /**
  36497. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36498. */
  36499. readonly autoUpdateTexture: boolean;
  36500. /**
  36501. * The video instance used by the texture internally
  36502. */
  36503. readonly video: HTMLVideoElement;
  36504. private _onUserActionRequestedObservable;
  36505. readonly onUserActionRequestedObservable: Observable<Texture>;
  36506. private _generateMipMaps;
  36507. private _engine;
  36508. private _stillImageCaptured;
  36509. private _poster;
  36510. /**
  36511. * Creates a video texture.
  36512. * Sample : https://doc.babylonjs.com/how_to/video_texture
  36513. * @param {string | null} name optional name, will detect from video source, if not defined
  36514. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  36515. * @param {BABYLON.Scene} scene is obviously the current scene.
  36516. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36517. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  36518. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36519. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  36520. */
  36521. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36522. private _getName(src);
  36523. private _getVideo(src);
  36524. private _createInternalTexture;
  36525. private reset;
  36526. /**
  36527. * Internal method to initiate `update`.
  36528. */
  36529. _rebuild(): void;
  36530. /**
  36531. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36532. */
  36533. update(): void;
  36534. /**
  36535. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36536. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36537. */
  36538. updateTexture(isVisible: boolean): void;
  36539. protected _updateInternalTexture: (e?: Event | undefined) => void;
  36540. /**
  36541. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36542. * @param url New url.
  36543. */
  36544. updateURL(url: string): void;
  36545. dispose(): void;
  36546. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36547. minWidth: number;
  36548. maxWidth: number;
  36549. minHeight: number;
  36550. maxHeight: number;
  36551. deviceId: string;
  36552. }): void;
  36553. }
  36554. }
  36555. declare var DracoDecoderModule: any;
  36556. declare var WebAssembly: any;
  36557. declare module BABYLON {
  36558. /**
  36559. * Configuration for Draco compression
  36560. */
  36561. interface IDracoCompressionConfiguration {
  36562. /**
  36563. * Configuration for the decoder.
  36564. */
  36565. decoder?: {
  36566. /**
  36567. * The url to the WebAssembly module.
  36568. */
  36569. wasmUrl?: string;
  36570. /**
  36571. * The url to the WebAssembly binary.
  36572. */
  36573. wasmBinaryUrl?: string;
  36574. /**
  36575. * The url to the fallback JavaScript module.
  36576. */
  36577. fallbackUrl?: string;
  36578. };
  36579. }
  36580. /**
  36581. * Draco compression (https://google.github.io/draco/)
  36582. *
  36583. * This class wraps the Draco module.
  36584. *
  36585. * **Encoder**
  36586. *
  36587. * The encoder is not currently implemented.
  36588. *
  36589. * **Decoder**
  36590. *
  36591. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  36592. *
  36593. * To update the configuration, use the following code:
  36594. * ```javascript
  36595. * BABYLON.DracoCompression.Configuration = {
  36596. * decoder: {
  36597. * wasmUrl: "<url to the WebAssembly library>",
  36598. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  36599. * fallbackUrl: "<url to the fallback JavaScript library>",
  36600. * }
  36601. * };
  36602. * ```
  36603. *
  36604. * 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.
  36605. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  36606. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  36607. *
  36608. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  36609. * ```javascript
  36610. * var dracoCompression = new BABYLON.DracoCompression();
  36611. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  36612. * [BABYLON.VertexBuffer.PositionKind]: 0
  36613. * });
  36614. * ```
  36615. *
  36616. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  36617. */
  36618. class DracoCompression implements IDisposable {
  36619. private static _DecoderModulePromise;
  36620. /**
  36621. * The configuration. Defaults to the following urls:
  36622. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  36623. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  36624. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  36625. */
  36626. static Configuration: IDracoCompressionConfiguration;
  36627. /**
  36628. * Returns true if the decoder is available.
  36629. */
  36630. static readonly DecoderAvailable: boolean;
  36631. /**
  36632. * Constructor
  36633. */
  36634. constructor();
  36635. /**
  36636. * Stop all async operations and release resources.
  36637. */
  36638. dispose(): void;
  36639. /**
  36640. * Decode Draco compressed mesh data to vertex data.
  36641. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  36642. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  36643. * @returns A promise that resolves with the decoded vertex data
  36644. */
  36645. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  36646. [kind: string]: number;
  36647. }): Promise<VertexData>;
  36648. private static _GetDecoderModule();
  36649. private static _LoadScriptAsync(url);
  36650. private static _LoadFileAsync(url);
  36651. }
  36652. }
  36653. declare module BABYLON {
  36654. class CannonJSPlugin implements IPhysicsEnginePlugin {
  36655. private _useDeltaForWorldStep;
  36656. world: any;
  36657. name: string;
  36658. private _physicsMaterials;
  36659. private _fixedTimeStep;
  36660. BJSCANNON: any;
  36661. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  36662. setGravity(gravity: Vector3): void;
  36663. setTimeStep(timeStep: number): void;
  36664. getTimeStep(): number;
  36665. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  36666. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36667. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36668. generatePhysicsBody(impostor: PhysicsImpostor): void;
  36669. private _processChildMeshes(mainImpostor);
  36670. removePhysicsBody(impostor: PhysicsImpostor): void;
  36671. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  36672. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  36673. private _addMaterial(name, friction, restitution);
  36674. private _checkWithEpsilon(value);
  36675. private _createShape(impostor);
  36676. private _createHeightmap(object, pointDepth?);
  36677. private _minus90X;
  36678. private _plus90X;
  36679. private _tmpPosition;
  36680. private _tmpDeltaPosition;
  36681. private _tmpUnityRotation;
  36682. private _updatePhysicsBodyTransformation(impostor);
  36683. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  36684. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  36685. isSupported(): boolean;
  36686. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36687. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36688. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36689. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36690. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  36691. getBodyMass(impostor: PhysicsImpostor): number;
  36692. getBodyFriction(impostor: PhysicsImpostor): number;
  36693. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  36694. getBodyRestitution(impostor: PhysicsImpostor): number;
  36695. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  36696. sleepBody(impostor: PhysicsImpostor): void;
  36697. wakeUpBody(impostor: PhysicsImpostor): void;
  36698. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  36699. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  36700. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  36701. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  36702. getRadius(impostor: PhysicsImpostor): number;
  36703. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  36704. dispose(): void;
  36705. private _extendNamespace();
  36706. }
  36707. }
  36708. declare module BABYLON {
  36709. class OimoJSPlugin implements IPhysicsEnginePlugin {
  36710. world: any;
  36711. name: string;
  36712. BJSOIMO: any;
  36713. constructor(iterations?: number);
  36714. setGravity(gravity: Vector3): void;
  36715. setTimeStep(timeStep: number): void;
  36716. getTimeStep(): number;
  36717. private _tmpImpostorsArray;
  36718. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  36719. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36720. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  36721. generatePhysicsBody(impostor: PhysicsImpostor): void;
  36722. private _tmpPositionVector;
  36723. removePhysicsBody(impostor: PhysicsImpostor): void;
  36724. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  36725. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  36726. isSupported(): boolean;
  36727. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  36728. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  36729. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36730. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  36731. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36732. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  36733. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  36734. getBodyMass(impostor: PhysicsImpostor): number;
  36735. getBodyFriction(impostor: PhysicsImpostor): number;
  36736. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  36737. getBodyRestitution(impostor: PhysicsImpostor): number;
  36738. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  36739. sleepBody(impostor: PhysicsImpostor): void;
  36740. wakeUpBody(impostor: PhysicsImpostor): void;
  36741. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  36742. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  36743. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  36744. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  36745. getRadius(impostor: PhysicsImpostor): number;
  36746. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  36747. dispose(): void;
  36748. }
  36749. }
  36750. declare module BABYLON {
  36751. /**
  36752. * Particle emitter emitting particles from the inside of a box.
  36753. * It emits the particles randomly between 2 given directions.
  36754. */
  36755. class BoxParticleEmitter implements IParticleEmitterType {
  36756. /**
  36757. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  36758. */
  36759. direction1: Vector3;
  36760. /**
  36761. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  36762. */
  36763. direction2: Vector3;
  36764. /**
  36765. * 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.
  36766. */
  36767. minEmitBox: Vector3;
  36768. /**
  36769. * 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.
  36770. */
  36771. maxEmitBox: Vector3;
  36772. /**
  36773. * Creates a new instance BoxParticleEmitter
  36774. */
  36775. constructor();
  36776. /**
  36777. * Called by the particle System when the direction is computed for the created particle.
  36778. * @param worldMatrix is the world matrix of the particle system
  36779. * @param directionToUpdate is the direction vector to update with the result
  36780. * @param particle is the particle we are computed the direction for
  36781. */
  36782. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36783. /**
  36784. * Called by the particle System when the position is computed for the created particle.
  36785. * @param worldMatrix is the world matrix of the particle system
  36786. * @param positionToUpdate is the position vector to update with the result
  36787. * @param particle is the particle we are computed the position for
  36788. */
  36789. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  36790. /**
  36791. * Clones the current emitter and returns a copy of it
  36792. * @returns the new emitter
  36793. */
  36794. clone(): BoxParticleEmitter;
  36795. /**
  36796. * Called by the GPUParticleSystem to setup the update shader
  36797. * @param effect defines the update shader
  36798. */
  36799. applyToShader(effect: Effect): void;
  36800. /**
  36801. * Returns a string to use to update the GPU particles update shader
  36802. * @returns a string containng the defines string
  36803. */
  36804. getEffectDefines(): string;
  36805. /**
  36806. * Returns the string "BoxParticleEmitter"
  36807. * @returns a string containing the class name
  36808. */
  36809. getClassName(): string;
  36810. /**
  36811. * Serializes the particle system to a JSON object.
  36812. * @returns the JSON object
  36813. */
  36814. serialize(): any;
  36815. /**
  36816. * Parse properties from a JSON object
  36817. * @param serializationObject defines the JSON object
  36818. */
  36819. parse(serializationObject: any): void;
  36820. }
  36821. }
  36822. declare module BABYLON {
  36823. /**
  36824. * Particle emitter emitting particles from the inside of a cone.
  36825. * It emits the particles alongside the cone volume from the base to the particle.
  36826. * The emission direction might be randomized.
  36827. */
  36828. class ConeParticleEmitter implements IParticleEmitterType {
  36829. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  36830. directionRandomizer: number;
  36831. private _radius;
  36832. private _angle;
  36833. private _height;
  36834. /**
  36835. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  36836. */
  36837. radiusRange: number;
  36838. /**
  36839. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  36840. */
  36841. heightRange: number;
  36842. /**
  36843. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  36844. */
  36845. emitFromSpawnPointOnly: boolean;
  36846. /**
  36847. * Gets or sets the radius of the emission cone
  36848. */
  36849. radius: number;
  36850. /**
  36851. * Gets or sets the angle of the emission cone
  36852. */
  36853. angle: number;
  36854. private _buildHeight();
  36855. /**
  36856. * Creates a new instance ConeParticleEmitter
  36857. * @param radius the radius of the emission cone (1 by default)
  36858. * @param angles the cone base angle (PI by default)
  36859. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  36860. */
  36861. constructor(radius?: number, angle?: number,
  36862. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  36863. directionRandomizer?: number);
  36864. /**
  36865. * Called by the particle System when the direction is computed for the created particle.
  36866. * @param worldMatrix is the world matrix of the particle system
  36867. * @param directionToUpdate is the direction vector to update with the result
  36868. * @param particle is the particle we are computed the direction for
  36869. */
  36870. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  36871. /**
  36872. * Called by the particle System when the position is computed for the created particle.
  36873. * @param worldMatrix is the world matrix of the particle system
  36874. * @param positionToUpdate is the position vector to update with the result
  36875. * @param particle is the particle we are computed the position for
  36876. */
  36877. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  36878. /**
  36879. * Clones the current emitter and returns a copy of it
  36880. * @returns the new emitter
  36881. */
  36882. clone(): ConeParticleEmitter;
  36883. /**
  36884. * Called by the GPUParticleSystem to setup the update shader
  36885. * @param effect defines the update shader
  36886. */
  36887. applyToShader(effect: Effect): void;
  36888. /**
  36889. * Returns a string to use to update the GPU particles update shader
  36890. * @returns a string containng the defines string
  36891. */
  36892. getEffectDefines(): string;
  36893. /**
  36894. * Returns the string "ConeParticleEmitter"
  36895. * @returns a string containing the class name
  36896. */
  36897. getClassName(): string;
  36898. /**
  36899. * Serializes the particle system to a JSON object.
  36900. * @returns the JSON object
  36901. */
  36902. serialize(): any;
  36903. /**
  36904. * Parse properties from a JSON object
  36905. * @param serializationObject defines the JSON object
  36906. */
  36907. parse(serializationObject: any): void;
  36908. }
  36909. }
  36910. declare module BABYLON {
  36911. /**
  36912. * Particle emitter emitting particles from the inside of a hemisphere.
  36913. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  36914. */
  36915. class HemisphericParticleEmitter implements IParticleEmitterType {
  36916. /**
  36917. * The radius of the emission hemisphere.
  36918. */
  36919. radius: number;
  36920. /**
  36921. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  36922. */
  36923. radiusRange: number;
  36924. /**
  36925. * How much to randomize the particle direction [0-1].
  36926. */
  36927. directionRandomizer: number;
  36928. /**
  36929. * Creates a new instance HemisphericParticleEmitter
  36930. * @param radius the radius of the emission hemisphere (1 by default)
  36931. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  36932. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  36933. */
  36934. constructor(
  36935. /**
  36936. * The radius of the emission hemisphere.
  36937. */
  36938. radius?: number,
  36939. /**
  36940. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  36941. */
  36942. radiusRange?: number,
  36943. /**
  36944. * How much to randomize the particle direction [0-1].
  36945. */
  36946. directionRandomizer?: number);
  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(): HemisphericParticleEmitter;
  36966. /**
  36967. * Called by the {BABYLON.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 "HemisphericParticleEmitter"
  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 represents a volume emitting particles.
  36996. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  36997. */
  36998. interface IParticleEmitterType {
  36999. /**
  37000. * Called by the particle System when the direction is computed for the created particle.
  37001. * @param worldMatrix is the world matrix of the particle system
  37002. * @param directionToUpdate is the direction vector to update with the result
  37003. * @param particle is the particle we are computed the direction for
  37004. */
  37005. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37006. /**
  37007. * Called by the particle System when the position is computed for the created particle.
  37008. * @param worldMatrix is the world matrix of the particle system
  37009. * @param positionToUpdate is the position vector to update with the result
  37010. * @param particle is the particle we are computed the position for
  37011. */
  37012. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37013. /**
  37014. * Clones the current emitter and returns a copy of it
  37015. * @returns the new emitter
  37016. */
  37017. clone(): IParticleEmitterType;
  37018. /**
  37019. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  37020. * @param effect defines the update shader
  37021. */
  37022. applyToShader(effect: Effect): void;
  37023. /**
  37024. * Returns a string to use to update the GPU particles update shader
  37025. * @returns the effect defines string
  37026. */
  37027. getEffectDefines(): string;
  37028. /**
  37029. * Returns a string representing the class name
  37030. * @returns a string containing the class name
  37031. */
  37032. getClassName(): string;
  37033. /**
  37034. * Serializes the particle system to a JSON object.
  37035. * @returns the JSON object
  37036. */
  37037. serialize(): any;
  37038. /**
  37039. * Parse properties from a JSON object
  37040. * @param serializationObject defines the JSON object
  37041. */
  37042. parse(serializationObject: any): void;
  37043. }
  37044. }
  37045. declare module BABYLON {
  37046. /**
  37047. * Particle emitter emitting particles from a point.
  37048. * It emits the particles randomly between 2 given directions.
  37049. */
  37050. class PointParticleEmitter implements IParticleEmitterType {
  37051. /**
  37052. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37053. */
  37054. direction1: Vector3;
  37055. /**
  37056. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  37057. */
  37058. direction2: Vector3;
  37059. /**
  37060. * Creates a new instance PointParticleEmitter
  37061. */
  37062. constructor();
  37063. /**
  37064. * Called by the particle System when the direction is computed for the created particle.
  37065. * @param worldMatrix is the world matrix of the particle system
  37066. * @param directionToUpdate is the direction vector to update with the result
  37067. * @param particle is the particle we are computed the direction for
  37068. */
  37069. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37070. /**
  37071. * Called by the particle System when the position is computed for the created particle.
  37072. * @param worldMatrix is the world matrix of the particle system
  37073. * @param positionToUpdate is the position vector to update with the result
  37074. * @param particle is the particle we are computed the position for
  37075. */
  37076. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37077. /**
  37078. * Clones the current emitter and returns a copy of it
  37079. * @returns the new emitter
  37080. */
  37081. clone(): PointParticleEmitter;
  37082. /**
  37083. * Called by the GPUParticleSystem to setup the update shader
  37084. * @param effect defines the update shader
  37085. */
  37086. applyToShader(effect: Effect): void;
  37087. /**
  37088. * Returns a string to use to update the GPU particles update shader
  37089. * @returns a string containng the defines string
  37090. */
  37091. getEffectDefines(): string;
  37092. /**
  37093. * Returns the string "PointParticleEmitter"
  37094. * @returns a string containing the class name
  37095. */
  37096. getClassName(): string;
  37097. /**
  37098. * Serializes the particle system to a JSON object.
  37099. * @returns the JSON object
  37100. */
  37101. serialize(): any;
  37102. /**
  37103. * Parse properties from a JSON object
  37104. * @param serializationObject defines the JSON object
  37105. */
  37106. parse(serializationObject: any): void;
  37107. }
  37108. }
  37109. declare module BABYLON {
  37110. /**
  37111. * Particle emitter emitting particles from the inside of a sphere.
  37112. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  37113. */
  37114. class SphereParticleEmitter implements IParticleEmitterType {
  37115. /**
  37116. * The radius of the emission sphere.
  37117. */
  37118. radius: number;
  37119. /**
  37120. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  37121. */
  37122. radiusRange: number;
  37123. /**
  37124. * How much to randomize the particle direction [0-1].
  37125. */
  37126. directionRandomizer: number;
  37127. /**
  37128. * Creates a new instance SphereParticleEmitter
  37129. * @param radius the radius of the emission sphere (1 by default)
  37130. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  37131. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  37132. */
  37133. constructor(
  37134. /**
  37135. * The radius of the emission sphere.
  37136. */
  37137. radius?: number,
  37138. /**
  37139. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  37140. */
  37141. radiusRange?: number,
  37142. /**
  37143. * How much to randomize the particle direction [0-1].
  37144. */
  37145. directionRandomizer?: number);
  37146. /**
  37147. * Called by the particle System when the direction is computed for the created particle.
  37148. * @param worldMatrix is the world matrix of the particle system
  37149. * @param directionToUpdate is the direction vector to update with the result
  37150. * @param particle is the particle we are computed the direction for
  37151. */
  37152. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37153. /**
  37154. * Called by the particle System when the position is computed for the created particle.
  37155. * @param worldMatrix is the world matrix of the particle system
  37156. * @param positionToUpdate is the position vector to update with the result
  37157. * @param particle is the particle we are computed the position for
  37158. */
  37159. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  37160. /**
  37161. * Clones the current emitter and returns a copy of it
  37162. * @returns the new emitter
  37163. */
  37164. clone(): SphereParticleEmitter;
  37165. /**
  37166. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  37167. * @param effect defines the update shader
  37168. */
  37169. applyToShader(effect: Effect): void;
  37170. /**
  37171. * Returns a string to use to update the GPU particles update shader
  37172. * @returns a string containng the defines string
  37173. */
  37174. getEffectDefines(): string;
  37175. /**
  37176. * Returns the string "SphereParticleEmitter"
  37177. * @returns a string containing the class name
  37178. */
  37179. getClassName(): string;
  37180. /**
  37181. * Serializes the particle system to a JSON object.
  37182. * @returns the JSON object
  37183. */
  37184. serialize(): any;
  37185. /**
  37186. * Parse properties from a JSON object
  37187. * @param serializationObject defines the JSON object
  37188. */
  37189. parse(serializationObject: any): void;
  37190. }
  37191. /**
  37192. * Particle emitter emitting particles from the inside of a sphere.
  37193. * It emits the particles randomly between two vectors.
  37194. */
  37195. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  37196. /**
  37197. * The min limit of the emission direction.
  37198. */
  37199. direction1: Vector3;
  37200. /**
  37201. * The max limit of the emission direction.
  37202. */
  37203. direction2: Vector3;
  37204. /**
  37205. * Creates a new instance SphereDirectedParticleEmitter
  37206. * @param radius the radius of the emission sphere (1 by default)
  37207. * @param direction1 the min limit of the emission direction (up vector by default)
  37208. * @param direction2 the max limit of the emission direction (up vector by default)
  37209. */
  37210. constructor(radius?: number,
  37211. /**
  37212. * The min limit of the emission direction.
  37213. */
  37214. direction1?: Vector3,
  37215. /**
  37216. * The max limit of the emission direction.
  37217. */
  37218. direction2?: Vector3);
  37219. /**
  37220. * Called by the particle System when the direction is computed for the created particle.
  37221. * @param worldMatrix is the world matrix of the particle system
  37222. * @param directionToUpdate is the direction vector to update with the result
  37223. * @param particle is the particle we are computed the direction for
  37224. */
  37225. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  37226. /**
  37227. * Clones the current emitter and returns a copy of it
  37228. * @returns the new emitter
  37229. */
  37230. clone(): SphereDirectedParticleEmitter;
  37231. /**
  37232. * Called by the GPUParticleSystem to setup the update shader
  37233. * @param effect defines the update shader
  37234. */
  37235. applyToShader(effect: Effect): void;
  37236. /**
  37237. * Returns a string to use to update the GPU particles update shader
  37238. * @returns a string containng the defines string
  37239. */
  37240. getEffectDefines(): string;
  37241. /**
  37242. * Returns the string "SphereDirectedParticleEmitter"
  37243. * @returns a string containing the class name
  37244. */
  37245. getClassName(): string;
  37246. /**
  37247. * Serializes the particle system to a JSON object.
  37248. * @returns the JSON object
  37249. */
  37250. serialize(): any;
  37251. /**
  37252. * Parse properties from a JSON object
  37253. * @param serializationObject defines the JSON object
  37254. */
  37255. parse(serializationObject: any): void;
  37256. }
  37257. }
  37258. declare module BABYLON {
  37259. /**
  37260. * This represents a set of one or more post processes in Babylon.
  37261. * A post process can be used to apply a shader to a texture after it is rendered.
  37262. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  37263. */
  37264. class PostProcessRenderEffect {
  37265. private _postProcesses;
  37266. private _getPostProcesses;
  37267. private _singleInstance;
  37268. private _cameras;
  37269. private _indicesForCamera;
  37270. /**
  37271. * Name of the effect
  37272. */
  37273. _name: string;
  37274. /**
  37275. * Instantiates a post process render effect.
  37276. * A post process can be used to apply a shader to a texture after it is rendered.
  37277. * @param engine The engine the effect is tied to
  37278. * @param name The name of the effect
  37279. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  37280. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  37281. */
  37282. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  37283. /**
  37284. * Checks if all the post processes in the effect are supported.
  37285. */
  37286. readonly isSupported: boolean;
  37287. /**
  37288. * Updates the current state of the effect
  37289. */
  37290. _update(): void;
  37291. /**
  37292. * Attaches the effect on cameras
  37293. * @param cameras The camera to attach to.
  37294. */
  37295. _attachCameras(cameras: Camera): void;
  37296. /**
  37297. * Attaches the effect on cameras
  37298. * @param cameras The camera to attach to.
  37299. */
  37300. _attachCameras(cameras: Camera[]): void;
  37301. /**
  37302. * Detatches the effect on cameras
  37303. * @param cameras The camera to detatch from.
  37304. */
  37305. _detachCameras(cameras: Camera): void;
  37306. /**
  37307. * Detatches the effect on cameras
  37308. * @param cameras The camera to detatch from.
  37309. */
  37310. _detachCameras(cameras: Camera[]): void;
  37311. /**
  37312. * Enables the effect on given cameras
  37313. * @param cameras The camera to enable.
  37314. */
  37315. _enable(cameras: Camera): void;
  37316. /**
  37317. * Enables the effect on given cameras
  37318. * @param cameras The camera to enable.
  37319. */
  37320. _enable(cameras: Nullable<Camera[]>): void;
  37321. /**
  37322. * Disables the effect on the given cameras
  37323. * @param cameras The camera to disable.
  37324. */
  37325. _disable(cameras: Camera): void;
  37326. /**
  37327. * Disables the effect on the given cameras
  37328. * @param cameras The camera to disable.
  37329. */
  37330. _disable(cameras: Nullable<Camera[]>): void;
  37331. /**
  37332. * Gets a list of the post processes contained in the effect.
  37333. * @param camera The camera to get the post processes on.
  37334. * @returns The list of the post processes in the effect.
  37335. */
  37336. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  37337. }
  37338. }
  37339. declare module BABYLON {
  37340. class PostProcessRenderPipeline {
  37341. private engine;
  37342. private _renderEffects;
  37343. private _renderEffectsForIsolatedPass;
  37344. protected _cameras: Camera[];
  37345. _name: string;
  37346. constructor(engine: Engine, name: string);
  37347. getClassName(): string;
  37348. readonly isSupported: boolean;
  37349. addEffect(renderEffect: PostProcessRenderEffect): void;
  37350. _rebuild(): void;
  37351. _enableEffect(renderEffectName: string, cameras: Camera): void;
  37352. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  37353. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  37354. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  37355. _attachCameras(cameras: Camera, unique: boolean): void;
  37356. _attachCameras(cameras: Camera[], unique: boolean): void;
  37357. _detachCameras(cameras: Camera): void;
  37358. _detachCameras(cameras: Nullable<Camera[]>): void;
  37359. _update(): void;
  37360. _reset(): void;
  37361. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  37362. dispose(): void;
  37363. }
  37364. }
  37365. declare module BABYLON {
  37366. class PostProcessRenderPipelineManager {
  37367. private _renderPipelines;
  37368. constructor();
  37369. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  37370. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  37371. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  37372. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  37373. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  37374. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  37375. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  37376. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  37377. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  37378. update(): void;
  37379. _rebuild(): void;
  37380. dispose(): void;
  37381. }
  37382. }
  37383. declare module BABYLON {
  37384. /**
  37385. * Helper class dealing with the extraction of spherical polynomial dataArray
  37386. * from a cube map.
  37387. */
  37388. class CubeMapToSphericalPolynomialTools {
  37389. private static FileFaces;
  37390. /**
  37391. * Converts a texture to the according Spherical Polynomial data.
  37392. * This extracts the first 3 orders only as they are the only one used in the lighting.
  37393. *
  37394. * @param texture The texture to extract the information from.
  37395. * @return The Spherical Polynomial data.
  37396. */
  37397. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  37398. /**
  37399. * Converts a cubemap to the according Spherical Polynomial data.
  37400. * This extracts the first 3 orders only as they are the only one used in the lighting.
  37401. *
  37402. * @param cubeInfo The Cube map to extract the information from.
  37403. * @return The Spherical Polynomial data.
  37404. */
  37405. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  37406. }
  37407. }
  37408. declare module BABYLON {
  37409. /**
  37410. * Header information of HDR texture files.
  37411. */
  37412. interface HDRInfo {
  37413. /**
  37414. * The height of the texture in pixels.
  37415. */
  37416. height: number;
  37417. /**
  37418. * The width of the texture in pixels.
  37419. */
  37420. width: number;
  37421. /**
  37422. * The index of the beginning of the data in the binary file.
  37423. */
  37424. dataPosition: number;
  37425. }
  37426. /**
  37427. * This groups tools to convert HDR texture to native colors array.
  37428. */
  37429. class HDRTools {
  37430. private static Ldexp(mantissa, exponent);
  37431. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  37432. private static readStringLine(uint8array, startIndex);
  37433. /**
  37434. * Reads header information from an RGBE texture stored in a native array.
  37435. * More information on this format are available here:
  37436. * https://en.wikipedia.org/wiki/RGBE_image_format
  37437. *
  37438. * @param uint8array The binary file stored in native array.
  37439. * @return The header information.
  37440. */
  37441. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  37442. /**
  37443. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  37444. * This RGBE texture needs to store the information as a panorama.
  37445. *
  37446. * More information on this format are available here:
  37447. * https://en.wikipedia.org/wiki/RGBE_image_format
  37448. *
  37449. * @param buffer The binary file stored in an array buffer.
  37450. * @param size The expected size of the extracted cubemap.
  37451. * @return The Cube Map information.
  37452. */
  37453. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  37454. /**
  37455. * Returns the pixels data extracted from an RGBE texture.
  37456. * This pixels will be stored left to right up to down in the R G B order in one array.
  37457. *
  37458. * More information on this format are available here:
  37459. * https://en.wikipedia.org/wiki/RGBE_image_format
  37460. *
  37461. * @param uint8array The binary file stored in an array buffer.
  37462. * @param hdrInfo The header information of the file.
  37463. * @return The pixels data in RGB right to left up to down order.
  37464. */
  37465. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  37466. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  37467. }
  37468. }
  37469. declare module BABYLON {
  37470. /**
  37471. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  37472. */
  37473. interface CubeMapInfo {
  37474. /**
  37475. * The pixel array for the front face.
  37476. * This is stored in format, left to right, up to down format.
  37477. */
  37478. front: Nullable<ArrayBufferView>;
  37479. /**
  37480. * The pixel array for the back face.
  37481. * This is stored in format, left to right, up to down format.
  37482. */
  37483. back: Nullable<ArrayBufferView>;
  37484. /**
  37485. * The pixel array for the left face.
  37486. * This is stored in format, left to right, up to down format.
  37487. */
  37488. left: Nullable<ArrayBufferView>;
  37489. /**
  37490. * The pixel array for the right face.
  37491. * This is stored in format, left to right, up to down format.
  37492. */
  37493. right: Nullable<ArrayBufferView>;
  37494. /**
  37495. * The pixel array for the up face.
  37496. * This is stored in format, left to right, up to down format.
  37497. */
  37498. up: Nullable<ArrayBufferView>;
  37499. /**
  37500. * The pixel array for the down face.
  37501. * This is stored in format, left to right, up to down format.
  37502. */
  37503. down: Nullable<ArrayBufferView>;
  37504. /**
  37505. * The size of the cubemap stored.
  37506. *
  37507. * Each faces will be size * size pixels.
  37508. */
  37509. size: number;
  37510. /**
  37511. * The format of the texture.
  37512. *
  37513. * RGBA, RGB.
  37514. */
  37515. format: number;
  37516. /**
  37517. * The type of the texture data.
  37518. *
  37519. * UNSIGNED_INT, FLOAT.
  37520. */
  37521. type: number;
  37522. /**
  37523. * Specifies whether the texture is in gamma space.
  37524. */
  37525. gammaSpace: boolean;
  37526. }
  37527. /**
  37528. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  37529. */
  37530. class PanoramaToCubeMapTools {
  37531. private static FACE_FRONT;
  37532. private static FACE_BACK;
  37533. private static FACE_RIGHT;
  37534. private static FACE_LEFT;
  37535. private static FACE_DOWN;
  37536. private static FACE_UP;
  37537. /**
  37538. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  37539. *
  37540. * @param float32Array The source data.
  37541. * @param inputWidth The width of the input panorama.
  37542. * @param inputhHeight The height of the input panorama.
  37543. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  37544. * @return The cubemap data
  37545. */
  37546. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  37547. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  37548. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  37549. }
  37550. }
  37551. declare module BABYLON {
  37552. }
  37553. declare module BABYLON {
  37554. }
  37555. declare module BABYLON {
  37556. }
  37557. declare module BABYLON {
  37558. }
  37559. declare module BABYLON {
  37560. class CustomProceduralTexture extends ProceduralTexture {
  37561. private _animate;
  37562. private _time;
  37563. private _config;
  37564. private _texturePath;
  37565. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  37566. private loadJson(jsonUrl);
  37567. isReady(): boolean;
  37568. render(useCameraPostProcess?: boolean): void;
  37569. updateTextures(): void;
  37570. updateShaderUniforms(): void;
  37571. animate: boolean;
  37572. }
  37573. }
  37574. declare module BABYLON {
  37575. /**
  37576. * Class used to generate noise procedural textures
  37577. */
  37578. class NoiseProceduralTexture extends ProceduralTexture {
  37579. private _time;
  37580. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  37581. brightness: number;
  37582. /** Defines the number of octaves to process */
  37583. octaves: number;
  37584. /** Defines the level of persistence (0.8 by default) */
  37585. persistence: number;
  37586. /** Gets or sets animation speed factor (default is 1) */
  37587. animationSpeedFactor: number;
  37588. /**
  37589. * Creates a new NoiseProceduralTexture
  37590. * @param name defines the name fo the texture
  37591. * @param size defines the size of the texture (default is 256)
  37592. * @param scene defines the hosting scene
  37593. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  37594. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  37595. */
  37596. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  37597. private _updateShaderUniforms();
  37598. /** Generate the current state of the procedural texture */
  37599. render(useCameraPostProcess?: boolean): void;
  37600. /**
  37601. * Serializes this noise procedural texture
  37602. * @returns a serialized noise procedural texture object
  37603. */
  37604. serialize(): any;
  37605. /**
  37606. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  37607. * @param parsedTexture defines parsed texture data
  37608. * @param scene defines the current scene
  37609. * @param rootUrl defines the root URL containing noise procedural texture information
  37610. * @returns a parsed NoiseProceduralTexture
  37611. */
  37612. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  37613. }
  37614. }
  37615. declare module BABYLON {
  37616. class ProceduralTexture extends Texture {
  37617. isCube: boolean;
  37618. private _size;
  37619. _generateMipMaps: boolean;
  37620. isEnabled: boolean;
  37621. private _currentRefreshId;
  37622. private _refreshRate;
  37623. onGenerated: () => void;
  37624. private _vertexBuffers;
  37625. private _indexBuffer;
  37626. private _effect;
  37627. private _uniforms;
  37628. private _samplers;
  37629. private _fragment;
  37630. _textures: {
  37631. [key: string]: Texture;
  37632. };
  37633. private _floats;
  37634. private _ints;
  37635. private _floatsArrays;
  37636. private _colors3;
  37637. private _colors4;
  37638. private _vectors2;
  37639. private _vectors3;
  37640. private _matrices;
  37641. private _fallbackTexture;
  37642. private _fallbackTextureUsed;
  37643. private _engine;
  37644. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  37645. private _createIndexBuffer();
  37646. _rebuild(): void;
  37647. reset(): void;
  37648. isReady(): boolean;
  37649. resetRefreshCounter(): void;
  37650. setFragment(fragment: any): void;
  37651. refreshRate: number;
  37652. _shouldRender(): boolean;
  37653. getRenderSize(): number;
  37654. resize(size: number, generateMipMaps: boolean): void;
  37655. private _checkUniform(uniformName);
  37656. setTexture(name: string, texture: Texture): ProceduralTexture;
  37657. setFloat(name: string, value: number): ProceduralTexture;
  37658. /**
  37659. * Set the value of an uniform to an integer value
  37660. * @param name defines the name of the uniform
  37661. * @param value defines the value to set
  37662. * @returns the current procedural texture
  37663. */
  37664. setInt(name: string, value: number): ProceduralTexture;
  37665. setFloats(name: string, value: number[]): ProceduralTexture;
  37666. setColor3(name: string, value: Color3): ProceduralTexture;
  37667. setColor4(name: string, value: Color4): ProceduralTexture;
  37668. setVector2(name: string, value: Vector2): ProceduralTexture;
  37669. setVector3(name: string, value: Vector3): ProceduralTexture;
  37670. setMatrix(name: string, value: Matrix): ProceduralTexture;
  37671. render(useCameraPostProcess?: boolean): void;
  37672. clone(): ProceduralTexture;
  37673. dispose(): void;
  37674. }
  37675. }
  37676. declare module BABYLON {
  37677. /**
  37678. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  37679. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  37680. */
  37681. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  37682. private _scene;
  37683. private _camerasToBeAttached;
  37684. /**
  37685. * ID of the sharpen post process,
  37686. */
  37687. private readonly SharpenPostProcessId;
  37688. /**
  37689. * ID of the image processing post process;
  37690. */
  37691. readonly ImageProcessingPostProcessId: string;
  37692. /**
  37693. * ID of the Fast Approximate Anti-Aliasing post process;
  37694. */
  37695. readonly FxaaPostProcessId: string;
  37696. /**
  37697. * ID of the chromatic aberration post process,
  37698. */
  37699. private readonly ChromaticAberrationPostProcessId;
  37700. /**
  37701. * ID of the grain post process
  37702. */
  37703. private readonly GrainPostProcessId;
  37704. /**
  37705. * Sharpen post process which will apply a sharpen convolution to enhance edges
  37706. */
  37707. sharpen: SharpenPostProcess;
  37708. private _sharpenEffect;
  37709. private bloom;
  37710. /**
  37711. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  37712. */
  37713. depthOfField: DepthOfFieldEffect;
  37714. /**
  37715. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  37716. */
  37717. fxaa: FxaaPostProcess;
  37718. /**
  37719. * Image post processing pass used to perform operations such as tone mapping or color grading.
  37720. */
  37721. imageProcessing: ImageProcessingPostProcess;
  37722. /**
  37723. * Chromatic aberration post process which will shift rgb colors in the image
  37724. */
  37725. chromaticAberration: ChromaticAberrationPostProcess;
  37726. private _chromaticAberrationEffect;
  37727. /**
  37728. * Grain post process which add noise to the image
  37729. */
  37730. grain: GrainPostProcess;
  37731. private _grainEffect;
  37732. /**
  37733. * Glow post process which adds a glow to emmisive areas of the image
  37734. */
  37735. private _glowLayer;
  37736. /**
  37737. * Animations which can be used to tweak settings over a period of time
  37738. */
  37739. animations: Animation[];
  37740. private _imageProcessingConfigurationObserver;
  37741. private _sharpenEnabled;
  37742. private _bloomEnabled;
  37743. private _depthOfFieldEnabled;
  37744. private _depthOfFieldBlurLevel;
  37745. private _fxaaEnabled;
  37746. private _imageProcessingEnabled;
  37747. private _defaultPipelineTextureType;
  37748. private _bloomScale;
  37749. private _chromaticAberrationEnabled;
  37750. private _grainEnabled;
  37751. private _buildAllowed;
  37752. /**
  37753. * Enable or disable the sharpen process from the pipeline
  37754. */
  37755. sharpenEnabled: boolean;
  37756. private _resizeObserver;
  37757. private _hardwareScaleLevel;
  37758. private _bloomKernel;
  37759. /**
  37760. * Specifies the size of the bloom blur kernel, relative to the final output size
  37761. */
  37762. bloomKernel: number;
  37763. /**
  37764. * Specifies the weight of the bloom in the final rendering
  37765. */
  37766. private _bloomWeight;
  37767. /**
  37768. * Specifies the luma threshold for the area that will be blurred by the bloom
  37769. */
  37770. private _bloomThreshold;
  37771. private _hdr;
  37772. /**
  37773. * The strength of the bloom.
  37774. */
  37775. bloomWeight: number;
  37776. /**
  37777. * The strength of the bloom.
  37778. */
  37779. bloomThreshold: number;
  37780. /**
  37781. * The scale of the bloom, lower value will provide better performance.
  37782. */
  37783. bloomScale: number;
  37784. /**
  37785. * Enable or disable the bloom from the pipeline
  37786. */
  37787. bloomEnabled: boolean;
  37788. private _rebuildBloom();
  37789. /**
  37790. * If the depth of field is enabled.
  37791. */
  37792. depthOfFieldEnabled: boolean;
  37793. /**
  37794. * Blur level of the depth of field effect. (Higher blur will effect performance)
  37795. */
  37796. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  37797. /**
  37798. * If the anti aliasing is enabled.
  37799. */
  37800. fxaaEnabled: boolean;
  37801. private _samples;
  37802. /**
  37803. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  37804. */
  37805. samples: number;
  37806. /**
  37807. * If image processing is enabled.
  37808. */
  37809. imageProcessingEnabled: boolean;
  37810. /**
  37811. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  37812. */
  37813. glowLayerEnabled: boolean;
  37814. /**
  37815. * Enable or disable the chromaticAberration process from the pipeline
  37816. */
  37817. chromaticAberrationEnabled: boolean;
  37818. /**
  37819. * Enable or disable the grain process from the pipeline
  37820. */
  37821. grainEnabled: boolean;
  37822. /**
  37823. * @constructor
  37824. * @param {string} name - The rendering pipeline name (default: "")
  37825. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  37826. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  37827. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  37828. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  37829. */
  37830. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  37831. /**
  37832. * Force the compilation of the entire pipeline.
  37833. */
  37834. prepare(): void;
  37835. private _hasCleared;
  37836. private _prevPostProcess;
  37837. private _prevPrevPostProcess;
  37838. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  37839. private _buildPipeline();
  37840. private _disposePostProcesses(disposeNonRecreated?);
  37841. /**
  37842. * Adds a camera to the pipeline
  37843. * @param camera the camera to be added
  37844. */
  37845. addCamera(camera: Camera): void;
  37846. /**
  37847. * Removes a camera from the pipeline
  37848. * @param camera the camera to remove
  37849. */
  37850. removeCamera(camera: Camera): void;
  37851. /**
  37852. * Dispose of the pipeline and stop all post processes
  37853. */
  37854. dispose(): void;
  37855. /**
  37856. * Serialize the rendering pipeline (Used when exporting)
  37857. * @returns the serialized object
  37858. */
  37859. serialize(): any;
  37860. /**
  37861. * Parse the serialized pipeline
  37862. * @param source Source pipeline.
  37863. * @param scene The scene to load the pipeline to.
  37864. * @param rootUrl The URL of the serialized pipeline.
  37865. * @returns An instantiated pipeline from the serialized object.
  37866. */
  37867. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  37868. }
  37869. }
  37870. declare module BABYLON {
  37871. class LensRenderingPipeline extends PostProcessRenderPipeline {
  37872. /**
  37873. * The chromatic aberration PostProcess id in the pipeline
  37874. */
  37875. LensChromaticAberrationEffect: string;
  37876. /**
  37877. * The highlights enhancing PostProcess id in the pipeline
  37878. */
  37879. HighlightsEnhancingEffect: string;
  37880. /**
  37881. * The depth-of-field PostProcess id in the pipeline
  37882. */
  37883. LensDepthOfFieldEffect: string;
  37884. private _scene;
  37885. private _depthTexture;
  37886. private _grainTexture;
  37887. private _chromaticAberrationPostProcess;
  37888. private _highlightsPostProcess;
  37889. private _depthOfFieldPostProcess;
  37890. private _edgeBlur;
  37891. private _grainAmount;
  37892. private _chromaticAberration;
  37893. private _distortion;
  37894. private _highlightsGain;
  37895. private _highlightsThreshold;
  37896. private _dofDistance;
  37897. private _dofAperture;
  37898. private _dofDarken;
  37899. private _dofPentagon;
  37900. private _blurNoise;
  37901. /**
  37902. * @constructor
  37903. *
  37904. * Effect parameters are as follow:
  37905. * {
  37906. * chromatic_aberration: number; // from 0 to x (1 for realism)
  37907. * edge_blur: number; // from 0 to x (1 for realism)
  37908. * distortion: number; // from 0 to x (1 for realism)
  37909. * grain_amount: number; // from 0 to 1
  37910. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  37911. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  37912. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  37913. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  37914. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  37915. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  37916. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  37917. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  37918. * }
  37919. * Note: if an effect parameter is unset, effect is disabled
  37920. *
  37921. * @param {string} name - The rendering pipeline name
  37922. * @param {object} parameters - An object containing all parameters (see above)
  37923. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  37924. * @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)
  37925. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  37926. */
  37927. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  37928. setEdgeBlur(amount: number): void;
  37929. disableEdgeBlur(): void;
  37930. setGrainAmount(amount: number): void;
  37931. disableGrain(): void;
  37932. setChromaticAberration(amount: number): void;
  37933. disableChromaticAberration(): void;
  37934. setEdgeDistortion(amount: number): void;
  37935. disableEdgeDistortion(): void;
  37936. setFocusDistance(amount: number): void;
  37937. disableDepthOfField(): void;
  37938. setAperture(amount: number): void;
  37939. setDarkenOutOfFocus(amount: number): void;
  37940. enablePentagonBokeh(): void;
  37941. disablePentagonBokeh(): void;
  37942. enableNoiseBlur(): void;
  37943. disableNoiseBlur(): void;
  37944. setHighlightsGain(amount: number): void;
  37945. setHighlightsThreshold(amount: number): void;
  37946. disableHighlights(): void;
  37947. /**
  37948. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  37949. */
  37950. dispose(disableDepthRender?: boolean): void;
  37951. private _createChromaticAberrationPostProcess(ratio);
  37952. private _createHighlightsPostProcess(ratio);
  37953. private _createDepthOfFieldPostProcess(ratio);
  37954. private _createGrainTexture();
  37955. }
  37956. }
  37957. declare module BABYLON {
  37958. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  37959. /**
  37960. * The PassPostProcess id in the pipeline that contains the original scene color
  37961. */
  37962. SSAOOriginalSceneColorEffect: string;
  37963. /**
  37964. * The SSAO PostProcess id in the pipeline
  37965. */
  37966. SSAORenderEffect: string;
  37967. /**
  37968. * The horizontal blur PostProcess id in the pipeline
  37969. */
  37970. SSAOBlurHRenderEffect: string;
  37971. /**
  37972. * The vertical blur PostProcess id in the pipeline
  37973. */
  37974. SSAOBlurVRenderEffect: string;
  37975. /**
  37976. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  37977. */
  37978. SSAOCombineRenderEffect: string;
  37979. /**
  37980. * The output strength of the SSAO post-process. Default value is 1.0.
  37981. */
  37982. totalStrength: number;
  37983. /**
  37984. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  37985. */
  37986. maxZ: number;
  37987. /**
  37988. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  37989. */
  37990. minZAspect: number;
  37991. /**
  37992. * Number of samples used for the SSAO calculations. Default value is 8
  37993. */
  37994. private _samples;
  37995. /**
  37996. * Ratio object used for SSAO ratio and blur ratio
  37997. */
  37998. private _ratio;
  37999. /**
  38000. * Dynamically generated sphere sampler.
  38001. */
  38002. private _sampleSphere;
  38003. /**
  38004. * Blur filter offsets
  38005. */
  38006. private _samplerOffsets;
  38007. samples: number;
  38008. /**
  38009. * Are we using bilateral blur ?
  38010. */
  38011. private _expensiveBlur;
  38012. expensiveBlur: boolean;
  38013. /**
  38014. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  38015. */
  38016. radius: number;
  38017. /**
  38018. * The base color of the SSAO post-process
  38019. * The final result is "base + ssao" between [0, 1]
  38020. */
  38021. base: number;
  38022. /**
  38023. * Support test.
  38024. */
  38025. static readonly IsSupported: boolean;
  38026. private _scene;
  38027. private _depthTexture;
  38028. private _normalTexture;
  38029. private _randomTexture;
  38030. private _originalColorPostProcess;
  38031. private _ssaoPostProcess;
  38032. private _blurHPostProcess;
  38033. private _blurVPostProcess;
  38034. private _ssaoCombinePostProcess;
  38035. private _firstUpdate;
  38036. /**
  38037. * @constructor
  38038. * @param {string} name - The rendering pipeline name
  38039. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  38040. * @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 }
  38041. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  38042. */
  38043. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  38044. /**
  38045. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  38046. */
  38047. dispose(disableGeometryBufferRenderer?: boolean): void;
  38048. private _createBlurPostProcess(ssaoRatio, blurRatio);
  38049. _rebuild(): void;
  38050. private _generateHemisphere();
  38051. private _createSSAOPostProcess(ratio);
  38052. private _createSSAOCombinePostProcess(ratio);
  38053. private _createRandomTexture();
  38054. /**
  38055. * Serialize the rendering pipeline (Used when exporting)
  38056. * @returns the serialized object
  38057. */
  38058. serialize(): any;
  38059. /**
  38060. * Parse the serialized pipeline
  38061. * @param source Source pipeline.
  38062. * @param scene The scene to load the pipeline to.
  38063. * @param rootUrl The URL of the serialized pipeline.
  38064. * @returns An instantiated pipeline from the serialized object.
  38065. */
  38066. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  38067. }
  38068. }
  38069. declare module BABYLON {
  38070. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  38071. /**
  38072. * The PassPostProcess id in the pipeline that contains the original scene color
  38073. */
  38074. SSAOOriginalSceneColorEffect: string;
  38075. /**
  38076. * The SSAO PostProcess id in the pipeline
  38077. */
  38078. SSAORenderEffect: string;
  38079. /**
  38080. * The horizontal blur PostProcess id in the pipeline
  38081. */
  38082. SSAOBlurHRenderEffect: string;
  38083. /**
  38084. * The vertical blur PostProcess id in the pipeline
  38085. */
  38086. SSAOBlurVRenderEffect: string;
  38087. /**
  38088. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  38089. */
  38090. SSAOCombineRenderEffect: string;
  38091. /**
  38092. * The output strength of the SSAO post-process. Default value is 1.0.
  38093. */
  38094. totalStrength: number;
  38095. /**
  38096. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  38097. */
  38098. radius: number;
  38099. /**
  38100. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  38101. * Must not be equal to fallOff and superior to fallOff.
  38102. * Default value is 0.975
  38103. */
  38104. area: number;
  38105. /**
  38106. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  38107. * Must not be equal to area and inferior to area.
  38108. * Default value is 0.0
  38109. */
  38110. fallOff: number;
  38111. /**
  38112. * The base color of the SSAO post-process
  38113. * The final result is "base + ssao" between [0, 1]
  38114. */
  38115. base: number;
  38116. private _scene;
  38117. private _depthTexture;
  38118. private _randomTexture;
  38119. private _originalColorPostProcess;
  38120. private _ssaoPostProcess;
  38121. private _blurHPostProcess;
  38122. private _blurVPostProcess;
  38123. private _ssaoCombinePostProcess;
  38124. private _firstUpdate;
  38125. /**
  38126. * @constructor
  38127. * @param {string} name - The rendering pipeline name
  38128. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  38129. * @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 }
  38130. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  38131. */
  38132. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  38133. /**
  38134. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  38135. */
  38136. dispose(disableDepthRender?: boolean): void;
  38137. private _createBlurPostProcess(ratio);
  38138. _rebuild(): void;
  38139. private _createSSAOPostProcess(ratio);
  38140. private _createSSAOCombinePostProcess(ratio);
  38141. private _createRandomTexture();
  38142. }
  38143. }
  38144. declare module BABYLON {
  38145. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  38146. /**
  38147. * Public members
  38148. */
  38149. originalPostProcess: Nullable<PostProcess>;
  38150. downSampleX4PostProcess: Nullable<PostProcess>;
  38151. brightPassPostProcess: Nullable<PostProcess>;
  38152. blurHPostProcesses: PostProcess[];
  38153. blurVPostProcesses: PostProcess[];
  38154. textureAdderPostProcess: Nullable<PostProcess>;
  38155. volumetricLightPostProcess: Nullable<PostProcess>;
  38156. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  38157. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  38158. volumetricLightMergePostProces: Nullable<PostProcess>;
  38159. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  38160. luminancePostProcess: Nullable<PostProcess>;
  38161. luminanceDownSamplePostProcesses: PostProcess[];
  38162. hdrPostProcess: Nullable<PostProcess>;
  38163. textureAdderFinalPostProcess: Nullable<PostProcess>;
  38164. lensFlareFinalPostProcess: Nullable<PostProcess>;
  38165. hdrFinalPostProcess: Nullable<PostProcess>;
  38166. lensFlarePostProcess: Nullable<PostProcess>;
  38167. lensFlareComposePostProcess: Nullable<PostProcess>;
  38168. motionBlurPostProcess: Nullable<PostProcess>;
  38169. depthOfFieldPostProcess: Nullable<PostProcess>;
  38170. brightThreshold: number;
  38171. blurWidth: number;
  38172. horizontalBlur: boolean;
  38173. exposure: number;
  38174. lensTexture: Nullable<Texture>;
  38175. volumetricLightCoefficient: number;
  38176. volumetricLightPower: number;
  38177. volumetricLightBlurScale: number;
  38178. sourceLight: Nullable<SpotLight | DirectionalLight>;
  38179. hdrMinimumLuminance: number;
  38180. hdrDecreaseRate: number;
  38181. hdrIncreaseRate: number;
  38182. lensColorTexture: Nullable<Texture>;
  38183. lensFlareStrength: number;
  38184. lensFlareGhostDispersal: number;
  38185. lensFlareHaloWidth: number;
  38186. lensFlareDistortionStrength: number;
  38187. lensStarTexture: Nullable<Texture>;
  38188. lensFlareDirtTexture: Nullable<Texture>;
  38189. depthOfFieldDistance: number;
  38190. depthOfFieldBlurWidth: number;
  38191. motionStrength: number;
  38192. animations: Animation[];
  38193. /**
  38194. * Private members
  38195. */
  38196. private _scene;
  38197. private _currentDepthOfFieldSource;
  38198. private _basePostProcess;
  38199. private _hdrCurrentLuminance;
  38200. private _floatTextureType;
  38201. private _ratio;
  38202. private _bloomEnabled;
  38203. private _depthOfFieldEnabled;
  38204. private _vlsEnabled;
  38205. private _lensFlareEnabled;
  38206. private _hdrEnabled;
  38207. private _motionBlurEnabled;
  38208. private _motionBlurSamples;
  38209. private _volumetricLightStepsCount;
  38210. BloomEnabled: boolean;
  38211. DepthOfFieldEnabled: boolean;
  38212. LensFlareEnabled: boolean;
  38213. HDREnabled: boolean;
  38214. VLSEnabled: boolean;
  38215. MotionBlurEnabled: boolean;
  38216. volumetricLightStepsCount: number;
  38217. motionBlurSamples: number;
  38218. /**
  38219. * @constructor
  38220. * @param {string} name - The rendering pipeline name
  38221. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  38222. * @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)
  38223. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  38224. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  38225. */
  38226. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  38227. private _buildPipeline();
  38228. private _createDownSampleX4PostProcess(scene, ratio);
  38229. private _createBrightPassPostProcess(scene, ratio);
  38230. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  38231. private _createTextureAdderPostProcess(scene, ratio);
  38232. private _createVolumetricLightPostProcess(scene, ratio);
  38233. private _createLuminancePostProcesses(scene, textureType);
  38234. private _createHdrPostProcess(scene, ratio);
  38235. private _createLensFlarePostProcess(scene, ratio);
  38236. private _createDepthOfFieldPostProcess(scene, ratio);
  38237. private _createMotionBlurPostProcess(scene, ratio);
  38238. private _getDepthTexture();
  38239. private _disposePostProcesses();
  38240. /**
  38241. * Dispose of the pipeline and stop all post processes
  38242. */
  38243. dispose(): void;
  38244. /**
  38245. * Serialize the rendering pipeline (Used when exporting)
  38246. * @returns the serialized object
  38247. */
  38248. serialize(): any;
  38249. /**
  38250. * Parse the serialized pipeline
  38251. * @param source Source pipeline.
  38252. * @param scene The scene to load the pipeline to.
  38253. * @param rootUrl The URL of the serialized pipeline.
  38254. * @returns An instantiated pipeline from the serialized object.
  38255. */
  38256. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  38257. static LuminanceSteps: number;
  38258. }
  38259. }