babylon.d.ts 1.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Set of assets to keep when moving a scene into an asset container.
  7. */
  8. class KeepAssets {
  9. /**
  10. * Cameras to keep.
  11. */
  12. cameras: Camera[];
  13. /**
  14. * Lights to keep.
  15. */
  16. lights: Light[];
  17. /**
  18. * Meshes to keep.
  19. */
  20. meshes: AbstractMesh[];
  21. /**
  22. * Skeletons to keep.
  23. */
  24. skeletons: Skeleton[];
  25. /**
  26. * ParticleSystems to keep.
  27. */
  28. particleSystems: ParticleSystem[];
  29. /**
  30. * Animations to keep.
  31. */
  32. animations: Animation[];
  33. /**
  34. * MultiMaterials to keep.
  35. */
  36. multiMaterials: MultiMaterial[];
  37. /**
  38. * Materials to keep.
  39. */
  40. materials: Material[];
  41. /**
  42. * MorphTargetManagers to keep.
  43. */
  44. morphTargetManagers: MorphTargetManager[];
  45. /**
  46. * Geometries to keep.
  47. */
  48. geometries: Geometry[];
  49. /**
  50. * TransformNodes to keep.
  51. */
  52. transformNodes: TransformNode[];
  53. /**
  54. * LensFlareSystems to keep.
  55. */
  56. lensFlareSystems: LensFlareSystem[];
  57. /**
  58. * ShadowGenerators to keep.
  59. */
  60. shadowGenerators: ShadowGenerator[];
  61. /**
  62. * ActionManagers to keep.
  63. */
  64. actionManagers: ActionManager[];
  65. /**
  66. * Sounds to keep.
  67. */
  68. sounds: Sound[];
  69. }
  70. /**
  71. * Container with a set of assets that can be added or removed from a scene.
  72. */
  73. class AssetContainer {
  74. /**
  75. * The scene the AssetContainer belongs to.
  76. */
  77. scene: Scene;
  78. /**
  79. * Cameras populated in the container.
  80. */
  81. cameras: Camera[];
  82. /**
  83. * Lights populated in the container.
  84. */
  85. lights: Light[];
  86. /**
  87. * Meshes populated in the container.
  88. */
  89. meshes: AbstractMesh[];
  90. /**
  91. * Skeletons populated in the container.
  92. */
  93. skeletons: Skeleton[];
  94. /**
  95. * ParticleSystems populated in the container.
  96. */
  97. particleSystems: IParticleSystem[];
  98. /**
  99. * Animations populated in the container.
  100. */
  101. animations: Animation[];
  102. /**
  103. * MultiMaterials populated in the container.
  104. */
  105. multiMaterials: MultiMaterial[];
  106. /**
  107. * Materials populated in the container.
  108. */
  109. materials: Material[];
  110. /**
  111. * MorphTargetManagers populated in the container.
  112. */
  113. morphTargetManagers: MorphTargetManager[];
  114. /**
  115. * Geometries populated in the container.
  116. */
  117. geometries: Geometry[];
  118. /**
  119. * TransformNodes populated in the container.
  120. */
  121. transformNodes: TransformNode[];
  122. /**
  123. * LensFlareSystems populated in the container.
  124. */
  125. lensFlareSystems: LensFlareSystem[];
  126. /**
  127. * ShadowGenerators populated in the container.
  128. */
  129. shadowGenerators: ShadowGenerator[];
  130. /**
  131. * ActionManagers populated in the container.
  132. */
  133. actionManagers: ActionManager[];
  134. /**
  135. * Sounds populated in the container.
  136. */
  137. sounds: Sound[];
  138. /**
  139. * Instantiates an AssetContainer.
  140. * @param scene The scene the AssetContainer belongs to.
  141. */
  142. constructor(scene: Scene);
  143. /**
  144. * Adds all the assets from the container to the scene.
  145. */
  146. addAllToScene(): void;
  147. /**
  148. * Removes all the assets in the container from the scene
  149. */
  150. removeAllFromScene(): void;
  151. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  152. /**
  153. * Removes all the assets contained in the scene and adds them to the container.
  154. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  155. */
  156. moveAllFromScene(keepAssets?: KeepAssets): void;
  157. }
  158. }
  159. interface Window {
  160. mozIndexedDB: IDBFactory;
  161. webkitIndexedDB: IDBFactory;
  162. msIndexedDB: IDBFactory;
  163. webkitURL: typeof URL;
  164. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  165. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  166. WebGLRenderingContext: WebGLRenderingContext;
  167. MSGesture: MSGesture;
  168. CANNON: any;
  169. AudioContext: AudioContext;
  170. webkitAudioContext: AudioContext;
  171. PointerEvent: any;
  172. Math: Math;
  173. Uint8Array: Uint8ArrayConstructor;
  174. Float32Array: Float32ArrayConstructor;
  175. mozURL: typeof URL;
  176. msURL: typeof URL;
  177. VRFrameData: any;
  178. DracoDecoderModule: any;
  179. }
  180. interface WebGLRenderingContext {
  181. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  182. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  183. vertexAttribDivisor(index: number, divisor: number): void;
  184. createVertexArray(): any;
  185. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  186. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  187. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  188. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  189. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  190. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  191. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  192. createQuery(): WebGLQuery;
  193. deleteQuery(query: WebGLQuery): void;
  194. beginQuery(target: number, query: WebGLQuery): void;
  195. endQuery(target: number): void;
  196. getQueryParameter(query: WebGLQuery, pname: number): any;
  197. getQuery(target: number, pname: number): any;
  198. MAX_SAMPLES: number;
  199. RGBA8: number;
  200. READ_FRAMEBUFFER: number;
  201. DRAW_FRAMEBUFFER: number;
  202. UNIFORM_BUFFER: number;
  203. HALF_FLOAT_OES: number;
  204. RGBA16F: number;
  205. RGBA32F: number;
  206. R32F: number;
  207. RG32F: number;
  208. RGB32F: number;
  209. RED: number;
  210. RG: number;
  211. UNSIGNED_INT_24_8: number;
  212. DEPTH24_STENCIL8: number;
  213. drawBuffers(buffers: number[]): void;
  214. readBuffer(src: number): void;
  215. readonly COLOR_ATTACHMENT0: number;
  216. readonly COLOR_ATTACHMENT1: number;
  217. readonly COLOR_ATTACHMENT2: number;
  218. readonly COLOR_ATTACHMENT3: number;
  219. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  220. ANY_SAMPLES_PASSED: number;
  221. QUERY_RESULT_AVAILABLE: number;
  222. QUERY_RESULT: number;
  223. }
  224. interface Document {
  225. mozCancelFullScreen(): void;
  226. msCancelFullScreen(): void;
  227. mozFullScreen: boolean;
  228. msIsFullScreen: boolean;
  229. fullscreen: boolean;
  230. mozPointerLockElement: HTMLElement;
  231. msPointerLockElement: HTMLElement;
  232. webkitPointerLockElement: HTMLElement;
  233. }
  234. interface HTMLCanvasElement {
  235. msRequestPointerLock?(): void;
  236. mozRequestPointerLock?(): void;
  237. webkitRequestPointerLock?(): void;
  238. }
  239. interface CanvasRenderingContext2D {
  240. msImageSmoothingEnabled: boolean;
  241. }
  242. interface WebGLBuffer {
  243. references: number;
  244. capacity: number;
  245. is32Bits: boolean;
  246. }
  247. interface WebGLProgram {
  248. transformFeedback?: WebGLTransformFeedback | null;
  249. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  250. }
  251. interface MouseEvent {
  252. mozMovementX: number;
  253. mozMovementY: number;
  254. webkitMovementX: number;
  255. webkitMovementY: number;
  256. msMovementX: number;
  257. msMovementY: number;
  258. }
  259. interface Navigator {
  260. getVRDisplays: () => any;
  261. mozGetVRDevices: (any: any) => any;
  262. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  263. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  264. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  265. webkitGetGamepads(): Gamepad[];
  266. msGetGamepads(): Gamepad[];
  267. webkitGamepads(): Gamepad[];
  268. }
  269. interface HTMLVideoElement {
  270. mozSrcObject: any;
  271. }
  272. interface Screen {
  273. orientation: string;
  274. mozOrientation: string;
  275. }
  276. interface Math {
  277. fround(x: number): number;
  278. imul(a: number, b: number): number;
  279. }
  280. interface GamepadPose {
  281. hasOrientation: boolean;
  282. hasPosition: boolean;
  283. position?: Float32Array;
  284. linearVelocity?: Float32Array;
  285. linearAcceleration?: Float32Array;
  286. orientation?: Float32Array;
  287. angularVelocity?: Float32Array;
  288. angularAcceleration?: Float32Array;
  289. }
  290. interface EXT_disjoint_timer_query {
  291. QUERY_COUNTER_BITS_EXT: number;
  292. TIME_ELAPSED_EXT: number;
  293. TIMESTAMP_EXT: number;
  294. GPU_DISJOINT_EXT: number;
  295. QUERY_RESULT_EXT: number;
  296. QUERY_RESULT_AVAILABLE_EXT: number;
  297. queryCounterEXT(query: WebGLQuery, target: number): void;
  298. createQueryEXT(): WebGLQuery;
  299. beginQueryEXT(target: number, query: WebGLQuery): void;
  300. endQueryEXT(target: number): void;
  301. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  302. deleteQueryEXT(query: WebGLQuery): void;
  303. }
  304. interface WebGLUniformLocation {
  305. _currentState: any;
  306. }
  307. declare module BABYLON {
  308. /**
  309. * Node is the basic class for all scene objects (Mesh, Light Camera).
  310. */
  311. class Node {
  312. /**
  313. * Gets or sets the name of the node
  314. */
  315. name: string;
  316. /**
  317. * Gets or sets the id of the node
  318. */
  319. id: string;
  320. /**
  321. * Gets or sets the unique id of the node
  322. */
  323. uniqueId: number;
  324. /**
  325. * Gets or sets a string used to store user defined state for the node
  326. */
  327. state: string;
  328. /**
  329. * Gets or sets an object used to store user defined information for the node
  330. */
  331. metadata: any;
  332. /**
  333. * Gets or sets a boolean used to define if the node must be serialized
  334. */
  335. doNotSerialize: boolean;
  336. /** @ignore */
  337. _isDisposed: boolean;
  338. /**
  339. * Gets a list of {BABYLON.Animation} associated with the node
  340. */
  341. animations: Animation[];
  342. private _ranges;
  343. /**
  344. * Callback raised when the node is ready to be used
  345. */
  346. onReady: (node: Node) => void;
  347. private _isEnabled;
  348. private _isReady;
  349. /** @ignore */
  350. _currentRenderId: number;
  351. private _parentRenderId;
  352. /** @ignore */
  353. _waitingParentId: Nullable<string>;
  354. private _scene;
  355. /** @ignore */
  356. _cache: any;
  357. private _parentNode;
  358. private _children;
  359. /**
  360. * Gets a boolean indicating if the node has been disposed
  361. * @returns true if the node was disposed
  362. */
  363. isDisposed(): boolean;
  364. /**
  365. * Gets or sets the parent of the node
  366. */
  367. parent: Nullable<Node>;
  368. private _animationPropertiesOverride;
  369. /**
  370. * Gets or sets the animation properties override
  371. */
  372. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  373. /**
  374. * Gets a string idenfifying the name of the class
  375. * @returns "Node" string
  376. */
  377. getClassName(): string;
  378. /**
  379. * An event triggered when the mesh is disposed
  380. * @type {BABYLON.Observable}
  381. */
  382. onDisposeObservable: Observable<Node>;
  383. private _onDisposeObserver;
  384. /**
  385. * Sets a callback that will be raised when the node will be disposed
  386. */
  387. onDispose: () => void;
  388. /**
  389. * Creates a new Node
  390. * @param {string} name - the name and id to be given to this node
  391. * @param {BABYLON.Scene} the scene this node will be added to
  392. */
  393. constructor(name: string, scene?: Nullable<Scene>);
  394. /**
  395. * Gets the scene of the node
  396. * @returns a {BABYLON.Scene}
  397. */
  398. getScene(): Scene;
  399. /**
  400. * Gets the engine of the node
  401. * @returns a {BABYLON.Engine}
  402. */
  403. getEngine(): Engine;
  404. private _behaviors;
  405. /**
  406. * Attach a behavior to the node
  407. * @see http://doc.babylonjs.com/features/behaviour
  408. * @param behavior defines the behavior to attach
  409. * @returns the current Node
  410. */
  411. addBehavior(behavior: Behavior<Node>): Node;
  412. /**
  413. * Remove an attached behavior
  414. * @see http://doc.babylonjs.com/features/behaviour
  415. * @param behavior defines the behavior to attach
  416. * @returns the current Node
  417. */
  418. removeBehavior(behavior: Behavior<Node>): Node;
  419. /**
  420. * Gets the list of attached behaviors
  421. * @see http://doc.babylonjs.com/features/behaviour
  422. */
  423. readonly behaviors: Behavior<Node>[];
  424. /**
  425. * Gets an attached behavior by name
  426. * @param name defines the name of the behavior to look for
  427. * @see http://doc.babylonjs.com/features/behaviour
  428. * @returns null if behavior was not found else the requested behavior
  429. */
  430. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  431. /**
  432. * Returns the world matrix of the node
  433. * @returns a matrix containing the node's world matrix
  434. */
  435. getWorldMatrix(): Matrix;
  436. /** @ignore */
  437. _initCache(): void;
  438. /** @ignore */
  439. updateCache(force?: boolean): void;
  440. /** @ignore */
  441. _updateCache(ignoreParentClass?: boolean): void;
  442. /** @ignore */
  443. _isSynchronized(): boolean;
  444. /** @ignore */
  445. _markSyncedWithParent(): void;
  446. /** @ignore */
  447. isSynchronizedWithParent(): boolean;
  448. /** @ignore */
  449. isSynchronized(updateCache?: boolean): boolean;
  450. /** @ignore */
  451. hasNewParent(update?: boolean): boolean;
  452. /**
  453. * Is this node ready to be used/rendered
  454. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  455. * @return true if the node is ready
  456. */
  457. isReady(completeCheck?: boolean): boolean;
  458. /**
  459. * Is this node enabled?
  460. * 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
  461. * @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
  462. * @return whether this node (and its parent) is enabled
  463. * @see setEnabled
  464. */
  465. isEnabled(checkAncestors?: boolean): boolean;
  466. /**
  467. * Set the enabled state of this node
  468. * @param value defines the new enabled state
  469. * @see isEnabled
  470. */
  471. setEnabled(value: boolean): void;
  472. /**
  473. * Is this node a descendant of the given node?
  474. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  475. * @param ancestor defines the parent node to inspect
  476. * @see parent
  477. * @returns a boolean indicating if this node is a descendant of the given node
  478. */
  479. isDescendantOf(ancestor: Node): boolean;
  480. /** @ignore */
  481. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  482. /**
  483. * Will return all nodes that have this node as ascendant
  484. * @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
  485. * @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
  486. * @return all children nodes of all types
  487. */
  488. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  489. /**
  490. * Get all child-meshes of this node
  491. * @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
  492. * @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
  493. * @returns an array of {BABYLON.AbstractMesh}
  494. */
  495. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  496. /**
  497. * Get all child-transformNodes of this node
  498. * @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
  499. * @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
  500. * @returns an array of {BABYLON.TransformNode}
  501. */
  502. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  503. /**
  504. * Get all direct children of this node
  505. * @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
  506. * @returns an array of {BABYLON.Node}
  507. */
  508. getChildren(predicate?: (node: Node) => boolean): Node[];
  509. /** @ignore */
  510. _setReady(state: boolean): void;
  511. /**
  512. * Get an animation by name
  513. * @param name defines the name of the animation to look for
  514. * @returns null if not found else the requested animation
  515. */
  516. getAnimationByName(name: string): Nullable<Animation>;
  517. /**
  518. * Creates an animation range for this node
  519. * @param name defines the name of the range
  520. * @param from defines the starting key
  521. * @param to defines the end key
  522. */
  523. createAnimationRange(name: string, from: number, to: number): void;
  524. /**
  525. * Delete a specific animation range
  526. * @param name defines the name of the range to delete
  527. * @param deleteFrames defines if animation frames from the range must be deleted as well
  528. */
  529. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  530. /**
  531. * Get an animation range by name
  532. * @param name defines the name of the animation range to look for
  533. * @returns null if not found else the requested animation range
  534. */
  535. getAnimationRange(name: string): Nullable<AnimationRange>;
  536. /**
  537. * Will start the animation sequence
  538. * @param name defines the range frames for animation sequence
  539. * @param loop defines if the animation should loop (false by default)
  540. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  541. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  542. * @returns the object created for this animation. If range does not exist, it will return null
  543. */
  544. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  545. /**
  546. * Serialize animation ranges into a JSON compatible object
  547. * @returns serialization object
  548. */
  549. serializeAnimationRanges(): any;
  550. /**
  551. * Computes the world matrix of the node
  552. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  553. * @returns the world matrix
  554. */
  555. computeWorldMatrix(force?: boolean): Matrix;
  556. /**
  557. * Releases all associated resources
  558. */
  559. dispose(): void;
  560. /**
  561. * Parse animation range data from a serialization object and store them into a given node
  562. * @param node defines where to store the animation ranges
  563. * @param parsedNode defines the serialization object to read data from
  564. * @param scene defines the hosting scene
  565. */
  566. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  567. }
  568. }
  569. declare module BABYLON {
  570. interface IDisposable {
  571. dispose(): void;
  572. }
  573. interface IActiveMeshCandidateProvider {
  574. getMeshes(scene: Scene): AbstractMesh[];
  575. readonly checksIsEnabled: boolean;
  576. }
  577. /**
  578. * This class is used by the onRenderingGroupObservable
  579. */
  580. class RenderingGroupInfo {
  581. /**
  582. * The Scene that being rendered
  583. */
  584. scene: Scene;
  585. /**
  586. * The camera currently used for the rendering pass
  587. */
  588. camera: Nullable<Camera>;
  589. /**
  590. * The ID of the renderingGroup being processed
  591. */
  592. renderingGroupId: number;
  593. /**
  594. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  595. */
  596. renderStage: number;
  597. /**
  598. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  599. * This stage will be fired no matter what
  600. */
  601. static STAGE_PRECLEAR: number;
  602. /**
  603. * Called before opaque object are rendered.
  604. * This stage will be fired only if there's 3D Opaque content to render
  605. */
  606. static STAGE_PREOPAQUE: number;
  607. /**
  608. * Called after the opaque objects are rendered and before the transparent ones
  609. * This stage will be fired only if there's 3D transparent content to render
  610. */
  611. static STAGE_PRETRANSPARENT: number;
  612. /**
  613. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  614. * This stage will be fired no matter what
  615. */
  616. static STAGE_POSTTRANSPARENT: number;
  617. }
  618. /**
  619. * Represents a scene to be rendered by the engine.
  620. * @see http://doc.babylonjs.com/page.php?p=21911
  621. */
  622. class Scene implements IAnimatable {
  623. private static _FOGMODE_NONE;
  624. private static _FOGMODE_EXP;
  625. private static _FOGMODE_EXP2;
  626. private static _FOGMODE_LINEAR;
  627. private static _uniqueIdCounter;
  628. static MinDeltaTime: number;
  629. static MaxDeltaTime: number;
  630. /** The fog is deactivated */
  631. static readonly FOGMODE_NONE: number;
  632. /** The fog density is following an exponential function */
  633. static readonly FOGMODE_EXP: number;
  634. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  635. static readonly FOGMODE_EXP2: number;
  636. /** The fog density is following a linear function. */
  637. static readonly FOGMODE_LINEAR: number;
  638. autoClear: boolean;
  639. autoClearDepthAndStencil: boolean;
  640. clearColor: Color4;
  641. ambientColor: Color3;
  642. _environmentBRDFTexture: BaseTexture;
  643. protected _environmentTexture: BaseTexture;
  644. /**
  645. * Texture used in all pbr material as the reflection texture.
  646. * As in the majority of the scene they are the same (exception for multi room and so on),
  647. * this is easier to reference from here than from all the materials.
  648. */
  649. /**
  650. * Texture used in all pbr material as the reflection texture.
  651. * As in the majority of the scene they are the same (exception for multi room and so on),
  652. * this is easier to set here than in all the materials.
  653. */
  654. environmentTexture: BaseTexture;
  655. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  656. /**
  657. * Default image processing configuration used either in the rendering
  658. * Forward main pass or through the imageProcessingPostProcess if present.
  659. * As in the majority of the scene they are the same (exception for multi camera),
  660. * this is easier to reference from here than from all the materials and post process.
  661. *
  662. * No setter as we it is a shared configuration, you can set the values instead.
  663. */
  664. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  665. forceWireframe: boolean;
  666. private _forcePointsCloud;
  667. forcePointsCloud: boolean;
  668. forceShowBoundingBoxes: boolean;
  669. clipPlane: Nullable<Plane>;
  670. animationsEnabled: boolean;
  671. useConstantAnimationDeltaTime: boolean;
  672. constantlyUpdateMeshUnderPointer: boolean;
  673. hoverCursor: string;
  674. defaultCursor: string;
  675. /**
  676. * This is used to call preventDefault() on pointer down
  677. * in order to block unwanted artifacts like system double clicks
  678. */
  679. preventDefaultOnPointerDown: boolean;
  680. metadata: any;
  681. loadingPluginName: string;
  682. private _spritePredicate;
  683. /**
  684. * An event triggered when the scene is disposed.
  685. * @type {BABYLON.Observable}
  686. */
  687. onDisposeObservable: Observable<Scene>;
  688. private _onDisposeObserver;
  689. /** A function to be executed when this scene is disposed. */
  690. onDispose: () => void;
  691. /**
  692. * An event triggered before rendering the scene (right after animations and physics)
  693. * @type {BABYLON.Observable}
  694. */
  695. onBeforeRenderObservable: Observable<Scene>;
  696. private _onBeforeRenderObserver;
  697. /** A function to be executed before rendering this scene */
  698. beforeRender: Nullable<() => void>;
  699. /**
  700. * An event triggered after rendering the scene
  701. * @type {BABYLON.Observable}
  702. */
  703. onAfterRenderObservable: Observable<Scene>;
  704. private _onAfterRenderObserver;
  705. /** A function to be executed after rendering this scene */
  706. afterRender: Nullable<() => void>;
  707. /**
  708. * An event triggered before animating the scene
  709. * @type {BABYLON.Observable}
  710. */
  711. onBeforeAnimationsObservable: Observable<Scene>;
  712. /**
  713. * An event triggered after animations processing
  714. * @type {BABYLON.Observable}
  715. */
  716. onAfterAnimationsObservable: Observable<Scene>;
  717. /**
  718. * An event triggered before draw calls are ready to be sent
  719. * @type {BABYLON.Observable}
  720. */
  721. onBeforeDrawPhaseObservable: Observable<Scene>;
  722. /**
  723. * An event triggered after draw calls have been sent
  724. * @type {BABYLON.Observable}
  725. */
  726. onAfterDrawPhaseObservable: Observable<Scene>;
  727. /**
  728. * An event triggered when physic simulation is about to be run
  729. * @type {BABYLON.Observable}
  730. */
  731. onBeforePhysicsObservable: Observable<Scene>;
  732. /**
  733. * An event triggered when physic simulation has been done
  734. * @type {BABYLON.Observable}
  735. */
  736. onAfterPhysicsObservable: Observable<Scene>;
  737. /**
  738. * An event triggered when the scene is ready
  739. * @type {BABYLON.Observable}
  740. */
  741. onReadyObservable: Observable<Scene>;
  742. /**
  743. * An event triggered before rendering a camera
  744. * @type {BABYLON.Observable}
  745. */
  746. onBeforeCameraRenderObservable: Observable<Camera>;
  747. private _onBeforeCameraRenderObserver;
  748. beforeCameraRender: () => void;
  749. /**
  750. * An event triggered after rendering a camera
  751. * @type {BABYLON.Observable}
  752. */
  753. onAfterCameraRenderObservable: Observable<Camera>;
  754. private _onAfterCameraRenderObserver;
  755. afterCameraRender: () => void;
  756. /**
  757. * An event triggered when active meshes evaluation is about to start
  758. * @type {BABYLON.Observable}
  759. */
  760. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  761. /**
  762. * An event triggered when active meshes evaluation is done
  763. * @type {BABYLON.Observable}
  764. */
  765. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  766. /**
  767. * An event triggered when particles rendering is about to start
  768. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  769. * @type {BABYLON.Observable}
  770. */
  771. onBeforeParticlesRenderingObservable: Observable<Scene>;
  772. /**
  773. * An event triggered when particles rendering is done
  774. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  775. * @type {BABYLON.Observable}
  776. */
  777. onAfterParticlesRenderingObservable: Observable<Scene>;
  778. /**
  779. * An event triggered when sprites rendering is about to start
  780. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  781. * @type {BABYLON.Observable}
  782. */
  783. onBeforeSpritesRenderingObservable: Observable<Scene>;
  784. /**
  785. * An event triggered when sprites rendering is done
  786. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  787. * @type {BABYLON.Observable}
  788. */
  789. onAfterSpritesRenderingObservable: Observable<Scene>;
  790. /**
  791. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  792. * @type {BABYLON.Observable}
  793. */
  794. onDataLoadedObservable: Observable<Scene>;
  795. /**
  796. * An event triggered when a camera is created
  797. * @type {BABYLON.Observable}
  798. */
  799. onNewCameraAddedObservable: Observable<Camera>;
  800. /**
  801. * An event triggered when a camera is removed
  802. * @type {BABYLON.Observable}
  803. */
  804. onCameraRemovedObservable: Observable<Camera>;
  805. /**
  806. * An event triggered when a light is created
  807. * @type {BABYLON.Observable}
  808. */
  809. onNewLightAddedObservable: Observable<Light>;
  810. /**
  811. * An event triggered when a light is removed
  812. * @type {BABYLON.Observable}
  813. */
  814. onLightRemovedObservable: Observable<Light>;
  815. /**
  816. * An event triggered when a geometry is created
  817. * @type {BABYLON.Observable}
  818. */
  819. onNewGeometryAddedObservable: Observable<Geometry>;
  820. /**
  821. * An event triggered when a geometry is removed
  822. * @type {BABYLON.Observable}
  823. */
  824. onGeometryRemovedObservable: Observable<Geometry>;
  825. /**
  826. * An event triggered when a transform node is created
  827. * @type {BABYLON.Observable}
  828. */
  829. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  830. /**
  831. * An event triggered when a transform node is removed
  832. * @type {BABYLON.Observable}
  833. */
  834. onTransformNodeRemovedObservable: Observable<TransformNode>;
  835. /**
  836. * An event triggered when a mesh is created
  837. * @type {BABYLON.Observable}
  838. */
  839. onNewMeshAddedObservable: Observable<AbstractMesh>;
  840. /**
  841. * An event triggered when a mesh is removed
  842. * @type {BABYLON.Observable}
  843. */
  844. onMeshRemovedObservable: Observable<AbstractMesh>;
  845. /**
  846. * An event triggered when render targets are about to be rendered
  847. * Can happen multiple times per frame.
  848. * @type {BABYLON.Observable}
  849. */
  850. OnBeforeRenderTargetsRenderObservable: Observable<Scene>;
  851. /**
  852. * An event triggered when render targets were rendered.
  853. * Can happen multiple times per frame.
  854. * @type {BABYLON.Observable}
  855. */
  856. OnAfterRenderTargetsRenderObservable: Observable<Scene>;
  857. /**
  858. * An event triggered before calculating deterministic simulation step
  859. * @type {BABYLON.Observable}
  860. */
  861. onBeforeStepObservable: Observable<Scene>;
  862. /**
  863. * An event triggered after calculating deterministic simulation step
  864. * @type {BABYLON.Observable}
  865. */
  866. onAfterStepObservable: Observable<Scene>;
  867. /**
  868. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  869. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  870. * 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)
  871. */
  872. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  873. animations: Animation[];
  874. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  875. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  876. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  877. private _onPointerMove;
  878. private _onPointerDown;
  879. private _onPointerUp;
  880. /** Deprecated. Use onPointerObservable instead */
  881. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  882. /** Deprecated. Use onPointerObservable instead */
  883. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  884. /** Deprecated. Use onPointerObservable instead */
  885. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>) => void;
  886. /** Deprecated. Use onPointerObservable instead */
  887. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  888. private _gamepadManager;
  889. readonly gamepadManager: GamepadManager;
  890. /**
  891. * 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).
  892. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  893. */
  894. onPrePointerObservable: Observable<PointerInfoPre>;
  895. /**
  896. * Observable event triggered each time an input event is received from the rendering canvas
  897. */
  898. onPointerObservable: Observable<PointerInfo>;
  899. readonly unTranslatedPointer: Vector2;
  900. /** The distance in pixel that you have to move to prevent some events */
  901. static DragMovementThreshold: number;
  902. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  903. static LongPressDelay: number;
  904. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  905. static DoubleClickDelay: number;
  906. /** If you need to check double click without raising a single click at first click, enable this flag */
  907. static ExclusiveDoubleClickMode: boolean;
  908. private _initClickEvent;
  909. private _initActionManager;
  910. private _delayedSimpleClick;
  911. private _delayedSimpleClickTimeout;
  912. private _previousDelayedSimpleClickTimeout;
  913. private _meshPickProceed;
  914. private _previousButtonPressed;
  915. private _currentPickResult;
  916. private _previousPickResult;
  917. private _totalPointersPressed;
  918. private _doubleClickOccured;
  919. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  920. cameraToUseForPointers: Nullable<Camera>;
  921. private _pointerX;
  922. private _pointerY;
  923. private _unTranslatedPointerX;
  924. private _unTranslatedPointerY;
  925. private _startingPointerPosition;
  926. private _previousStartingPointerPosition;
  927. private _startingPointerTime;
  928. private _previousStartingPointerTime;
  929. private _timeAccumulator;
  930. private _currentStepId;
  931. private _currentInternalStep;
  932. _mirroredCameraPosition: Nullable<Vector3>;
  933. /**
  934. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  935. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  936. */
  937. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  938. /**
  939. * Observable event triggered each time an keyboard event is received from the hosting window
  940. */
  941. onKeyboardObservable: Observable<KeyboardInfo>;
  942. private _onKeyDown;
  943. private _onKeyUp;
  944. private _onCanvasFocusObserver;
  945. private _onCanvasBlurObserver;
  946. /**
  947. * use right-handed coordinate system on this scene.
  948. * @type {boolean}
  949. */
  950. private _useRightHandedSystem;
  951. useRightHandedSystem: boolean;
  952. setStepId(newStepId: number): void;
  953. getStepId(): number;
  954. getInternalStep(): number;
  955. private _fogEnabled;
  956. /**
  957. * is fog enabled on this scene.
  958. */
  959. fogEnabled: boolean;
  960. private _fogMode;
  961. fogMode: number;
  962. fogColor: Color3;
  963. fogDensity: number;
  964. fogStart: number;
  965. fogEnd: number;
  966. /**
  967. * is shadow enabled on this scene.
  968. * @type {boolean}
  969. */
  970. private _shadowsEnabled;
  971. shadowsEnabled: boolean;
  972. /**
  973. * is light enabled on this scene.
  974. * @type {boolean}
  975. */
  976. private _lightsEnabled;
  977. lightsEnabled: boolean;
  978. /**
  979. * All of the lights added to this scene.
  980. * @see BABYLON.Light
  981. * @type {BABYLON.Light[]}
  982. */
  983. lights: Light[];
  984. /** All of the cameras added to this scene. */
  985. cameras: Camera[];
  986. /** All of the active cameras added to this scene. */
  987. activeCameras: Camera[];
  988. /** The current active camera */
  989. activeCamera: Nullable<Camera>;
  990. /**
  991. * All of the tranform nodes added to this scene.
  992. * @see BABYLON.TransformNode
  993. * @type {BABYLON.TransformNode[]}
  994. */
  995. transformNodes: TransformNode[];
  996. /**
  997. * All of the (abstract) meshes added to this scene.
  998. * @see BABYLON.AbstractMesh
  999. * @type {BABYLON.AbstractMesh[]}
  1000. */
  1001. meshes: AbstractMesh[];
  1002. /**
  1003. * All of the animation groups added to this scene.
  1004. * @see BABYLON.AnimationGroup
  1005. * @type {BABYLON.AnimationGroup[]}
  1006. */
  1007. animationGroups: AnimationGroup[];
  1008. private _geometries;
  1009. materials: Material[];
  1010. multiMaterials: MultiMaterial[];
  1011. private _defaultMaterial;
  1012. /** The default material used on meshes when no material is affected */
  1013. /** The default material used on meshes when no material is affected */
  1014. defaultMaterial: Material;
  1015. private _texturesEnabled;
  1016. texturesEnabled: boolean;
  1017. textures: BaseTexture[];
  1018. particlesEnabled: boolean;
  1019. particleSystems: IParticleSystem[];
  1020. spritesEnabled: boolean;
  1021. spriteManagers: SpriteManager[];
  1022. /**
  1023. * The list of layers (background and foreground) of the scene.
  1024. */
  1025. layers: Layer[];
  1026. /**
  1027. * The list of effect layers (highlights/glow) contained in the scene.
  1028. */
  1029. effectLayers: EffectLayer[];
  1030. private _skeletonsEnabled;
  1031. skeletonsEnabled: boolean;
  1032. skeletons: Skeleton[];
  1033. morphTargetManagers: MorphTargetManager[];
  1034. lensFlaresEnabled: boolean;
  1035. lensFlareSystems: LensFlareSystem[];
  1036. collisionsEnabled: boolean;
  1037. private _workerCollisions;
  1038. collisionCoordinator: ICollisionCoordinator;
  1039. /** Defines the gravity applied to this scene */
  1040. gravity: Vector3;
  1041. postProcesses: PostProcess[];
  1042. postProcessesEnabled: boolean;
  1043. postProcessManager: PostProcessManager;
  1044. private _postProcessRenderPipelineManager;
  1045. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1046. renderTargetsEnabled: boolean;
  1047. dumpNextRenderTargets: boolean;
  1048. customRenderTargets: RenderTargetTexture[];
  1049. useDelayedTextureLoading: boolean;
  1050. importedMeshesFiles: String[];
  1051. probesEnabled: boolean;
  1052. reflectionProbes: ReflectionProbe[];
  1053. database: Database;
  1054. /**
  1055. * This scene's action manager
  1056. * @type {BABYLON.ActionManager}
  1057. */
  1058. actionManager: ActionManager;
  1059. _actionManagers: ActionManager[];
  1060. private _meshesForIntersections;
  1061. proceduralTexturesEnabled: boolean;
  1062. _proceduralTextures: ProceduralTexture[];
  1063. private _mainSoundTrack;
  1064. soundTracks: SoundTrack[];
  1065. private _audioEnabled;
  1066. private _headphone;
  1067. readonly mainSoundTrack: SoundTrack;
  1068. VRHelper: VRExperienceHelper;
  1069. simplificationQueue: SimplificationQueue;
  1070. private _engine;
  1071. private _totalVertices;
  1072. _activeIndices: PerfCounter;
  1073. _activeParticles: PerfCounter;
  1074. _activeBones: PerfCounter;
  1075. private _animationRatio;
  1076. private _animationTimeLast;
  1077. private _animationTime;
  1078. animationTimeScale: number;
  1079. _cachedMaterial: Nullable<Material>;
  1080. _cachedEffect: Nullable<Effect>;
  1081. _cachedVisibility: Nullable<number>;
  1082. private _renderId;
  1083. private _executeWhenReadyTimeoutId;
  1084. private _intermediateRendering;
  1085. private _viewUpdateFlag;
  1086. private _projectionUpdateFlag;
  1087. private _alternateViewUpdateFlag;
  1088. private _alternateProjectionUpdateFlag;
  1089. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1090. private _activeRequests;
  1091. private _pendingData;
  1092. private _isDisposed;
  1093. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1094. private _activeMeshes;
  1095. private _processedMaterials;
  1096. private _renderTargets;
  1097. _activeParticleSystems: SmartArray<IParticleSystem>;
  1098. private _activeSkeletons;
  1099. private _softwareSkinnedMeshes;
  1100. private _renderingManager;
  1101. private _physicsEngine;
  1102. _activeAnimatables: Animatable[];
  1103. private _transformMatrix;
  1104. private _sceneUbo;
  1105. private _alternateSceneUbo;
  1106. private _pickWithRayInverseMatrix;
  1107. private _boundingBoxRenderer;
  1108. private _outlineRenderer;
  1109. private _viewMatrix;
  1110. private _projectionMatrix;
  1111. private _alternateViewMatrix;
  1112. private _alternateProjectionMatrix;
  1113. private _alternateTransformMatrix;
  1114. private _useAlternateCameraConfiguration;
  1115. private _alternateRendering;
  1116. _forcedViewPosition: Nullable<Vector3>;
  1117. readonly _isAlternateRenderingEnabled: boolean;
  1118. private _frustumPlanes;
  1119. readonly frustumPlanes: Plane[];
  1120. requireLightSorting: boolean;
  1121. private _selectionOctree;
  1122. private _pointerOverMesh;
  1123. private _pointerOverSprite;
  1124. private _debugLayer;
  1125. private _depthRenderer;
  1126. private _geometryBufferRenderer;
  1127. /**
  1128. * Gets the current geometry buffer associated to the scene.
  1129. */
  1130. /**
  1131. * Sets the current geometry buffer for the scene.
  1132. */
  1133. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1134. private _pickedDownMesh;
  1135. private _pickedUpMesh;
  1136. private _pickedDownSprite;
  1137. private _externalData;
  1138. private _uid;
  1139. /**
  1140. * @constructor
  1141. * @param {BABYLON.Engine} engine - the engine to be used to render this scene.
  1142. */
  1143. constructor(engine: Engine);
  1144. readonly debugLayer: DebugLayer;
  1145. workerCollisions: boolean;
  1146. readonly selectionOctree: Octree<AbstractMesh>;
  1147. /**
  1148. * The mesh that is currently under the pointer.
  1149. * @return {BABYLON.AbstractMesh} mesh under the pointer/mouse cursor or null if none.
  1150. */
  1151. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1152. /**
  1153. * Current on-screen X position of the pointer
  1154. * @return {number} X position of the pointer
  1155. */
  1156. readonly pointerX: number;
  1157. /**
  1158. * Current on-screen Y position of the pointer
  1159. * @return {number} Y position of the pointer
  1160. */
  1161. readonly pointerY: number;
  1162. getCachedMaterial(): Nullable<Material>;
  1163. getCachedEffect(): Nullable<Effect>;
  1164. getCachedVisibility(): Nullable<number>;
  1165. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1166. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1167. getOutlineRenderer(): OutlineRenderer;
  1168. getEngine(): Engine;
  1169. getTotalVertices(): number;
  1170. readonly totalVerticesPerfCounter: PerfCounter;
  1171. getActiveIndices(): number;
  1172. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1173. getActiveParticles(): number;
  1174. readonly activeParticlesPerfCounter: PerfCounter;
  1175. getActiveBones(): number;
  1176. readonly activeBonesPerfCounter: PerfCounter;
  1177. getInterFramePerfCounter(): number;
  1178. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1179. getLastFrameDuration(): number;
  1180. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1181. getEvaluateActiveMeshesDuration(): number;
  1182. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1183. getActiveMeshes(): SmartArray<AbstractMesh>;
  1184. getRenderTargetsDuration(): number;
  1185. getRenderDuration(): number;
  1186. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1187. getParticlesDuration(): number;
  1188. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1189. getSpritesDuration(): number;
  1190. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1191. getAnimationRatio(): number;
  1192. getRenderId(): number;
  1193. incrementRenderId(): void;
  1194. private _updatePointerPosition(evt);
  1195. private _createUbo();
  1196. private _createAlternateUbo();
  1197. /**
  1198. * Use this method to simulate a pointer move on a mesh
  1199. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1200. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1201. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1202. */
  1203. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1204. private _processPointerMove(pickResult, evt);
  1205. /**
  1206. * Use this method to simulate a pointer down on a mesh
  1207. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1208. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1209. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1210. */
  1211. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1212. private _processPointerDown(pickResult, evt);
  1213. /**
  1214. * Use this method to simulate a pointer up on a mesh
  1215. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1216. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1217. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1218. */
  1219. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1220. private _processPointerUp(pickResult, evt, clickInfo);
  1221. /**
  1222. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1223. * @param attachUp defines if you want to attach events to pointerup
  1224. * @param attachDown defines if you want to attach events to pointerdown
  1225. * @param attachMove defines if you want to attach events to pointermove
  1226. */
  1227. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1228. detachControl(): void;
  1229. /**
  1230. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1231. * Delay loaded resources are not taking in account
  1232. * @return true if all required resources are ready
  1233. */
  1234. isReady(): boolean;
  1235. resetCachedMaterial(): void;
  1236. registerBeforeRender(func: () => void): void;
  1237. unregisterBeforeRender(func: () => void): void;
  1238. registerAfterRender(func: () => void): void;
  1239. unregisterAfterRender(func: () => void): void;
  1240. private _executeOnceBeforeRender(func);
  1241. /**
  1242. * The provided function will run before render once and will be disposed afterwards.
  1243. * A timeout delay can be provided so that the function will be executed in N ms.
  1244. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1245. * @param func The function to be executed.
  1246. * @param timeout optional delay in ms
  1247. */
  1248. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1249. _addPendingData(data: any): void;
  1250. _removePendingData(data: any): void;
  1251. getWaitingItemsCount(): number;
  1252. readonly isLoading: boolean;
  1253. /**
  1254. * Registers a function to be executed when the scene is ready.
  1255. * @param {Function} func - the function to be executed.
  1256. */
  1257. executeWhenReady(func: () => void): void;
  1258. /**
  1259. * Returns a promise that resolves when the scene is ready.
  1260. * @returns A promise that resolves when the scene is ready.
  1261. */
  1262. whenReadyAsync(): Promise<void>;
  1263. _checkIsReady(): void;
  1264. /**
  1265. * Will start the animation sequence of a given target
  1266. * @param target - the target
  1267. * @param {number} from - from which frame should animation start
  1268. * @param {number} to - till which frame should animation run.
  1269. * @param {boolean} [loop] - should the animation loop
  1270. * @param {number} [speedRatio] - the speed in which to run the animation
  1271. * @param {Function} [onAnimationEnd] function to be executed when the animation ended.
  1272. * @param {BABYLON.Animatable} [animatable] an animatable object. If not provided a new one will be created from the given params.
  1273. * Returns {BABYLON.Animatable} the animatable object created for this animation
  1274. * See BABYLON.Animatable
  1275. */
  1276. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1277. /**
  1278. * Begin a new animation on a given node
  1279. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1280. * @param {BABYLON.Animation[]} defines the list of animations to start
  1281. * @param {number} from defines the initial value
  1282. * @param {number} to defines the final value
  1283. * @param {boolean} loop defines if you want animation to loop (off by default)
  1284. * @param {number} speedRatio defines the speed ratio to apply to all animations
  1285. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1286. * @returns the list of created animatables
  1287. */
  1288. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1289. /**
  1290. * Begin a new animation on a given node and its hierarchy
  1291. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1292. * @param {boolean} directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1293. * @param {BABYLON.Animation[]} defines the list of animations to start
  1294. * @param {number} from defines the initial value
  1295. * @param {number} to defines the final value
  1296. * @param {boolean} loop defines if you want animation to loop (off by default)
  1297. * @param {number} speedRatio defines the speed ratio to apply to all animations
  1298. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1299. * @returns the list of animatables created for all nodes
  1300. */
  1301. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1302. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1303. readonly animatables: Animatable[];
  1304. /**
  1305. * Will stop the animation of the given target
  1306. * @param target - the target
  1307. * @param animationName - the name of the animation to stop (all animations will be stopped is empty)
  1308. * @see beginAnimation
  1309. */
  1310. stopAnimation(target: any, animationName?: string): void;
  1311. /**
  1312. * Stops and removes all animations that have been applied to the scene
  1313. */
  1314. stopAllAnimations(): void;
  1315. private _animate();
  1316. _switchToAlternateCameraConfiguration(active: boolean): void;
  1317. getViewMatrix(): Matrix;
  1318. getProjectionMatrix(): Matrix;
  1319. getTransformMatrix(): Matrix;
  1320. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1321. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1322. getSceneUniformBuffer(): UniformBuffer;
  1323. getUniqueId(): number;
  1324. addMesh(newMesh: AbstractMesh): void;
  1325. removeMesh(toRemove: AbstractMesh): number;
  1326. addTransformNode(newTransformNode: TransformNode): void;
  1327. removeTransformNode(toRemove: TransformNode): number;
  1328. removeSkeleton(toRemove: Skeleton): number;
  1329. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1330. removeLight(toRemove: Light): number;
  1331. removeCamera(toRemove: Camera): number;
  1332. removeParticleSystem(toRemove: IParticleSystem): number;
  1333. removeAnimation(toRemove: Animation): number;
  1334. removeMultiMaterial(toRemove: MultiMaterial): number;
  1335. removeMaterial(toRemove: Material): number;
  1336. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1337. removeActionManager(toRemove: ActionManager): number;
  1338. addLight(newLight: Light): void;
  1339. sortLightsByPriority(): void;
  1340. addCamera(newCamera: Camera): void;
  1341. addSkeleton(newSkeleton: Skeleton): void;
  1342. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1343. addAnimation(newAnimation: Animation): void;
  1344. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1345. addMaterial(newMaterial: Material): void;
  1346. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1347. addGeometry(newGeometrie: Geometry): void;
  1348. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1349. addActionManager(newActionManager: ActionManager): void;
  1350. /**
  1351. * Switch active camera
  1352. * @param {Camera} newCamera - new active camera
  1353. * @param {boolean} attachControl - call attachControl for the new active camera (default: true)
  1354. */
  1355. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1356. /**
  1357. * sets the active camera of the scene using its ID
  1358. * @param {string} id - the camera's ID
  1359. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1360. * @see activeCamera
  1361. */
  1362. setActiveCameraByID(id: string): Nullable<Camera>;
  1363. /**
  1364. * sets the active camera of the scene using its name
  1365. * @param {string} name - the camera's name
  1366. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1367. * @see activeCamera
  1368. */
  1369. setActiveCameraByName(name: string): Nullable<Camera>;
  1370. /**
  1371. * get an animation group using its name
  1372. * @param {string} the material's name
  1373. * @return {BABYLON.AnimationGroup|null} the animation group or null if none found.
  1374. */
  1375. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1376. /**
  1377. * get a material using its id
  1378. * @param {string} the material's ID
  1379. * @return {BABYLON.Material|null} the material or null if none found.
  1380. */
  1381. getMaterialByID(id: string): Nullable<Material>;
  1382. /**
  1383. * get a material using its name
  1384. * @param {string} the material's name
  1385. * @return {BABYLON.Material|null} the material or null if none found.
  1386. */
  1387. getMaterialByName(name: string): Nullable<Material>;
  1388. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  1389. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  1390. getCameraByID(id: string): Nullable<Camera>;
  1391. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1392. /**
  1393. * get a camera using its name
  1394. * @param {string} the camera's name
  1395. * @return {BABYLON.Camera|null} the camera or null if none found.
  1396. */
  1397. getCameraByName(name: string): Nullable<Camera>;
  1398. /**
  1399. * get a bone using its id
  1400. * @param {string} the bone's id
  1401. * @return {BABYLON.Bone|null} the bone or null if not found
  1402. */
  1403. getBoneByID(id: string): Nullable<Bone>;
  1404. /**
  1405. * get a bone using its id
  1406. * @param {string} the bone's name
  1407. * @return {BABYLON.Bone|null} the bone or null if not found
  1408. */
  1409. getBoneByName(name: string): Nullable<Bone>;
  1410. /**
  1411. * get a light node using its name
  1412. * @param {string} the light's name
  1413. * @return {BABYLON.Light|null} the light or null if none found.
  1414. */
  1415. getLightByName(name: string): Nullable<Light>;
  1416. /**
  1417. * get a light node using its ID
  1418. * @param {string} the light's id
  1419. * @return {BABYLON.Light|null} the light or null if none found.
  1420. */
  1421. getLightByID(id: string): Nullable<Light>;
  1422. /**
  1423. * get a light node using its scene-generated unique ID
  1424. * @param {number} the light's unique id
  1425. * @return {BABYLON.Light|null} the light or null if none found.
  1426. */
  1427. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  1428. /**
  1429. * get a particle system by id
  1430. * @param id {number} the particle system id
  1431. * @return {BABYLON.IParticleSystem|null} the corresponding system or null if none found.
  1432. */
  1433. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  1434. /**
  1435. * get a geometry using its ID
  1436. * @param {string} the geometry's id
  1437. * @return {BABYLON.Geometry|null} the geometry or null if none found.
  1438. */
  1439. getGeometryByID(id: string): Nullable<Geometry>;
  1440. /**
  1441. * add a new geometry to this scene.
  1442. * @param {BABYLON.Geometry} geometry - the geometry to be added to the scene.
  1443. * @param {boolean} [force] - force addition, even if a geometry with this ID already exists
  1444. * @return {boolean} was the geometry added or not
  1445. */
  1446. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  1447. /**
  1448. * Removes an existing geometry
  1449. * @param {BABYLON.Geometry} geometry - the geometry to be removed from the scene.
  1450. * @return {boolean} was the geometry removed or not
  1451. */
  1452. removeGeometry(geometry: Geometry): boolean;
  1453. getGeometries(): Geometry[];
  1454. /**
  1455. * Get the first added mesh found of a given ID
  1456. * @param {string} id - the id to search for
  1457. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1458. */
  1459. getMeshByID(id: string): Nullable<AbstractMesh>;
  1460. getMeshesByID(id: string): Array<AbstractMesh>;
  1461. /**
  1462. * Get the first added transform node found of a given ID
  1463. * @param {string} id - the id to search for
  1464. * @return {BABYLON.TransformNode|null} the transform node found or null if not found at all.
  1465. */
  1466. getTransformNodeByID(id: string): Nullable<TransformNode>;
  1467. getTransformNodesByID(id: string): Array<TransformNode>;
  1468. /**
  1469. * Get a mesh with its auto-generated unique id
  1470. * @param {number} uniqueId - the unique id to search for
  1471. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1472. */
  1473. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  1474. /**
  1475. * Get a the last added mesh found of a given ID
  1476. * @param {string} id - the id to search for
  1477. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1478. */
  1479. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  1480. /**
  1481. * Get a the last added node (Mesh, Camera, Light) found of a given ID
  1482. * @param {string} id - the id to search for
  1483. * @return {BABYLON.Node|null} the node found or null if not found at all.
  1484. */
  1485. getLastEntryByID(id: string): Nullable<Node>;
  1486. getNodeByID(id: string): Nullable<Node>;
  1487. getNodeByName(name: string): Nullable<Node>;
  1488. getMeshByName(name: string): Nullable<AbstractMesh>;
  1489. getTransformNodeByName(name: string): Nullable<TransformNode>;
  1490. getSoundByName(name: string): Nullable<Sound>;
  1491. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  1492. getSkeletonById(id: string): Nullable<Skeleton>;
  1493. getSkeletonByName(name: string): Nullable<Skeleton>;
  1494. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  1495. isActiveMesh(mesh: AbstractMesh): boolean;
  1496. /**
  1497. * Return a the first highlight layer of the scene with a given name.
  1498. * @param name The name of the highlight layer to look for.
  1499. * @return The highlight layer if found otherwise null.
  1500. */
  1501. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  1502. /**
  1503. * Return a the first highlight layer of the scene with a given name.
  1504. * @param name The name of the highlight layer to look for.
  1505. * @return The highlight layer if found otherwise null.
  1506. */
  1507. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  1508. /**
  1509. * Return a unique id as a string which can serve as an identifier for the scene
  1510. */
  1511. readonly uid: string;
  1512. /**
  1513. * Add an externaly attached data from its key.
  1514. * This method call will fail and return false, if such key already exists.
  1515. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  1516. * @param key the unique key that identifies the data
  1517. * @param data the data object to associate to the key for this Engine instance
  1518. * @return true if no such key were already present and the data was added successfully, false otherwise
  1519. */
  1520. addExternalData<T>(key: string, data: T): boolean;
  1521. /**
  1522. * Get an externaly attached data from its key
  1523. * @param key the unique key that identifies the data
  1524. * @return the associated data, if present (can be null), or undefined if not present
  1525. */
  1526. getExternalData<T>(key: string): Nullable<T>;
  1527. /**
  1528. * Get an externaly attached data from its key, create it using a factory if it's not already present
  1529. * @param key the unique key that identifies the data
  1530. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  1531. * @return the associated data, can be null if the factory returned null.
  1532. */
  1533. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  1534. /**
  1535. * Remove an externaly attached data from the Engine instance
  1536. * @param key the unique key that identifies the data
  1537. * @return true if the data was successfully removed, false if it doesn't exist
  1538. */
  1539. removeExternalData(key: string): boolean;
  1540. private _evaluateSubMesh(subMesh, mesh);
  1541. _isInIntermediateRendering(): boolean;
  1542. private _activeMeshCandidateProvider;
  1543. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  1544. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  1545. private _activeMeshesFrozen;
  1546. /**
  1547. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  1548. */
  1549. freezeActiveMeshes(): Scene;
  1550. /**
  1551. * Use this function to restart evaluating active meshes on every frame
  1552. */
  1553. unfreezeActiveMeshes(): this;
  1554. private _evaluateActiveMeshes();
  1555. private _activeMesh(sourceMesh, mesh);
  1556. updateTransformMatrix(force?: boolean): void;
  1557. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  1558. private _renderForCamera(camera, rigParent?);
  1559. private _processSubCameras(camera);
  1560. private _checkIntersections();
  1561. render(): void;
  1562. private _updateAudioParameters();
  1563. audioEnabled: boolean;
  1564. private _disableAudio();
  1565. private _enableAudio();
  1566. headphone: boolean;
  1567. private _switchAudioModeForHeadphones();
  1568. private _switchAudioModeForNormalSpeakers();
  1569. /**
  1570. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  1571. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  1572. * @returns the created depth renderer
  1573. */
  1574. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  1575. /**
  1576. * Disables a depth renderer for a given camera
  1577. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  1578. */
  1579. disableDepthRenderer(camera?: Nullable<Camera>): void;
  1580. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  1581. disableGeometryBufferRenderer(): void;
  1582. freezeMaterials(): void;
  1583. unfreezeMaterials(): void;
  1584. dispose(): void;
  1585. readonly isDisposed: boolean;
  1586. disposeSounds(): void;
  1587. /**
  1588. * Get the world extend vectors with an optional filter
  1589. *
  1590. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  1591. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  1592. */
  1593. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  1594. min: Vector3;
  1595. max: Vector3;
  1596. };
  1597. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  1598. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  1599. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  1600. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  1601. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  1602. private _internalPick(rayFunction, predicate?, fastCheck?);
  1603. private _internalMultiPick(rayFunction, predicate?);
  1604. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  1605. private _tempPickingRay;
  1606. /** Launch a ray to try to pick a mesh in the scene
  1607. * @param x position on screen
  1608. * @param y position on screen
  1609. * @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
  1610. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1611. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1612. */
  1613. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  1614. /** Launch a ray to try to pick a sprite in the scene
  1615. * @param x position on screen
  1616. * @param y position on screen
  1617. * @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
  1618. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1619. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1620. */
  1621. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  1622. private _cachedRayForTransform;
  1623. /** Use the given ray to pick a mesh in the scene
  1624. * @param ray The ray to use to pick meshes
  1625. * @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
  1626. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1627. */
  1628. pickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  1629. /**
  1630. * Launch a ray to try to pick a mesh in the scene
  1631. * @param x X position on screen
  1632. * @param y Y position on screen
  1633. * @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
  1634. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1635. */
  1636. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  1637. /**
  1638. * Launch a ray to try to pick a mesh in the scene
  1639. * @param ray Ray to use
  1640. * @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
  1641. */
  1642. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  1643. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  1644. getPointerOverMesh(): Nullable<AbstractMesh>;
  1645. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  1646. getPointerOverSprite(): Nullable<Sprite>;
  1647. getPhysicsEngine(): Nullable<PhysicsEngine>;
  1648. /**
  1649. * Enables physics to the current scene
  1650. * @param {BABYLON.Vector3} [gravity] - the scene's gravity for the physics engine
  1651. * @param {BABYLON.IPhysicsEnginePlugin} [plugin] - The physics engine to be used. defaults to OimoJS.
  1652. * @return {boolean} was the physics engine initialized
  1653. */
  1654. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  1655. disablePhysicsEngine(): void;
  1656. isPhysicsEnabled(): boolean;
  1657. deleteCompoundImpostor(compound: any): void;
  1658. _rebuildGeometries(): void;
  1659. _rebuildTextures(): void;
  1660. /**
  1661. * Creates a default light for the scene.
  1662. * @param replace Whether to replace the existing lights in the scene.
  1663. */
  1664. createDefaultLight(replace?: boolean): void;
  1665. /**
  1666. * Creates a default camera for the scene.
  1667. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  1668. * @param replace Whether to replace the existing active camera in the scene.
  1669. * @param attachCameraControls Whether to attach camera controls to the canvas.
  1670. */
  1671. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  1672. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  1673. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number): Nullable<Mesh>;
  1674. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  1675. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  1676. private _getByTags(list, tagsQuery, forEach?);
  1677. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  1678. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  1679. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  1680. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  1681. /**
  1682. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  1683. * This allowed control for front to back rendering or reversly depending of the special needs.
  1684. *
  1685. * @param renderingGroupId The rendering group id corresponding to its index
  1686. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  1687. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  1688. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  1689. */
  1690. 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;
  1691. /**
  1692. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  1693. *
  1694. * @param renderingGroupId The rendering group id corresponding to its index
  1695. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  1696. * @param depth Automatically clears depth between groups if true and autoClear is true.
  1697. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  1698. */
  1699. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  1700. /**
  1701. * Will flag all materials as dirty to trigger new shader compilation
  1702. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  1703. */
  1704. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  1705. _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;
  1706. /** @ignore */
  1707. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  1708. }
  1709. }
  1710. declare module BABYLON {
  1711. type Nullable<T> = T | null;
  1712. type float = number;
  1713. type double = number;
  1714. type int = number;
  1715. type FloatArray = number[] | Float32Array;
  1716. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  1717. }
  1718. declare module BABYLON {
  1719. class Action {
  1720. triggerOptions: any;
  1721. trigger: number;
  1722. _actionManager: ActionManager;
  1723. private _nextActiveAction;
  1724. private _child;
  1725. private _condition?;
  1726. private _triggerParameter;
  1727. onBeforeExecuteObservable: Observable<Action>;
  1728. constructor(triggerOptions: any, condition?: Condition);
  1729. _prepare(): void;
  1730. getTriggerParameter(): any;
  1731. _executeCurrent(evt?: ActionEvent): void;
  1732. execute(evt?: ActionEvent): void;
  1733. skipToNextActiveAction(): void;
  1734. then(action: Action): Action;
  1735. _getProperty(propertyPath: string): string;
  1736. _getEffectiveTarget(target: any, propertyPath: string): any;
  1737. serialize(parent: any): any;
  1738. protected _serialize(serializedAction: any, parent?: any): any;
  1739. static _SerializeValueAsString: (value: any) => string;
  1740. static _GetTargetProperty: (target: Scene | Node) => {
  1741. name: string;
  1742. targetType: string;
  1743. value: string;
  1744. };
  1745. }
  1746. }
  1747. declare module BABYLON {
  1748. /**
  1749. * ActionEvent is the event beint sent when an action is triggered.
  1750. */
  1751. class ActionEvent {
  1752. source: any;
  1753. pointerX: number;
  1754. pointerY: number;
  1755. meshUnderPointer: Nullable<AbstractMesh>;
  1756. sourceEvent: any;
  1757. additionalData: any;
  1758. /**
  1759. * @param source The mesh or sprite that triggered the action.
  1760. * @param pointerX The X mouse cursor position at the time of the event
  1761. * @param pointerY The Y mouse cursor position at the time of the event
  1762. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  1763. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  1764. */
  1765. constructor(source: any, pointerX: number, pointerY: number, meshUnderPointer: Nullable<AbstractMesh>, sourceEvent?: any, additionalData?: any);
  1766. /**
  1767. * Helper function to auto-create an ActionEvent from a source mesh.
  1768. * @param source The source mesh that triggered the event
  1769. * @param evt {Event} The original (browser) event
  1770. */
  1771. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  1772. /**
  1773. * Helper function to auto-create an ActionEvent from a source mesh.
  1774. * @param source The source sprite that triggered the event
  1775. * @param scene Scene associated with the sprite
  1776. * @param evt {Event} The original (browser) event
  1777. */
  1778. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  1779. /**
  1780. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  1781. * @param scene the scene where the event occurred
  1782. * @param evt {Event} The original (browser) event
  1783. */
  1784. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  1785. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  1786. }
  1787. /**
  1788. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  1789. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  1790. */
  1791. class ActionManager {
  1792. private static _NothingTrigger;
  1793. private static _OnPickTrigger;
  1794. private static _OnLeftPickTrigger;
  1795. private static _OnRightPickTrigger;
  1796. private static _OnCenterPickTrigger;
  1797. private static _OnPickDownTrigger;
  1798. private static _OnDoublePickTrigger;
  1799. private static _OnPickUpTrigger;
  1800. private static _OnLongPressTrigger;
  1801. private static _OnPointerOverTrigger;
  1802. private static _OnPointerOutTrigger;
  1803. private static _OnEveryFrameTrigger;
  1804. private static _OnIntersectionEnterTrigger;
  1805. private static _OnIntersectionExitTrigger;
  1806. private static _OnKeyDownTrigger;
  1807. private static _OnKeyUpTrigger;
  1808. private static _OnPickOutTrigger;
  1809. static readonly NothingTrigger: number;
  1810. static readonly OnPickTrigger: number;
  1811. static readonly OnLeftPickTrigger: number;
  1812. static readonly OnRightPickTrigger: number;
  1813. static readonly OnCenterPickTrigger: number;
  1814. static readonly OnPickDownTrigger: number;
  1815. static readonly OnDoublePickTrigger: number;
  1816. static readonly OnPickUpTrigger: number;
  1817. static readonly OnPickOutTrigger: number;
  1818. static readonly OnLongPressTrigger: number;
  1819. static readonly OnPointerOverTrigger: number;
  1820. static readonly OnPointerOutTrigger: number;
  1821. static readonly OnEveryFrameTrigger: number;
  1822. static readonly OnIntersectionEnterTrigger: number;
  1823. static readonly OnIntersectionExitTrigger: number;
  1824. static readonly OnKeyDownTrigger: number;
  1825. static readonly OnKeyUpTrigger: number;
  1826. static Triggers: {
  1827. [key: string]: number;
  1828. };
  1829. actions: Action[];
  1830. hoverCursor: string;
  1831. private _scene;
  1832. constructor(scene: Scene);
  1833. dispose(): void;
  1834. getScene(): Scene;
  1835. /**
  1836. * Does this action manager handles actions of any of the given triggers
  1837. * @param {number[]} triggers - the triggers to be tested
  1838. * @return {boolean} whether one (or more) of the triggers is handeled
  1839. */
  1840. hasSpecificTriggers(triggers: number[]): boolean;
  1841. /**
  1842. * Does this action manager handles actions of a given trigger
  1843. * @param {number} trigger - the trigger to be tested
  1844. * @return {boolean} whether the trigger is handeled
  1845. */
  1846. hasSpecificTrigger(trigger: number): boolean;
  1847. /**
  1848. * Does this action manager has pointer triggers
  1849. * @return {boolean} whether or not it has pointer triggers
  1850. */
  1851. readonly hasPointerTriggers: boolean;
  1852. /**
  1853. * Does this action manager has pick triggers
  1854. * @return {boolean} whether or not it has pick triggers
  1855. */
  1856. readonly hasPickTriggers: boolean;
  1857. /**
  1858. * Does exist one action manager with at least one trigger
  1859. * @return {boolean} whether or not it exists one action manager with one trigger
  1860. **/
  1861. static readonly HasTriggers: boolean;
  1862. /**
  1863. * Does exist one action manager with at least one pick trigger
  1864. * @return {boolean} whether or not it exists one action manager with one pick trigger
  1865. **/
  1866. static readonly HasPickTriggers: boolean;
  1867. /**
  1868. * Does exist one action manager that handles actions of a given trigger
  1869. * @param {number} trigger - the trigger to be tested
  1870. * @return {boolean} whether the trigger is handeled by at least one action manager
  1871. **/
  1872. static HasSpecificTrigger(trigger: number): boolean;
  1873. /**
  1874. * Registers an action to this action manager
  1875. * @param {BABYLON.Action} action - the action to be registered
  1876. * @return {BABYLON.Action} the action amended (prepared) after registration
  1877. */
  1878. registerAction(action: Action): Nullable<Action>;
  1879. /**
  1880. * Unregisters an action to this action manager
  1881. * @param action The action to be unregistered
  1882. * @return whether the action has been unregistered
  1883. */
  1884. unregisterAction(action: Action): Boolean;
  1885. /**
  1886. * Process a specific trigger
  1887. * @param {number} trigger - the trigger to process
  1888. * @param evt {BABYLON.ActionEvent} the event details to be processed
  1889. */
  1890. processTrigger(trigger: number, evt?: ActionEvent): void;
  1891. _getEffectiveTarget(target: any, propertyPath: string): any;
  1892. _getProperty(propertyPath: string): string;
  1893. serialize(name: string): any;
  1894. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  1895. static GetTriggerName(trigger: number): string;
  1896. }
  1897. }
  1898. declare module BABYLON {
  1899. class Condition {
  1900. _actionManager: ActionManager;
  1901. _evaluationId: number;
  1902. _currentResult: boolean;
  1903. constructor(actionManager: ActionManager);
  1904. isValid(): boolean;
  1905. _getProperty(propertyPath: string): string;
  1906. _getEffectiveTarget(target: any, propertyPath: string): any;
  1907. serialize(): any;
  1908. protected _serialize(serializedCondition: any): any;
  1909. }
  1910. class ValueCondition extends Condition {
  1911. propertyPath: string;
  1912. value: any;
  1913. operator: number;
  1914. private static _IsEqual;
  1915. private static _IsDifferent;
  1916. private static _IsGreater;
  1917. private static _IsLesser;
  1918. static readonly IsEqual: number;
  1919. static readonly IsDifferent: number;
  1920. static readonly IsGreater: number;
  1921. static readonly IsLesser: number;
  1922. _actionManager: ActionManager;
  1923. private _target;
  1924. private _effectiveTarget;
  1925. private _property;
  1926. constructor(actionManager: ActionManager, target: any, propertyPath: string, value: any, operator?: number);
  1927. isValid(): boolean;
  1928. serialize(): any;
  1929. static GetOperatorName(operator: number): string;
  1930. }
  1931. class PredicateCondition extends Condition {
  1932. predicate: () => boolean;
  1933. _actionManager: ActionManager;
  1934. constructor(actionManager: ActionManager, predicate: () => boolean);
  1935. isValid(): boolean;
  1936. }
  1937. class StateCondition extends Condition {
  1938. value: string;
  1939. _actionManager: ActionManager;
  1940. private _target;
  1941. constructor(actionManager: ActionManager, target: any, value: string);
  1942. isValid(): boolean;
  1943. serialize(): any;
  1944. }
  1945. }
  1946. declare module BABYLON {
  1947. class SwitchBooleanAction extends Action {
  1948. propertyPath: string;
  1949. private _target;
  1950. private _effectiveTarget;
  1951. private _property;
  1952. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  1953. _prepare(): void;
  1954. execute(): void;
  1955. serialize(parent: any): any;
  1956. }
  1957. class SetStateAction extends Action {
  1958. value: string;
  1959. private _target;
  1960. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  1961. execute(): void;
  1962. serialize(parent: any): any;
  1963. }
  1964. class SetValueAction extends Action {
  1965. propertyPath: string;
  1966. value: any;
  1967. private _target;
  1968. private _effectiveTarget;
  1969. private _property;
  1970. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1971. _prepare(): void;
  1972. execute(): void;
  1973. serialize(parent: any): any;
  1974. }
  1975. class IncrementValueAction extends Action {
  1976. propertyPath: string;
  1977. value: any;
  1978. private _target;
  1979. private _effectiveTarget;
  1980. private _property;
  1981. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1982. _prepare(): void;
  1983. execute(): void;
  1984. serialize(parent: any): any;
  1985. }
  1986. class PlayAnimationAction extends Action {
  1987. from: number;
  1988. to: number;
  1989. loop: boolean | undefined;
  1990. private _target;
  1991. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  1992. _prepare(): void;
  1993. execute(): void;
  1994. serialize(parent: any): any;
  1995. }
  1996. class StopAnimationAction extends Action {
  1997. private _target;
  1998. constructor(triggerOptions: any, target: any, condition?: Condition);
  1999. _prepare(): void;
  2000. execute(): void;
  2001. serialize(parent: any): any;
  2002. }
  2003. class DoNothingAction extends Action {
  2004. constructor(triggerOptions?: any, condition?: Condition);
  2005. execute(): void;
  2006. serialize(parent: any): any;
  2007. }
  2008. class CombineAction extends Action {
  2009. children: Action[];
  2010. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  2011. _prepare(): void;
  2012. execute(evt: ActionEvent): void;
  2013. serialize(parent: any): any;
  2014. }
  2015. class ExecuteCodeAction extends Action {
  2016. func: (evt: ActionEvent) => void;
  2017. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  2018. execute(evt: ActionEvent): void;
  2019. }
  2020. class SetParentAction extends Action {
  2021. private _parent;
  2022. private _target;
  2023. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  2024. _prepare(): void;
  2025. execute(): void;
  2026. serialize(parent: any): any;
  2027. }
  2028. class PlaySoundAction extends Action {
  2029. private _sound;
  2030. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  2031. _prepare(): void;
  2032. execute(): void;
  2033. serialize(parent: any): any;
  2034. }
  2035. class StopSoundAction extends Action {
  2036. private _sound;
  2037. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  2038. _prepare(): void;
  2039. execute(): void;
  2040. serialize(parent: any): any;
  2041. }
  2042. }
  2043. declare module BABYLON {
  2044. class InterpolateValueAction extends Action {
  2045. propertyPath: string;
  2046. value: any;
  2047. duration: number;
  2048. stopOtherAnimations: boolean | undefined;
  2049. onInterpolationDone: (() => void) | undefined;
  2050. private _target;
  2051. private _effectiveTarget;
  2052. private _property;
  2053. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  2054. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  2055. _prepare(): void;
  2056. execute(): void;
  2057. serialize(parent: any): any;
  2058. }
  2059. }
  2060. declare module BABYLON {
  2061. class Analyser {
  2062. SMOOTHING: number;
  2063. FFT_SIZE: number;
  2064. BARGRAPHAMPLITUDE: number;
  2065. DEBUGCANVASPOS: {
  2066. x: number;
  2067. y: number;
  2068. };
  2069. DEBUGCANVASSIZE: {
  2070. width: number;
  2071. height: number;
  2072. };
  2073. private _byteFreqs;
  2074. private _byteTime;
  2075. private _floatFreqs;
  2076. private _webAudioAnalyser;
  2077. private _debugCanvas;
  2078. private _debugCanvasContext;
  2079. private _scene;
  2080. private _registerFunc;
  2081. private _audioEngine;
  2082. constructor(scene: Scene);
  2083. getFrequencyBinCount(): number;
  2084. getByteFrequencyData(): Uint8Array;
  2085. getByteTimeDomainData(): Uint8Array;
  2086. getFloatFrequencyData(): Uint8Array;
  2087. drawDebugCanvas(): void;
  2088. stopDebugCanvas(): void;
  2089. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  2090. dispose(): void;
  2091. }
  2092. }
  2093. declare module BABYLON {
  2094. class AudioEngine {
  2095. private _audioContext;
  2096. private _audioContextInitialized;
  2097. canUseWebAudio: boolean;
  2098. masterGain: GainNode;
  2099. private _connectedAnalyser;
  2100. WarnedWebAudioUnsupported: boolean;
  2101. unlocked: boolean;
  2102. onAudioUnlocked: () => any;
  2103. isMP3supported: boolean;
  2104. isOGGsupported: boolean;
  2105. readonly audioContext: Nullable<AudioContext>;
  2106. constructor();
  2107. private _unlockiOSaudio();
  2108. private _initializeAudioContext();
  2109. dispose(): void;
  2110. getGlobalVolume(): number;
  2111. setGlobalVolume(newVolume: number): void;
  2112. connectToAnalyser(analyser: Analyser): void;
  2113. }
  2114. }
  2115. declare module BABYLON {
  2116. class Sound {
  2117. name: string;
  2118. autoplay: boolean;
  2119. loop: boolean;
  2120. useCustomAttenuation: boolean;
  2121. soundTrackId: number;
  2122. spatialSound: boolean;
  2123. refDistance: number;
  2124. rolloffFactor: number;
  2125. maxDistance: number;
  2126. distanceModel: string;
  2127. private _panningModel;
  2128. onended: () => any;
  2129. private _playbackRate;
  2130. private _streaming;
  2131. private _startTime;
  2132. private _startOffset;
  2133. private _position;
  2134. private _localDirection;
  2135. private _volume;
  2136. private _isReadyToPlay;
  2137. isPlaying: boolean;
  2138. isPaused: boolean;
  2139. private _isDirectional;
  2140. private _readyToPlayCallback;
  2141. private _audioBuffer;
  2142. private _soundSource;
  2143. private _streamingSource;
  2144. private _soundPanner;
  2145. private _soundGain;
  2146. private _inputAudioNode;
  2147. private _ouputAudioNode;
  2148. private _coneInnerAngle;
  2149. private _coneOuterAngle;
  2150. private _coneOuterGain;
  2151. private _scene;
  2152. private _connectedMesh;
  2153. private _customAttenuationFunction;
  2154. private _registerFunc;
  2155. private _isOutputConnected;
  2156. private _htmlAudioElement;
  2157. private _urlType;
  2158. /**
  2159. * Create a sound and attach it to a scene
  2160. * @param name Name of your sound
  2161. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  2162. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  2163. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  2164. */
  2165. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  2166. dispose(): void;
  2167. isReady(): boolean;
  2168. private _soundLoaded(audioData);
  2169. setAudioBuffer(audioBuffer: AudioBuffer): void;
  2170. updateOptions(options: any): void;
  2171. private _createSpatialParameters();
  2172. private _updateSpatialParameters();
  2173. switchPanningModelToHRTF(): void;
  2174. switchPanningModelToEqualPower(): void;
  2175. private _switchPanningModel();
  2176. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  2177. /**
  2178. * Transform this sound into a directional source
  2179. * @param coneInnerAngle Size of the inner cone in degree
  2180. * @param coneOuterAngle Size of the outer cone in degree
  2181. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  2182. */
  2183. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  2184. setPosition(newPosition: Vector3): void;
  2185. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  2186. private _updateDirection();
  2187. updateDistanceFromListener(): void;
  2188. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  2189. /**
  2190. * Play the sound
  2191. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  2192. * @param offset (optional) Start the sound setting it at a specific time
  2193. */
  2194. play(time?: number, offset?: number): void;
  2195. private _onended();
  2196. /**
  2197. * Stop the sound
  2198. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  2199. */
  2200. stop(time?: number): void;
  2201. pause(): void;
  2202. setVolume(newVolume: number, time?: number): void;
  2203. setPlaybackRate(newPlaybackRate: number): void;
  2204. getVolume(): number;
  2205. attachToMesh(meshToConnectTo: AbstractMesh): void;
  2206. detachFromMesh(): void;
  2207. private _onRegisterAfterWorldMatrixUpdate(node);
  2208. clone(): Nullable<Sound>;
  2209. getAudioBuffer(): AudioBuffer | null;
  2210. serialize(): any;
  2211. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  2212. }
  2213. }
  2214. declare module BABYLON {
  2215. class SoundTrack {
  2216. private _outputAudioNode;
  2217. private _scene;
  2218. id: number;
  2219. soundCollection: Array<Sound>;
  2220. private _isMainTrack;
  2221. private _connectedAnalyser;
  2222. private _options;
  2223. private _isInitialized;
  2224. constructor(scene: Scene, options?: any);
  2225. private _initializeSoundTrackAudioGraph();
  2226. dispose(): void;
  2227. AddSound(sound: Sound): void;
  2228. RemoveSound(sound: Sound): void;
  2229. setVolume(newVolume: number): void;
  2230. switchPanningModelToHRTF(): void;
  2231. switchPanningModelToEqualPower(): void;
  2232. connectToAnalyser(analyser: Analyser): void;
  2233. }
  2234. }
  2235. declare module BABYLON {
  2236. class Animatable {
  2237. target: any;
  2238. fromFrame: number;
  2239. toFrame: number;
  2240. loopAnimation: boolean;
  2241. onAnimationEnd: (() => void) | null | undefined;
  2242. private _localDelayOffset;
  2243. private _pausedDelay;
  2244. private _runtimeAnimations;
  2245. private _paused;
  2246. private _scene;
  2247. private _speedRatio;
  2248. animationStarted: boolean;
  2249. speedRatio: number;
  2250. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  2251. getAnimations(): RuntimeAnimation[];
  2252. appendAnimations(target: any, animations: Animation[]): void;
  2253. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  2254. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  2255. reset(): void;
  2256. enableBlending(blendingSpeed: number): void;
  2257. disableBlending(): void;
  2258. goToFrame(frame: number): void;
  2259. pause(): void;
  2260. restart(): void;
  2261. stop(animationName?: string): void;
  2262. _animate(delay: number): boolean;
  2263. }
  2264. }
  2265. declare module BABYLON {
  2266. class AnimationRange {
  2267. name: string;
  2268. from: number;
  2269. to: number;
  2270. constructor(name: string, from: number, to: number);
  2271. clone(): AnimationRange;
  2272. }
  2273. /**
  2274. * Composed of a frame, and an action function
  2275. */
  2276. class AnimationEvent {
  2277. frame: number;
  2278. action: () => void;
  2279. onlyOnce: boolean | undefined;
  2280. isDone: boolean;
  2281. constructor(frame: number, action: () => void, onlyOnce?: boolean | undefined);
  2282. }
  2283. class PathCursor {
  2284. private path;
  2285. private _onchange;
  2286. value: number;
  2287. animations: Animation[];
  2288. constructor(path: Path2);
  2289. getPoint(): Vector3;
  2290. moveAhead(step?: number): PathCursor;
  2291. moveBack(step?: number): PathCursor;
  2292. move(step: number): PathCursor;
  2293. private ensureLimits();
  2294. private raiseOnChange();
  2295. onchange(f: (cursor: PathCursor) => void): PathCursor;
  2296. }
  2297. interface IAnimationKey {
  2298. frame: number;
  2299. value: any;
  2300. inTangent?: any;
  2301. outTangent?: any;
  2302. interpolation?: AnimationKeyInterpolation;
  2303. }
  2304. enum AnimationKeyInterpolation {
  2305. /**
  2306. * Do not interpolate between keys and use the start key value only. Tangents are ignored.
  2307. */
  2308. STEP = 1,
  2309. }
  2310. class Animation {
  2311. name: string;
  2312. targetProperty: string;
  2313. framePerSecond: number;
  2314. dataType: number;
  2315. loopMode: number | undefined;
  2316. enableBlending: boolean | undefined;
  2317. static AllowMatricesInterpolation: boolean;
  2318. private _keys;
  2319. private _easingFunction;
  2320. _runtimeAnimations: RuntimeAnimation[];
  2321. private _events;
  2322. targetPropertyPath: string[];
  2323. blendingSpeed: number;
  2324. private _ranges;
  2325. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  2326. /**
  2327. * Sets up an animation.
  2328. * @param property the property to animate
  2329. * @param animationType the animation type to apply
  2330. * @param easingFunction the easing function used in the animation
  2331. * @returns The created animation
  2332. */
  2333. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  2334. /**
  2335. * Create and start an animation on a node
  2336. * @param {string} name defines the name of the global animation that will be run on all nodes
  2337. * @param {BABYLON.Node} node defines the root node where the animation will take place
  2338. * @param {string} targetProperty defines property to animate
  2339. * @param {number} framePerSecond defines the number of frame per second yo use
  2340. * @param {number} totalFrame defines the number of frames in total
  2341. * @param {any} from defines the initial value
  2342. * @param {any} to defines the final value
  2343. * @param {number} loopMode defines which loop mode you want to use (off by default)
  2344. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  2345. * @param onAnimationEnd defines the callback to call when animation end
  2346. * @returns the animatable created for this animation
  2347. */
  2348. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  2349. /**
  2350. * Create and start an animation on a node and its descendants
  2351. * @param {string} name defines the name of the global animation that will be run on all nodes
  2352. * @param {BABYLON.Node} node defines the root node where the animation will take place
  2353. * @param {boolean} directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  2354. * @param {string} targetProperty defines property to animate
  2355. * @param {number} framePerSecond defines the number of frame per second yo use
  2356. * @param {number} totalFrame defines the number of frames in total
  2357. * @param {any} from defines the initial value
  2358. * @param {any} to defines the final value
  2359. * @param {number} loopMode defines which loop mode you want to use (off by default)
  2360. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  2361. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  2362. * @returns the list of animatables created for all nodes
  2363. * @example https://www.babylonjs-playground.com/#MH0VLI
  2364. */
  2365. 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[]>;
  2366. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  2367. /**
  2368. * Transition property of the Camera to the target Value.
  2369. * @param property The property to transition
  2370. * @param targetValue The target Value of the property
  2371. * @param host The object where the property to animate belongs
  2372. * @param scene Scene used to run the animation
  2373. * @param frameRate Framerate (in frame/s) to use
  2374. * @param transition The transition type we want to use
  2375. * @param duration The duration of the animation, in milliseconds
  2376. * @param onAnimationEnd Call back trigger at the end of the animation.
  2377. */
  2378. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  2379. /**
  2380. * Return the array of runtime animations currently using this animation
  2381. */
  2382. readonly runtimeAnimations: RuntimeAnimation[];
  2383. readonly hasRunningRuntimeAnimations: boolean;
  2384. constructor(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number | undefined, enableBlending?: boolean | undefined);
  2385. /**
  2386. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  2387. */
  2388. toString(fullDetails?: boolean): string;
  2389. /**
  2390. * Add an event to this animation.
  2391. */
  2392. addEvent(event: AnimationEvent): void;
  2393. /**
  2394. * Remove all events found at the given frame
  2395. * @param frame
  2396. */
  2397. removeEvents(frame: number): void;
  2398. getEvents(): AnimationEvent[];
  2399. createRange(name: string, from: number, to: number): void;
  2400. deleteRange(name: string, deleteFrames?: boolean): void;
  2401. getRange(name: string): Nullable<AnimationRange>;
  2402. getKeys(): Array<IAnimationKey>;
  2403. getHighestFrame(): number;
  2404. getEasingFunction(): IEasingFunction;
  2405. setEasingFunction(easingFunction: EasingFunction): void;
  2406. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  2407. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  2408. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  2409. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  2410. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  2411. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  2412. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  2413. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  2414. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  2415. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  2416. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  2417. clone(): Animation;
  2418. setKeys(values: Array<IAnimationKey>): void;
  2419. serialize(): any;
  2420. private static _ANIMATIONTYPE_FLOAT;
  2421. private static _ANIMATIONTYPE_VECTOR3;
  2422. private static _ANIMATIONTYPE_QUATERNION;
  2423. private static _ANIMATIONTYPE_MATRIX;
  2424. private static _ANIMATIONTYPE_COLOR3;
  2425. private static _ANIMATIONTYPE_VECTOR2;
  2426. private static _ANIMATIONTYPE_SIZE;
  2427. private static _ANIMATIONLOOPMODE_RELATIVE;
  2428. private static _ANIMATIONLOOPMODE_CYCLE;
  2429. private static _ANIMATIONLOOPMODE_CONSTANT;
  2430. static readonly ANIMATIONTYPE_FLOAT: number;
  2431. static readonly ANIMATIONTYPE_VECTOR3: number;
  2432. static readonly ANIMATIONTYPE_VECTOR2: number;
  2433. static readonly ANIMATIONTYPE_SIZE: number;
  2434. static readonly ANIMATIONTYPE_QUATERNION: number;
  2435. static readonly ANIMATIONTYPE_MATRIX: number;
  2436. static readonly ANIMATIONTYPE_COLOR3: number;
  2437. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  2438. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  2439. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  2440. static Parse(parsedAnimation: any): Animation;
  2441. static AppendSerializedAnimations(source: IAnimatable, destination: any): any;
  2442. }
  2443. }
  2444. declare module BABYLON {
  2445. /**
  2446. * This class defines the direct association between an animation and a target
  2447. */
  2448. class TargetedAnimation {
  2449. animation: Animation;
  2450. target: any;
  2451. }
  2452. /**
  2453. * Use this class to create coordinated animations on multiple targets
  2454. */
  2455. class AnimationGroup implements IDisposable {
  2456. name: string;
  2457. private _scene;
  2458. private _targetedAnimations;
  2459. private _animatables;
  2460. private _from;
  2461. private _to;
  2462. private _isStarted;
  2463. private _speedRatio;
  2464. onAnimationEndObservable: Observable<TargetedAnimation>;
  2465. /**
  2466. * Define if the animations are started
  2467. */
  2468. readonly isStarted: boolean;
  2469. /**
  2470. * Gets or sets the speed ratio to use for all animations
  2471. */
  2472. /**
  2473. * Gets or sets the speed ratio to use for all animations
  2474. */
  2475. speedRatio: number;
  2476. /**
  2477. * Gets the targeted animations for this animation group
  2478. */
  2479. readonly targetedAnimations: Array<TargetedAnimation>;
  2480. /**
  2481. * returning the list of animatables controlled by this animation group.
  2482. */
  2483. readonly animatables: Array<Animatable>;
  2484. constructor(name: string, scene?: Nullable<Scene>);
  2485. /**
  2486. * Add an animation (with its target) in the group
  2487. * @param animation defines the animation we want to add
  2488. * @param target defines the target of the animation
  2489. * @returns the {BABYLON.TargetedAnimation} object
  2490. */
  2491. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  2492. /**
  2493. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  2494. * It can add constant keys at begin or end
  2495. * @param beginFrame defines the new begin frame for all animations. It can't be bigger than the smallest begin frame of all animations
  2496. * @param endFrame defines the new end frame for all animations. It can't be smaller than the largest end frame of all animations
  2497. */
  2498. normalize(beginFrame?: number, endFrame?: number): AnimationGroup;
  2499. /**
  2500. * Start all animations on given targets
  2501. * @param loop defines if animations must loop
  2502. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  2503. */
  2504. start(loop?: boolean, speedRatio?: number): AnimationGroup;
  2505. /**
  2506. * Pause all animations
  2507. */
  2508. pause(): AnimationGroup;
  2509. /**
  2510. * Play all animations to initial state
  2511. * This function will start() the animations if they were not started or will restart() them if they were paused
  2512. * @param loop defines if animations must loop
  2513. */
  2514. play(loop?: boolean): AnimationGroup;
  2515. /**
  2516. * Reset all animations to initial state
  2517. */
  2518. reset(): AnimationGroup;
  2519. /**
  2520. * Restart animations from key 0
  2521. */
  2522. restart(): AnimationGroup;
  2523. /**
  2524. * Stop all animations
  2525. */
  2526. stop(): AnimationGroup;
  2527. /**
  2528. * Goes to a specific frame in this animation group
  2529. *
  2530. * @param frame the frame number to go to
  2531. * @return the animationGroup
  2532. */
  2533. goToFrame(frame: number): AnimationGroup;
  2534. /**
  2535. * Dispose all associated resources
  2536. */
  2537. dispose(): void;
  2538. }
  2539. }
  2540. declare module BABYLON {
  2541. /**
  2542. * Class used to override all child animations of a given target
  2543. */
  2544. class AnimationPropertiesOverride {
  2545. /**
  2546. * Gets or sets a value indicating if animation blending must be used
  2547. */
  2548. enableBlending: boolean;
  2549. /**
  2550. * Gets or sets the blending speed to use when enableBlending is true
  2551. */
  2552. blendingSpeed: number;
  2553. /**
  2554. * Gets or sets the default loop mode to use
  2555. */
  2556. loopMode: number;
  2557. }
  2558. }
  2559. declare module BABYLON {
  2560. interface IEasingFunction {
  2561. ease(gradient: number): number;
  2562. }
  2563. class EasingFunction implements IEasingFunction {
  2564. private static _EASINGMODE_EASEIN;
  2565. private static _EASINGMODE_EASEOUT;
  2566. private static _EASINGMODE_EASEINOUT;
  2567. static readonly EASINGMODE_EASEIN: number;
  2568. static readonly EASINGMODE_EASEOUT: number;
  2569. static readonly EASINGMODE_EASEINOUT: number;
  2570. private _easingMode;
  2571. setEasingMode(easingMode: number): void;
  2572. getEasingMode(): number;
  2573. easeInCore(gradient: number): number;
  2574. ease(gradient: number): number;
  2575. }
  2576. class CircleEase extends EasingFunction implements IEasingFunction {
  2577. easeInCore(gradient: number): number;
  2578. }
  2579. class BackEase extends EasingFunction implements IEasingFunction {
  2580. amplitude: number;
  2581. constructor(amplitude?: number);
  2582. easeInCore(gradient: number): number;
  2583. }
  2584. class BounceEase extends EasingFunction implements IEasingFunction {
  2585. bounces: number;
  2586. bounciness: number;
  2587. constructor(bounces?: number, bounciness?: number);
  2588. easeInCore(gradient: number): number;
  2589. }
  2590. class CubicEase extends EasingFunction implements IEasingFunction {
  2591. easeInCore(gradient: number): number;
  2592. }
  2593. class ElasticEase extends EasingFunction implements IEasingFunction {
  2594. oscillations: number;
  2595. springiness: number;
  2596. constructor(oscillations?: number, springiness?: number);
  2597. easeInCore(gradient: number): number;
  2598. }
  2599. class ExponentialEase extends EasingFunction implements IEasingFunction {
  2600. exponent: number;
  2601. constructor(exponent?: number);
  2602. easeInCore(gradient: number): number;
  2603. }
  2604. class PowerEase extends EasingFunction implements IEasingFunction {
  2605. power: number;
  2606. constructor(power?: number);
  2607. easeInCore(gradient: number): number;
  2608. }
  2609. class QuadraticEase extends EasingFunction implements IEasingFunction {
  2610. easeInCore(gradient: number): number;
  2611. }
  2612. class QuarticEase extends EasingFunction implements IEasingFunction {
  2613. easeInCore(gradient: number): number;
  2614. }
  2615. class QuinticEase extends EasingFunction implements IEasingFunction {
  2616. easeInCore(gradient: number): number;
  2617. }
  2618. class SineEase extends EasingFunction implements IEasingFunction {
  2619. easeInCore(gradient: number): number;
  2620. }
  2621. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  2622. x1: number;
  2623. y1: number;
  2624. x2: number;
  2625. y2: number;
  2626. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  2627. easeInCore(gradient: number): number;
  2628. }
  2629. }
  2630. declare module BABYLON {
  2631. class RuntimeAnimation {
  2632. currentFrame: number;
  2633. private _animation;
  2634. private _target;
  2635. private _originalBlendValue;
  2636. private _offsetsCache;
  2637. private _highLimitsCache;
  2638. private _stopped;
  2639. private _blendingFactor;
  2640. constructor(target: any, animation: Animation);
  2641. readonly animation: Animation;
  2642. reset(): void;
  2643. isStopped(): boolean;
  2644. dispose(): void;
  2645. private _getKeyValue(value);
  2646. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  2647. setValue(currentValue: any, blend?: boolean): void;
  2648. private _getCorrectLoopMode();
  2649. goToFrame(frame: number): void;
  2650. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  2651. private _ratioOffset;
  2652. private _previousDelay;
  2653. private _previousRatio;
  2654. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, blend?: boolean): boolean;
  2655. }
  2656. }
  2657. declare module BABYLON {
  2658. interface Behavior<T extends Node> {
  2659. name: string;
  2660. init(): void;
  2661. attach(node: T): void;
  2662. detach(): void;
  2663. }
  2664. }
  2665. declare module BABYLON {
  2666. class Bone extends Node {
  2667. name: string;
  2668. private static _tmpVecs;
  2669. private static _tmpQuat;
  2670. private static _tmpMats;
  2671. children: Bone[];
  2672. animations: Animation[];
  2673. length: number;
  2674. _index: Nullable<number>;
  2675. private _skeleton;
  2676. private _localMatrix;
  2677. private _restPose;
  2678. private _baseMatrix;
  2679. private _worldTransform;
  2680. private _absoluteTransform;
  2681. private _invertedAbsoluteTransform;
  2682. private _parent;
  2683. private _scaleMatrix;
  2684. private _scaleVector;
  2685. private _negateScaleChildren;
  2686. private _scalingDeterminant;
  2687. _matrix: Matrix;
  2688. constructor(name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  2689. getSkeleton(): Skeleton;
  2690. getParent(): Nullable<Bone>;
  2691. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  2692. getLocalMatrix(): Matrix;
  2693. getBaseMatrix(): Matrix;
  2694. getRestPose(): Matrix;
  2695. returnToRest(): void;
  2696. getWorldMatrix(): Matrix;
  2697. getInvertedAbsoluteTransform(): Matrix;
  2698. getAbsoluteTransform(): Matrix;
  2699. position: Vector3;
  2700. rotation: Vector3;
  2701. rotationQuaternion: Quaternion;
  2702. scaling: Vector3;
  2703. /**
  2704. * Gets the animation properties override
  2705. */
  2706. readonly animationPropertiesOverride: AnimationPropertiesOverride;
  2707. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean): void;
  2708. _updateDifferenceMatrix(rootMatrix?: Matrix): void;
  2709. markAsDirty(): void;
  2710. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  2711. /**
  2712. * Translate the bone in local or world space.
  2713. * @param vec The amount to translate the bone.
  2714. * @param space The space that the translation is in.
  2715. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2716. */
  2717. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2718. /**
  2719. * Set the postion of the bone in local or world space.
  2720. * @param position The position to set the bone.
  2721. * @param space The space that the position is in.
  2722. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2723. */
  2724. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2725. /**
  2726. * Set the absolute postion of the bone (world space).
  2727. * @param position The position to set the bone.
  2728. * @param mesh The mesh that this bone is attached to.
  2729. */
  2730. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  2731. /**
  2732. * Set the scale of the bone on the x, y and z axes.
  2733. * @param x The scale of the bone on the x axis.
  2734. * @param x The scale of the bone on the y axis.
  2735. * @param z The scale of the bone on the z axis.
  2736. * @param scaleChildren Set this to true if children of the bone should be scaled.
  2737. */
  2738. setScale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  2739. /**
  2740. * Scale the bone on the x, y and z axes.
  2741. * @param x The amount to scale the bone on the x axis.
  2742. * @param x The amount to scale the bone on the y axis.
  2743. * @param z The amount to scale the bone on the z axis.
  2744. * @param scaleChildren Set this to true if children of the bone should be scaled.
  2745. */
  2746. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  2747. /**
  2748. * Set the yaw, pitch, and roll of the bone in local or world space.
  2749. * @param yaw The rotation of the bone on the y axis.
  2750. * @param pitch The rotation of the bone on the x axis.
  2751. * @param roll The rotation of the bone on the z axis.
  2752. * @param space The space that the axes of rotation are in.
  2753. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2754. */
  2755. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  2756. /**
  2757. * Rotate the bone on an axis in local or world space.
  2758. * @param axis The axis to rotate the bone on.
  2759. * @param amount The amount to rotate the bone.
  2760. * @param space The space that the axis is in.
  2761. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2762. */
  2763. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  2764. /**
  2765. * Set the rotation of the bone to a particular axis angle in local or world space.
  2766. * @param axis The axis to rotate the bone on.
  2767. * @param angle The angle that the bone should be rotated to.
  2768. * @param space The space that the axis is in.
  2769. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2770. */
  2771. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  2772. /**
  2773. * Set the euler rotation of the bone in local of world space.
  2774. * @param rotation The euler rotation that the bone should be set to.
  2775. * @param space The space that the rotation is in.
  2776. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2777. */
  2778. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2779. /**
  2780. * Set the quaternion rotation of the bone in local of world space.
  2781. * @param quat The quaternion rotation that the bone should be set to.
  2782. * @param space The space that the rotation is in.
  2783. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2784. */
  2785. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  2786. /**
  2787. * Set the rotation matrix of the bone in local of world space.
  2788. * @param rotMat The rotation matrix that the bone should be set to.
  2789. * @param space The space that the rotation is in.
  2790. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2791. */
  2792. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  2793. private _rotateWithMatrix(rmat, space?, mesh?);
  2794. private _getNegativeRotationToRef(rotMatInv, space?, mesh?);
  2795. /**
  2796. * Get the scale of the bone
  2797. * @returns the scale of the bone
  2798. */
  2799. getScale(): Vector3;
  2800. /**
  2801. * Copy the scale of the bone to a vector3.
  2802. * @param result The vector3 to copy the scale to
  2803. */
  2804. getScaleToRef(result: Vector3): void;
  2805. /**
  2806. * Get the position of the bone in local or world space.
  2807. * @param space The space that the returned position is in.
  2808. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2809. * @returns The position of the bone
  2810. */
  2811. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  2812. /**
  2813. * Copy the position of the bone to a vector3 in local or world space.
  2814. * @param space The space that the returned position is in.
  2815. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2816. * @param result The vector3 to copy the position to.
  2817. */
  2818. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  2819. /**
  2820. * Get the absolute position of the bone (world space).
  2821. * @param mesh The mesh that this bone is attached to.
  2822. * @returns The absolute position of the bone
  2823. */
  2824. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  2825. /**
  2826. * Copy the absolute position of the bone (world space) to the result param.
  2827. * @param mesh The mesh that this bone is attached to.
  2828. * @param result The vector3 to copy the absolute position to.
  2829. */
  2830. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  2831. /**
  2832. * Compute the absolute transforms of this bone and its children.
  2833. */
  2834. computeAbsoluteTransforms(): void;
  2835. private _syncScaleVector();
  2836. /**
  2837. * Get the world direction from an axis that is in the local space of the bone.
  2838. * @param localAxis The local direction that is used to compute the world direction.
  2839. * @param mesh The mesh that this bone is attached to.
  2840. * @returns The world direction
  2841. */
  2842. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2843. /**
  2844. * Copy the world direction to a vector3 from an axis that is in the local space of the bone.
  2845. * @param localAxis The local direction that is used to compute the world direction.
  2846. * @param mesh The mesh that this bone is attached to.
  2847. * @param result The vector3 that the world direction will be copied to.
  2848. */
  2849. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2850. /**
  2851. * Get the euler rotation of the bone in local or world space.
  2852. * @param space The space that the rotation should be in.
  2853. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2854. * @returns The euler rotation
  2855. */
  2856. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  2857. /**
  2858. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space.
  2859. * @param space The space that the rotation should be in.
  2860. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2861. * @param result The vector3 that the rotation should be copied to.
  2862. */
  2863. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2864. /**
  2865. * Get the quaternion rotation of the bone in either local or world space.
  2866. * @param space The space that the rotation should be in.
  2867. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2868. * @returns The quaternion rotation
  2869. */
  2870. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  2871. /**
  2872. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space.
  2873. * @param space The space that the rotation should be in.
  2874. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2875. * @param result The quaternion that the rotation should be copied to.
  2876. */
  2877. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  2878. /**
  2879. * Get the rotation matrix of the bone in local or world space.
  2880. * @param space The space that the rotation should be in.
  2881. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2882. * @returns The rotation matrix
  2883. */
  2884. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  2885. /**
  2886. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space.
  2887. * @param space The space that the rotation should be in.
  2888. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2889. * @param result The quaternion that the rotation should be copied to.
  2890. */
  2891. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  2892. /**
  2893. * Get the world position of a point that is in the local space of the bone.
  2894. * @param position The local position
  2895. * @param mesh The mesh that this bone is attached to.
  2896. * @returns The world position
  2897. */
  2898. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2899. /**
  2900. * Get the world position of a point that is in the local space of the bone and copy it to the result param.
  2901. * @param position The local position
  2902. * @param mesh The mesh that this bone is attached to.
  2903. * @param result The vector3 that the world position should be copied to.
  2904. */
  2905. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2906. /**
  2907. * Get the local position of a point that is in world space.
  2908. * @param position The world position
  2909. * @param mesh The mesh that this bone is attached to.
  2910. * @returns The local position
  2911. */
  2912. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2913. /**
  2914. * Get the local position of a point that is in world space and copy it to the result param.
  2915. * @param position The world position
  2916. * @param mesh The mesh that this bone is attached to.
  2917. * @param result The vector3 that the local position should be copied to.
  2918. */
  2919. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2920. }
  2921. }
  2922. declare module BABYLON {
  2923. class BoneIKController {
  2924. private static _tmpVecs;
  2925. private static _tmpQuat;
  2926. private static _tmpMats;
  2927. targetMesh: AbstractMesh;
  2928. poleTargetMesh: AbstractMesh;
  2929. poleTargetBone: Nullable<Bone>;
  2930. targetPosition: Vector3;
  2931. poleTargetPosition: Vector3;
  2932. poleTargetLocalOffset: Vector3;
  2933. poleAngle: number;
  2934. mesh: AbstractMesh;
  2935. slerpAmount: number;
  2936. private _bone1Quat;
  2937. private _bone1Mat;
  2938. private _bone2Ang;
  2939. private _bone1;
  2940. private _bone2;
  2941. private _bone1Length;
  2942. private _bone2Length;
  2943. private _maxAngle;
  2944. private _maxReach;
  2945. private _rightHandedSystem;
  2946. private _bendAxis;
  2947. private _slerping;
  2948. private _adjustRoll;
  2949. maxAngle: number;
  2950. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  2951. targetMesh?: AbstractMesh;
  2952. poleTargetMesh?: AbstractMesh;
  2953. poleTargetBone?: Bone;
  2954. poleTargetLocalOffset?: Vector3;
  2955. poleAngle?: number;
  2956. bendAxis?: Vector3;
  2957. maxAngle?: number;
  2958. slerpAmount?: number;
  2959. });
  2960. private _setMaxAngle(ang);
  2961. update(): void;
  2962. }
  2963. }
  2964. declare module BABYLON {
  2965. class BoneLookController {
  2966. private static _tmpVecs;
  2967. private static _tmpQuat;
  2968. private static _tmpMats;
  2969. /**
  2970. * The target Vector3 that the bone will look at.
  2971. */
  2972. target: Vector3;
  2973. /**
  2974. * The mesh that the bone is attached to.
  2975. */
  2976. mesh: AbstractMesh;
  2977. /**
  2978. * The bone that will be looking to the target.
  2979. */
  2980. bone: Bone;
  2981. /**
  2982. * The up axis of the coordinate system that is used when the bone is rotated.
  2983. */
  2984. upAxis: Vector3;
  2985. /**
  2986. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  2987. */
  2988. upAxisSpace: Space;
  2989. /**
  2990. * Used to make an adjustment to the yaw of the bone.
  2991. */
  2992. adjustYaw: number;
  2993. /**
  2994. * Used to make an adjustment to the pitch of the bone.
  2995. */
  2996. adjustPitch: number;
  2997. /**
  2998. * Used to make an adjustment to the roll of the bone.
  2999. */
  3000. adjustRoll: number;
  3001. /**
  3002. * 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).
  3003. */
  3004. slerpAmount: number;
  3005. private _minYaw;
  3006. private _maxYaw;
  3007. private _minPitch;
  3008. private _maxPitch;
  3009. private _minYawSin;
  3010. private _minYawCos;
  3011. private _maxYawSin;
  3012. private _maxYawCos;
  3013. private _midYawConstraint;
  3014. private _minPitchTan;
  3015. private _maxPitchTan;
  3016. private _boneQuat;
  3017. private _slerping;
  3018. private _transformYawPitch;
  3019. private _transformYawPitchInv;
  3020. private _firstFrameSkipped;
  3021. private _yawRange;
  3022. private _fowardAxis;
  3023. /**
  3024. * Get/set the minimum yaw angle that the bone can look to.
  3025. */
  3026. minYaw: number;
  3027. /**
  3028. * Get/set the maximum yaw angle that the bone can look to.
  3029. */
  3030. maxYaw: number;
  3031. /**
  3032. * Get/set the minimum pitch angle that the bone can look to.
  3033. */
  3034. minPitch: number;
  3035. /**
  3036. * Get/set the maximum pitch angle that the bone can look to.
  3037. */
  3038. maxPitch: number;
  3039. /**
  3040. * Create a BoneLookController
  3041. * @param mesh the mesh that the bone belongs to
  3042. * @param bone the bone that will be looking to the target
  3043. * @param target the target Vector3 to look at
  3044. * @param settings optional settings:
  3045. * - maxYaw: the maximum angle the bone will yaw to
  3046. * - minYaw: the minimum angle the bone will yaw to
  3047. * - maxPitch: the maximum angle the bone will pitch to
  3048. * - minPitch: the minimum angle the bone will yaw to
  3049. * - slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  3050. * - upAxis: the up axis of the coordinate system
  3051. * - upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  3052. * - yawAxis: set yawAxis if the bone does not yaw on the y axis
  3053. * - pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  3054. * - adjustYaw: used to make an adjustment to the yaw of the bone
  3055. * - adjustPitch: used to make an adjustment to the pitch of the bone
  3056. * - adjustRoll: used to make an adjustment to the roll of the bone
  3057. **/
  3058. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  3059. maxYaw?: number;
  3060. minYaw?: number;
  3061. maxPitch?: number;
  3062. minPitch?: number;
  3063. slerpAmount?: number;
  3064. upAxis?: Vector3;
  3065. upAxisSpace?: Space;
  3066. yawAxis?: Vector3;
  3067. pitchAxis?: Vector3;
  3068. adjustYaw?: number;
  3069. adjustPitch?: number;
  3070. adjustRoll?: number;
  3071. });
  3072. /**
  3073. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender()).
  3074. */
  3075. update(): void;
  3076. private _getAngleDiff(ang1, ang2);
  3077. private _getAngleBetween(ang1, ang2);
  3078. private _isAngleBetween(ang, ang1, ang2);
  3079. }
  3080. }
  3081. declare module BABYLON {
  3082. class Skeleton implements IAnimatable {
  3083. name: string;
  3084. id: string;
  3085. bones: Bone[];
  3086. dimensionsAtRest: Vector3;
  3087. needInitialSkinMatrix: boolean;
  3088. animations: Array<Animation>;
  3089. private _scene;
  3090. private _isDirty;
  3091. private _transformMatrices;
  3092. private _meshesWithPoseMatrix;
  3093. private _animatables;
  3094. private _identity;
  3095. private _synchronizedWithMesh;
  3096. private _ranges;
  3097. private _lastAbsoluteTransformsUpdateId;
  3098. /**
  3099. * Specifies if the skeleton should be serialized.
  3100. */
  3101. doNotSerialize: boolean;
  3102. /**
  3103. * Gets or sets the animation properties override
  3104. */
  3105. animationPropertiesOverride: AnimationPropertiesOverride;
  3106. /**
  3107. * An event triggered before computing the skeleton's matrices
  3108. * @type {BABYLON.Observable}
  3109. */
  3110. onBeforeComputeObservable: Observable<Skeleton>;
  3111. constructor(name: string, id: string, scene: Scene);
  3112. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  3113. getScene(): Scene;
  3114. /**
  3115. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  3116. */
  3117. toString(fullDetails?: boolean): string;
  3118. /**
  3119. * Get bone's index searching by name
  3120. * @param {string} name is bone's name to search for
  3121. * @return {number} Indice of the bone. Returns -1 if not found
  3122. */
  3123. getBoneIndexByName(name: string): number;
  3124. createAnimationRange(name: string, from: number, to: number): void;
  3125. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  3126. getAnimationRange(name: string): Nullable<AnimationRange>;
  3127. /**
  3128. * Returns as an Array, all AnimationRanges defined on this skeleton
  3129. */
  3130. getAnimationRanges(): Nullable<AnimationRange>[];
  3131. /**
  3132. * note: This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  3133. */
  3134. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  3135. returnToRest(): void;
  3136. private _getHighestAnimationFrame();
  3137. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  3138. _markAsDirty(): void;
  3139. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  3140. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  3141. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  3142. prepare(): void;
  3143. getAnimatables(): IAnimatable[];
  3144. clone(name: string, id: string): Skeleton;
  3145. enableBlending(blendingSpeed?: number): void;
  3146. dispose(): void;
  3147. serialize(): any;
  3148. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  3149. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  3150. getPoseMatrix(): Nullable<Matrix>;
  3151. sortBones(): void;
  3152. private _sortBones(index, bones, visited);
  3153. }
  3154. }
  3155. declare module BABYLON {
  3156. class ArcRotateCamera extends TargetCamera {
  3157. alpha: number;
  3158. beta: number;
  3159. radius: number;
  3160. protected _target: Vector3;
  3161. protected _targetHost: Nullable<AbstractMesh>;
  3162. target: Vector3;
  3163. inertialAlphaOffset: number;
  3164. inertialBetaOffset: number;
  3165. inertialRadiusOffset: number;
  3166. lowerAlphaLimit: Nullable<number>;
  3167. upperAlphaLimit: Nullable<number>;
  3168. lowerBetaLimit: number;
  3169. upperBetaLimit: number;
  3170. lowerRadiusLimit: Nullable<number>;
  3171. upperRadiusLimit: Nullable<number>;
  3172. inertialPanningX: number;
  3173. inertialPanningY: number;
  3174. pinchToPanMaxDistance: number;
  3175. panningDistanceLimit: Nullable<number>;
  3176. panningOriginTarget: Vector3;
  3177. panningInertia: number;
  3178. angularSensibilityX: number;
  3179. angularSensibilityY: number;
  3180. pinchPrecision: number;
  3181. pinchDeltaPercentage: number;
  3182. panningSensibility: number;
  3183. keysUp: number[];
  3184. keysDown: number[];
  3185. keysLeft: number[];
  3186. keysRight: number[];
  3187. wheelPrecision: number;
  3188. wheelDeltaPercentage: number;
  3189. zoomOnFactor: number;
  3190. targetScreenOffset: Vector2;
  3191. allowUpsideDown: boolean;
  3192. _viewMatrix: Matrix;
  3193. _useCtrlForPanning: boolean;
  3194. _panningMouseButton: number;
  3195. inputs: ArcRotateCameraInputsManager;
  3196. _reset: () => void;
  3197. panningAxis: Vector3;
  3198. protected _localDirection: Vector3;
  3199. protected _transformedDirection: Vector3;
  3200. private _bouncingBehavior;
  3201. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  3202. useBouncingBehavior: boolean;
  3203. private _framingBehavior;
  3204. readonly framingBehavior: Nullable<FramingBehavior>;
  3205. useFramingBehavior: boolean;
  3206. private _autoRotationBehavior;
  3207. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  3208. useAutoRotationBehavior: boolean;
  3209. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  3210. onCollide: (collidedMesh: AbstractMesh) => void;
  3211. checkCollisions: boolean;
  3212. collisionRadius: Vector3;
  3213. protected _collider: Collider;
  3214. protected _previousPosition: Vector3;
  3215. protected _collisionVelocity: Vector3;
  3216. protected _newPosition: Vector3;
  3217. protected _previousAlpha: number;
  3218. protected _previousBeta: number;
  3219. protected _previousRadius: number;
  3220. protected _collisionTriggered: boolean;
  3221. protected _targetBoundingCenter: Nullable<Vector3>;
  3222. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene);
  3223. _initCache(): void;
  3224. _updateCache(ignoreParentClass?: boolean): void;
  3225. protected _getTargetPosition(): Vector3;
  3226. /**
  3227. * Store current camera state (fov, position, etc..)
  3228. */
  3229. private _storedAlpha;
  3230. private _storedBeta;
  3231. private _storedRadius;
  3232. private _storedTarget;
  3233. storeState(): Camera;
  3234. /**
  3235. * Restored camera state. You must call storeState() first
  3236. */
  3237. _restoreStateValues(): boolean;
  3238. _isSynchronizedViewMatrix(): boolean;
  3239. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  3240. detachControl(element: HTMLElement): void;
  3241. _checkInputs(): void;
  3242. protected _checkLimits(): void;
  3243. rebuildAnglesAndRadius(): void;
  3244. setPosition(position: Vector3): void;
  3245. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  3246. _getViewMatrix(): Matrix;
  3247. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  3248. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  3249. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  3250. min: Vector3;
  3251. max: Vector3;
  3252. distance: number;
  3253. }, doNotUpdateMaxZ?: boolean): void;
  3254. /**
  3255. * @override
  3256. * Override Camera.createRigCamera
  3257. */
  3258. createRigCamera(name: string, cameraIndex: number): Camera;
  3259. /**
  3260. * @override
  3261. * Override Camera._updateRigCameras
  3262. */
  3263. _updateRigCameras(): void;
  3264. dispose(): void;
  3265. getClassName(): string;
  3266. }
  3267. }
  3268. declare module BABYLON {
  3269. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  3270. constructor(camera: ArcRotateCamera);
  3271. addMouseWheel(): ArcRotateCameraInputsManager;
  3272. addPointers(): ArcRotateCameraInputsManager;
  3273. addKeyboard(): ArcRotateCameraInputsManager;
  3274. addGamepad(): ArcRotateCameraInputsManager;
  3275. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  3276. }
  3277. }
  3278. declare module BABYLON {
  3279. class Camera extends Node {
  3280. inputs: CameraInputsManager<Camera>;
  3281. private static _PERSPECTIVE_CAMERA;
  3282. private static _ORTHOGRAPHIC_CAMERA;
  3283. private static _FOVMODE_VERTICAL_FIXED;
  3284. private static _FOVMODE_HORIZONTAL_FIXED;
  3285. private static _RIG_MODE_NONE;
  3286. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  3287. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  3288. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  3289. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  3290. private static _RIG_MODE_VR;
  3291. private static _RIG_MODE_WEBVR;
  3292. static readonly PERSPECTIVE_CAMERA: number;
  3293. static readonly ORTHOGRAPHIC_CAMERA: number;
  3294. /**
  3295. * This is the default FOV mode for perspective cameras.
  3296. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  3297. *
  3298. */
  3299. static readonly FOVMODE_VERTICAL_FIXED: number;
  3300. /**
  3301. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  3302. *
  3303. */
  3304. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  3305. static readonly RIG_MODE_NONE: number;
  3306. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  3307. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  3308. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  3309. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  3310. static readonly RIG_MODE_VR: number;
  3311. static readonly RIG_MODE_WEBVR: number;
  3312. static ForceAttachControlToAlwaysPreventDefault: boolean;
  3313. static UseAlternateWebVRRendering: boolean;
  3314. position: Vector3;
  3315. /**
  3316. * The vector the camera should consider as up.
  3317. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  3318. */
  3319. upVector: Vector3;
  3320. orthoLeft: Nullable<number>;
  3321. orthoRight: Nullable<number>;
  3322. orthoBottom: Nullable<number>;
  3323. orthoTop: Nullable<number>;
  3324. /**
  3325. * FOV is set in Radians. (default is 0.8)
  3326. */
  3327. fov: number;
  3328. minZ: number;
  3329. maxZ: number;
  3330. inertia: number;
  3331. mode: number;
  3332. isIntermediate: boolean;
  3333. viewport: Viewport;
  3334. /**
  3335. * Restricts the camera to viewing objects with the same layerMask.
  3336. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  3337. */
  3338. layerMask: number;
  3339. /**
  3340. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  3341. */
  3342. fovMode: number;
  3343. cameraRigMode: number;
  3344. interaxialDistance: number;
  3345. isStereoscopicSideBySide: boolean;
  3346. _cameraRigParams: any;
  3347. _rigCameras: Camera[];
  3348. _rigPostProcess: Nullable<PostProcess>;
  3349. protected _webvrViewMatrix: Matrix;
  3350. _skipRendering: boolean;
  3351. _alternateCamera: Camera;
  3352. customRenderTargets: RenderTargetTexture[];
  3353. onViewMatrixChangedObservable: Observable<Camera>;
  3354. onProjectionMatrixChangedObservable: Observable<Camera>;
  3355. onAfterCheckInputsObservable: Observable<Camera>;
  3356. onRestoreStateObservable: Observable<Camera>;
  3357. private _computedViewMatrix;
  3358. _projectionMatrix: Matrix;
  3359. private _doNotComputeProjectionMatrix;
  3360. private _worldMatrix;
  3361. _postProcesses: PostProcess[];
  3362. private _transformMatrix;
  3363. _activeMeshes: SmartArray<AbstractMesh>;
  3364. private _globalPosition;
  3365. private _frustumPlanes;
  3366. private _refreshFrustumPlanes;
  3367. constructor(name: string, position: Vector3, scene: Scene);
  3368. private _storedFov;
  3369. private _stateStored;
  3370. /**
  3371. * Store current camera state (fov, position, etc..)
  3372. */
  3373. storeState(): Camera;
  3374. /**
  3375. * Restores the camera state values if it has been stored. You must call storeState() first
  3376. */
  3377. protected _restoreStateValues(): boolean;
  3378. /**
  3379. * Restored camera state. You must call storeState() first
  3380. */
  3381. restoreState(): boolean;
  3382. getClassName(): string;
  3383. /**
  3384. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  3385. */
  3386. toString(fullDetails?: boolean): string;
  3387. readonly globalPosition: Vector3;
  3388. getActiveMeshes(): SmartArray<AbstractMesh>;
  3389. isActiveMesh(mesh: Mesh): boolean;
  3390. _initCache(): void;
  3391. _updateCache(ignoreParentClass?: boolean): void;
  3392. _isSynchronized(): boolean;
  3393. _isSynchronizedViewMatrix(): boolean;
  3394. _isSynchronizedProjectionMatrix(): boolean;
  3395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  3396. detachControl(element: HTMLElement): void;
  3397. update(): void;
  3398. _checkInputs(): void;
  3399. readonly rigCameras: Camera[];
  3400. readonly rigPostProcess: Nullable<PostProcess>;
  3401. private _cascadePostProcessesToRigCams();
  3402. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  3403. detachPostProcess(postProcess: PostProcess): void;
  3404. getWorldMatrix(): Matrix;
  3405. _getViewMatrix(): Matrix;
  3406. getViewMatrix(force?: boolean): Matrix;
  3407. freezeProjectionMatrix(projection?: Matrix): void;
  3408. unfreezeProjectionMatrix(): void;
  3409. getProjectionMatrix(force?: boolean): Matrix;
  3410. getTranformationMatrix(): Matrix;
  3411. private updateFrustumPlanes();
  3412. isInFrustum(target: ICullable): boolean;
  3413. isCompletelyInFrustum(target: ICullable): boolean;
  3414. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  3415. dispose(): void;
  3416. readonly leftCamera: Nullable<FreeCamera>;
  3417. readonly rightCamera: Nullable<FreeCamera>;
  3418. getLeftTarget(): Nullable<Vector3>;
  3419. getRightTarget(): Nullable<Vector3>;
  3420. setCameraRigMode(mode: number, rigParams: any): void;
  3421. private _getVRProjectionMatrix();
  3422. protected _updateCameraRotationMatrix(): void;
  3423. protected _updateWebVRCameraRotationMatrix(): void;
  3424. /**
  3425. * This function MUST be overwritten by the different WebVR cameras available.
  3426. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  3427. */
  3428. protected _getWebVRProjectionMatrix(): Matrix;
  3429. /**
  3430. * This function MUST be overwritten by the different WebVR cameras available.
  3431. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  3432. */
  3433. protected _getWebVRViewMatrix(): Matrix;
  3434. setCameraRigParameter(name: string, value: any): void;
  3435. /**
  3436. * needs to be overridden by children so sub has required properties to be copied
  3437. */
  3438. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  3439. /**
  3440. * May need to be overridden by children
  3441. */
  3442. _updateRigCameras(): void;
  3443. _setupInputs(): void;
  3444. serialize(): any;
  3445. clone(name: string): Camera;
  3446. getDirection(localAxis: Vector3): Vector3;
  3447. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  3448. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  3449. computeWorldMatrix(): Matrix;
  3450. static Parse(parsedCamera: any, scene: Scene): Camera;
  3451. }
  3452. }
  3453. declare module BABYLON {
  3454. var CameraInputTypes: {};
  3455. interface ICameraInput<TCamera extends Camera> {
  3456. camera: Nullable<TCamera>;
  3457. getClassName(): string;
  3458. getSimpleName(): string;
  3459. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  3460. detachControl: (element: Nullable<HTMLElement>) => void;
  3461. checkInputs?: () => void;
  3462. }
  3463. interface CameraInputsMap<TCamera extends Camera> {
  3464. [name: string]: ICameraInput<TCamera>;
  3465. [idx: number]: ICameraInput<TCamera>;
  3466. }
  3467. class CameraInputsManager<TCamera extends Camera> {
  3468. attached: CameraInputsMap<TCamera>;
  3469. attachedElement: Nullable<HTMLElement>;
  3470. noPreventDefault: boolean;
  3471. camera: TCamera;
  3472. checkInputs: () => void;
  3473. constructor(camera: TCamera);
  3474. /**
  3475. * Add an input method to a camera.
  3476. * builtin inputs example: camera.inputs.addGamepad();
  3477. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  3478. * @param input camera input method
  3479. */
  3480. add(input: ICameraInput<TCamera>): void;
  3481. /**
  3482. * Remove a specific input method from a camera
  3483. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  3484. * @param inputToRemove camera input method
  3485. */
  3486. remove(inputToRemove: ICameraInput<TCamera>): void;
  3487. removeByType(inputType: string): void;
  3488. private _addCheckInputs(fn);
  3489. attachInput(input: ICameraInput<TCamera>): void;
  3490. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  3491. detachElement(element: HTMLElement, disconnect?: boolean): void;
  3492. rebuildInputCheck(): void;
  3493. /**
  3494. * Remove all attached input methods from a camera
  3495. */
  3496. clear(): void;
  3497. serialize(serializedCamera: any): void;
  3498. parse(parsedCamera: any): void;
  3499. }
  3500. }
  3501. declare module BABYLON {
  3502. /**
  3503. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  3504. * being tilted forward or back and left or right.
  3505. */
  3506. class DeviceOrientationCamera extends FreeCamera {
  3507. private _initialQuaternion;
  3508. private _quaternionCache;
  3509. /**
  3510. * Creates a new device orientation camera. @see DeviceOrientationCamera
  3511. * @param name The name of the camera
  3512. * @param position The start position camera
  3513. * @param scene The scene the camera belongs to
  3514. */
  3515. constructor(name: string, position: Vector3, scene: Scene);
  3516. /**
  3517. * Gets the current instance class name ("DeviceOrientationCamera").
  3518. * This helps avoiding instanceof at run time.
  3519. * @returns the class name
  3520. */
  3521. getClassName(): string;
  3522. /**
  3523. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  3524. */
  3525. _checkInputs(): void;
  3526. /**
  3527. * Reset the camera to its default orientation on the specified axis only.
  3528. * @param axis The axis to reset
  3529. */
  3530. resetToCurrentRotation(axis?: Axis): void;
  3531. }
  3532. }
  3533. declare module BABYLON {
  3534. class FollowCamera extends TargetCamera {
  3535. radius: number;
  3536. rotationOffset: number;
  3537. heightOffset: number;
  3538. cameraAcceleration: number;
  3539. maxCameraSpeed: number;
  3540. lockedTarget: Nullable<AbstractMesh>;
  3541. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  3542. private getRadians(degrees);
  3543. private follow(cameraTarget);
  3544. _checkInputs(): void;
  3545. getClassName(): string;
  3546. }
  3547. class ArcFollowCamera extends TargetCamera {
  3548. alpha: number;
  3549. beta: number;
  3550. radius: number;
  3551. target: Nullable<AbstractMesh>;
  3552. private _cartesianCoordinates;
  3553. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  3554. private follow();
  3555. _checkInputs(): void;
  3556. getClassName(): string;
  3557. }
  3558. }
  3559. declare module BABYLON {
  3560. class FreeCamera extends TargetCamera {
  3561. ellipsoid: Vector3;
  3562. ellipsoidOffset: Vector3;
  3563. checkCollisions: boolean;
  3564. applyGravity: boolean;
  3565. inputs: FreeCameraInputsManager;
  3566. /**
  3567. * Gets the input sensibility for a mouse input. (default is 2000.0)
  3568. * Higher values reduce sensitivity.
  3569. */
  3570. /**
  3571. * Sets the input sensibility for a mouse input. (default is 2000.0)
  3572. * Higher values reduce sensitivity.
  3573. */
  3574. angularSensibility: number;
  3575. keysUp: number[];
  3576. keysDown: number[];
  3577. keysLeft: number[];
  3578. keysRight: number[];
  3579. onCollide: (collidedMesh: AbstractMesh) => void;
  3580. private _collider;
  3581. private _needMoveForGravity;
  3582. private _oldPosition;
  3583. private _diffPosition;
  3584. private _newPosition;
  3585. _localDirection: Vector3;
  3586. _transformedDirection: Vector3;
  3587. constructor(name: string, position: Vector3, scene: Scene);
  3588. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  3589. detachControl(element: HTMLElement): void;
  3590. private _collisionMask;
  3591. collisionMask: number;
  3592. _collideWithWorld(displacement: Vector3): void;
  3593. private _onCollisionPositionChange;
  3594. _checkInputs(): void;
  3595. _decideIfNeedsToMove(): boolean;
  3596. _updatePosition(): void;
  3597. dispose(): void;
  3598. getClassName(): string;
  3599. }
  3600. }
  3601. declare module BABYLON {
  3602. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  3603. constructor(camera: FreeCamera);
  3604. addKeyboard(): FreeCameraInputsManager;
  3605. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  3606. addGamepad(): FreeCameraInputsManager;
  3607. addDeviceOrientation(): FreeCameraInputsManager;
  3608. addTouch(): FreeCameraInputsManager;
  3609. addVirtualJoystick(): FreeCameraInputsManager;
  3610. }
  3611. }
  3612. declare module BABYLON {
  3613. class GamepadCamera extends UniversalCamera {
  3614. gamepadAngularSensibility: number;
  3615. gamepadMoveSensibility: number;
  3616. constructor(name: string, position: Vector3, scene: Scene);
  3617. getClassName(): string;
  3618. }
  3619. }
  3620. declare module BABYLON {
  3621. class AnaglyphFreeCamera extends FreeCamera {
  3622. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3623. getClassName(): string;
  3624. }
  3625. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  3626. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  3627. getClassName(): string;
  3628. }
  3629. class AnaglyphGamepadCamera extends GamepadCamera {
  3630. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3631. getClassName(): string;
  3632. }
  3633. class AnaglyphUniversalCamera extends UniversalCamera {
  3634. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3635. getClassName(): string;
  3636. }
  3637. class StereoscopicFreeCamera extends FreeCamera {
  3638. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3639. getClassName(): string;
  3640. }
  3641. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  3642. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3643. getClassName(): string;
  3644. }
  3645. class StereoscopicGamepadCamera extends GamepadCamera {
  3646. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3647. getClassName(): string;
  3648. }
  3649. class StereoscopicUniversalCamera extends UniversalCamera {
  3650. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3651. getClassName(): string;
  3652. }
  3653. }
  3654. declare module BABYLON {
  3655. class TargetCamera extends Camera {
  3656. cameraDirection: Vector3;
  3657. cameraRotation: Vector2;
  3658. rotation: Vector3;
  3659. rotationQuaternion: Quaternion;
  3660. speed: number;
  3661. noRotationConstraint: boolean;
  3662. lockedTarget: any;
  3663. _currentTarget: Vector3;
  3664. _viewMatrix: Matrix;
  3665. _camMatrix: Matrix;
  3666. _cameraTransformMatrix: Matrix;
  3667. _cameraRotationMatrix: Matrix;
  3668. private _rigCamTransformMatrix;
  3669. _referencePoint: Vector3;
  3670. private _currentUpVector;
  3671. _transformedReferencePoint: Vector3;
  3672. _lookAtTemp: Matrix;
  3673. _tempMatrix: Matrix;
  3674. _reset: () => void;
  3675. constructor(name: string, position: Vector3, scene: Scene);
  3676. getFrontPosition(distance: number): Vector3;
  3677. _getLockedTargetPosition(): Nullable<Vector3>;
  3678. /**
  3679. * Store current camera state (fov, position, etc..)
  3680. */
  3681. private _storedPosition;
  3682. private _storedRotation;
  3683. private _storedRotationQuaternion;
  3684. storeState(): Camera;
  3685. /**
  3686. * Restored camera state. You must call storeState() first
  3687. */
  3688. _restoreStateValues(): boolean;
  3689. _initCache(): void;
  3690. _updateCache(ignoreParentClass?: boolean): void;
  3691. _isSynchronizedViewMatrix(): boolean;
  3692. _computeLocalCameraSpeed(): number;
  3693. setTarget(target: Vector3): void;
  3694. /**
  3695. * Return the current target position of the camera. This value is expressed in local space.
  3696. */
  3697. getTarget(): Vector3;
  3698. _decideIfNeedsToMove(): boolean;
  3699. _updatePosition(): void;
  3700. _checkInputs(): void;
  3701. protected _updateCameraRotationMatrix(): void;
  3702. _getViewMatrix(): Matrix;
  3703. /**
  3704. * @override
  3705. * Override Camera.createRigCamera
  3706. */
  3707. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  3708. /**
  3709. * @override
  3710. * Override Camera._updateRigCameras
  3711. */
  3712. _updateRigCameras(): void;
  3713. private _getRigCamPosition(halfSpace, result);
  3714. getClassName(): string;
  3715. }
  3716. }
  3717. declare module BABYLON {
  3718. class TouchCamera extends FreeCamera {
  3719. touchAngularSensibility: number;
  3720. touchMoveSensibility: number;
  3721. constructor(name: string, position: Vector3, scene: Scene);
  3722. getClassName(): string;
  3723. _setupInputs(): void;
  3724. }
  3725. }
  3726. declare module BABYLON {
  3727. class UniversalCamera extends TouchCamera {
  3728. gamepadAngularSensibility: number;
  3729. gamepadMoveSensibility: number;
  3730. constructor(name: string, position: Vector3, scene: Scene);
  3731. getClassName(): string;
  3732. }
  3733. }
  3734. declare module BABYLON {
  3735. class VirtualJoysticksCamera extends FreeCamera {
  3736. constructor(name: string, position: Vector3, scene: Scene);
  3737. getClassName(): string;
  3738. }
  3739. }
  3740. declare module BABYLON {
  3741. class BoundingBox implements ICullable {
  3742. minimum: Vector3;
  3743. maximum: Vector3;
  3744. vectors: Vector3[];
  3745. center: Vector3;
  3746. centerWorld: Vector3;
  3747. extendSize: Vector3;
  3748. extendSizeWorld: Vector3;
  3749. directions: Vector3[];
  3750. vectorsWorld: Vector3[];
  3751. minimumWorld: Vector3;
  3752. maximumWorld: Vector3;
  3753. private _worldMatrix;
  3754. constructor(minimum: Vector3, maximum: Vector3);
  3755. getWorldMatrix(): Matrix;
  3756. setWorldMatrix(matrix: Matrix): BoundingBox;
  3757. _update(world: Matrix): void;
  3758. isInFrustum(frustumPlanes: Plane[]): boolean;
  3759. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  3760. intersectsPoint(point: Vector3): boolean;
  3761. intersectsSphere(sphere: BoundingSphere): boolean;
  3762. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  3763. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  3764. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  3765. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  3766. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  3767. }
  3768. }
  3769. declare module BABYLON {
  3770. interface ICullable {
  3771. isInFrustum(frustumPlanes: Plane[]): boolean;
  3772. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  3773. }
  3774. class BoundingInfo implements ICullable {
  3775. minimum: Vector3;
  3776. maximum: Vector3;
  3777. boundingBox: BoundingBox;
  3778. boundingSphere: BoundingSphere;
  3779. private _isLocked;
  3780. constructor(minimum: Vector3, maximum: Vector3);
  3781. isLocked: boolean;
  3782. update(world: Matrix): void;
  3783. /**
  3784. * Recreate the bounding info to be centered around a specific point given a specific extend.
  3785. * @param center New center of the bounding info
  3786. * @param extend New extend of the bounding info
  3787. */
  3788. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  3789. isInFrustum(frustumPlanes: Plane[]): boolean;
  3790. /**
  3791. * Gets the world distance between the min and max points of the bounding box
  3792. */
  3793. readonly diagonalLength: number;
  3794. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  3795. _checkCollision(collider: Collider): boolean;
  3796. intersectsPoint(point: Vector3): boolean;
  3797. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  3798. }
  3799. }
  3800. declare module BABYLON {
  3801. class BoundingSphere {
  3802. minimum: Vector3;
  3803. maximum: Vector3;
  3804. center: Vector3;
  3805. radius: number;
  3806. centerWorld: Vector3;
  3807. radiusWorld: number;
  3808. private _tempRadiusVector;
  3809. constructor(minimum: Vector3, maximum: Vector3);
  3810. _update(world: Matrix): void;
  3811. isInFrustum(frustumPlanes: Plane[]): boolean;
  3812. intersectsPoint(point: Vector3): boolean;
  3813. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  3814. }
  3815. }
  3816. declare module BABYLON {
  3817. class Ray {
  3818. origin: Vector3;
  3819. direction: Vector3;
  3820. length: number;
  3821. private _edge1;
  3822. private _edge2;
  3823. private _pvec;
  3824. private _tvec;
  3825. private _qvec;
  3826. private _tmpRay;
  3827. constructor(origin: Vector3, direction: Vector3, length?: number);
  3828. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  3829. intersectsBox(box: BoundingBox): boolean;
  3830. intersectsSphere(sphere: BoundingSphere): boolean;
  3831. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  3832. intersectsPlane(plane: Plane): Nullable<number>;
  3833. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  3834. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  3835. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  3836. private static smallnum;
  3837. private static rayl;
  3838. /**
  3839. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  3840. * @param sega the first point of the segment to test the intersection against
  3841. * @param segb the second point of the segment to test the intersection against
  3842. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  3843. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  3844. */
  3845. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  3846. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  3847. static Zero(): Ray;
  3848. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  3849. /**
  3850. * 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
  3851. * transformed to the given world matrix.
  3852. * @param origin The origin point
  3853. * @param end The end point
  3854. * @param world a matrix to transform the ray to. Default is the identity matrix.
  3855. */
  3856. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  3857. static Transform(ray: Ray, matrix: Matrix): Ray;
  3858. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  3859. }
  3860. }
  3861. declare module BABYLON {
  3862. class DebugLayer {
  3863. private _scene;
  3864. static InspectorURL: string;
  3865. private _inspector;
  3866. private BJSINSPECTOR;
  3867. constructor(scene: Scene);
  3868. /** Creates the inspector window. */
  3869. private _createInspector(config?);
  3870. isVisible(): boolean;
  3871. hide(): void;
  3872. show(config?: {
  3873. popup?: boolean;
  3874. initialTab?: number;
  3875. parentElement?: HTMLElement;
  3876. newColors?: {
  3877. backgroundColor?: string;
  3878. backgroundColorLighter?: string;
  3879. backgroundColorLighter2?: string;
  3880. backgroundColorLighter3?: string;
  3881. color?: string;
  3882. colorTop?: string;
  3883. colorBot?: string;
  3884. };
  3885. }): void;
  3886. }
  3887. }
  3888. declare module BABYLON {
  3889. class Debug {
  3890. static AxesViewer: {
  3891. new (scene: Scene, scaleLines?: number): {
  3892. _xline: Vector3[];
  3893. _yline: Vector3[];
  3894. _zline: Vector3[];
  3895. _xmesh: Nullable<LinesMesh>;
  3896. _ymesh: Nullable<LinesMesh>;
  3897. _zmesh: Nullable<LinesMesh>;
  3898. scene: Nullable<Scene>;
  3899. scaleLines: number;
  3900. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  3901. dispose(): void;
  3902. };
  3903. };
  3904. static BoneAxesViewer: {
  3905. new (scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number): {
  3906. mesh: Nullable<Mesh>;
  3907. bone: Nullable<Bone>;
  3908. pos: Vector3;
  3909. xaxis: Vector3;
  3910. yaxis: Vector3;
  3911. zaxis: Vector3;
  3912. update(): void;
  3913. dispose(): void;
  3914. _xline: Vector3[];
  3915. _yline: Vector3[];
  3916. _zline: Vector3[];
  3917. _xmesh: Nullable<LinesMesh>;
  3918. _ymesh: Nullable<LinesMesh>;
  3919. _zmesh: Nullable<LinesMesh>;
  3920. scene: Nullable<Scene>;
  3921. scaleLines: number;
  3922. };
  3923. };
  3924. static PhysicsViewer: {
  3925. new (scene: Scene): {
  3926. _impostors: Nullable<PhysicsImpostor>[];
  3927. _meshes: Nullable<AbstractMesh>[];
  3928. _scene: Nullable<Scene>;
  3929. _numMeshes: number;
  3930. _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  3931. _renderFunction: () => void;
  3932. _debugBoxMesh: Mesh;
  3933. _debugSphereMesh: Mesh;
  3934. _debugMaterial: StandardMaterial;
  3935. _updateDebugMeshes(): void;
  3936. showImpostor(impostor: PhysicsImpostor): void;
  3937. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  3938. _getDebugMaterial(scene: Scene): Material;
  3939. _getDebugBoxMesh(scene: Scene): AbstractMesh;
  3940. _getDebugSphereMesh(scene: Scene): AbstractMesh;
  3941. _getDebugMesh(impostor: PhysicsImpostor, scene: Scene): Nullable<AbstractMesh>;
  3942. dispose(): void;
  3943. };
  3944. };
  3945. static SkeletonViewer: {
  3946. new (skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number): {
  3947. color: Color3;
  3948. _scene: Scene;
  3949. _debugLines: Vector3[][];
  3950. _debugMesh: Nullable<LinesMesh>;
  3951. _isEnabled: boolean;
  3952. _renderFunction: () => void;
  3953. skeleton: Skeleton;
  3954. mesh: AbstractMesh;
  3955. autoUpdateBonesMatrices: boolean;
  3956. renderingGroupId: number;
  3957. isEnabled: boolean;
  3958. _getBonePosition(position: Vector3, bone: Bone, meshMat: Matrix, x?: number, y?: number, z?: number): void;
  3959. _getLinesForBonesWithLength(bones: Bone[], meshMat: Matrix): void;
  3960. _getLinesForBonesNoLength(bones: Bone[], meshMat: Matrix): void;
  3961. update(): void;
  3962. dispose(): void;
  3963. };
  3964. };
  3965. }
  3966. }
  3967. declare module BABYLON {
  3968. class RayHelper {
  3969. ray: Nullable<Ray>;
  3970. private _renderPoints;
  3971. private _renderLine;
  3972. private _renderFunction;
  3973. private _scene;
  3974. private _updateToMeshFunction;
  3975. private _attachedToMesh;
  3976. private _meshSpaceDirection;
  3977. private _meshSpaceOrigin;
  3978. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  3979. constructor(ray: Ray);
  3980. show(scene: Scene, color: Color3): void;
  3981. hide(): void;
  3982. private _render();
  3983. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  3984. detachFromMesh(): void;
  3985. private _updateToMesh();
  3986. dispose(): void;
  3987. }
  3988. }
  3989. declare module BABYLON {
  3990. class Collider {
  3991. /** Define if a collision was found */
  3992. collisionFound: boolean;
  3993. /**
  3994. * Define last intersection point in local space
  3995. */
  3996. intersectionPoint: Vector3;
  3997. /**
  3998. * Define last collided mesh
  3999. */
  4000. collidedMesh: Nullable<AbstractMesh>;
  4001. private _collisionPoint;
  4002. private _planeIntersectionPoint;
  4003. private _tempVector;
  4004. private _tempVector2;
  4005. private _tempVector3;
  4006. private _tempVector4;
  4007. private _edge;
  4008. private _baseToVertex;
  4009. private _destinationPoint;
  4010. private _slidePlaneNormal;
  4011. private _displacementVector;
  4012. _radius: Vector3;
  4013. _retry: number;
  4014. private _velocity;
  4015. private _basePoint;
  4016. private _epsilon;
  4017. _velocityWorldLength: number;
  4018. _basePointWorld: Vector3;
  4019. private _velocityWorld;
  4020. private _normalizedVelocity;
  4021. _initialVelocity: Vector3;
  4022. _initialPosition: Vector3;
  4023. private _nearestDistance;
  4024. private _collisionMask;
  4025. collisionMask: number;
  4026. /**
  4027. * Gets the plane normal used to compute the sliding response (in local space)
  4028. */
  4029. readonly slidePlaneNormal: Vector3;
  4030. _initialize(source: Vector3, dir: Vector3, e: number): void;
  4031. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  4032. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  4033. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  4034. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  4035. _getResponse(pos: Vector3, vel: Vector3): void;
  4036. }
  4037. }
  4038. declare module BABYLON {
  4039. var CollisionWorker: string;
  4040. interface ICollisionCoordinator {
  4041. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4042. init(scene: Scene): void;
  4043. destroy(): void;
  4044. onMeshAdded(mesh: AbstractMesh): void;
  4045. onMeshUpdated(mesh: AbstractMesh): void;
  4046. onMeshRemoved(mesh: AbstractMesh): void;
  4047. onGeometryAdded(geometry: Geometry): void;
  4048. onGeometryUpdated(geometry: Geometry): void;
  4049. onGeometryDeleted(geometry: Geometry): void;
  4050. }
  4051. interface SerializedMesh {
  4052. id: string;
  4053. name: string;
  4054. uniqueId: number;
  4055. geometryId: Nullable<string>;
  4056. sphereCenter: Array<number>;
  4057. sphereRadius: number;
  4058. boxMinimum: Array<number>;
  4059. boxMaximum: Array<number>;
  4060. worldMatrixFromCache: any;
  4061. subMeshes: Array<SerializedSubMesh>;
  4062. checkCollisions: boolean;
  4063. }
  4064. interface SerializedSubMesh {
  4065. position: number;
  4066. verticesStart: number;
  4067. verticesCount: number;
  4068. indexStart: number;
  4069. indexCount: number;
  4070. hasMaterial: boolean;
  4071. sphereCenter: Array<number>;
  4072. sphereRadius: number;
  4073. boxMinimum: Array<number>;
  4074. boxMaximum: Array<number>;
  4075. }
  4076. /**
  4077. * Interface describing the value associated with a geometry
  4078. */
  4079. interface SerializedGeometry {
  4080. /**
  4081. * Defines the unique ID of the geometry
  4082. */
  4083. id: string;
  4084. /**
  4085. * Defines the array containing the positions
  4086. */
  4087. positions: Float32Array;
  4088. /**
  4089. * Defines the array containing the indices
  4090. */
  4091. indices: Uint32Array;
  4092. /**
  4093. * Defines the array containing the normals
  4094. */
  4095. normals: Float32Array;
  4096. }
  4097. interface BabylonMessage {
  4098. taskType: WorkerTaskType;
  4099. payload: InitPayload | CollidePayload | UpdatePayload;
  4100. }
  4101. interface SerializedColliderToWorker {
  4102. position: Array<number>;
  4103. velocity: Array<number>;
  4104. radius: Array<number>;
  4105. }
  4106. enum WorkerTaskType {
  4107. INIT = 0,
  4108. UPDATE = 1,
  4109. COLLIDE = 2,
  4110. }
  4111. interface WorkerReply {
  4112. error: WorkerReplyType;
  4113. taskType: WorkerTaskType;
  4114. payload?: any;
  4115. }
  4116. interface CollisionReplyPayload {
  4117. newPosition: Array<number>;
  4118. collisionId: number;
  4119. collidedMeshUniqueId: number;
  4120. }
  4121. interface InitPayload {
  4122. }
  4123. interface CollidePayload {
  4124. collisionId: number;
  4125. collider: SerializedColliderToWorker;
  4126. maximumRetry: number;
  4127. excludedMeshUniqueId: Nullable<number>;
  4128. }
  4129. interface UpdatePayload {
  4130. updatedMeshes: {
  4131. [n: number]: SerializedMesh;
  4132. };
  4133. updatedGeometries: {
  4134. [s: string]: SerializedGeometry;
  4135. };
  4136. removedMeshes: Array<number>;
  4137. removedGeometries: Array<string>;
  4138. }
  4139. enum WorkerReplyType {
  4140. SUCCESS = 0,
  4141. UNKNOWN_ERROR = 1,
  4142. }
  4143. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  4144. private _scene;
  4145. private _scaledPosition;
  4146. private _scaledVelocity;
  4147. private _collisionsCallbackArray;
  4148. private _init;
  4149. private _runningUpdated;
  4150. private _worker;
  4151. private _addUpdateMeshesList;
  4152. private _addUpdateGeometriesList;
  4153. private _toRemoveMeshesArray;
  4154. private _toRemoveGeometryArray;
  4155. constructor();
  4156. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  4157. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  4158. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4159. init(scene: Scene): void;
  4160. destroy(): void;
  4161. onMeshAdded(mesh: AbstractMesh): void;
  4162. onMeshUpdated: (transformNode: TransformNode) => void;
  4163. onMeshRemoved(mesh: AbstractMesh): void;
  4164. onGeometryAdded(geometry: Geometry): void;
  4165. onGeometryUpdated: (geometry: Geometry) => void;
  4166. onGeometryDeleted(geometry: Geometry): void;
  4167. private _afterRender;
  4168. private _onMessageFromWorker;
  4169. }
  4170. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  4171. private _scene;
  4172. private _scaledPosition;
  4173. private _scaledVelocity;
  4174. private _finalPosition;
  4175. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4176. init(scene: Scene): void;
  4177. destroy(): void;
  4178. onMeshAdded(mesh: AbstractMesh): void;
  4179. onMeshUpdated(mesh: AbstractMesh): void;
  4180. onMeshRemoved(mesh: AbstractMesh): void;
  4181. onGeometryAdded(geometry: Geometry): void;
  4182. onGeometryUpdated(geometry: Geometry): void;
  4183. onGeometryDeleted(geometry: Geometry): void;
  4184. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  4185. }
  4186. }
  4187. declare function importScripts(...urls: string[]): void;
  4188. declare const safePostMessage: any;
  4189. declare module BABYLON {
  4190. var WorkerIncluded: boolean;
  4191. class CollisionCache {
  4192. private _meshes;
  4193. private _geometries;
  4194. getMeshes(): {
  4195. [n: number]: SerializedMesh;
  4196. };
  4197. getGeometries(): {
  4198. [s: number]: SerializedGeometry;
  4199. };
  4200. getMesh(id: any): SerializedMesh;
  4201. addMesh(mesh: SerializedMesh): void;
  4202. removeMesh(uniqueId: number): void;
  4203. getGeometry(id: string): SerializedGeometry;
  4204. addGeometry(geometry: SerializedGeometry): void;
  4205. removeGeometry(id: string): void;
  4206. }
  4207. class CollideWorker {
  4208. collider: Collider;
  4209. private _collisionCache;
  4210. private finalPosition;
  4211. private collisionsScalingMatrix;
  4212. private collisionTranformationMatrix;
  4213. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  4214. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  4215. private checkCollision(mesh);
  4216. private processCollisionsForSubMeshes(transformMatrix, mesh);
  4217. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  4218. private checkSubmeshCollision(subMesh);
  4219. }
  4220. interface ICollisionDetector {
  4221. onInit(payload: InitPayload): void;
  4222. onUpdate(payload: UpdatePayload): void;
  4223. onCollision(payload: CollidePayload): void;
  4224. }
  4225. class CollisionDetectorTransferable implements ICollisionDetector {
  4226. private _collisionCache;
  4227. onInit(payload: InitPayload): void;
  4228. onUpdate(payload: UpdatePayload): void;
  4229. onCollision(payload: CollidePayload): void;
  4230. }
  4231. }
  4232. declare module BABYLON {
  4233. class IntersectionInfo {
  4234. bu: Nullable<number>;
  4235. bv: Nullable<number>;
  4236. distance: number;
  4237. faceId: number;
  4238. subMeshId: number;
  4239. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  4240. }
  4241. class PickingInfo {
  4242. hit: boolean;
  4243. distance: number;
  4244. pickedPoint: Nullable<Vector3>;
  4245. pickedMesh: Nullable<AbstractMesh>;
  4246. bu: number;
  4247. bv: number;
  4248. faceId: number;
  4249. subMeshId: number;
  4250. pickedSprite: Nullable<Sprite>;
  4251. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  4252. getTextureCoordinates(): Nullable<Vector2>;
  4253. }
  4254. }
  4255. declare module BABYLON {
  4256. class InstancingAttributeInfo {
  4257. /**
  4258. * Index/offset of the attribute in the vertex shader
  4259. */
  4260. index: number;
  4261. /**
  4262. * size of the attribute, 1, 2, 3 or 4
  4263. */
  4264. attributeSize: number;
  4265. /**
  4266. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  4267. * default is FLOAT
  4268. */
  4269. attribyteType: number;
  4270. /**
  4271. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  4272. */
  4273. normalized: boolean;
  4274. /**
  4275. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  4276. */
  4277. offset: number;
  4278. /**
  4279. * Name of the GLSL attribute, for debugging purpose only
  4280. */
  4281. attributeName: string;
  4282. }
  4283. /**
  4284. * Define options used to create a render target texture
  4285. */
  4286. class RenderTargetCreationOptions {
  4287. generateMipMaps?: boolean;
  4288. generateDepthBuffer?: boolean;
  4289. generateStencilBuffer?: boolean;
  4290. type?: number;
  4291. samplingMode?: number;
  4292. }
  4293. /**
  4294. * Define options used to create a depth texture
  4295. */
  4296. class DepthTextureCreationOptions {
  4297. /** Specifies wether or not a stencil should be allocated in the texture */
  4298. generateStencil?: boolean;
  4299. /** Specifies wether or not bilinear filtering is enable on the texture */
  4300. bilinearFiltering?: boolean;
  4301. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  4302. comparisonFunction?: number;
  4303. }
  4304. /**
  4305. * Regroup several parameters relative to the browser in use
  4306. */
  4307. class EngineCapabilities {
  4308. /** The maximum textures image */
  4309. maxTexturesImageUnits: number;
  4310. maxVertexTextureImageUnits: number;
  4311. maxCombinedTexturesImageUnits: number;
  4312. /** The maximum texture size */
  4313. maxTextureSize: number;
  4314. maxCubemapTextureSize: number;
  4315. maxRenderTextureSize: number;
  4316. maxVertexAttribs: number;
  4317. maxVaryingVectors: number;
  4318. maxVertexUniformVectors: number;
  4319. maxFragmentUniformVectors: number;
  4320. standardDerivatives: boolean;
  4321. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  4322. pvrtc: any;
  4323. etc1: any;
  4324. etc2: any;
  4325. astc: any;
  4326. textureFloat: boolean;
  4327. vertexArrayObject: boolean;
  4328. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  4329. maxAnisotropy: number;
  4330. instancedArrays: boolean;
  4331. uintIndices: boolean;
  4332. highPrecisionShaderSupported: boolean;
  4333. fragmentDepthSupported: boolean;
  4334. textureFloatLinearFiltering: boolean;
  4335. textureFloatRender: boolean;
  4336. textureHalfFloat: boolean;
  4337. textureHalfFloatLinearFiltering: boolean;
  4338. textureHalfFloatRender: boolean;
  4339. textureLOD: boolean;
  4340. drawBuffersExtension: boolean;
  4341. depthTextureExtension: boolean;
  4342. colorBufferFloat: boolean;
  4343. timerQuery: EXT_disjoint_timer_query;
  4344. canUseTimestampForTimerQuery: boolean;
  4345. }
  4346. interface EngineOptions extends WebGLContextAttributes {
  4347. limitDeviceRatio?: number;
  4348. autoEnableWebVR?: boolean;
  4349. disableWebGL2Support?: boolean;
  4350. audioEngine?: boolean;
  4351. deterministicLockstep?: boolean;
  4352. lockstepMaxSteps?: number;
  4353. doNotHandleContextLost?: boolean;
  4354. }
  4355. interface IDisplayChangedEventArgs {
  4356. vrDisplay: Nullable<any>;
  4357. vrSupported: boolean;
  4358. }
  4359. /**
  4360. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio.
  4361. */
  4362. class Engine {
  4363. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  4364. static ExceptionList: ({
  4365. key: string;
  4366. capture: string;
  4367. captureConstraint: number;
  4368. targets: string[];
  4369. } | {
  4370. key: string;
  4371. capture: null;
  4372. captureConstraint: null;
  4373. targets: string[];
  4374. })[];
  4375. static Instances: Engine[];
  4376. static readonly LastCreatedEngine: Nullable<Engine>;
  4377. static readonly LastCreatedScene: Nullable<Scene>;
  4378. /**
  4379. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  4380. */
  4381. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  4382. private static _ALPHA_DISABLE;
  4383. private static _ALPHA_ADD;
  4384. private static _ALPHA_COMBINE;
  4385. private static _ALPHA_SUBTRACT;
  4386. private static _ALPHA_MULTIPLY;
  4387. private static _ALPHA_MAXIMIZED;
  4388. private static _ALPHA_ONEONE;
  4389. private static _ALPHA_PREMULTIPLIED;
  4390. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  4391. private static _ALPHA_INTERPOLATE;
  4392. private static _ALPHA_SCREENMODE;
  4393. private static _DELAYLOADSTATE_NONE;
  4394. private static _DELAYLOADSTATE_LOADED;
  4395. private static _DELAYLOADSTATE_LOADING;
  4396. private static _DELAYLOADSTATE_NOTLOADED;
  4397. private static _TEXTUREFORMAT_ALPHA;
  4398. private static _TEXTUREFORMAT_LUMINANCE;
  4399. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  4400. private static _TEXTUREFORMAT_RGB;
  4401. private static _TEXTUREFORMAT_RGBA;
  4402. private static _TEXTUREFORMAT_R32F;
  4403. private static _TEXTUREFORMAT_RG32F;
  4404. private static _TEXTUREFORMAT_RGB32F;
  4405. private static _TEXTUREFORMAT_RGBA32F;
  4406. private static _TEXTURETYPE_UNSIGNED_INT;
  4407. private static _TEXTURETYPE_FLOAT;
  4408. private static _TEXTURETYPE_HALF_FLOAT;
  4409. private static _NEVER;
  4410. private static _ALWAYS;
  4411. private static _LESS;
  4412. private static _EQUAL;
  4413. private static _LEQUAL;
  4414. private static _GREATER;
  4415. private static _GEQUAL;
  4416. private static _NOTEQUAL;
  4417. static readonly NEVER: number;
  4418. static readonly ALWAYS: number;
  4419. static readonly LESS: number;
  4420. static readonly EQUAL: number;
  4421. static readonly LEQUAL: number;
  4422. static readonly GREATER: number;
  4423. static readonly GEQUAL: number;
  4424. static readonly NOTEQUAL: number;
  4425. private static _KEEP;
  4426. private static _REPLACE;
  4427. private static _INCR;
  4428. private static _DECR;
  4429. private static _INVERT;
  4430. private static _INCR_WRAP;
  4431. private static _DECR_WRAP;
  4432. static readonly KEEP: number;
  4433. static readonly REPLACE: number;
  4434. static readonly INCR: number;
  4435. static readonly DECR: number;
  4436. static readonly INVERT: number;
  4437. static readonly INCR_WRAP: number;
  4438. static readonly DECR_WRAP: number;
  4439. static readonly ALPHA_DISABLE: number;
  4440. static readonly ALPHA_ONEONE: number;
  4441. static readonly ALPHA_ADD: number;
  4442. static readonly ALPHA_COMBINE: number;
  4443. static readonly ALPHA_SUBTRACT: number;
  4444. static readonly ALPHA_MULTIPLY: number;
  4445. static readonly ALPHA_MAXIMIZED: number;
  4446. static readonly ALPHA_PREMULTIPLIED: number;
  4447. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4448. static readonly ALPHA_INTERPOLATE: number;
  4449. static readonly ALPHA_SCREENMODE: number;
  4450. static readonly DELAYLOADSTATE_NONE: number;
  4451. static readonly DELAYLOADSTATE_LOADED: number;
  4452. static readonly DELAYLOADSTATE_LOADING: number;
  4453. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4454. static readonly TEXTUREFORMAT_ALPHA: number;
  4455. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4456. /**
  4457. * R32F
  4458. */
  4459. static readonly TEXTUREFORMAT_R32F: number;
  4460. /**
  4461. * RG32F
  4462. */
  4463. static readonly TEXTUREFORMAT_RG32F: number;
  4464. /**
  4465. * RGB32F
  4466. */
  4467. static readonly TEXTUREFORMAT_RGB32F: number;
  4468. /**
  4469. * RGBA32F
  4470. */
  4471. static readonly TEXTUREFORMAT_RGBA32F: number;
  4472. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4473. static readonly TEXTUREFORMAT_RGB: number;
  4474. static readonly TEXTUREFORMAT_RGBA: number;
  4475. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4476. static readonly TEXTURETYPE_FLOAT: number;
  4477. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4478. private static _SCALEMODE_FLOOR;
  4479. private static _SCALEMODE_NEAREST;
  4480. private static _SCALEMODE_CEILING;
  4481. static readonly SCALEMODE_FLOOR: number;
  4482. static readonly SCALEMODE_NEAREST: number;
  4483. static readonly SCALEMODE_CEILING: number;
  4484. static readonly Version: string;
  4485. static CollisionsEpsilon: number;
  4486. static CodeRepository: string;
  4487. static ShadersRepository: string;
  4488. forcePOTTextures: boolean;
  4489. isFullscreen: boolean;
  4490. isPointerLock: boolean;
  4491. cullBackFaces: boolean;
  4492. renderEvenInBackground: boolean;
  4493. preventCacheWipeBetweenFrames: boolean;
  4494. enableOfflineSupport: boolean;
  4495. scenes: Scene[];
  4496. postProcesses: PostProcess[];
  4497. /**
  4498. * Observable event triggered each time the rendering canvas is resized
  4499. */
  4500. onResizeObservable: Observable<Engine>;
  4501. /**
  4502. * Observable event triggered each time the canvas loses focus
  4503. */
  4504. onCanvasBlurObservable: Observable<Engine>;
  4505. /**
  4506. * Observable event triggered each time the canvas gains focus
  4507. */
  4508. onCanvasFocusObservable: Observable<Engine>;
  4509. /**
  4510. * Observable event triggered each time the canvas receives pointerout event
  4511. */
  4512. onCanvasPointerOutObservable: Observable<PointerEvent>;
  4513. /**
  4514. * Observable event triggered before each texture is initialized
  4515. */
  4516. onBeforeTextureInitObservable: Observable<Texture>;
  4517. private _vrDisplay;
  4518. private _vrSupported;
  4519. private _oldSize;
  4520. private _oldHardwareScaleFactor;
  4521. private _vrExclusivePointerMode;
  4522. private _webVRInitPromise;
  4523. readonly isInVRExclusivePointerMode: boolean;
  4524. disableUniformBuffers: boolean;
  4525. _uniformBuffers: UniformBuffer[];
  4526. readonly supportsUniformBuffers: boolean;
  4527. /**
  4528. * Observable raised when the engine begins a new frame
  4529. */
  4530. onBeginFrameObservable: Observable<Engine>;
  4531. /**
  4532. * Observable raised when the engine ends the current frame
  4533. */
  4534. onEndFrameObservable: Observable<Engine>;
  4535. /**
  4536. * Observable raised when the engine is about to compile a shader
  4537. */
  4538. onBeforeShaderCompilationObservable: Observable<Engine>;
  4539. /**
  4540. * Observable raised when the engine has jsut compiled a shader
  4541. */
  4542. onAfterShaderCompilationObservable: Observable<Engine>;
  4543. private _gl;
  4544. private _renderingCanvas;
  4545. private _windowIsBackground;
  4546. private _webGLVersion;
  4547. readonly needPOTTextures: boolean;
  4548. private _badOS;
  4549. readonly badOS: boolean;
  4550. private _badDesktopOS;
  4551. readonly badDesktopOS: boolean;
  4552. /**
  4553. * Gets or sets a value indicating if we want to disable texture binding optmization.
  4554. * This could be required on some buggy drivers which wants to have textures bound in a progressive order
  4555. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is.
  4556. */
  4557. disableTextureBindingOptimization: boolean;
  4558. static audioEngine: AudioEngine;
  4559. private _onFocus;
  4560. private _onBlur;
  4561. private _onCanvasPointerOut;
  4562. private _onCanvasBlur;
  4563. private _onCanvasFocus;
  4564. private _onFullscreenChange;
  4565. private _onPointerLockChange;
  4566. private _onVRDisplayPointerRestricted;
  4567. private _onVRDisplayPointerUnrestricted;
  4568. private _onVrDisplayConnect;
  4569. private _onVrDisplayDisconnect;
  4570. private _onVrDisplayPresentChange;
  4571. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  4572. onVRRequestPresentComplete: Observable<boolean>;
  4573. onVRRequestPresentStart: Observable<Engine>;
  4574. private _hardwareScalingLevel;
  4575. protected _caps: EngineCapabilities;
  4576. private _pointerLockRequested;
  4577. private _isStencilEnable;
  4578. private _colorWrite;
  4579. private _loadingScreen;
  4580. _drawCalls: PerfCounter;
  4581. _textureCollisions: PerfCounter;
  4582. private _glVersion;
  4583. private _glRenderer;
  4584. private _glVendor;
  4585. private _videoTextureSupported;
  4586. private _renderingQueueLaunched;
  4587. private _activeRenderLoops;
  4588. private _deterministicLockstep;
  4589. private _lockstepMaxSteps;
  4590. onContextLostObservable: Observable<Engine>;
  4591. onContextRestoredObservable: Observable<Engine>;
  4592. private _onContextLost;
  4593. private _onContextRestored;
  4594. private _contextWasLost;
  4595. private _doNotHandleContextLost;
  4596. private _performanceMonitor;
  4597. private _fps;
  4598. private _deltaTime;
  4599. /**
  4600. * Turn this value on if you want to pause FPS computation when in background
  4601. */
  4602. disablePerformanceMonitorInBackground: boolean;
  4603. readonly performanceMonitor: PerformanceMonitor;
  4604. protected _depthCullingState: _DepthCullingState;
  4605. protected _stencilState: _StencilState;
  4606. protected _alphaState: _AlphaState;
  4607. protected _alphaMode: number;
  4608. private _internalTexturesCache;
  4609. protected _activeChannel: number;
  4610. private _currentTextureChannel;
  4611. protected _boundTexturesCache: {
  4612. [key: string]: Nullable<InternalTexture>;
  4613. };
  4614. protected _currentEffect: Nullable<Effect>;
  4615. protected _currentProgram: Nullable<WebGLProgram>;
  4616. private _compiledEffects;
  4617. private _vertexAttribArraysEnabled;
  4618. protected _cachedViewport: Nullable<Viewport>;
  4619. private _cachedVertexArrayObject;
  4620. protected _cachedVertexBuffers: any;
  4621. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  4622. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  4623. protected _currentRenderTarget: Nullable<InternalTexture>;
  4624. private _uintIndicesCurrentlySet;
  4625. private _currentBoundBuffer;
  4626. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  4627. private _currentBufferPointers;
  4628. private _currentInstanceLocations;
  4629. private _currentInstanceBuffers;
  4630. private _textureUnits;
  4631. private _firstBoundInternalTextureTracker;
  4632. private _lastBoundInternalTextureTracker;
  4633. private _workingCanvas;
  4634. private _workingContext;
  4635. private _rescalePostProcess;
  4636. private _dummyFramebuffer;
  4637. private _externalData;
  4638. private _bindedRenderFunction;
  4639. private _vaoRecordInProgress;
  4640. private _mustWipeVertexAttributes;
  4641. private _emptyTexture;
  4642. private _emptyCubeTexture;
  4643. private _emptyTexture3D;
  4644. private _frameHandler;
  4645. private _nextFreeTextureSlots;
  4646. private _maxSimultaneousTextures;
  4647. private _activeRequests;
  4648. private _texturesSupported;
  4649. private _textureFormatInUse;
  4650. readonly texturesSupported: Array<string>;
  4651. readonly textureFormatInUse: Nullable<string>;
  4652. readonly currentViewport: Nullable<Viewport>;
  4653. readonly emptyTexture: InternalTexture;
  4654. readonly emptyTexture3D: InternalTexture;
  4655. readonly emptyCubeTexture: InternalTexture;
  4656. /**
  4657. * @constructor
  4658. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  4659. * @param antialias defines enable antialiasing (default: false)
  4660. * @param options defines further options to be sent to the getContext() function
  4661. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  4662. */
  4663. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  4664. private _rebuildInternalTextures();
  4665. private _rebuildEffects();
  4666. private _rebuildBuffers();
  4667. private _initGLContext();
  4668. readonly webGLVersion: number;
  4669. /**
  4670. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  4671. */
  4672. readonly isStencilEnable: boolean;
  4673. private _prepareWorkingCanvas();
  4674. resetTextureCache(): void;
  4675. isDeterministicLockStep(): boolean;
  4676. getLockstepMaxSteps(): number;
  4677. getGlInfo(): {
  4678. vendor: string;
  4679. renderer: string;
  4680. version: string;
  4681. };
  4682. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  4683. getRenderWidth(useScreen?: boolean): number;
  4684. getRenderHeight(useScreen?: boolean): number;
  4685. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  4686. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  4687. setHardwareScalingLevel(level: number): void;
  4688. getHardwareScalingLevel(): number;
  4689. getLoadedTexturesCache(): InternalTexture[];
  4690. getCaps(): EngineCapabilities;
  4691. /** The number of draw calls submitted last frame */
  4692. readonly drawCalls: number;
  4693. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  4694. getDepthFunction(): Nullable<number>;
  4695. setDepthFunction(depthFunc: number): void;
  4696. setDepthFunctionToGreater(): void;
  4697. setDepthFunctionToGreaterOrEqual(): void;
  4698. setDepthFunctionToLess(): void;
  4699. setDepthFunctionToLessOrEqual(): void;
  4700. getStencilBuffer(): boolean;
  4701. setStencilBuffer(enable: boolean): void;
  4702. getStencilMask(): number;
  4703. setStencilMask(mask: number): void;
  4704. getStencilFunction(): number;
  4705. getStencilFunctionReference(): number;
  4706. getStencilFunctionMask(): number;
  4707. setStencilFunction(stencilFunc: number): void;
  4708. setStencilFunctionReference(reference: number): void;
  4709. setStencilFunctionMask(mask: number): void;
  4710. getStencilOperationFail(): number;
  4711. getStencilOperationDepthFail(): number;
  4712. getStencilOperationPass(): number;
  4713. setStencilOperationFail(operation: number): void;
  4714. setStencilOperationDepthFail(operation: number): void;
  4715. setStencilOperationPass(operation: number): void;
  4716. setDitheringState(value: boolean): void;
  4717. setRasterizerState(value: boolean): void;
  4718. /**
  4719. * stop executing a render loop function and remove it from the execution array
  4720. * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
  4721. */
  4722. stopRenderLoop(renderFunction?: () => void): void;
  4723. _renderLoop(): void;
  4724. /**
  4725. * Register and execute a render loop. The engine can have more than one render function.
  4726. * @param {Function} renderFunction - the function to continuously execute starting the next render loop.
  4727. * @example
  4728. * engine.runRenderLoop(function () {
  4729. * scene.render()
  4730. * })
  4731. */
  4732. runRenderLoop(renderFunction: () => void): void;
  4733. /**
  4734. * Toggle full screen mode.
  4735. * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
  4736. * @param {any} options - an options object to be sent to the requestFullscreen function
  4737. */
  4738. switchFullscreen(requestPointerLock: boolean): void;
  4739. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  4740. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  4741. /**
  4742. * Set the WebGL's viewport
  4743. * @param {BABYLON.Viewport} viewport - the viewport element to be used.
  4744. * @param {number} [requiredWidth] - the width required for rendering. If not provided the rendering canvas' width is used.
  4745. * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
  4746. */
  4747. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  4748. /**
  4749. * Directly set the WebGL Viewport
  4750. * The x, y, width & height are directly passed to the WebGL call
  4751. * @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.
  4752. */
  4753. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  4754. beginFrame(): void;
  4755. endFrame(): void;
  4756. /**
  4757. * resize the view according to the canvas' size.
  4758. * @example
  4759. * window.addEventListener("resize", function () {
  4760. * engine.resize();
  4761. * });
  4762. */
  4763. resize(): void;
  4764. /**
  4765. * force a specific size of the canvas
  4766. * @param {number} width - the new canvas' width
  4767. * @param {number} height - the new canvas' height
  4768. */
  4769. setSize(width: number, height: number): void;
  4770. isVRDevicePresent(): boolean;
  4771. getVRDevice(): any;
  4772. /**
  4773. * Initializes a webVR display and starts listening to display change events.
  4774. * The onVRDisplayChangedObservable will be notified upon these changes.
  4775. * @returns The onVRDisplayChangedObservable.
  4776. */
  4777. initWebVR(): Observable<IDisplayChangedEventArgs>;
  4778. /**
  4779. * Initializes a webVR display and starts listening to display change events.
  4780. * The onVRDisplayChangedObservable will be notified upon these changes.
  4781. * @returns A promise containing a VRDisplay and if vr is supported.
  4782. */
  4783. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  4784. enableVR(): void;
  4785. disableVR(): void;
  4786. private _onVRFullScreenTriggered;
  4787. private _getVRDisplaysAsync();
  4788. /**
  4789. * Binds the frame buffer to the specified texture.
  4790. * @param texture The texture to render to or null for the default canvas
  4791. * @param faceIndex The face of the texture to render to in case of cube texture
  4792. * @param requiredWidth The width of the target to render to
  4793. * @param requiredHeight The height of the target to render to
  4794. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  4795. * @param depthStencilTexture The depth stencil texture to use to render
  4796. */
  4797. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  4798. private bindUnboundFramebuffer(framebuffer);
  4799. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  4800. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  4801. generateMipMapsForCubemap(texture: InternalTexture): void;
  4802. flushFramebuffer(): void;
  4803. restoreDefaultFramebuffer(): void;
  4804. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  4805. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  4806. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  4807. private _resetVertexBufferBinding();
  4808. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4809. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4810. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  4811. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  4812. private _resetIndexBufferBinding();
  4813. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  4814. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  4815. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  4816. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  4817. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  4818. private bindIndexBuffer(buffer);
  4819. private bindBuffer(buffer, target);
  4820. updateArrayBuffer(data: Float32Array): void;
  4821. private vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  4822. private _bindIndexBufferWithCache(indexBuffer);
  4823. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  4824. recordVertexArrayObject(vertexBuffers: {
  4825. [key: string]: VertexBuffer;
  4826. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  4827. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  4828. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  4829. private _unbindVertexArrayObject();
  4830. bindBuffers(vertexBuffers: {
  4831. [key: string]: Nullable<VertexBuffer>;
  4832. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  4833. unbindInstanceAttributes(): void;
  4834. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  4835. _releaseBuffer(buffer: WebGLBuffer): boolean;
  4836. createInstancesBuffer(capacity: number): WebGLBuffer;
  4837. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  4838. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  4839. applyStates(): void;
  4840. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  4841. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4842. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4843. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  4844. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4845. private DrawMode(fillMode);
  4846. _releaseEffect(effect: Effect): void;
  4847. _deleteProgram(program: WebGLProgram): void;
  4848. /**
  4849. * @param baseName The base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  4850. * @param samplers An array of string used to represent textures
  4851. */
  4852. 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;
  4853. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  4854. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  4855. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  4856. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  4857. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  4858. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  4859. enableEffect(effect: Nullable<Effect>): void;
  4860. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4861. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4862. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4863. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4864. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4865. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4866. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4867. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4868. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4869. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4870. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4871. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4872. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  4873. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  4874. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  4875. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  4876. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  4877. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  4878. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  4879. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  4880. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  4881. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  4882. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  4883. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  4884. /**
  4885. * Sets a Color4 on a uniform variable
  4886. * @param uniform defines the uniform location
  4887. * @param color4 defines the value to be set
  4888. */
  4889. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  4890. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  4891. setZOffset(value: number): void;
  4892. getZOffset(): number;
  4893. setDepthBuffer(enable: boolean): void;
  4894. getDepthWrite(): boolean;
  4895. setDepthWrite(enable: boolean): void;
  4896. setColorWrite(enable: boolean): void;
  4897. getColorWrite(): boolean;
  4898. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  4899. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  4900. getAlphaMode(): number;
  4901. wipeCaches(bruteForce?: boolean): void;
  4902. /**
  4903. * Set the compressed texture format to use, based on the formats you have, and the formats
  4904. * supported by the hardware / browser.
  4905. *
  4906. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  4907. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  4908. * to API arguments needed to compressed textures. This puts the burden on the container
  4909. * generator to house the arcane code for determining these for current & future formats.
  4910. *
  4911. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  4912. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  4913. *
  4914. * Note: The result of this call is not taken into account when a texture is base64.
  4915. *
  4916. * @param {Array<string>} formatsAvailable- The list of those format families you have created
  4917. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  4918. *
  4919. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  4920. * @returns The extension selected.
  4921. */
  4922. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  4923. _createTexture(): WebGLTexture;
  4924. /**
  4925. * Usually called from BABYLON.Texture.ts. Passed information to create a WebGLTexture.
  4926. * @param {string} urlArg- This contains one of the following:
  4927. * 1. A conventional http URL, e.g. 'http://...' or 'file://...'
  4928. * 2. A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  4929. * 3. An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  4930. *
  4931. * @param {boolean} noMipmap- When true, no mipmaps shall be generated. Ignored for compressed textures. They must be in the file.
  4932. * @param {boolean} invertY- When true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file.
  4933. * @param {Scene} scene- Needed for loading to the correct scene.
  4934. * @param {number} samplingMode- Mode with should be used sample / access the texture. Default: TRILINEAR
  4935. * @param {callback} onLoad- Optional callback to be called upon successful completion.
  4936. * @param {callback} onError- Optional callback to be called upon failure.
  4937. * @param {ArrayBuffer | HTMLImageElement} buffer- A source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
  4938. * @param {WebGLTexture} fallback- An internal argument in case the function must be called again, due to etc1 not having alpha capabilities.
  4939. * @param {number} format- Internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures.
  4940. *
  4941. * @returns {WebGLTexture} for assignment back into BABYLON.Texture
  4942. */
  4943. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  4944. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  4945. private _getInternalFormat(format);
  4946. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  4947. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  4948. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  4949. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  4950. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  4951. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  4952. /**
  4953. * Updates a depth texture Comparison Mode and Function.
  4954. * If the comparison Function is equal to 0, the mode will be set to none.
  4955. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  4956. * @param texture The texture to set the comparison function for
  4957. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  4958. */
  4959. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  4960. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  4961. /**
  4962. * Creates a depth stencil texture.
  4963. * This is only available in WebGL 2 or with the depth texture extension available.
  4964. * @param size The size of face edge in the texture.
  4965. * @param options The options defining the texture.
  4966. * @returns The texture
  4967. */
  4968. createDepthStencilTexture(size: number | {
  4969. width: number;
  4970. height: number;
  4971. }, options: DepthTextureCreationOptions): InternalTexture;
  4972. /**
  4973. * Creates a depth stencil cube texture.
  4974. * This is only available in WebGL 2.
  4975. * @param size The size of face edge in the cube texture.
  4976. * @param options The options defining the cube texture.
  4977. * @returns The cube texture
  4978. */
  4979. createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  4980. /**
  4981. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  4982. * @param renderTarget The render target to set the frame buffer for
  4983. */
  4984. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  4985. createRenderTargetTexture(size: number | {
  4986. width: number;
  4987. height: number;
  4988. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  4989. createMultipleRenderTarget(size: any, options: any): InternalTexture[];
  4990. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  4991. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  4992. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  4993. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  4994. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  4995. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  4996. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, scale: number, offset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any): InternalTexture;
  4997. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any): InternalTexture;
  4998. private setCubeMapTextureParams(gl, loadMipmap);
  4999. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  5000. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  5001. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, samplingMode?: number, invertY?: boolean): InternalTexture;
  5002. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  5003. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  5004. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  5005. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  5006. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  5007. _releaseFramebufferObjects(texture: InternalTexture): void;
  5008. _releaseTexture(texture: InternalTexture): void;
  5009. private setProgram(program);
  5010. private _boundUniforms;
  5011. bindSamplers(effect: Effect): void;
  5012. private _moveBoundTextureOnTop(internalTexture);
  5013. private _getCorrectTextureChannel(channel, internalTexture);
  5014. private _linkTrackers(previous, next);
  5015. private _removeDesignatedSlot(internalTexture);
  5016. private _activateCurrentTexture();
  5017. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean): void;
  5018. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  5019. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  5020. unbindAllTextures(): void;
  5021. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  5022. private _bindSamplerUniformToChannel(sourceSlot, destination);
  5023. private _setTexture(channel, texture, isPartOfTextureArray?);
  5024. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  5025. _setAnisotropicLevel(key: number, texture: BaseTexture): void;
  5026. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  5027. /**
  5028. * Add an externaly attached data from its key.
  5029. * This method call will fail and return false, if such key already exists.
  5030. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  5031. * @param key the unique key that identifies the data
  5032. * @param data the data object to associate to the key for this Engine instance
  5033. * @return true if no such key were already present and the data was added successfully, false otherwise
  5034. */
  5035. addExternalData<T>(key: string, data: T): boolean;
  5036. /**
  5037. * Get an externaly attached data from its key
  5038. * @param key the unique key that identifies the data
  5039. * @return the associated data, if present (can be null), or undefined if not present
  5040. */
  5041. getExternalData<T>(key: string): T;
  5042. /**
  5043. * Get an externaly attached data from its key, create it using a factory if it's not already present
  5044. * @param key the unique key that identifies the data
  5045. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  5046. * @return the associated data, can be null if the factory returned null.
  5047. */
  5048. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  5049. /**
  5050. * Remove an externaly attached data from the Engine instance
  5051. * @param key the unique key that identifies the data
  5052. * @return true if the data was successfully removed, false if it doesn't exist
  5053. */
  5054. removeExternalData(key: string): boolean;
  5055. unbindAllAttributes(): void;
  5056. releaseEffects(): void;
  5057. dispose(): void;
  5058. displayLoadingUI(): void;
  5059. hideLoadingUI(): void;
  5060. loadingScreen: ILoadingScreen;
  5061. loadingUIText: string;
  5062. loadingUIBackgroundColor: string;
  5063. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  5064. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  5065. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  5066. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  5067. getError(): number;
  5068. getFps(): number;
  5069. getDeltaTime(): number;
  5070. private _measureFps();
  5071. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  5072. private _canRenderToFloatFramebuffer();
  5073. private _canRenderToHalfFloatFramebuffer();
  5074. private _canRenderToFramebuffer(type);
  5075. _getWebGLTextureType(type: number): number;
  5076. /** @ignore */
  5077. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  5078. _getRGBAMultiSampleBufferFormat(type: number): number;
  5079. createQuery(): WebGLQuery;
  5080. deleteQuery(query: WebGLQuery): Engine;
  5081. isQueryResultAvailable(query: WebGLQuery): boolean;
  5082. getQueryResult(query: WebGLQuery): number;
  5083. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  5084. endOcclusionQuery(algorithmType: number): Engine;
  5085. private _createTimeQuery();
  5086. private _deleteTimeQuery(query);
  5087. private _getTimeQueryResult(query);
  5088. private _getTimeQueryAvailability(query);
  5089. private _currentNonTimestampToken;
  5090. startTimeQuery(): Nullable<_TimeToken>;
  5091. endTimeQuery(token: _TimeToken): int;
  5092. private getGlAlgorithmType(algorithmType);
  5093. createTransformFeedback(): WebGLTransformFeedback;
  5094. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  5095. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  5096. beginTransformFeedback(usePoints?: boolean): void;
  5097. endTransformFeedback(): void;
  5098. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  5099. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  5100. _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;
  5101. /** @ignore */
  5102. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  5103. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  5104. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  5105. static isSupported(): boolean;
  5106. }
  5107. }
  5108. declare module BABYLON {
  5109. class NullEngineOptions {
  5110. renderWidth: number;
  5111. renderHeight: number;
  5112. textureSize: number;
  5113. deterministicLockstep: boolean;
  5114. lockstepMaxSteps: number;
  5115. }
  5116. /**
  5117. * The null engine class provides support for headless version of babylon.js.
  5118. * This can be used in server side scenario or for testing purposes
  5119. */
  5120. class NullEngine extends Engine {
  5121. private _options;
  5122. isDeterministicLockStep(): boolean;
  5123. getLockstepMaxSteps(): number;
  5124. getHardwareScalingLevel(): number;
  5125. constructor(options?: NullEngineOptions);
  5126. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  5127. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  5128. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  5129. getRenderWidth(useScreen?: boolean): number;
  5130. getRenderHeight(useScreen?: boolean): number;
  5131. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  5132. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  5133. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  5134. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  5135. bindSamplers(effect: Effect): void;
  5136. enableEffect(effect: Effect): void;
  5137. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  5138. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  5139. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  5140. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  5141. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  5142. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  5143. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  5144. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  5145. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  5146. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  5147. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  5148. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  5149. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  5150. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  5151. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  5152. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  5153. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  5154. setFloat(uniform: WebGLUniformLocation, value: number): void;
  5155. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  5156. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  5157. setBool(uniform: WebGLUniformLocation, bool: number): void;
  5158. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  5159. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  5160. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  5161. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  5162. bindBuffers(vertexBuffers: {
  5163. [key: string]: VertexBuffer;
  5164. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  5165. wipeCaches(bruteForce?: boolean): void;
  5166. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  5167. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  5168. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  5169. _createTexture(): WebGLTexture;
  5170. 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;
  5171. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  5172. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  5173. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  5174. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  5175. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  5176. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  5177. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  5178. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  5179. _bindTexture(channel: number, texture: InternalTexture): void;
  5180. _releaseBuffer(buffer: WebGLBuffer): boolean;
  5181. }
  5182. }
  5183. interface WebGLRenderingContext {
  5184. readonly RASTERIZER_DISCARD: number;
  5185. readonly DEPTH_COMPONENT24: number;
  5186. readonly TEXTURE_3D: number;
  5187. readonly TEXTURE_2D_ARRAY: number;
  5188. readonly TEXTURE_COMPARE_FUNC: number;
  5189. readonly TEXTURE_COMPARE_MODE: number;
  5190. readonly COMPARE_REF_TO_TEXTURE: number;
  5191. readonly TEXTURE_WRAP_R: number;
  5192. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  5193. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  5194. 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;
  5195. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  5196. readonly TRANSFORM_FEEDBACK: number;
  5197. readonly INTERLEAVED_ATTRIBS: number;
  5198. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  5199. createTransformFeedback(): WebGLTransformFeedback;
  5200. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  5201. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  5202. beginTransformFeedback(primitiveMode: number): void;
  5203. endTransformFeedback(): void;
  5204. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  5205. }
  5206. interface ImageBitmap {
  5207. readonly width: number;
  5208. readonly height: number;
  5209. close(): void;
  5210. }
  5211. interface WebGLQuery extends WebGLObject {
  5212. }
  5213. declare var WebGLQuery: {
  5214. prototype: WebGLQuery;
  5215. new (): WebGLQuery;
  5216. };
  5217. interface WebGLSampler extends WebGLObject {
  5218. }
  5219. declare var WebGLSampler: {
  5220. prototype: WebGLSampler;
  5221. new (): WebGLSampler;
  5222. };
  5223. interface WebGLSync extends WebGLObject {
  5224. }
  5225. declare var WebGLSync: {
  5226. prototype: WebGLSync;
  5227. new (): WebGLSync;
  5228. };
  5229. interface WebGLTransformFeedback extends WebGLObject {
  5230. }
  5231. declare var WebGLTransformFeedback: {
  5232. prototype: WebGLTransformFeedback;
  5233. new (): WebGLTransformFeedback;
  5234. };
  5235. interface WebGLVertexArrayObject extends WebGLObject {
  5236. }
  5237. declare var WebGLVertexArrayObject: {
  5238. prototype: WebGLVertexArrayObject;
  5239. new (): WebGLVertexArrayObject;
  5240. };
  5241. declare module BABYLON {
  5242. class KeyboardEventTypes {
  5243. static _KEYDOWN: number;
  5244. static _KEYUP: number;
  5245. static readonly KEYDOWN: number;
  5246. static readonly KEYUP: number;
  5247. }
  5248. class KeyboardInfo {
  5249. type: number;
  5250. event: KeyboardEvent;
  5251. constructor(type: number, event: KeyboardEvent);
  5252. }
  5253. /**
  5254. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  5255. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  5256. */
  5257. class KeyboardInfoPre extends KeyboardInfo {
  5258. constructor(type: number, event: KeyboardEvent);
  5259. skipOnPointerObservable: boolean;
  5260. }
  5261. }
  5262. declare module BABYLON {
  5263. class PointerEventTypes {
  5264. static _POINTERDOWN: number;
  5265. static _POINTERUP: number;
  5266. static _POINTERMOVE: number;
  5267. static _POINTERWHEEL: number;
  5268. static _POINTERPICK: number;
  5269. static _POINTERTAP: number;
  5270. static _POINTERDOUBLETAP: number;
  5271. static readonly POINTERDOWN: number;
  5272. static readonly POINTERUP: number;
  5273. static readonly POINTERMOVE: number;
  5274. static readonly POINTERWHEEL: number;
  5275. static readonly POINTERPICK: number;
  5276. static readonly POINTERTAP: number;
  5277. static readonly POINTERDOUBLETAP: number;
  5278. }
  5279. class PointerInfoBase {
  5280. type: number;
  5281. event: PointerEvent | MouseWheelEvent;
  5282. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  5283. }
  5284. /**
  5285. * This class is used to store pointer related info for the onPrePointerObservable event.
  5286. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  5287. */
  5288. class PointerInfoPre extends PointerInfoBase {
  5289. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  5290. localPosition: Vector2;
  5291. skipOnPointerObservable: boolean;
  5292. }
  5293. /**
  5294. * This type contains all the data related to a pointer event in Babylon.js.
  5295. * 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.
  5296. */
  5297. class PointerInfo extends PointerInfoBase {
  5298. pickInfo: Nullable<PickingInfo>;
  5299. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  5300. }
  5301. }
  5302. declare module BABYLON {
  5303. class StickValues {
  5304. x: number;
  5305. y: number;
  5306. constructor(x: number, y: number);
  5307. }
  5308. interface GamepadButtonChanges {
  5309. changed: boolean;
  5310. pressChanged: boolean;
  5311. touchChanged: boolean;
  5312. valueChanged: boolean;
  5313. }
  5314. class Gamepad {
  5315. id: string;
  5316. index: number;
  5317. browserGamepad: any;
  5318. type: number;
  5319. private _leftStick;
  5320. private _rightStick;
  5321. _isConnected: boolean;
  5322. private _leftStickAxisX;
  5323. private _leftStickAxisY;
  5324. private _rightStickAxisX;
  5325. private _rightStickAxisY;
  5326. private _onleftstickchanged;
  5327. private _onrightstickchanged;
  5328. static GAMEPAD: number;
  5329. static GENERIC: number;
  5330. static XBOX: number;
  5331. static POSE_ENABLED: number;
  5332. protected _invertLeftStickY: boolean;
  5333. readonly isConnected: boolean;
  5334. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  5335. onleftstickchanged(callback: (values: StickValues) => void): void;
  5336. onrightstickchanged(callback: (values: StickValues) => void): void;
  5337. leftStick: StickValues;
  5338. rightStick: StickValues;
  5339. update(): void;
  5340. dispose(): void;
  5341. }
  5342. class GenericPad extends Gamepad {
  5343. private _buttons;
  5344. private _onbuttondown;
  5345. private _onbuttonup;
  5346. onButtonDownObservable: Observable<number>;
  5347. onButtonUpObservable: Observable<number>;
  5348. onbuttondown(callback: (buttonPressed: number) => void): void;
  5349. onbuttonup(callback: (buttonReleased: number) => void): void;
  5350. constructor(id: string, index: number, browserGamepad: any);
  5351. private _setButtonValue(newValue, currentValue, buttonIndex);
  5352. update(): void;
  5353. dispose(): void;
  5354. }
  5355. }
  5356. declare module BABYLON {
  5357. class GamepadManager {
  5358. private _scene;
  5359. private _babylonGamepads;
  5360. private _oneGamepadConnected;
  5361. _isMonitoring: boolean;
  5362. private _gamepadEventSupported;
  5363. private _gamepadSupport;
  5364. onGamepadConnectedObservable: Observable<Gamepad>;
  5365. onGamepadDisconnectedObservable: Observable<Gamepad>;
  5366. private _onGamepadConnectedEvent;
  5367. private _onGamepadDisconnectedEvent;
  5368. constructor(_scene?: Scene | undefined);
  5369. readonly gamepads: Gamepad[];
  5370. getGamepadByType(type?: number): Nullable<Gamepad>;
  5371. dispose(): void;
  5372. private _addNewGamepad(gamepad);
  5373. private _startMonitoringGamepads();
  5374. private _stopMonitoringGamepads();
  5375. _checkGamepadsStatus(): void;
  5376. private _updateGamepadObjects();
  5377. }
  5378. }
  5379. declare module BABYLON {
  5380. enum Xbox360Button {
  5381. A = 0,
  5382. B = 1,
  5383. X = 2,
  5384. Y = 3,
  5385. Start = 4,
  5386. Back = 5,
  5387. LB = 6,
  5388. RB = 7,
  5389. LeftStick = 8,
  5390. RightStick = 9,
  5391. }
  5392. enum Xbox360Dpad {
  5393. Up = 0,
  5394. Down = 1,
  5395. Left = 2,
  5396. Right = 3,
  5397. }
  5398. class Xbox360Pad extends Gamepad {
  5399. private _leftTrigger;
  5400. private _rightTrigger;
  5401. private _onlefttriggerchanged;
  5402. private _onrighttriggerchanged;
  5403. private _onbuttondown;
  5404. private _onbuttonup;
  5405. private _ondpaddown;
  5406. private _ondpadup;
  5407. onButtonDownObservable: Observable<Xbox360Button>;
  5408. onButtonUpObservable: Observable<Xbox360Button>;
  5409. onPadDownObservable: Observable<Xbox360Dpad>;
  5410. onPadUpObservable: Observable<Xbox360Dpad>;
  5411. private _buttonA;
  5412. private _buttonB;
  5413. private _buttonX;
  5414. private _buttonY;
  5415. private _buttonBack;
  5416. private _buttonStart;
  5417. private _buttonLB;
  5418. private _buttonRB;
  5419. private _buttonLeftStick;
  5420. private _buttonRightStick;
  5421. private _dPadUp;
  5422. private _dPadDown;
  5423. private _dPadLeft;
  5424. private _dPadRight;
  5425. private _isXboxOnePad;
  5426. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  5427. onlefttriggerchanged(callback: (value: number) => void): void;
  5428. onrighttriggerchanged(callback: (value: number) => void): void;
  5429. leftTrigger: number;
  5430. rightTrigger: number;
  5431. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  5432. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  5433. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  5434. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  5435. private _setButtonValue(newValue, currentValue, buttonType);
  5436. private _setDPadValue(newValue, currentValue, buttonType);
  5437. buttonA: number;
  5438. buttonB: number;
  5439. buttonX: number;
  5440. buttonY: number;
  5441. buttonStart: number;
  5442. buttonBack: number;
  5443. buttonLB: number;
  5444. buttonRB: number;
  5445. buttonLeftStick: number;
  5446. buttonRightStick: number;
  5447. dPadUp: number;
  5448. dPadDown: number;
  5449. dPadLeft: number;
  5450. dPadRight: number;
  5451. update(): void;
  5452. dispose(): void;
  5453. }
  5454. }
  5455. declare module BABYLON {
  5456. class LensFlare {
  5457. size: number;
  5458. position: number;
  5459. color: Color3;
  5460. texture: Nullable<Texture>;
  5461. alphaMode: number;
  5462. private _system;
  5463. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  5464. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  5465. dispose(): void;
  5466. }
  5467. }
  5468. declare module BABYLON {
  5469. class LensFlareSystem {
  5470. name: string;
  5471. lensFlares: LensFlare[];
  5472. borderLimit: number;
  5473. viewportBorder: number;
  5474. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  5475. layerMask: number;
  5476. id: string;
  5477. private _scene;
  5478. private _emitter;
  5479. private _vertexBuffers;
  5480. private _indexBuffer;
  5481. private _effect;
  5482. private _positionX;
  5483. private _positionY;
  5484. private _isEnabled;
  5485. constructor(name: string, emitter: any, scene: Scene);
  5486. isEnabled: boolean;
  5487. getScene(): Scene;
  5488. getEmitter(): any;
  5489. setEmitter(newEmitter: any): void;
  5490. getEmitterPosition(): Vector3;
  5491. computeEffectivePosition(globalViewport: Viewport): boolean;
  5492. _isVisible(): boolean;
  5493. render(): boolean;
  5494. dispose(): void;
  5495. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  5496. serialize(): any;
  5497. }
  5498. }
  5499. declare module BABYLON {
  5500. /**
  5501. * Represents the different options available during the creation of
  5502. * a Environment helper.
  5503. *
  5504. * This can control the default ground, skybox and image processing setup of your scene.
  5505. */
  5506. interface IEnvironmentHelperOptions {
  5507. /**
  5508. * Specifies wether or not to create a ground.
  5509. * True by default.
  5510. */
  5511. createGround: boolean;
  5512. /**
  5513. * Specifies the ground size.
  5514. * 15 by default.
  5515. */
  5516. groundSize: number;
  5517. /**
  5518. * The texture used on the ground for the main color.
  5519. * Comes from the BabylonJS CDN by default.
  5520. *
  5521. * Remarks: Can be either a texture or a url.
  5522. */
  5523. groundTexture: string | BaseTexture;
  5524. /**
  5525. * The color mixed in the ground texture by default.
  5526. * BabylonJS clearColor by default.
  5527. */
  5528. groundColor: Color3;
  5529. /**
  5530. * Specifies the ground opacity.
  5531. * 1 by default.
  5532. */
  5533. groundOpacity: number;
  5534. /**
  5535. * Enables the ground to receive shadows.
  5536. * True by default.
  5537. */
  5538. enableGroundShadow: boolean;
  5539. /**
  5540. * Helps preventing the shadow to be fully black on the ground.
  5541. * 0.5 by default.
  5542. */
  5543. groundShadowLevel: number;
  5544. /**
  5545. * Creates a mirror texture attach to the ground.
  5546. * false by default.
  5547. */
  5548. enableGroundMirror: boolean;
  5549. /**
  5550. * Specifies the ground mirror size ratio.
  5551. * 0.3 by default as the default kernel is 64.
  5552. */
  5553. groundMirrorSizeRatio: number;
  5554. /**
  5555. * Specifies the ground mirror blur kernel size.
  5556. * 64 by default.
  5557. */
  5558. groundMirrorBlurKernel: number;
  5559. /**
  5560. * Specifies the ground mirror visibility amount.
  5561. * 1 by default
  5562. */
  5563. groundMirrorAmount: number;
  5564. /**
  5565. * Specifies the ground mirror reflectance weight.
  5566. * This uses the standard weight of the background material to setup the fresnel effect
  5567. * of the mirror.
  5568. * 1 by default.
  5569. */
  5570. groundMirrorFresnelWeight: number;
  5571. /**
  5572. * Specifies the ground mirror Falloff distance.
  5573. * This can helps reducing the size of the reflection.
  5574. * 0 by Default.
  5575. */
  5576. groundMirrorFallOffDistance: number;
  5577. /**
  5578. * Specifies the ground mirror texture type.
  5579. * Unsigned Int by Default.
  5580. */
  5581. groundMirrorTextureType: number;
  5582. /**
  5583. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  5584. * the shown objects.
  5585. */
  5586. groundYBias: number;
  5587. /**
  5588. * Specifies wether or not to create a skybox.
  5589. * True by default.
  5590. */
  5591. createSkybox: boolean;
  5592. /**
  5593. * Specifies the skybox size.
  5594. * 20 by default.
  5595. */
  5596. skyboxSize: number;
  5597. /**
  5598. * The texture used on the skybox for the main color.
  5599. * Comes from the BabylonJS CDN by default.
  5600. *
  5601. * Remarks: Can be either a texture or a url.
  5602. */
  5603. skyboxTexture: string | BaseTexture;
  5604. /**
  5605. * The color mixed in the skybox texture by default.
  5606. * BabylonJS clearColor by default.
  5607. */
  5608. skyboxColor: Color3;
  5609. /**
  5610. * The background rotation around the Y axis of the scene.
  5611. * This helps aligning the key lights of your scene with the background.
  5612. * 0 by default.
  5613. */
  5614. backgroundYRotation: number;
  5615. /**
  5616. * Compute automatically the size of the elements to best fit with the scene.
  5617. */
  5618. sizeAuto: boolean;
  5619. /**
  5620. * Default position of the rootMesh if autoSize is not true.
  5621. */
  5622. rootPosition: Vector3;
  5623. /**
  5624. * Sets up the image processing in the scene.
  5625. * true by default.
  5626. */
  5627. setupImageProcessing: boolean;
  5628. /**
  5629. * The texture used as your environment texture in the scene.
  5630. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  5631. *
  5632. * Remarks: Can be either a texture or a url.
  5633. */
  5634. environmentTexture: string | BaseTexture;
  5635. /**
  5636. * The value of the exposure to apply to the scene.
  5637. * 0.6 by default if setupImageProcessing is true.
  5638. */
  5639. cameraExposure: number;
  5640. /**
  5641. * The value of the contrast to apply to the scene.
  5642. * 1.6 by default if setupImageProcessing is true.
  5643. */
  5644. cameraContrast: number;
  5645. /**
  5646. * Specifies wether or not tonemapping should be enabled in the scene.
  5647. * true by default if setupImageProcessing is true.
  5648. */
  5649. toneMappingEnabled: boolean;
  5650. }
  5651. /**
  5652. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  5653. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  5654. * It also helps with the default setup of your imageProcessing configuration.
  5655. */
  5656. class EnvironmentHelper {
  5657. /**
  5658. * Default ground texture URL.
  5659. */
  5660. private static _groundTextureCDNUrl;
  5661. /**
  5662. * Default skybox texture URL.
  5663. */
  5664. private static _skyboxTextureCDNUrl;
  5665. /**
  5666. * Default environment texture URL.
  5667. */
  5668. private static _environmentTextureCDNUrl;
  5669. /**
  5670. * Creates the default options for the helper.
  5671. */
  5672. private static _getDefaultOptions();
  5673. private _rootMesh;
  5674. /**
  5675. * Gets the root mesh created by the helper.
  5676. */
  5677. readonly rootMesh: Mesh;
  5678. private _skybox;
  5679. /**
  5680. * Gets the skybox created by the helper.
  5681. */
  5682. readonly skybox: Nullable<Mesh>;
  5683. private _skyboxTexture;
  5684. /**
  5685. * Gets the skybox texture created by the helper.
  5686. */
  5687. readonly skyboxTexture: Nullable<BaseTexture>;
  5688. private _skyboxMaterial;
  5689. /**
  5690. * Gets the skybox material created by the helper.
  5691. */
  5692. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  5693. private _ground;
  5694. /**
  5695. * Gets the ground mesh created by the helper.
  5696. */
  5697. readonly ground: Nullable<Mesh>;
  5698. private _groundTexture;
  5699. /**
  5700. * Gets the ground texture created by the helper.
  5701. */
  5702. readonly groundTexture: Nullable<BaseTexture>;
  5703. private _groundMirror;
  5704. /**
  5705. * Gets the ground mirror created by the helper.
  5706. */
  5707. readonly groundMirror: Nullable<MirrorTexture>;
  5708. /**
  5709. * Gets the ground mirror render list to helps pushing the meshes
  5710. * you wish in the ground reflection.
  5711. */
  5712. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  5713. private _groundMaterial;
  5714. /**
  5715. * Gets the ground material created by the helper.
  5716. */
  5717. readonly groundMaterial: Nullable<BackgroundMaterial>;
  5718. /**
  5719. * Stores the creation options.
  5720. */
  5721. private readonly _scene;
  5722. private _options;
  5723. /**
  5724. * This observable will be notified with any error during the creation of the environment,
  5725. * mainly texture creation errors.
  5726. */
  5727. onErrorObservable: Observable<{
  5728. message?: string;
  5729. exception?: any;
  5730. }>;
  5731. /**
  5732. * constructor
  5733. * @param options
  5734. * @param scene The scene to add the material to
  5735. */
  5736. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  5737. /**
  5738. * Updates the background according to the new options
  5739. * @param options
  5740. */
  5741. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  5742. /**
  5743. * Sets the primary color of all the available elements.
  5744. * @param color
  5745. */
  5746. setMainColor(color: Color3): void;
  5747. /**
  5748. * Setup the image processing according to the specified options.
  5749. */
  5750. private _setupImageProcessing();
  5751. /**
  5752. * Setup the environment texture according to the specified options.
  5753. */
  5754. private _setupEnvironmentTexture();
  5755. /**
  5756. * Setup the background according to the specified options.
  5757. */
  5758. private _setupBackground();
  5759. /**
  5760. * Get the scene sizes according to the setup.
  5761. */
  5762. private _getSceneSize();
  5763. /**
  5764. * Setup the ground according to the specified options.
  5765. */
  5766. private _setupGround(sceneSize);
  5767. /**
  5768. * Setup the ground material according to the specified options.
  5769. */
  5770. private _setupGroundMaterial();
  5771. /**
  5772. * Setup the ground diffuse texture according to the specified options.
  5773. */
  5774. private _setupGroundDiffuseTexture();
  5775. /**
  5776. * Setup the ground mirror texture according to the specified options.
  5777. */
  5778. private _setupGroundMirrorTexture(sceneSize);
  5779. /**
  5780. * Setup the ground to receive the mirror texture.
  5781. */
  5782. private _setupMirrorInGroundMaterial();
  5783. /**
  5784. * Setup the skybox according to the specified options.
  5785. */
  5786. private _setupSkybox(sceneSize);
  5787. /**
  5788. * Setup the skybox material according to the specified options.
  5789. */
  5790. private _setupSkyboxMaterial();
  5791. /**
  5792. * Setup the skybox reflection texture according to the specified options.
  5793. */
  5794. private _setupSkyboxReflectionTexture();
  5795. private _errorHandler;
  5796. /**
  5797. * Dispose all the elements created by the Helper.
  5798. */
  5799. dispose(): void;
  5800. }
  5801. }
  5802. declare module BABYLON {
  5803. /**
  5804. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  5805. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  5806. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  5807. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  5808. */
  5809. class VideoDome extends Node {
  5810. /**
  5811. * The video texture being displayed on the sphere
  5812. */
  5813. protected _videoTexture: VideoTexture;
  5814. /**
  5815. * The skybox material
  5816. */
  5817. protected _material: BackgroundMaterial;
  5818. /**
  5819. * The surface used for the skybox
  5820. */
  5821. protected _mesh: Mesh;
  5822. /**
  5823. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  5824. * Also see the options.resolution property.
  5825. */
  5826. fovMultiplier: number;
  5827. /**
  5828. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  5829. * @param name Element's name, child elements will append suffixes for their own names.
  5830. * @param urlsOrVideo
  5831. * @param options An object containing optional or exposed sub element properties:
  5832. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  5833. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  5834. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  5835. * @param options **loop=true** Automatically loop video on end.
  5836. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  5837. */
  5838. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  5839. resolution?: number;
  5840. clickToPlay?: boolean;
  5841. autoPlay?: boolean;
  5842. loop?: boolean;
  5843. size?: number;
  5844. }, scene: Scene);
  5845. /**
  5846. * Releases all associated resources
  5847. */
  5848. dispose(): void;
  5849. }
  5850. }
  5851. declare module BABYLON {
  5852. /**
  5853. * This class can be used to get instrumentation data from a Babylon engine
  5854. */
  5855. class EngineInstrumentation implements IDisposable {
  5856. engine: Engine;
  5857. private _captureGPUFrameTime;
  5858. private _gpuFrameTimeToken;
  5859. private _gpuFrameTime;
  5860. private _captureShaderCompilationTime;
  5861. private _shaderCompilationTime;
  5862. private _onBeginFrameObserver;
  5863. private _onEndFrameObserver;
  5864. private _onBeforeShaderCompilationObserver;
  5865. private _onAfterShaderCompilationObserver;
  5866. /**
  5867. * Gets the perf counter used for GPU frame time
  5868. */
  5869. readonly gpuFrameTimeCounter: PerfCounter;
  5870. /**
  5871. * Gets the GPU frame time capture status
  5872. */
  5873. /**
  5874. * Enable or disable the GPU frame time capture
  5875. */
  5876. captureGPUFrameTime: boolean;
  5877. /**
  5878. * Gets the perf counter used for shader compilation time
  5879. */
  5880. readonly shaderCompilationTimeCounter: PerfCounter;
  5881. /**
  5882. * Gets the shader compilation time capture status
  5883. */
  5884. /**
  5885. * Enable or disable the shader compilation time capture
  5886. */
  5887. captureShaderCompilationTime: boolean;
  5888. constructor(engine: Engine);
  5889. dispose(): void;
  5890. }
  5891. }
  5892. declare module BABYLON {
  5893. /**
  5894. * This class can be used to get instrumentation data from a Babylon engine
  5895. */
  5896. class SceneInstrumentation implements IDisposable {
  5897. scene: Scene;
  5898. private _captureActiveMeshesEvaluationTime;
  5899. private _activeMeshesEvaluationTime;
  5900. private _captureRenderTargetsRenderTime;
  5901. private _renderTargetsRenderTime;
  5902. private _captureFrameTime;
  5903. private _frameTime;
  5904. private _captureRenderTime;
  5905. private _renderTime;
  5906. private _captureInterFrameTime;
  5907. private _interFrameTime;
  5908. private _captureParticlesRenderTime;
  5909. private _particlesRenderTime;
  5910. private _captureSpritesRenderTime;
  5911. private _spritesRenderTime;
  5912. private _capturePhysicsTime;
  5913. private _physicsTime;
  5914. private _captureAnimationsTime;
  5915. private _animationsTime;
  5916. private _onBeforeActiveMeshesEvaluationObserver;
  5917. private _onAfterActiveMeshesEvaluationObserver;
  5918. private _onBeforeRenderTargetsRenderObserver;
  5919. private _onAfterRenderTargetsRenderObserver;
  5920. private _onAfterRenderObserver;
  5921. private _onBeforeDrawPhaseObserver;
  5922. private _onAfterDrawPhaseObserver;
  5923. private _onBeforeAnimationsObserver;
  5924. private _onBeforeParticlesRenderingObserver;
  5925. private _onAfterParticlesRenderingObserver;
  5926. private _onBeforeSpritesRenderingObserver;
  5927. private _onAfterSpritesRenderingObserver;
  5928. private _onBeforePhysicsObserver;
  5929. private _onAfterPhysicsObserver;
  5930. private _onAfterAnimationsObserver;
  5931. /**
  5932. * Gets the perf counter used for active meshes evaluation time
  5933. */
  5934. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  5935. /**
  5936. * Gets the active meshes evaluation time capture status
  5937. */
  5938. /**
  5939. * Enable or disable the active meshes evaluation time capture
  5940. */
  5941. captureActiveMeshesEvaluationTime: boolean;
  5942. /**
  5943. * Gets the perf counter used for render targets render time
  5944. */
  5945. readonly renderTargetsRenderTimeCounter: PerfCounter;
  5946. /**
  5947. * Gets the render targets render time capture status
  5948. */
  5949. /**
  5950. * Enable or disable the render targets render time capture
  5951. */
  5952. captureRenderTargetsRenderTime: boolean;
  5953. /**
  5954. * Gets the perf counter used for particles render time
  5955. */
  5956. readonly particlesRenderTimeCounter: PerfCounter;
  5957. /**
  5958. * Gets the particles render time capture status
  5959. */
  5960. /**
  5961. * Enable or disable the particles render time capture
  5962. */
  5963. captureParticlesRenderTime: boolean;
  5964. /**
  5965. * Gets the perf counter used for sprites render time
  5966. */
  5967. readonly spritesRenderTimeCounter: PerfCounter;
  5968. /**
  5969. * Gets the sprites render time capture status
  5970. */
  5971. /**
  5972. * Enable or disable the sprites render time capture
  5973. */
  5974. captureSpritesRenderTime: boolean;
  5975. /**
  5976. * Gets the perf counter used for physics time
  5977. */
  5978. readonly physicsTimeCounter: PerfCounter;
  5979. /**
  5980. * Gets the physics time capture status
  5981. */
  5982. /**
  5983. * Enable or disable the physics time capture
  5984. */
  5985. capturePhysicsTime: boolean;
  5986. /**
  5987. * Gets the perf counter used for animations time
  5988. */
  5989. readonly animationsTimeCounter: PerfCounter;
  5990. /**
  5991. * Gets the animations time capture status
  5992. */
  5993. /**
  5994. * Enable or disable the animations time capture
  5995. */
  5996. captureAnimationsTime: boolean;
  5997. /**
  5998. * Gets the perf counter used for frame time capture
  5999. */
  6000. readonly frameTimeCounter: PerfCounter;
  6001. /**
  6002. * Gets the frame time capture status
  6003. */
  6004. /**
  6005. * Enable or disable the frame time capture
  6006. */
  6007. captureFrameTime: boolean;
  6008. /**
  6009. * Gets the perf counter used for inter-frames time capture
  6010. */
  6011. readonly interFrameTimeCounter: PerfCounter;
  6012. /**
  6013. * Gets the inter-frames time capture status
  6014. */
  6015. /**
  6016. * Enable or disable the inter-frames time capture
  6017. */
  6018. captureInterFrameTime: boolean;
  6019. /**
  6020. * Gets the perf counter used for render time capture
  6021. */
  6022. readonly renderTimeCounter: PerfCounter;
  6023. /**
  6024. * Gets the render time capture status
  6025. */
  6026. /**
  6027. * Enable or disable the render time capture
  6028. */
  6029. captureRenderTime: boolean;
  6030. /**
  6031. * Gets the perf counter used for draw calls
  6032. */
  6033. readonly drawCallsCounter: PerfCounter;
  6034. /**
  6035. * Gets the perf counter used for texture collisions
  6036. */
  6037. readonly textureCollisionsCounter: PerfCounter;
  6038. constructor(scene: Scene);
  6039. dispose(): void;
  6040. }
  6041. }
  6042. declare module BABYLON {
  6043. class _TimeToken {
  6044. _startTimeQuery: Nullable<WebGLQuery>;
  6045. _endTimeQuery: Nullable<WebGLQuery>;
  6046. _timeElapsedQuery: Nullable<WebGLQuery>;
  6047. _timeElapsedQueryEnded: boolean;
  6048. }
  6049. }
  6050. declare module BABYLON {
  6051. /**
  6052. * Effect layer options. This helps customizing the behaviour
  6053. * of the effect layer.
  6054. */
  6055. interface IEffectLayerOptions {
  6056. /**
  6057. * Multiplication factor apply to the canvas size to compute the render target size
  6058. * used to generated the objects (the smaller the faster).
  6059. */
  6060. mainTextureRatio: number;
  6061. /**
  6062. * Enforces a fixed size texture to ensure effect stability across devices.
  6063. */
  6064. mainTextureFixedSize?: number;
  6065. /**
  6066. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  6067. */
  6068. alphaBlendingMode: number;
  6069. /**
  6070. * The camera attached to the layer.
  6071. */
  6072. camera: Nullable<Camera>;
  6073. }
  6074. /**
  6075. * The effect layer Helps adding post process effect blended with the main pass.
  6076. *
  6077. * This can be for instance use to generate glow or higlight effects on the scene.
  6078. *
  6079. * The effect layer class can not be used directly and is intented to inherited from to be
  6080. * customized per effects.
  6081. */
  6082. abstract class EffectLayer {
  6083. /** The Friendly of the effect in the scene */
  6084. name: string;
  6085. private _vertexBuffers;
  6086. private _indexBuffer;
  6087. private _cachedDefines;
  6088. private _effectLayerMapGenerationEffect;
  6089. private _effectLayerOptions;
  6090. private _mergeEffect;
  6091. protected _scene: Scene;
  6092. protected _engine: Engine;
  6093. protected _maxSize: number;
  6094. protected _mainTextureDesiredSize: ISize;
  6095. protected _mainTexture: RenderTargetTexture;
  6096. protected _shouldRender: boolean;
  6097. protected _postProcesses: PostProcess[];
  6098. protected _textures: BaseTexture[];
  6099. protected _emissiveTextureAndColor: {
  6100. texture: Nullable<BaseTexture>;
  6101. color: Color4;
  6102. };
  6103. /**
  6104. * The clear color of the texture used to generate the glow map.
  6105. */
  6106. neutralColor: Color4;
  6107. /**
  6108. * Specifies wether the highlight layer is enabled or not.
  6109. */
  6110. isEnabled: boolean;
  6111. /**
  6112. * Gets the camera attached to the layer.
  6113. */
  6114. readonly camera: Nullable<Camera>;
  6115. /**
  6116. * An event triggered when the effect layer has been disposed.
  6117. */
  6118. onDisposeObservable: Observable<EffectLayer>;
  6119. /**
  6120. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  6121. */
  6122. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  6123. /**
  6124. * An event triggered when the generated texture is being merged in the scene.
  6125. */
  6126. onBeforeComposeObservable: Observable<EffectLayer>;
  6127. /**
  6128. * An event triggered when the generated texture has been merged in the scene.
  6129. */
  6130. onAfterComposeObservable: Observable<EffectLayer>;
  6131. /**
  6132. * An event triggered when the efffect layer changes its size.
  6133. */
  6134. onSizeChangedObservable: Observable<EffectLayer>;
  6135. /**
  6136. * Instantiates a new effect Layer and references it in the scene.
  6137. * @param name The name of the layer
  6138. * @param scene The scene to use the layer in
  6139. */
  6140. constructor(
  6141. /** The Friendly of the effect in the scene */
  6142. name: string, scene: Scene);
  6143. /**
  6144. * Get the effect name of the layer.
  6145. * @return The effect name
  6146. */
  6147. abstract getEffectName(): string;
  6148. /**
  6149. * Checks for the readiness of the element composing the layer.
  6150. * @param subMesh the mesh to check for
  6151. * @param useInstances specify wether or not to use instances to render the mesh
  6152. * @return true if ready otherwise, false
  6153. */
  6154. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  6155. /**
  6156. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  6157. * @returns true if the effect requires stencil during the main canvas render pass.
  6158. */
  6159. abstract needStencil(): boolean;
  6160. /**
  6161. * Create the merge effect. This is the shader use to blit the information back
  6162. * to the main canvas at the end of the scene rendering.
  6163. * @returns The effect containing the shader used to merge the effect on the main canvas
  6164. */
  6165. protected abstract _createMergeEffect(): Effect;
  6166. /**
  6167. * Creates the render target textures and post processes used in the effect layer.
  6168. */
  6169. protected abstract _createTextureAndPostProcesses(): void;
  6170. /**
  6171. * Implementation specific of rendering the generating effect on the main canvas.
  6172. * @param effect The effect used to render through
  6173. */
  6174. protected abstract _internalRender(effect: Effect): void;
  6175. /**
  6176. * Sets the required values for both the emissive texture and and the main color.
  6177. */
  6178. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  6179. /**
  6180. * Free any resources and references associated to a mesh.
  6181. * Internal use
  6182. * @param mesh The mesh to free.
  6183. */
  6184. abstract _disposeMesh(mesh: Mesh): void;
  6185. /**
  6186. * Initializes the effect layer with the required options.
  6187. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  6188. */
  6189. protected _init(options: Partial<IEffectLayerOptions>): void;
  6190. /**
  6191. * Generates the index buffer of the full screen quad blending to the main canvas.
  6192. */
  6193. private _generateIndexBuffer();
  6194. /**
  6195. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  6196. */
  6197. private _genrateVertexBuffer();
  6198. /**
  6199. * Sets the main texture desired size which is the closest power of two
  6200. * of the engine canvas size.
  6201. */
  6202. private _setMainTextureSize();
  6203. /**
  6204. * Creates the main texture for the effect layer.
  6205. */
  6206. protected _createMainTexture(): void;
  6207. /**
  6208. * Checks for the readiness of the element composing the layer.
  6209. * @param subMesh the mesh to check for
  6210. * @param useInstances specify wether or not to use instances to render the mesh
  6211. * @param emissiveTexture the associated emissive texture used to generate the glow
  6212. * @return true if ready otherwise, false
  6213. */
  6214. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  6215. /**
  6216. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  6217. */
  6218. render(): void;
  6219. /**
  6220. * Determine if a given mesh will be used in the current effect.
  6221. * @param mesh mesh to test
  6222. * @returns true if the mesh will be used
  6223. */
  6224. hasMesh(mesh: AbstractMesh): boolean;
  6225. /**
  6226. * Returns true if the layer contains information to display, otherwise false.
  6227. * @returns true if the glow layer should be rendered
  6228. */
  6229. shouldRender(): boolean;
  6230. /**
  6231. * Returns true if the mesh should render, otherwise false.
  6232. * @param mesh The mesh to render
  6233. * @returns true if it should render otherwise false
  6234. */
  6235. protected _shouldRenderMesh(mesh: Mesh): boolean;
  6236. /**
  6237. * Returns true if the mesh should render, otherwise false.
  6238. * @param mesh The mesh to render
  6239. * @returns true if it should render otherwise false
  6240. */
  6241. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  6242. /**
  6243. * Renders the submesh passed in parameter to the generation map.
  6244. */
  6245. protected _renderSubMesh(subMesh: SubMesh): void;
  6246. /**
  6247. * Rebuild the required buffers.
  6248. * @ignore Internal use only.
  6249. */
  6250. _rebuild(): void;
  6251. /**
  6252. * Dispose only the render target textures and post process.
  6253. */
  6254. private _disposeTextureAndPostProcesses();
  6255. /**
  6256. * Dispose the highlight layer and free resources.
  6257. */
  6258. dispose(): void;
  6259. }
  6260. }
  6261. declare module BABYLON {
  6262. /**
  6263. * Glow layer options. This helps customizing the behaviour
  6264. * of the glow layer.
  6265. */
  6266. interface IGlowLayerOptions {
  6267. /**
  6268. * Multiplication factor apply to the canvas size to compute the render target size
  6269. * used to generated the glowing objects (the smaller the faster).
  6270. */
  6271. mainTextureRatio: number;
  6272. /**
  6273. * Enforces a fixed size texture to ensure resize independant blur.
  6274. */
  6275. mainTextureFixedSize?: number;
  6276. /**
  6277. * How big is the kernel of the blur texture.
  6278. */
  6279. blurKernelSize: number;
  6280. /**
  6281. * The camera attached to the layer.
  6282. */
  6283. camera: Nullable<Camera>;
  6284. /**
  6285. * Enable MSAA by chosing the number of samples.
  6286. */
  6287. mainTextureSamples?: number;
  6288. }
  6289. /**
  6290. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  6291. *
  6292. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  6293. * glowy meshes to your scene.
  6294. *
  6295. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  6296. */
  6297. class GlowLayer extends EffectLayer {
  6298. name: string;
  6299. /**
  6300. * Effect Name of the layer.
  6301. */
  6302. static readonly EffectName: string;
  6303. /**
  6304. * The default blur kernel size used for the glow.
  6305. */
  6306. static DefaultBlurKernelSize: number;
  6307. /**
  6308. * The default texture size ratio used for the glow.
  6309. */
  6310. static DefaultTextureRatio: number;
  6311. /**
  6312. * Gets the kernel size of the blur.
  6313. */
  6314. /**
  6315. * Sets the kernel size of the blur.
  6316. */
  6317. blurKernelSize: number;
  6318. /**
  6319. * Gets the glow intensity.
  6320. */
  6321. /**
  6322. * Sets the glow intensity.
  6323. */
  6324. intensity: number;
  6325. private _options;
  6326. private _intensity;
  6327. private _horizontalBlurPostprocess1;
  6328. private _verticalBlurPostprocess1;
  6329. private _horizontalBlurPostprocess2;
  6330. private _verticalBlurPostprocess2;
  6331. private _blurTexture1;
  6332. private _blurTexture2;
  6333. private _postProcesses1;
  6334. private _postProcesses2;
  6335. private _includedOnlyMeshes;
  6336. private _excludedMeshes;
  6337. /**
  6338. * Callback used to let the user override the color selection on a per mesh basis
  6339. */
  6340. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  6341. /**
  6342. * Callback used to let the user override the texture selection on a per mesh basis
  6343. */
  6344. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  6345. /**
  6346. * Instantiates a new glow Layer and references it to the scene.
  6347. * @param name The name of the layer
  6348. * @param scene The scene to use the layer in
  6349. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  6350. */
  6351. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  6352. /**
  6353. * Get the effect name of the layer.
  6354. * @return The effect name
  6355. */
  6356. getEffectName(): string;
  6357. /**
  6358. * Create the merge effect. This is the shader use to blit the information back
  6359. * to the main canvas at the end of the scene rendering.
  6360. */
  6361. protected _createMergeEffect(): Effect;
  6362. /**
  6363. * Creates the render target textures and post processes used in the glow layer.
  6364. */
  6365. protected _createTextureAndPostProcesses(): void;
  6366. /**
  6367. * Checks for the readiness of the element composing the layer.
  6368. * @param subMesh the mesh to check for
  6369. * @param useInstances specify wether or not to use instances to render the mesh
  6370. * @param emissiveTexture the associated emissive texture used to generate the glow
  6371. * @return true if ready otherwise, false
  6372. */
  6373. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  6374. /**
  6375. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  6376. */
  6377. needStencil(): boolean;
  6378. /**
  6379. * Implementation specific of rendering the generating effect on the main canvas.
  6380. * @param effect The effect used to render through
  6381. */
  6382. protected _internalRender(effect: Effect): void;
  6383. /**
  6384. * Sets the required values for both the emissive texture and and the main color.
  6385. */
  6386. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  6387. /**
  6388. * Returns true if the mesh should render, otherwise false.
  6389. * @param mesh The mesh to render
  6390. * @returns true if it should render otherwise false
  6391. */
  6392. protected _shouldRenderMesh(mesh: Mesh): boolean;
  6393. /**
  6394. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  6395. * @param mesh The mesh to exclude from the glow layer
  6396. */
  6397. addExcludedMesh(mesh: Mesh): void;
  6398. /**
  6399. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  6400. * @param mesh The mesh to remove
  6401. */
  6402. removeExcludedMesh(mesh: Mesh): void;
  6403. /**
  6404. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  6405. * @param mesh The mesh to include in the glow layer
  6406. */
  6407. addIncludedOnlyMesh(mesh: Mesh): void;
  6408. /**
  6409. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  6410. * @param mesh The mesh to remove
  6411. */
  6412. removeIncludedOnlyMesh(mesh: Mesh): void;
  6413. /**
  6414. * Determine if a given mesh will be used in the glow layer
  6415. * @param mesh The mesh to test
  6416. * @returns true if the mesh will be highlighted by the current glow layer
  6417. */
  6418. hasMesh(mesh: AbstractMesh): boolean;
  6419. /**
  6420. * Free any resources and references associated to a mesh.
  6421. * Internal use
  6422. * @param mesh The mesh to free.
  6423. */
  6424. _disposeMesh(mesh: Mesh): void;
  6425. }
  6426. }
  6427. declare module BABYLON {
  6428. /**
  6429. * Highlight layer options. This helps customizing the behaviour
  6430. * of the highlight layer.
  6431. */
  6432. interface IHighlightLayerOptions {
  6433. /**
  6434. * Multiplication factor apply to the canvas size to compute the render target size
  6435. * used to generated the glowing objects (the smaller the faster).
  6436. */
  6437. mainTextureRatio: number;
  6438. /**
  6439. * Enforces a fixed size texture to ensure resize independant blur.
  6440. */
  6441. mainTextureFixedSize?: number;
  6442. /**
  6443. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  6444. * of the picture to blur (the smaller the faster).
  6445. */
  6446. blurTextureSizeRatio: number;
  6447. /**
  6448. * How big in texel of the blur texture is the vertical blur.
  6449. */
  6450. blurVerticalSize: number;
  6451. /**
  6452. * How big in texel of the blur texture is the horizontal blur.
  6453. */
  6454. blurHorizontalSize: number;
  6455. /**
  6456. * Alpha blending mode used to apply the blur. Default is combine.
  6457. */
  6458. alphaBlendingMode: number;
  6459. /**
  6460. * The camera attached to the layer.
  6461. */
  6462. camera: Nullable<Camera>;
  6463. /**
  6464. * Should we display highlight as a solid stroke?
  6465. */
  6466. isStroke?: boolean;
  6467. }
  6468. /**
  6469. * The highlight layer Helps adding a glow effect around a mesh.
  6470. *
  6471. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  6472. * glowy meshes to your scene.
  6473. *
  6474. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  6475. */
  6476. class HighlightLayer extends EffectLayer {
  6477. name: string;
  6478. /**
  6479. * Effect Name of the highlight layer.
  6480. */
  6481. static readonly EffectName: string;
  6482. /**
  6483. * The neutral color used during the preparation of the glow effect.
  6484. * This is black by default as the blend operation is a blend operation.
  6485. */
  6486. static NeutralColor: Color4;
  6487. /**
  6488. * Stencil value used for glowing meshes.
  6489. */
  6490. static GlowingMeshStencilReference: number;
  6491. /**
  6492. * Stencil value used for the other meshes in the scene.
  6493. */
  6494. static NormalMeshStencilReference: number;
  6495. /**
  6496. * Specifies whether or not the inner glow is ACTIVE in the layer.
  6497. */
  6498. innerGlow: boolean;
  6499. /**
  6500. * Specifies whether or not the outer glow is ACTIVE in the layer.
  6501. */
  6502. outerGlow: boolean;
  6503. /**
  6504. * Gets the horizontal size of the blur.
  6505. */
  6506. /**
  6507. * Specifies the horizontal size of the blur.
  6508. */
  6509. blurHorizontalSize: number;
  6510. /**
  6511. * Gets the vertical size of the blur.
  6512. */
  6513. /**
  6514. * Specifies the vertical size of the blur.
  6515. */
  6516. blurVerticalSize: number;
  6517. /**
  6518. * An event triggered when the highlight layer is being blurred.
  6519. */
  6520. onBeforeBlurObservable: Observable<HighlightLayer>;
  6521. /**
  6522. * An event triggered when the highlight layer has been blurred.
  6523. */
  6524. onAfterBlurObservable: Observable<HighlightLayer>;
  6525. private _instanceGlowingMeshStencilReference;
  6526. private _options;
  6527. private _downSamplePostprocess;
  6528. private _horizontalBlurPostprocess;
  6529. private _verticalBlurPostprocess;
  6530. private _blurTexture;
  6531. private _meshes;
  6532. private _excludedMeshes;
  6533. /**
  6534. * Instantiates a new highlight Layer and references it to the scene..
  6535. * @param name The name of the layer
  6536. * @param scene The scene to use the layer in
  6537. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  6538. */
  6539. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  6540. /**
  6541. * Get the effect name of the layer.
  6542. * @return The effect name
  6543. */
  6544. getEffectName(): string;
  6545. /**
  6546. * Create the merge effect. This is the shader use to blit the information back
  6547. * to the main canvas at the end of the scene rendering.
  6548. */
  6549. protected _createMergeEffect(): Effect;
  6550. /**
  6551. * Creates the render target textures and post processes used in the highlight layer.
  6552. */
  6553. protected _createTextureAndPostProcesses(): void;
  6554. /**
  6555. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  6556. */
  6557. needStencil(): boolean;
  6558. /**
  6559. * Checks for the readiness of the element composing the layer.
  6560. * @param subMesh the mesh to check for
  6561. * @param useInstances specify wether or not to use instances to render the mesh
  6562. * @param emissiveTexture the associated emissive texture used to generate the glow
  6563. * @return true if ready otherwise, false
  6564. */
  6565. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  6566. /**
  6567. * Implementation specific of rendering the generating effect on the main canvas.
  6568. * @param effect The effect used to render through
  6569. */
  6570. protected _internalRender(effect: Effect): void;
  6571. /**
  6572. * Returns true if the layer contains information to display, otherwise false.
  6573. */
  6574. shouldRender(): boolean;
  6575. /**
  6576. * Returns true if the mesh should render, otherwise false.
  6577. * @param mesh The mesh to render
  6578. * @returns true if it should render otherwise false
  6579. */
  6580. protected _shouldRenderMesh(mesh: Mesh): boolean;
  6581. /**
  6582. * Sets the required values for both the emissive texture and and the main color.
  6583. */
  6584. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  6585. /**
  6586. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  6587. * @param mesh The mesh to exclude from the highlight layer
  6588. */
  6589. addExcludedMesh(mesh: Mesh): void;
  6590. /**
  6591. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  6592. * @param mesh The mesh to highlight
  6593. */
  6594. removeExcludedMesh(mesh: Mesh): void;
  6595. /**
  6596. * Determine if a given mesh will be highlighted by the current HighlightLayer
  6597. * @param mesh mesh to test
  6598. * @returns true if the mesh will be highlighted by the current HighlightLayer
  6599. */
  6600. hasMesh(mesh: AbstractMesh): boolean;
  6601. /**
  6602. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  6603. * @param mesh The mesh to highlight
  6604. * @param color The color of the highlight
  6605. * @param glowEmissiveOnly Extract the glow from the emissive texture
  6606. */
  6607. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  6608. /**
  6609. * Remove a mesh from the highlight layer in order to make it stop glowing.
  6610. * @param mesh The mesh to highlight
  6611. */
  6612. removeMesh(mesh: Mesh): void;
  6613. /**
  6614. * Force the stencil to the normal expected value for none glowing parts
  6615. */
  6616. private _defaultStencilReference(mesh);
  6617. /**
  6618. * Free any resources and references associated to a mesh.
  6619. * Internal use
  6620. * @param mesh The mesh to free.
  6621. */
  6622. _disposeMesh(mesh: Mesh): void;
  6623. /**
  6624. * Dispose the highlight layer and free resources.
  6625. */
  6626. dispose(): void;
  6627. }
  6628. }
  6629. declare module BABYLON {
  6630. class Layer {
  6631. name: string;
  6632. texture: Nullable<Texture>;
  6633. isBackground: boolean;
  6634. color: Color4;
  6635. scale: Vector2;
  6636. offset: Vector2;
  6637. alphaBlendingMode: number;
  6638. alphaTest: boolean;
  6639. layerMask: number;
  6640. private _scene;
  6641. private _vertexBuffers;
  6642. private _indexBuffer;
  6643. private _effect;
  6644. private _alphaTestEffect;
  6645. /**
  6646. * An event triggered when the layer is disposed.
  6647. * @type {BABYLON.Observable}
  6648. */
  6649. onDisposeObservable: Observable<Layer>;
  6650. private _onDisposeObserver;
  6651. onDispose: () => void;
  6652. /**
  6653. * An event triggered before rendering the scene
  6654. * @type {BABYLON.Observable}
  6655. */
  6656. onBeforeRenderObservable: Observable<Layer>;
  6657. private _onBeforeRenderObserver;
  6658. onBeforeRender: () => void;
  6659. /**
  6660. * An event triggered after rendering the scene
  6661. * @type {BABYLON.Observable}
  6662. */
  6663. onAfterRenderObservable: Observable<Layer>;
  6664. private _onAfterRenderObserver;
  6665. onAfterRender: () => void;
  6666. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  6667. private _createIndexBuffer();
  6668. _rebuild(): void;
  6669. render(): void;
  6670. dispose(): void;
  6671. }
  6672. }
  6673. declare module BABYLON {
  6674. /**
  6675. * A directional light is defined by a direction (what a surprise!).
  6676. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  6677. * 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.
  6678. * Documentation: https://doc.babylonjs.com/babylon101/lights
  6679. */
  6680. class DirectionalLight extends ShadowLight {
  6681. private _shadowFrustumSize;
  6682. /**
  6683. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  6684. */
  6685. /**
  6686. * Specifies a fix frustum size for the shadow generation.
  6687. */
  6688. shadowFrustumSize: number;
  6689. private _shadowOrthoScale;
  6690. /**
  6691. * Gets the shadow projection scale against the optimal computed one.
  6692. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  6693. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  6694. */
  6695. /**
  6696. * Sets the shadow projection scale against the optimal computed one.
  6697. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  6698. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  6699. */
  6700. shadowOrthoScale: number;
  6701. /**
  6702. * Automatically compute the projection matrix to best fit (including all the casters)
  6703. * on each frame.
  6704. */
  6705. autoUpdateExtends: boolean;
  6706. private _orthoLeft;
  6707. private _orthoRight;
  6708. private _orthoTop;
  6709. private _orthoBottom;
  6710. /**
  6711. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  6712. * The directional light is emitted from everywhere in the given direction.
  6713. * It can cast shawdows.
  6714. * Documentation : http://doc.babylonjs.com/tutorials/lights
  6715. * @param name The friendly name of the light
  6716. * @param direction The direction of the light
  6717. * @param scene The scene the light belongs to
  6718. */
  6719. constructor(name: string, direction: Vector3, scene: Scene);
  6720. /**
  6721. * Returns the string "DirectionalLight".
  6722. * @return The class name
  6723. */
  6724. getClassName(): string;
  6725. /**
  6726. * Returns the integer 1.
  6727. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  6728. */
  6729. getTypeID(): number;
  6730. /**
  6731. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  6732. * Returns the DirectionalLight Shadow projection matrix.
  6733. */
  6734. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  6735. /**
  6736. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  6737. * Returns the DirectionalLight Shadow projection matrix.
  6738. */
  6739. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  6740. /**
  6741. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  6742. * Returns the DirectionalLight Shadow projection matrix.
  6743. */
  6744. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  6745. protected _buildUniformLayout(): void;
  6746. /**
  6747. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  6748. * @param effect The effect to update
  6749. * @param lightIndex The index of the light in the effect to update
  6750. * @returns The directional light
  6751. */
  6752. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  6753. /**
  6754. * Gets the minZ used for shadow according to both the scene and the light.
  6755. *
  6756. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  6757. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  6758. * @param activeCamera The camera we are returning the min for
  6759. * @returns the depth min z
  6760. */
  6761. getDepthMinZ(activeCamera: Camera): number;
  6762. /**
  6763. * Gets the maxZ used for shadow according to both the scene and the light.
  6764. *
  6765. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  6766. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  6767. * @param activeCamera The camera we are returning the max for
  6768. * @returns the depth max z
  6769. */
  6770. getDepthMaxZ(activeCamera: Camera): number;
  6771. }
  6772. }
  6773. declare module BABYLON {
  6774. /**
  6775. * The HemisphericLight simulates the ambient environment light,
  6776. * so the passed direction is the light reflection direction, not the incoming direction.
  6777. */
  6778. class HemisphericLight extends Light {
  6779. /**
  6780. * The groundColor is the light in the opposite direction to the one specified during creation.
  6781. * 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.
  6782. */
  6783. groundColor: Color3;
  6784. /**
  6785. * The light reflection direction, not the incoming direction.
  6786. */
  6787. direction: Vector3;
  6788. private _worldMatrix;
  6789. /**
  6790. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  6791. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  6792. * The HemisphericLight can't cast shadows.
  6793. * Documentation : http://doc.babylonjs.com/tutorials/lights
  6794. * @param name The friendly name of the light
  6795. * @param direction The direction of the light reflection
  6796. * @param scene The scene the light belongs to
  6797. */
  6798. constructor(name: string, direction: Vector3, scene: Scene);
  6799. protected _buildUniformLayout(): void;
  6800. /**
  6801. * Returns the string "HemisphericLight".
  6802. * @return The class name
  6803. */
  6804. getClassName(): string;
  6805. /**
  6806. * Sets the HemisphericLight direction towards the passed target (Vector3).
  6807. * Returns the updated direction.
  6808. * @param target The target the direction should point to
  6809. * @return The computed direction
  6810. */
  6811. setDirectionToTarget(target: Vector3): Vector3;
  6812. /**
  6813. * Returns the shadow generator associated to the light.
  6814. * @returns Always null for hemispheric lights because it does not support shadows.
  6815. */
  6816. getShadowGenerator(): Nullable<ShadowGenerator>;
  6817. /**
  6818. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  6819. * @param effect The effect to update
  6820. * @param lightIndex The index of the light in the effect to update
  6821. * @returns The hemispheric light
  6822. */
  6823. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  6824. /**
  6825. * @ignore internal use only.
  6826. */
  6827. _getWorldMatrix(): Matrix;
  6828. /**
  6829. * Returns the integer 3.
  6830. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  6831. */
  6832. getTypeID(): number;
  6833. }
  6834. }
  6835. declare module BABYLON {
  6836. /**
  6837. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  6838. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  6839. * 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.
  6840. */
  6841. abstract class Light extends Node {
  6842. private static _LIGHTMAP_DEFAULT;
  6843. private static _LIGHTMAP_SPECULAR;
  6844. private static _LIGHTMAP_SHADOWSONLY;
  6845. /**
  6846. * If every light affecting the material is in this lightmapMode,
  6847. * material.lightmapTexture adds or multiplies
  6848. * (depends on material.useLightmapAsShadowmap)
  6849. * after every other light calculations.
  6850. */
  6851. static readonly LIGHTMAP_DEFAULT: number;
  6852. /**
  6853. * material.lightmapTexture as only diffuse lighting from this light
  6854. * adds only specular lighting from this light
  6855. * adds dynamic shadows
  6856. */
  6857. static readonly LIGHTMAP_SPECULAR: number;
  6858. /**
  6859. * material.lightmapTexture as only lighting
  6860. * no light calculation from this light
  6861. * only adds dynamic shadows from this light
  6862. */
  6863. static readonly LIGHTMAP_SHADOWSONLY: number;
  6864. private static _INTENSITYMODE_AUTOMATIC;
  6865. private static _INTENSITYMODE_LUMINOUSPOWER;
  6866. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  6867. private static _INTENSITYMODE_ILLUMINANCE;
  6868. private static _INTENSITYMODE_LUMINANCE;
  6869. /**
  6870. * Each light type uses the default quantity according to its type:
  6871. * point/spot lights use luminous intensity
  6872. * directional lights use illuminance
  6873. */
  6874. static readonly INTENSITYMODE_AUTOMATIC: number;
  6875. /**
  6876. * lumen (lm)
  6877. */
  6878. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  6879. /**
  6880. * candela (lm/sr)
  6881. */
  6882. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  6883. /**
  6884. * lux (lm/m^2)
  6885. */
  6886. static readonly INTENSITYMODE_ILLUMINANCE: number;
  6887. /**
  6888. * nit (cd/m^2)
  6889. */
  6890. static readonly INTENSITYMODE_LUMINANCE: number;
  6891. private static _LIGHTTYPEID_POINTLIGHT;
  6892. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  6893. private static _LIGHTTYPEID_SPOTLIGHT;
  6894. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  6895. /**
  6896. * Light type const id of the point light.
  6897. */
  6898. static readonly LIGHTTYPEID_POINTLIGHT: number;
  6899. /**
  6900. * Light type const id of the directional light.
  6901. */
  6902. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  6903. /**
  6904. * Light type const id of the spot light.
  6905. */
  6906. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  6907. /**
  6908. * Light type const id of the hemispheric light.
  6909. */
  6910. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  6911. /**
  6912. * Diffuse gives the basic color to an object.
  6913. */
  6914. diffuse: Color3;
  6915. /**
  6916. * Specular produces a highlight color on an object.
  6917. * Note: This is note affecting PBR materials.
  6918. */
  6919. specular: Color3;
  6920. /**
  6921. * Strength of the light.
  6922. * Note: By default it is define in the framework own unit.
  6923. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  6924. */
  6925. intensity: number;
  6926. /**
  6927. * Defines how far from the source the light is impacting in scene units.
  6928. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  6929. */
  6930. range: number;
  6931. /**
  6932. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  6933. * of light.
  6934. */
  6935. private _photometricScale;
  6936. private _intensityMode;
  6937. /**
  6938. * Gets the photometric scale used to interpret the intensity.
  6939. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  6940. */
  6941. /**
  6942. * Sets the photometric scale used to interpret the intensity.
  6943. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  6944. */
  6945. intensityMode: number;
  6946. private _radius;
  6947. /**
  6948. * Gets the light radius used by PBR Materials to simulate soft area lights.
  6949. */
  6950. /**
  6951. * sets the light radius used by PBR Materials to simulate soft area lights.
  6952. */
  6953. radius: number;
  6954. private _renderPriority;
  6955. /**
  6956. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  6957. * exceeding the number allowed of the materials.
  6958. */
  6959. renderPriority: number;
  6960. /**
  6961. * Defines wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  6962. * the current shadow generator.
  6963. */
  6964. shadowEnabled: boolean;
  6965. private _includedOnlyMeshes;
  6966. /**
  6967. * Gets the only meshes impacted by this light.
  6968. */
  6969. /**
  6970. * Sets the only meshes impacted by this light.
  6971. */
  6972. includedOnlyMeshes: AbstractMesh[];
  6973. private _excludedMeshes;
  6974. /**
  6975. * Gets the meshes not impacted by this light.
  6976. */
  6977. /**
  6978. * Sets the meshes not impacted by this light.
  6979. */
  6980. excludedMeshes: AbstractMesh[];
  6981. private _excludeWithLayerMask;
  6982. /**
  6983. * Gets the layer id use to find what meshes are not impacted by the light.
  6984. * Inactive if 0
  6985. */
  6986. /**
  6987. * Sets the layer id use to find what meshes are not impacted by the light.
  6988. * Inactive if 0
  6989. */
  6990. excludeWithLayerMask: number;
  6991. private _includeOnlyWithLayerMask;
  6992. /**
  6993. * Gets the layer id use to find what meshes are impacted by the light.
  6994. * Inactive if 0
  6995. */
  6996. /**
  6997. * Sets the layer id use to find what meshes are impacted by the light.
  6998. * Inactive if 0
  6999. */
  7000. includeOnlyWithLayerMask: number;
  7001. private _lightmapMode;
  7002. /**
  7003. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  7004. */
  7005. /**
  7006. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  7007. */
  7008. lightmapMode: number;
  7009. private _parentedWorldMatrix;
  7010. /**
  7011. * Shadow generator associted to the light.
  7012. * Internal use only.
  7013. */
  7014. _shadowGenerator: Nullable<IShadowGenerator>;
  7015. /**
  7016. * @ignore Internal use only.
  7017. */
  7018. _excludedMeshesIds: string[];
  7019. /**
  7020. * @ignore Internal use only.
  7021. */
  7022. _includedOnlyMeshesIds: string[];
  7023. /**
  7024. * The current light unifom buffer.
  7025. * @ignore Internal use only.
  7026. */
  7027. _uniformBuffer: UniformBuffer;
  7028. /**
  7029. * Creates a Light object in the scene.
  7030. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7031. * @param name The firendly name of the light
  7032. * @param scene The scene the light belongs too
  7033. */
  7034. constructor(name: string, scene: Scene);
  7035. protected abstract _buildUniformLayout(): void;
  7036. /**
  7037. * Sets the passed Effect "effect" with the Light information.
  7038. * @param effect The effect to update
  7039. * @param lightIndex The index of the light in the effect to update
  7040. * @returns The light
  7041. */
  7042. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  7043. /**
  7044. * @ignore internal use only.
  7045. */
  7046. abstract _getWorldMatrix(): Matrix;
  7047. /**
  7048. * Returns the string "Light".
  7049. * @returns the class name
  7050. */
  7051. getClassName(): string;
  7052. /**
  7053. * Converts the light information to a readable string for debug purpose.
  7054. * @param fullDetails Supports for multiple levels of logging within scene loading
  7055. * @returns the human readable light info
  7056. */
  7057. toString(fullDetails?: boolean): string;
  7058. /**
  7059. * Set the enabled state of this node.
  7060. * @param value - the new enabled state
  7061. * @see isEnabled
  7062. */
  7063. setEnabled(value: boolean): void;
  7064. /**
  7065. * Returns the Light associated shadow generator if any.
  7066. * @return the associated shadow generator.
  7067. */
  7068. getShadowGenerator(): Nullable<IShadowGenerator>;
  7069. /**
  7070. * Returns a Vector3, the absolute light position in the World.
  7071. * @returns the world space position of the light
  7072. */
  7073. getAbsolutePosition(): Vector3;
  7074. /**
  7075. * Specifies if the light will affect the passed mesh.
  7076. * @param mesh The mesh to test against the light
  7077. * @return true the mesh is affected otherwise, false.
  7078. */
  7079. canAffectMesh(mesh: AbstractMesh): boolean;
  7080. /**
  7081. * Computes and Returns the light World matrix.
  7082. * @returns the world matrix
  7083. */
  7084. getWorldMatrix(): Matrix;
  7085. /**
  7086. * Sort function to order lights for rendering.
  7087. * @param a First Light object to compare to second.
  7088. * @param b Second Light object to compare first.
  7089. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  7090. */
  7091. static CompareLightsPriority(a: Light, b: Light): number;
  7092. /**
  7093. * Disposes the light.
  7094. */
  7095. dispose(): void;
  7096. /**
  7097. * Returns the light type ID (integer).
  7098. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7099. */
  7100. getTypeID(): number;
  7101. /**
  7102. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  7103. * @returns the scaled intensity in intensity mode unit
  7104. */
  7105. getScaledIntensity(): number;
  7106. /**
  7107. * Returns a new Light object, named "name", from the current one.
  7108. * @param name The name of the cloned light
  7109. * @returns the new created light
  7110. */
  7111. clone(name: string): Nullable<Light>;
  7112. /**
  7113. * Serializes the current light into a Serialization object.
  7114. * @returns the serialized object.
  7115. */
  7116. serialize(): any;
  7117. /**
  7118. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  7119. * This new light is named "name" and added to the passed scene.
  7120. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  7121. * @param name The friendly name of the light
  7122. * @param scene The scene the new light will belong to
  7123. * @returns the constructor function
  7124. */
  7125. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  7126. /**
  7127. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  7128. * @param parsedLight The JSON representation of the light
  7129. * @param scene The scene to create the parsed light in
  7130. * @returns the created light after parsing
  7131. */
  7132. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  7133. private _hookArrayForExcluded(array);
  7134. private _hookArrayForIncludedOnly(array);
  7135. private _resyncMeshes();
  7136. /**
  7137. * Forces the meshes to update their light related information in their rendering used effects
  7138. * @ignore Internal Use Only
  7139. */
  7140. _markMeshesAsLightDirty(): void;
  7141. /**
  7142. * Recomputes the cached photometric scale if needed.
  7143. */
  7144. private _computePhotometricScale();
  7145. /**
  7146. * Returns the Photometric Scale according to the light type and intensity mode.
  7147. */
  7148. private _getPhotometricScale();
  7149. /**
  7150. * Reorder the light in the scene according to their defined priority.
  7151. * @ignore Internal Use Only
  7152. */
  7153. _reorderLightsInScene(): void;
  7154. }
  7155. }
  7156. declare module BABYLON {
  7157. /**
  7158. * A point light is a light defined by an unique point in world space.
  7159. * The light is emitted in every direction from this point.
  7160. * A good example of a point light is a standard light bulb.
  7161. * Documentation: https://doc.babylonjs.com/babylon101/lights
  7162. */
  7163. class PointLight extends ShadowLight {
  7164. private _shadowAngle;
  7165. /**
  7166. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7167. * This specifies what angle the shadow will use to be created.
  7168. *
  7169. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  7170. */
  7171. /**
  7172. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7173. * This specifies what angle the shadow will use to be created.
  7174. *
  7175. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  7176. */
  7177. shadowAngle: number;
  7178. /**
  7179. * Gets the direction if it has been set.
  7180. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7181. */
  7182. /**
  7183. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7184. */
  7185. direction: Vector3;
  7186. /**
  7187. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  7188. * A PointLight emits the light in every direction.
  7189. * It can cast shadows.
  7190. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  7191. * ```javascript
  7192. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  7193. * ```
  7194. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7195. * @param name The light friendly name
  7196. * @param position The position of the point light in the scene
  7197. * @param scene The scene the lights belongs to
  7198. */
  7199. constructor(name: string, position: Vector3, scene: Scene);
  7200. /**
  7201. * Returns the string "PointLight"
  7202. * @returns the class name
  7203. */
  7204. getClassName(): string;
  7205. /**
  7206. * Returns the integer 0.
  7207. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7208. */
  7209. getTypeID(): number;
  7210. /**
  7211. * Specifies wether or not the shadowmap should be a cube texture.
  7212. * @returns true if the shadowmap needs to be a cube texture.
  7213. */
  7214. needCube(): boolean;
  7215. /**
  7216. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  7217. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7218. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7219. */
  7220. getShadowDirection(faceIndex?: number): Vector3;
  7221. /**
  7222. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  7223. * - fov = PI / 2
  7224. * - aspect ratio : 1.0
  7225. * - z-near and far equal to the active camera minZ and maxZ.
  7226. * Returns the PointLight.
  7227. */
  7228. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7229. protected _buildUniformLayout(): void;
  7230. /**
  7231. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  7232. * @param effect The effect to update
  7233. * @param lightIndex The index of the light in the effect to update
  7234. * @returns The point light
  7235. */
  7236. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  7237. }
  7238. }
  7239. declare module BABYLON {
  7240. /**
  7241. * Interface describing all the common properties and methods a shadow light needs to implement.
  7242. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  7243. * as well as binding the different shadow properties to the effects.
  7244. */
  7245. interface IShadowLight extends Light {
  7246. /**
  7247. * The light id in the scene (used in scene.findLighById for instance)
  7248. */
  7249. id: string;
  7250. /**
  7251. * The position the shdow will be casted from.
  7252. */
  7253. position: Vector3;
  7254. /**
  7255. * In 2d mode (needCube being false), the direction used to cast the shadow.
  7256. */
  7257. direction: Vector3;
  7258. /**
  7259. * The transformed position. Position of the light in world space taking parenting in account.
  7260. */
  7261. transformedPosition: Vector3;
  7262. /**
  7263. * The transformed direction. Direction of the light in world space taking parenting in account.
  7264. */
  7265. transformedDirection: Vector3;
  7266. /**
  7267. * The friendly name of the light in the scene.
  7268. */
  7269. name: string;
  7270. /**
  7271. * Defines the shadow projection clipping minimum z value.
  7272. */
  7273. shadowMinZ: number;
  7274. /**
  7275. * Defines the shadow projection clipping maximum z value.
  7276. */
  7277. shadowMaxZ: number;
  7278. /**
  7279. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  7280. * @returns true if the information has been computed, false if it does not need to (no parenting)
  7281. */
  7282. computeTransformedInformation(): boolean;
  7283. /**
  7284. * Gets the scene the light belongs to.
  7285. * @returns The scene
  7286. */
  7287. getScene(): Scene;
  7288. /**
  7289. * Callback defining a custom Projection Matrix Builder.
  7290. * This can be used to override the default projection matrix computation.
  7291. */
  7292. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  7293. /**
  7294. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  7295. * @param matrix The materix to updated with the projection information
  7296. * @param viewMatrix The transform matrix of the light
  7297. * @param renderList The list of mesh to render in the map
  7298. * @returns The current light
  7299. */
  7300. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  7301. /**
  7302. * Gets the current depth scale used in ESM.
  7303. * @returns The scale
  7304. */
  7305. getDepthScale(): number;
  7306. /**
  7307. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  7308. * @returns true if a cube texture needs to be use
  7309. */
  7310. needCube(): boolean;
  7311. /**
  7312. * Detects if the projection matrix requires to be recomputed this frame.
  7313. * @returns true if it requires to be recomputed otherwise, false.
  7314. */
  7315. needProjectionMatrixCompute(): boolean;
  7316. /**
  7317. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  7318. */
  7319. forceProjectionMatrixCompute(): void;
  7320. /**
  7321. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  7322. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7323. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7324. */
  7325. getShadowDirection(faceIndex?: number): Vector3;
  7326. /**
  7327. * Gets the minZ used for shadow according to both the scene and the light.
  7328. * @param activeCamera The camera we are returning the min for
  7329. * @returns the depth min z
  7330. */
  7331. getDepthMinZ(activeCamera: Camera): number;
  7332. /**
  7333. * Gets the maxZ used for shadow according to both the scene and the light.
  7334. * @param activeCamera The camera we are returning the max for
  7335. * @returns the depth max z
  7336. */
  7337. getDepthMaxZ(activeCamera: Camera): number;
  7338. }
  7339. /**
  7340. * Base implementation of @see IShadowLight
  7341. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  7342. */
  7343. abstract class ShadowLight extends Light implements IShadowLight {
  7344. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7345. protected _position: Vector3;
  7346. protected _setPosition(value: Vector3): void;
  7347. /**
  7348. * Sets the position the shadow will be casted from. Also use as the light position for both
  7349. * point and spot lights.
  7350. */
  7351. /**
  7352. * Sets the position the shadow will be casted from. Also use as the light position for both
  7353. * point and spot lights.
  7354. */
  7355. position: Vector3;
  7356. protected _direction: Vector3;
  7357. protected _setDirection(value: Vector3): void;
  7358. /**
  7359. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  7360. * Also use as the light direction on spot and directional lights.
  7361. */
  7362. /**
  7363. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  7364. * Also use as the light direction on spot and directional lights.
  7365. */
  7366. direction: Vector3;
  7367. private _shadowMinZ;
  7368. /**
  7369. * Gets the shadow projection clipping minimum z value.
  7370. */
  7371. /**
  7372. * Sets the shadow projection clipping minimum z value.
  7373. */
  7374. shadowMinZ: number;
  7375. private _shadowMaxZ;
  7376. /**
  7377. * Sets the shadow projection clipping maximum z value.
  7378. */
  7379. /**
  7380. * Gets the shadow projection clipping maximum z value.
  7381. */
  7382. shadowMaxZ: number;
  7383. /**
  7384. * Callback defining a custom Projection Matrix Builder.
  7385. * This can be used to override the default projection matrix computation.
  7386. */
  7387. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  7388. /**
  7389. * The transformed position. Position of the light in world space taking parenting in account.
  7390. */
  7391. transformedPosition: Vector3;
  7392. /**
  7393. * The transformed direction. Direction of the light in world space taking parenting in account.
  7394. */
  7395. transformedDirection: Vector3;
  7396. private _worldMatrix;
  7397. private _needProjectionMatrixCompute;
  7398. /**
  7399. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  7400. * @returns true if the information has been computed, false if it does not need to (no parenting)
  7401. */
  7402. computeTransformedInformation(): boolean;
  7403. /**
  7404. * Return the depth scale used for the shadow map.
  7405. * @returns the depth scale.
  7406. */
  7407. getDepthScale(): number;
  7408. /**
  7409. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  7410. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7411. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7412. */
  7413. getShadowDirection(faceIndex?: number): Vector3;
  7414. /**
  7415. * Returns the ShadowLight absolute position in the World.
  7416. * @returns the position vector in world space
  7417. */
  7418. getAbsolutePosition(): Vector3;
  7419. /**
  7420. * Sets the ShadowLight direction toward the passed target.
  7421. * @param target The point tot target in local space
  7422. * @returns the updated ShadowLight direction
  7423. */
  7424. setDirectionToTarget(target: Vector3): Vector3;
  7425. /**
  7426. * Returns the light rotation in euler definition.
  7427. * @returns the x y z rotation in local space.
  7428. */
  7429. getRotation(): Vector3;
  7430. /**
  7431. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  7432. * @returns true if a cube texture needs to be use
  7433. */
  7434. needCube(): boolean;
  7435. /**
  7436. * Detects if the projection matrix requires to be recomputed this frame.
  7437. * @returns true if it requires to be recomputed otherwise, false.
  7438. */
  7439. needProjectionMatrixCompute(): boolean;
  7440. /**
  7441. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  7442. */
  7443. forceProjectionMatrixCompute(): void;
  7444. /**
  7445. * Get the world matrix of the sahdow lights.
  7446. * @ignore Internal Use Only
  7447. */
  7448. _getWorldMatrix(): Matrix;
  7449. /**
  7450. * Gets the minZ used for shadow according to both the scene and the light.
  7451. * @param activeCamera The camera we are returning the min for
  7452. * @returns the depth min z
  7453. */
  7454. getDepthMinZ(activeCamera: Camera): number;
  7455. /**
  7456. * Gets the maxZ used for shadow according to both the scene and the light.
  7457. * @param activeCamera The camera we are returning the max for
  7458. * @returns the depth max z
  7459. */
  7460. getDepthMaxZ(activeCamera: Camera): number;
  7461. /**
  7462. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  7463. * @param matrix The materix to updated with the projection information
  7464. * @param viewMatrix The transform matrix of the light
  7465. * @param renderList The list of mesh to render in the map
  7466. * @returns The current light
  7467. */
  7468. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  7469. }
  7470. }
  7471. declare module BABYLON {
  7472. /**
  7473. * A spot light is defined by a position, a direction, an angle, and an exponent.
  7474. * These values define a cone of light starting from the position, emitting toward the direction.
  7475. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  7476. * and the exponent defines the speed of the decay of the light with distance (reach).
  7477. * Documentation: https://doc.babylonjs.com/babylon101/lights
  7478. */
  7479. class SpotLight extends ShadowLight {
  7480. private _angle;
  7481. /**
  7482. * Gets the cone angle of the spot light in Radians.
  7483. */
  7484. /**
  7485. * Sets the cone angle of the spot light in Radians.
  7486. */
  7487. angle: number;
  7488. private _shadowAngleScale;
  7489. /**
  7490. * Allows scaling the angle of the light for shadow generation only.
  7491. */
  7492. /**
  7493. * Allows scaling the angle of the light for shadow generation only.
  7494. */
  7495. shadowAngleScale: number;
  7496. /**
  7497. * The light decay speed with the distance from the emission spot.
  7498. */
  7499. exponent: number;
  7500. private _projectionTextureMatrix;
  7501. /**
  7502. * Allows reading the projecton texture
  7503. */
  7504. readonly projectionTextureMatrix: Matrix;
  7505. protected _projectionTextureLightNear: number;
  7506. /**
  7507. * Gets the near clip of the Spotlight for texture projection.
  7508. */
  7509. /**
  7510. * Sets the near clip of the Spotlight for texture projection.
  7511. */
  7512. projectionTextureLightNear: number;
  7513. protected _projectionTextureLightFar: number;
  7514. /**
  7515. * Gets the far clip of the Spotlight for texture projection.
  7516. */
  7517. /**
  7518. * Sets the far clip of the Spotlight for texture projection.
  7519. */
  7520. projectionTextureLightFar: number;
  7521. protected _projectionTextureUpDirection: Vector3;
  7522. /**
  7523. * Gets the Up vector of the Spotlight for texture projection.
  7524. */
  7525. /**
  7526. * Sets the Up vector of the Spotlight for texture projection.
  7527. */
  7528. projectionTextureUpDirection: Vector3;
  7529. private _projectionTexture;
  7530. /**
  7531. * Gets the projection texture of the light.
  7532. */
  7533. /**
  7534. * Sets the projection texture of the light.
  7535. */
  7536. projectionTexture: Nullable<BaseTexture>;
  7537. private _projectionTextureViewLightDirty;
  7538. private _projectionTextureProjectionLightDirty;
  7539. private _projectionTextureDirty;
  7540. private _projectionTextureViewTargetVector;
  7541. private _projectionTextureViewLightMatrix;
  7542. private _projectionTextureProjectionLightMatrix;
  7543. private _projectionTextureScalingMatrix;
  7544. /**
  7545. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  7546. * It can cast shadows.
  7547. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7548. * @param name The light friendly name
  7549. * @param position The position of the spot light in the scene
  7550. * @param direction The direction of the light in the scene
  7551. * @param angle The cone angle of the light in Radians
  7552. * @param exponent The light decay speed with the distance from the emission spot
  7553. * @param scene The scene the lights belongs to
  7554. */
  7555. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  7556. /**
  7557. * Returns the string "SpotLight".
  7558. * @returns the class name
  7559. */
  7560. getClassName(): string;
  7561. /**
  7562. * Returns the integer 2.
  7563. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7564. */
  7565. getTypeID(): number;
  7566. /**
  7567. * Overrides the direction setter to recompute the projection texture view light Matrix.
  7568. */
  7569. protected _setDirection(value: Vector3): void;
  7570. /**
  7571. * Overrides the position setter to recompute the projection texture view light Matrix.
  7572. */
  7573. protected _setPosition(value: Vector3): void;
  7574. /**
  7575. * 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.
  7576. * Returns the SpotLight.
  7577. */
  7578. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7579. protected _computeProjectionTextureViewLightMatrix(): void;
  7580. protected _computeProjectionTextureProjectionLightMatrix(): void;
  7581. /**
  7582. * Main function for light texture projection matrix computing.
  7583. */
  7584. protected _computeProjectionTextureMatrix(): void;
  7585. protected _buildUniformLayout(): void;
  7586. /**
  7587. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  7588. * @param effect The effect to update
  7589. * @param lightIndex The index of the light in the effect to update
  7590. * @returns The spot light
  7591. */
  7592. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  7593. /**
  7594. * Disposes the light and the associated resources.
  7595. */
  7596. dispose(): void;
  7597. }
  7598. }
  7599. declare module BABYLON {
  7600. interface ILoadingScreen {
  7601. displayLoadingUI: () => void;
  7602. hideLoadingUI: () => void;
  7603. loadingUIBackgroundColor: string;
  7604. loadingUIText: string;
  7605. }
  7606. class DefaultLoadingScreen implements ILoadingScreen {
  7607. private _renderingCanvas;
  7608. private _loadingText;
  7609. private _loadingDivBackgroundColor;
  7610. private _loadingDiv;
  7611. private _loadingTextDiv;
  7612. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  7613. displayLoadingUI(): void;
  7614. hideLoadingUI(): void;
  7615. loadingUIText: string;
  7616. loadingUIBackgroundColor: string;
  7617. private _resizeLoadingUI;
  7618. }
  7619. }
  7620. declare module BABYLON {
  7621. class SceneLoaderProgressEvent {
  7622. readonly lengthComputable: boolean;
  7623. readonly loaded: number;
  7624. readonly total: number;
  7625. constructor(lengthComputable: boolean, loaded: number, total: number);
  7626. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  7627. }
  7628. interface ISceneLoaderPluginExtensions {
  7629. [extension: string]: {
  7630. isBinary: boolean;
  7631. };
  7632. }
  7633. interface ISceneLoaderPluginFactory {
  7634. name: string;
  7635. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  7636. canDirectLoad?: (data: string) => boolean;
  7637. }
  7638. interface ISceneLoaderPlugin {
  7639. /**
  7640. * The friendly name of this plugin.
  7641. */
  7642. name: string;
  7643. /**
  7644. * The file extensions supported by this plugin.
  7645. */
  7646. extensions: string | ISceneLoaderPluginExtensions;
  7647. /**
  7648. * Import meshes into a scene.
  7649. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  7650. * @param scene The scene to import into
  7651. * @param data The data to import
  7652. * @param rootUrl The root url for scene and resources
  7653. * @param meshes The meshes array to import into
  7654. * @param particleSystems The particle systems array to import into
  7655. * @param skeletons The skeletons array to import into
  7656. * @param onError The callback when import fails
  7657. * @returns True if successful or false otherwise
  7658. */
  7659. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  7660. /**
  7661. * Load into a scene.
  7662. * @param scene The scene to load into
  7663. * @param data The data to import
  7664. * @param rootUrl The root url for scene and resources
  7665. * @param onError The callback when import fails
  7666. * @returns true if successful or false otherwise
  7667. */
  7668. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  7669. /**
  7670. * The callback that returns true if the data can be directly loaded.
  7671. */
  7672. canDirectLoad?: (data: string) => boolean;
  7673. /**
  7674. * The callback that allows custom handling of the root url based on the response url.
  7675. */
  7676. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  7677. /**
  7678. * Load into an asset container.
  7679. * @param scene The scene to load into
  7680. * @param data The data to import
  7681. * @param rootUrl The root url for scene and resources
  7682. * @param onError The callback when import fails
  7683. * @returns The loaded asset container
  7684. */
  7685. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  7686. }
  7687. interface ISceneLoaderPluginAsync {
  7688. /**
  7689. * The friendly name of this plugin.
  7690. */
  7691. name: string;
  7692. /**
  7693. * The file extensions supported by this plugin.
  7694. */
  7695. extensions: string | ISceneLoaderPluginExtensions;
  7696. /**
  7697. * Import meshes into a scene.
  7698. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  7699. * @param scene The scene to import into
  7700. * @param data The data to import
  7701. * @param rootUrl The root url for scene and resources
  7702. * @param onProgress The callback when the load progresses
  7703. * @returns The loaded meshes, particle systems, and skeletons
  7704. */
  7705. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  7706. meshes: AbstractMesh[];
  7707. particleSystems: ParticleSystem[];
  7708. skeletons: Skeleton[];
  7709. }>;
  7710. /**
  7711. * Load into a scene.
  7712. * @param scene The scene to load into
  7713. * @param data The data to import
  7714. * @param rootUrl The root url for scene and resources
  7715. * @param onProgress The callback when the load progresses
  7716. * @returns Nothing
  7717. */
  7718. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  7719. /**
  7720. * The callback that returns true if the data can be directly loaded.
  7721. */
  7722. canDirectLoad?: (data: string) => boolean;
  7723. /**
  7724. * The callback that allows custom handling of the root url based on the response url.
  7725. */
  7726. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  7727. /**
  7728. * Load into an asset container.
  7729. * @param scene The scene to load into
  7730. * @param data The data to import
  7731. * @param rootUrl The root url for scene and resources
  7732. * @param onProgress The callback when the load progresses
  7733. * @returns The loaded asset container
  7734. */
  7735. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  7736. }
  7737. class SceneLoader {
  7738. private static _ForceFullSceneLoadingForIncremental;
  7739. private static _ShowLoadingScreen;
  7740. private static _CleanBoneMatrixWeights;
  7741. static readonly NO_LOGGING: number;
  7742. static readonly MINIMAL_LOGGING: number;
  7743. static readonly SUMMARY_LOGGING: number;
  7744. static readonly DETAILED_LOGGING: number;
  7745. private static _loggingLevel;
  7746. static ForceFullSceneLoadingForIncremental: boolean;
  7747. static ShowLoadingScreen: boolean;
  7748. static loggingLevel: number;
  7749. static CleanBoneMatrixWeights: boolean;
  7750. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  7751. private static _registeredPlugins;
  7752. private static _getDefaultPlugin();
  7753. private static _getPluginForExtension(extension);
  7754. private static _getPluginForDirectLoad(data);
  7755. private static _getPluginForFilename(sceneFilename);
  7756. private static _getDirectLoad(sceneFilename);
  7757. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  7758. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  7759. static IsPluginForExtensionAvailable(extension: string): boolean;
  7760. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  7761. /**
  7762. * Import meshes into a scene
  7763. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  7764. * @param rootUrl a string that defines the root url for scene and resources
  7765. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7766. * @param scene the instance of BABYLON.Scene to append to
  7767. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  7768. * @param onProgress a callback with a progress event for each file being loaded
  7769. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  7770. * @param pluginExtension the extension used to determine the plugin
  7771. * @returns The loaded plugin
  7772. */
  7773. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  7774. /**
  7775. * Import meshes into a scene
  7776. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  7777. * @param rootUrl a string that defines the root url for scene and resources
  7778. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7779. * @param scene the instance of BABYLON.Scene to append to
  7780. * @param onProgress a callback with a progress event for each file being loaded
  7781. * @param pluginExtension the extension used to determine the plugin
  7782. * @returns The loaded list of imported meshes, particleSystems, and skeletons
  7783. */
  7784. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  7785. meshes: AbstractMesh[];
  7786. particleSystems: ParticleSystem[];
  7787. skeletons: Skeleton[];
  7788. }>;
  7789. /**
  7790. * Load a scene
  7791. * @param rootUrl a string that defines the root url for scene and resources
  7792. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7793. * @param engine is the instance of BABYLON.Engine to use to create the scene
  7794. * @param onSuccess a callback with the scene when import succeeds
  7795. * @param onProgress a callback with a progress event for each file being loaded
  7796. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  7797. * @param pluginExtension the extension used to determine the plugin
  7798. * @returns The loaded plugin
  7799. */
  7800. 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>;
  7801. /**
  7802. * Load a scene
  7803. * @param rootUrl a string that defines the root url for scene and resources
  7804. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7805. * @param engine is the instance of BABYLON.Engine to use to create the scene
  7806. * @param onProgress a callback with a progress event for each file being loaded
  7807. * @param pluginExtension the extension used to determine the plugin
  7808. * @returns The loaded scene
  7809. */
  7810. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  7811. /**
  7812. * Append a scene
  7813. * @param rootUrl a string that defines the root url for scene and resources
  7814. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7815. * @param scene is the instance of BABYLON.Scene to append to
  7816. * @param onSuccess a callback with the scene when import succeeds
  7817. * @param onProgress a callback with a progress event for each file being loaded
  7818. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  7819. * @param pluginExtension the extension used to determine the plugin
  7820. * @returns The loaded plugin
  7821. */
  7822. static Append(rootUrl: string, sceneFilename: any, scene: Scene, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  7823. /**
  7824. * Append a scene
  7825. * @param rootUrl a string that defines the root url for scene and resources
  7826. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7827. * @param scene is the instance of BABYLON.Scene to append to
  7828. * @param onProgress a callback with a progress event for each file being loaded
  7829. * @param pluginExtension the extension used to determine the plugin
  7830. * @returns The given scene
  7831. */
  7832. static AppendAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  7833. /**
  7834. * Load a scene into an asset container
  7835. * @param rootUrl a string that defines the root url for scene and resources
  7836. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7837. * @param scene is the instance of BABYLON.Scene to append to
  7838. * @param onSuccess a callback with the scene when import succeeds
  7839. * @param onProgress a callback with a progress event for each file being loaded
  7840. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  7841. * @param pluginExtension the extension used to determine the plugin
  7842. * @returns The loaded plugin
  7843. */
  7844. static LoadAssetContainer(rootUrl: string, sceneFilename: any, scene: Scene, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  7845. /**
  7846. * Load a scene into an asset container
  7847. * @param rootUrl a string that defines the root url for scene and resources
  7848. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7849. * @param scene is the instance of BABYLON.Scene to append to
  7850. * @param onProgress a callback with a progress event for each file being loaded
  7851. * @param pluginExtension the extension used to determine the plugin
  7852. * @returns The loaded asset container
  7853. */
  7854. static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  7855. }
  7856. }
  7857. declare module BABYLON {
  7858. class Scalar {
  7859. /**
  7860. * Two pi constants convenient for computation.
  7861. */
  7862. static TwoPi: number;
  7863. /**
  7864. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  7865. */
  7866. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  7867. /**
  7868. * Returns a string : the upper case translation of the number i to hexadecimal.
  7869. */
  7870. static ToHex(i: number): string;
  7871. /**
  7872. * Returns -1 if value is negative and +1 is value is positive.
  7873. * Returns the value itself if it's equal to zero.
  7874. */
  7875. static Sign(value: number): number;
  7876. /**
  7877. * Returns the value itself if it's between min and max.
  7878. * Returns min if the value is lower than min.
  7879. * Returns max if the value is greater than max.
  7880. */
  7881. static Clamp(value: number, min?: number, max?: number): number;
  7882. /**
  7883. * Returns the log2 of value.
  7884. */
  7885. static Log2(value: number): number;
  7886. /**
  7887. * Loops the value, so that it is never larger than length and never smaller than 0.
  7888. *
  7889. * This is similar to the modulo operator but it works with floating point numbers.
  7890. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  7891. * With t = 5 and length = 2.5, the result would be 0.0.
  7892. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  7893. */
  7894. static Repeat(value: number, length: number): number;
  7895. /**
  7896. * Normalize the value between 0.0 and 1.0 using min and max values
  7897. */
  7898. static Normalize(value: number, min: number, max: number): number;
  7899. /**
  7900. * Denormalize the value from 0.0 and 1.0 using min and max values
  7901. */
  7902. static Denormalize(normalized: number, min: number, max: number): number;
  7903. /**
  7904. * Calculates the shortest difference between two given angles given in degrees.
  7905. */
  7906. static DeltaAngle(current: number, target: number): number;
  7907. /**
  7908. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  7909. *
  7910. * The returned value will move back and forth between 0 and length
  7911. */
  7912. static PingPong(tx: number, length: number): number;
  7913. /**
  7914. * Interpolates between min and max with smoothing at the limits.
  7915. *
  7916. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  7917. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  7918. */
  7919. static SmoothStep(from: number, to: number, tx: number): number;
  7920. /**
  7921. * Moves a value current towards target.
  7922. *
  7923. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  7924. * Negative values of maxDelta pushes the value away from target.
  7925. */
  7926. static MoveTowards(current: number, target: number, maxDelta: number): number;
  7927. /**
  7928. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  7929. *
  7930. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  7931. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  7932. */
  7933. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  7934. /**
  7935. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  7936. */
  7937. static Lerp(start: number, end: number, amount: number): number;
  7938. /**
  7939. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  7940. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  7941. */
  7942. static LerpAngle(start: number, end: number, amount: number): number;
  7943. /**
  7944. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  7945. */
  7946. static InverseLerp(a: number, b: number, value: number): number;
  7947. /**
  7948. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  7949. */
  7950. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  7951. /**
  7952. * Returns a random float number between and min and max values
  7953. */
  7954. static RandomRange(min: number, max: number): number;
  7955. /**
  7956. * This function returns percentage of a number in a given range.
  7957. *
  7958. * RangeToPercent(40,20,60) will return 0.5 (50%)
  7959. * RangeToPercent(34,0,100) will return 0.34 (34%)
  7960. */
  7961. static RangeToPercent(number: number, min: number, max: number): number;
  7962. /**
  7963. * This function returns number that corresponds to the percentage in a given range.
  7964. *
  7965. * PercentToRange(0.34,0,100) will return 34.
  7966. */
  7967. static PercentToRange(percent: number, min: number, max: number): number;
  7968. /**
  7969. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  7970. * @param angle The angle to normalize in radian.
  7971. * @return The converted angle.
  7972. */
  7973. static NormalizeRadians(angle: number): number;
  7974. }
  7975. }
  7976. declare module BABYLON {
  7977. const ToGammaSpace: number;
  7978. const ToLinearSpace = 2.2;
  7979. const Epsilon = 0.001;
  7980. /**
  7981. * Class used to hold a RBG color
  7982. */
  7983. class Color3 {
  7984. /**
  7985. * Defines the red component (between 0 and 1, default is 0)
  7986. */
  7987. r: number;
  7988. /**
  7989. * Defines the green component (between 0 and 1, default is 0)
  7990. */
  7991. g: number;
  7992. /**
  7993. * Defines the blue component (between 0 and 1, default is 0)
  7994. */
  7995. b: number;
  7996. /**
  7997. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  7998. * @param r defines the red component (between 0 and 1, default is 0)
  7999. * @param g defines the green component (between 0 and 1, default is 0)
  8000. * @param b defines the blue component (between 0 and 1, default is 0)
  8001. */
  8002. constructor(
  8003. /**
  8004. * Defines the red component (between 0 and 1, default is 0)
  8005. */
  8006. r?: number,
  8007. /**
  8008. * Defines the green component (between 0 and 1, default is 0)
  8009. */
  8010. g?: number,
  8011. /**
  8012. * Defines the blue component (between 0 and 1, default is 0)
  8013. */
  8014. b?: number);
  8015. /**
  8016. * Creates a string with the Color3 current values
  8017. * @returns the string representation of the Color3 object
  8018. */
  8019. toString(): string;
  8020. /**
  8021. * Returns the string "Color3"
  8022. * @returns "Color3"
  8023. */
  8024. getClassName(): string;
  8025. /**
  8026. * Compute the Color3 hash code
  8027. * @returns an unique number that can be used to hash Color3 objects
  8028. */
  8029. getHashCode(): number;
  8030. /**
  8031. * Stores in the passed array from the passed starting index the red, green, blue values as successive elements
  8032. * @param array defines the array where to store the r,g,b components
  8033. * @param index defines an optional index in the target array to define where to start storing values
  8034. * @returns the current Color3 object
  8035. */
  8036. toArray(array: FloatArray, index?: number): Color3;
  8037. /**
  8038. * Returns a new {BABYLON.Color4} object from the current Color3 and the passed alpha
  8039. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  8040. * @returns a new {BABYLON.Color4} object
  8041. */
  8042. toColor4(alpha?: number): Color4;
  8043. /**
  8044. * Returns a new array populated with 3 numeric elements : red, green and blue values
  8045. * @returns the new array
  8046. */
  8047. asArray(): number[];
  8048. /**
  8049. * Returns the luminance value
  8050. * @returns a float value
  8051. */
  8052. toLuminance(): number;
  8053. /**
  8054. * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object
  8055. * @param otherColor defines the second operand
  8056. * @returns the new Color3 object
  8057. */
  8058. multiply(otherColor: Color3): Color3;
  8059. /**
  8060. * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result"
  8061. * @param otherColor defines the second operand
  8062. * @param result defines the Color3 object where to store the result
  8063. * @returns the current Color3
  8064. */
  8065. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  8066. /**
  8067. * Determines equality between Color3 objects
  8068. * @param otherColor defines the second operand
  8069. * @returns true if the rgb values are equal to the passed ones
  8070. */
  8071. equals(otherColor: Color3): boolean;
  8072. /**
  8073. * Determines equality between the current Color3 object and a set of r,b,g values
  8074. * @param r defines the red component to check
  8075. * @param g defines the green component to check
  8076. * @param b defines the blue component to check
  8077. * @returns true if the rgb values are equal to the passed ones
  8078. */
  8079. equalsFloats(r: number, g: number, b: number): boolean;
  8080. /**
  8081. * Multiplies in place each rgb value by scale
  8082. * @param scale defines the scaling factor
  8083. * @returns the updated Color3.
  8084. */
  8085. scale(scale: number): Color3;
  8086. /**
  8087. * Multiplies the rgb values by scale and stores the result into "result"
  8088. * @param scale defines the scaling factor
  8089. * @param result defines the Color3 object where to store the result
  8090. * @returns the unmodified current Color3.
  8091. */
  8092. scaleToRef(scale: number, result: Color3): Color3;
  8093. /**
  8094. * Clamps the rgb values by the min and max values and stores the result into "result"
  8095. * @param min defines minimum clamping value (default is 0)
  8096. * @param max defines maximum clamping value (default is 1)
  8097. * @param result defines color to store the result into
  8098. * @returns the original Color3
  8099. */
  8100. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  8101. /**
  8102. * Creates a new Color3 set with the added values of the current Color3 and of the passed one
  8103. * @param otherColor defines the second operand
  8104. * @returns the new Color3
  8105. */
  8106. add(otherColor: Color3): Color3;
  8107. /**
  8108. * Stores the result of the addition of the current Color3 and passed one rgb values into "result"
  8109. * @param otherColor defines the second operand
  8110. * @param result defines Color3 object to store the result into
  8111. * @returns the unmodified current Color3
  8112. */
  8113. addToRef(otherColor: Color3, result: Color3): Color3;
  8114. /**
  8115. * Returns a new Color3 set with the subtracted values of the passed one from the current Color3
  8116. * @param otherColor defines the second operand
  8117. * @returns the new Color3
  8118. */
  8119. subtract(otherColor: Color3): Color3;
  8120. /**
  8121. * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result"
  8122. * @param otherColor defines the second operand
  8123. * @param result defines Color3 object to store the result into
  8124. * @returns the unmodified current Color3
  8125. */
  8126. subtractToRef(otherColor: Color3, result: Color3): Color3;
  8127. /**
  8128. * Copy the current object
  8129. * @returns a new Color3 copied the current one
  8130. */
  8131. clone(): Color3;
  8132. /**
  8133. * Copies the rgb values from the source in the current Color3
  8134. * @param source defines the source Color3 object
  8135. * @returns the updated Color3 object
  8136. */
  8137. copyFrom(source: Color3): Color3;
  8138. /**
  8139. * Updates the Color3 rgb values from the passed floats
  8140. * @param r defines the red component to read from
  8141. * @param g defines the green component to read from
  8142. * @param b defines the blue component to read from
  8143. * @returns the current Color3 object
  8144. */
  8145. copyFromFloats(r: number, g: number, b: number): Color3;
  8146. /**
  8147. * Updates the Color3 rgb values from the passed floats
  8148. * @param r defines the red component to read from
  8149. * @param g defines the green component to read from
  8150. * @param b defines the blue component to read from
  8151. * @returns the current Color3 object
  8152. */
  8153. set(r: number, g: number, b: number): Color3;
  8154. /**
  8155. * Compute the Color3 hexadecimal code as a string
  8156. * @returns a string containing the hexadecimal representation of the Color3 object
  8157. */
  8158. toHexString(): string;
  8159. /**
  8160. * Computes a new Color3 converted from the current one to linear space
  8161. * @returns a new Color3 object
  8162. */
  8163. toLinearSpace(): Color3;
  8164. /**
  8165. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  8166. * @param convertedColor defines the Color3 object where to store the linear space version
  8167. * @returns the unmodified Color3
  8168. */
  8169. toLinearSpaceToRef(convertedColor: Color3): Color3;
  8170. /**
  8171. * Computes a new Color3 converted from the current one to gamma space
  8172. * @returns a new Color3 object
  8173. */
  8174. toGammaSpace(): Color3;
  8175. /**
  8176. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  8177. * @param convertedColor defines the Color3 object where to store the gamma space version
  8178. * @returns the unmodified Color3
  8179. */
  8180. toGammaSpaceToRef(convertedColor: Color3): Color3;
  8181. /**
  8182. * Creates a new Color3 from the string containing valid hexadecimal values
  8183. * @param hex defines a string containing valid hexadecimal values
  8184. * @returns a new Color3 object
  8185. */
  8186. static FromHexString(hex: string): Color3;
  8187. /**
  8188. * Creates a new Vector3 from the starting index of the passed array
  8189. * @param array defines the source array
  8190. * @param offset defines an offset in the source array
  8191. * @returns a new Color3 object
  8192. */
  8193. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  8194. /**
  8195. * Creates a new Color3 from integer values (< 256)
  8196. * @param r defines the red component to read from (value between 0 and 255)
  8197. * @param g defines the green component to read from (value between 0 and 255)
  8198. * @param b defines the blue component to read from (value between 0 and 255)
  8199. * @returns a new Color3 object
  8200. */
  8201. static FromInts(r: number, g: number, b: number): Color3;
  8202. /**
  8203. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  8204. * @param start defines the start Color3 value
  8205. * @param end defines the end Color3 value
  8206. * @param amount defines the gradient value between start and end
  8207. * @returns a new Color3 object
  8208. */
  8209. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  8210. /**
  8211. * Returns a Color3 value containing a red color
  8212. * @returns a new Color3 object
  8213. */
  8214. static Red(): Color3;
  8215. /**
  8216. * Returns a Color3 value containing a green color
  8217. * @returns a new Color3 object
  8218. */
  8219. static Green(): Color3;
  8220. /**
  8221. * Returns a Color3 value containing a blue color
  8222. * @returns a new Color3 object
  8223. */
  8224. static Blue(): Color3;
  8225. /**
  8226. * Returns a Color3 value containing a black color
  8227. * @returns a new Color3 object
  8228. */
  8229. static Black(): Color3;
  8230. /**
  8231. * Returns a Color3 value containing a white color
  8232. * @returns a new Color3 object
  8233. */
  8234. static White(): Color3;
  8235. /**
  8236. * Returns a Color3 value containing a purple color
  8237. * @returns a new Color3 object
  8238. */
  8239. static Purple(): Color3;
  8240. /**
  8241. * Returns a Color3 value containing a magenta color
  8242. * @returns a new Color3 object
  8243. */
  8244. static Magenta(): Color3;
  8245. /**
  8246. * Returns a Color3 value containing a yellow color
  8247. * @returns a new Color3 object
  8248. */
  8249. static Yellow(): Color3;
  8250. /**
  8251. * Returns a Color3 value containing a gray color
  8252. * @returns a new Color3 object
  8253. */
  8254. static Gray(): Color3;
  8255. /**
  8256. * Returns a Color3 value containing a teal color
  8257. * @returns a new Color3 object
  8258. */
  8259. static Teal(): Color3;
  8260. /**
  8261. * Returns a Color3 value containing a random color
  8262. * @returns a new Color3 object
  8263. */
  8264. static Random(): Color3;
  8265. }
  8266. /**
  8267. * Class used to hold a RBGA color
  8268. */
  8269. class Color4 {
  8270. /**
  8271. * Defines the red component (between 0 and 1, default is 0)
  8272. */
  8273. r: number;
  8274. /**
  8275. * Defines the green component (between 0 and 1, default is 0)
  8276. */
  8277. g: number;
  8278. /**
  8279. * Defines the blue component (between 0 and 1, default is 0)
  8280. */
  8281. b: number;
  8282. /**
  8283. * Defines the alpha component (between 0 and 1, default is 1)
  8284. */
  8285. a: number;
  8286. /**
  8287. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  8288. * @param r defines the red component (between 0 and 1, default is 0)
  8289. * @param g defines the green component (between 0 and 1, default is 0)
  8290. * @param b defines the blue component (between 0 and 1, default is 0)
  8291. * @param a defines the alpha component (between 0 and 1, default is 1)
  8292. */
  8293. constructor(
  8294. /**
  8295. * Defines the red component (between 0 and 1, default is 0)
  8296. */
  8297. r?: number,
  8298. /**
  8299. * Defines the green component (between 0 and 1, default is 0)
  8300. */
  8301. g?: number,
  8302. /**
  8303. * Defines the blue component (between 0 and 1, default is 0)
  8304. */
  8305. b?: number,
  8306. /**
  8307. * Defines the alpha component (between 0 and 1, default is 1)
  8308. */
  8309. a?: number);
  8310. /**
  8311. * Adds in place the passed Color4 values to the current Color4 object
  8312. * @param right defines the second operand
  8313. * @returns the current updated Color4 object
  8314. */
  8315. addInPlace(right: Color4): Color4;
  8316. /**
  8317. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  8318. * @returns the new array
  8319. */
  8320. asArray(): number[];
  8321. /**
  8322. * Stores from the starting index in the passed array the Color4 successive values
  8323. * @param array defines the array where to store the r,g,b components
  8324. * @param index defines an optional index in the target array to define where to start storing values
  8325. * @returns the current Color4 object
  8326. */
  8327. toArray(array: number[], index?: number): Color4;
  8328. /**
  8329. * Creates a new Color4 set with the added values of the current Color4 and of the passed one
  8330. * @param right defines the second operand
  8331. * @returns a new Color4 object
  8332. */
  8333. add(right: Color4): Color4;
  8334. /**
  8335. * Creates a new Color4 set with the subtracted values of the passed one from the current Color4
  8336. * @param right defines the second operand
  8337. * @returns a new Color4 object
  8338. */
  8339. subtract(right: Color4): Color4;
  8340. /**
  8341. * Subtracts the passed ones from the current Color4 values and stores the results in "result"
  8342. * @param right defines the second operand
  8343. * @param result defines the Color4 object where to store the result
  8344. * @returns the current Color4 object
  8345. */
  8346. subtractToRef(right: Color4, result: Color4): Color4;
  8347. /**
  8348. * Creates a new Color4 with the current Color4 values multiplied by scale
  8349. * @param scale defines the scaling factor to apply
  8350. * @returns a new Color4 object
  8351. */
  8352. scale(scale: number): Color4;
  8353. /**
  8354. * Multiplies the current Color4 values by scale and stores the result in "result"
  8355. * @param scale defines the scaling factor to apply
  8356. * @param result defines the Color4 object where to store the result
  8357. * @returns the current Color4.
  8358. */
  8359. scaleToRef(scale: number, result: Color4): Color4;
  8360. /**
  8361. * Clamps the rgb values by the min and max values and stores the result into "result"
  8362. * @param min defines minimum clamping value (default is 0)
  8363. * @param max defines maximum clamping value (default is 1)
  8364. * @param result defines color to store the result into.
  8365. * @returns the cuurent Color4
  8366. */
  8367. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  8368. /**
  8369. * Multipy an Color4 value by another and return a new Color4 object
  8370. * @param color defines the Color4 value to multiply by
  8371. * @returns a new Color4 object
  8372. */
  8373. multiply(color: Color4): Color4;
  8374. /**
  8375. * Multipy a Color4 value by another and push the result in a reference value
  8376. * @param color defines the Color4 value to multiply by
  8377. * @param result defines the Color4 to fill the result in
  8378. * @returns the result Color4
  8379. */
  8380. multiplyToRef(color: Color4, result: Color4): Color4;
  8381. /**
  8382. * Creates a string with the Color4 current values
  8383. * @returns the string representation of the Color4 object
  8384. */
  8385. toString(): string;
  8386. /**
  8387. * Returns the string "Color4"
  8388. * @returns "Color4"
  8389. */
  8390. getClassName(): string;
  8391. /**
  8392. * Compute the Color4 hash code
  8393. * @returns an unique number that can be used to hash Color4 objects
  8394. */
  8395. getHashCode(): number;
  8396. /**
  8397. * Creates a new Color4 copied from the current one
  8398. * @returns a new Color4 object
  8399. */
  8400. clone(): Color4;
  8401. /**
  8402. * Copies the passed Color4 values into the current one
  8403. * @param source defines the source Color4 object
  8404. * @returns the current updated Color4 object
  8405. */
  8406. copyFrom(source: Color4): Color4;
  8407. /**
  8408. * Copies the passed float values into the current one
  8409. * @param r defines the red component to read from
  8410. * @param g defines the green component to read from
  8411. * @param b defines the blue component to read from
  8412. * @param a defines the alpha component to read from
  8413. * @returns the current updated Color4 object
  8414. */
  8415. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  8416. /**
  8417. * Copies the passed float values into the current one
  8418. * @param r defines the red component to read from
  8419. * @param g defines the green component to read from
  8420. * @param b defines the blue component to read from
  8421. * @param a defines the alpha component to read from
  8422. * @returns the current updated Color4 object
  8423. */
  8424. set(r: number, g: number, b: number, a: number): Color4;
  8425. /**
  8426. * Compute the Color4 hexadecimal code as a string
  8427. * @returns a string containing the hexadecimal representation of the Color4 object
  8428. */
  8429. toHexString(): string;
  8430. /**
  8431. * Computes a new Color4 converted from the current one to linear space
  8432. * @returns a new Color4 object
  8433. */
  8434. toLinearSpace(): Color4;
  8435. /**
  8436. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  8437. * @param convertedColor defines the Color4 object where to store the linear space version
  8438. * @returns the unmodified Color4
  8439. */
  8440. toLinearSpaceToRef(convertedColor: Color4): Color4;
  8441. /**
  8442. * Computes a new Color4 converted from the current one to gamma space
  8443. * @returns a new Color4 object
  8444. */
  8445. toGammaSpace(): Color4;
  8446. /**
  8447. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  8448. * @param convertedColor defines the Color4 object where to store the gamma space version
  8449. * @returns the unmodified Color4
  8450. */
  8451. toGammaSpaceToRef(convertedColor: Color4): Color4;
  8452. /**
  8453. * Creates a new Color4 from the string containing valid hexadecimal values
  8454. * @param hex defines a string containing valid hexadecimal values
  8455. * @returns a new Color4 object
  8456. */
  8457. static FromHexString(hex: string): Color4;
  8458. /**
  8459. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  8460. * @param left defines the start value
  8461. * @param right defines the end value
  8462. * @param amount defines the gradient factor
  8463. * @returns a new Color4 object
  8464. */
  8465. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  8466. /**
  8467. * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  8468. * @param left defines the start value
  8469. * @param right defines the end value
  8470. * @param amount defines the gradient factor
  8471. * @param result defines the Color4 object where to store data
  8472. */
  8473. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  8474. /**
  8475. * Creates a new Color4 from the starting index element of the passed array
  8476. * @param array defines the source array to read from
  8477. * @param offset defines the offset in the source array
  8478. * @returns a new Color4 object
  8479. */
  8480. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  8481. /**
  8482. * Creates a new Color3 from integer values (< 256)
  8483. * @param r defines the red component to read from (value between 0 and 255)
  8484. * @param g defines the green component to read from (value between 0 and 255)
  8485. * @param b defines the blue component to read from (value between 0 and 255)
  8486. * @param a defines the alpha component to read from (value between 0 and 255)
  8487. * @returns a new Color3 object
  8488. */
  8489. static FromInts(r: number, g: number, b: number, a: number): Color4;
  8490. /**
  8491. * Check the content of a given array and convert it to an array containing RGBA data
  8492. * If the original array was already containing count * 4 values then it is returned directly
  8493. * @param colors defines the array to check
  8494. * @param count defines the number of RGBA data to expect
  8495. * @returns an array containing count * 4 values (RGBA)
  8496. */
  8497. static CheckColors4(colors: number[], count: number): number[];
  8498. }
  8499. class Vector2 {
  8500. x: number;
  8501. y: number;
  8502. /**
  8503. * Creates a new Vector2 from the passed x and y coordinates.
  8504. */
  8505. constructor(x: number, y: number);
  8506. /**
  8507. * Returns a string with the Vector2 coordinates.
  8508. */
  8509. toString(): string;
  8510. /**
  8511. * Returns the string "Vector2"
  8512. */
  8513. getClassName(): string;
  8514. /**
  8515. * Returns the Vector2 hash code as a number.
  8516. */
  8517. getHashCode(): number;
  8518. /**
  8519. * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index.
  8520. * Returns the Vector2.
  8521. */
  8522. toArray(array: FloatArray, index?: number): Vector2;
  8523. /**
  8524. * Returns a new array with 2 elements : the Vector2 coordinates.
  8525. */
  8526. asArray(): number[];
  8527. /**
  8528. * Sets the Vector2 coordinates with the passed Vector2 coordinates.
  8529. * Returns the updated Vector2.
  8530. */
  8531. copyFrom(source: Vector2): Vector2;
  8532. /**
  8533. * Sets the Vector2 coordinates with the passed floats.
  8534. * Returns the updated Vector2.
  8535. */
  8536. copyFromFloats(x: number, y: number): Vector2;
  8537. /**
  8538. * Sets the Vector2 coordinates with the passed floats.
  8539. * Returns the updated Vector2.
  8540. */
  8541. set(x: number, y: number): Vector2;
  8542. /**
  8543. * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates.
  8544. */
  8545. add(otherVector: Vector2): Vector2;
  8546. /**
  8547. * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates.
  8548. * Returns the Vector2.
  8549. */
  8550. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  8551. /**
  8552. * Set the Vector2 coordinates by adding the passed Vector2 coordinates.
  8553. * Returns the updated Vector2.
  8554. */
  8555. addInPlace(otherVector: Vector2): Vector2;
  8556. /**
  8557. * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates.
  8558. */
  8559. addVector3(otherVector: Vector3): Vector2;
  8560. /**
  8561. * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2.
  8562. */
  8563. subtract(otherVector: Vector2): Vector2;
  8564. /**
  8565. * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates.
  8566. * Returns the Vector2.
  8567. */
  8568. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  8569. /**
  8570. * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates.
  8571. * Returns the updated Vector2.
  8572. */
  8573. subtractInPlace(otherVector: Vector2): Vector2;
  8574. /**
  8575. * Multiplies in place the current Vector2 coordinates by the passed ones.
  8576. * Returns the updated Vector2.
  8577. */
  8578. multiplyInPlace(otherVector: Vector2): Vector2;
  8579. /**
  8580. * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates.
  8581. */
  8582. multiply(otherVector: Vector2): Vector2;
  8583. /**
  8584. * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates.
  8585. * Returns the Vector2.
  8586. */
  8587. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  8588. /**
  8589. * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats.
  8590. */
  8591. multiplyByFloats(x: number, y: number): Vector2;
  8592. /**
  8593. * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates.
  8594. */
  8595. divide(otherVector: Vector2): Vector2;
  8596. /**
  8597. * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates.
  8598. * Returns the Vector2.
  8599. */
  8600. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  8601. /**
  8602. * Divides the current Vector3 coordinates by the passed ones.
  8603. * Returns the updated Vector3.
  8604. */
  8605. divideInPlace(otherVector: Vector2): Vector2;
  8606. /**
  8607. * Returns a new Vector2 with current Vector2 negated coordinates.
  8608. */
  8609. negate(): Vector2;
  8610. /**
  8611. * Multiply the Vector2 coordinates by scale.
  8612. * Returns the updated Vector2.
  8613. */
  8614. scaleInPlace(scale: number): Vector2;
  8615. /**
  8616. * Returns a new Vector2 scaled by "scale" from the current Vector2.
  8617. */
  8618. scale(scale: number): Vector2;
  8619. /**
  8620. * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones.
  8621. */
  8622. equals(otherVector: Vector2): boolean;
  8623. /**
  8624. * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon.
  8625. */
  8626. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  8627. /**
  8628. * Returns the vector length (float).
  8629. */
  8630. length(): number;
  8631. /**
  8632. * Returns the vector squared length (float);
  8633. */
  8634. lengthSquared(): number;
  8635. /**
  8636. * Normalize the vector.
  8637. * Returns the updated Vector2.
  8638. */
  8639. normalize(): Vector2;
  8640. /**
  8641. * Returns a new Vector2 copied from the Vector2.
  8642. */
  8643. clone(): Vector2;
  8644. /**
  8645. * Returns a new Vector2(0, 0)
  8646. */
  8647. static Zero(): Vector2;
  8648. /**
  8649. * Returns a new Vector2(1, 1)
  8650. */
  8651. static One(): Vector2;
  8652. /**
  8653. * Returns a new Vector2 set from the passed index element of the passed array.
  8654. */
  8655. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  8656. /**
  8657. * Sets "result" from the passed index element of the passed array.
  8658. */
  8659. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  8660. /**
  8661. * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2.
  8662. */
  8663. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  8664. /**
  8665. * 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".
  8666. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  8667. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate.
  8668. */
  8669. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  8670. /**
  8671. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2".
  8672. */
  8673. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  8674. /**
  8675. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  8676. */
  8677. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  8678. /**
  8679. * Returns the dot product (float) of the vector "left" and the vector "right".
  8680. */
  8681. static Dot(left: Vector2, right: Vector2): number;
  8682. /**
  8683. * Returns a new Vector2 equal to the normalized passed vector.
  8684. */
  8685. static Normalize(vector: Vector2): Vector2;
  8686. /**
  8687. * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors.
  8688. */
  8689. static Minimize(left: Vector2, right: Vector2): Vector2;
  8690. /**
  8691. * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors.
  8692. */
  8693. static Maximize(left: Vector2, right: Vector2): Vector2;
  8694. /**
  8695. * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix.
  8696. */
  8697. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  8698. /**
  8699. * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates.
  8700. */
  8701. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  8702. /**
  8703. * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  8704. */
  8705. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  8706. /**
  8707. * Returns the distance (float) between the vectors "value1" and "value2".
  8708. */
  8709. static Distance(value1: Vector2, value2: Vector2): number;
  8710. /**
  8711. * Returns the squared distance (float) between the vectors "value1" and "value2".
  8712. */
  8713. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  8714. /**
  8715. * Returns a new Vecto2 located at the center of the vectors "value1" and "value2".
  8716. */
  8717. static Center(value1: Vector2, value2: Vector2): Vector2;
  8718. /**
  8719. * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  8720. */
  8721. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  8722. }
  8723. /**
  8724. * Classed used to store (x,y,z) vector representation
  8725. * A Vector3 is the main object used in 3D geometry
  8726. * It can represent etiher the coordinates of a point the space, either a direction
  8727. * Reminder: Babylon.js uses a left handed forward facing system
  8728. */
  8729. class Vector3 {
  8730. /**
  8731. * Defines the first coordinates (on X axis)
  8732. */
  8733. x: number;
  8734. /**
  8735. * Defines the second coordinates (on Y axis)
  8736. */
  8737. y: number;
  8738. /**
  8739. * Defines the third coordinates (on Z axis)
  8740. */
  8741. z: number;
  8742. /**
  8743. * Creates a new Vector3 object from the passed x, y, z (floats) coordinates.
  8744. * @param x defines the first coordinates (on X axis)
  8745. * @param y defines the second coordinates (on Y axis)
  8746. * @param z defines the third coordinates (on Z axis)
  8747. */
  8748. constructor(
  8749. /**
  8750. * Defines the first coordinates (on X axis)
  8751. */
  8752. x: number,
  8753. /**
  8754. * Defines the second coordinates (on Y axis)
  8755. */
  8756. y: number,
  8757. /**
  8758. * Defines the third coordinates (on Z axis)
  8759. */
  8760. z: number);
  8761. /**
  8762. * Creates a string representation of the Vector3
  8763. * @returns a string with the Vector3 coordinates.
  8764. */
  8765. toString(): string;
  8766. /**
  8767. * Gets the class name
  8768. * @returns the string "Vector3"
  8769. */
  8770. getClassName(): string;
  8771. /**
  8772. * Creates the Vector3 hash code
  8773. * @returns a number which tends to be unique between Vector3 instances
  8774. */
  8775. getHashCode(): number;
  8776. /**
  8777. * Creates an array containing three elements : the coordinates of the Vector3
  8778. * @returns a new array of numbers
  8779. */
  8780. asArray(): number[];
  8781. /**
  8782. * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3
  8783. * @param array defines the destination array
  8784. * @param index defines the offset in the destination array
  8785. * @returns the current Vector3
  8786. */
  8787. toArray(array: FloatArray, index?: number): Vector3;
  8788. /**
  8789. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  8790. * @returns a new Quaternion object, computed from the Vector3 coordinates
  8791. */
  8792. toQuaternion(): Quaternion;
  8793. /**
  8794. * Adds the passed vector to the current Vector3
  8795. * @param otherVector defines the second operand
  8796. * @returns the current updated Vector3
  8797. */
  8798. addInPlace(otherVector: Vector3): Vector3;
  8799. /**
  8800. * Gets a new Vector3, result of the addition the current Vector3 and the passed vector
  8801. * @param otherVector defines the second operand
  8802. * @returns the resulting Vector3
  8803. */
  8804. add(otherVector: Vector3): Vector3;
  8805. /**
  8806. * Adds the current Vector3 to the passed one and stores the result in the vector "result"
  8807. * @param otherVector defines the second operand
  8808. * @param result defines the Vector3 object where to store the result
  8809. * @returns the current Vector3
  8810. */
  8811. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  8812. /**
  8813. * Subtract the passed vector from the current Vector3
  8814. * @param otherVector defines the second operand
  8815. * @returns the current updated Vector3
  8816. */
  8817. subtractInPlace(otherVector: Vector3): Vector3;
  8818. /**
  8819. * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3
  8820. * @param otherVector defines the second operand
  8821. * @returns the resulting Vector3
  8822. */
  8823. subtract(otherVector: Vector3): Vector3;
  8824. /**
  8825. * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result".
  8826. * @param otherVector defines the second operand
  8827. * @param result defines the Vector3 object where to store the result
  8828. * @returns the current Vector3
  8829. */
  8830. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  8831. /**
  8832. * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates
  8833. * @param x defines the x coordinate of the operand
  8834. * @param y defines the y coordinate of the operand
  8835. * @param z defines the z coordinate of the operand
  8836. * @returns the resulting Vector3
  8837. */
  8838. subtractFromFloats(x: number, y: number, z: number): Vector3;
  8839. /**
  8840. * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result
  8841. * @param x defines the x coordinate of the operand
  8842. * @param y defines the y coordinate of the operand
  8843. * @param z defines the z coordinate of the operand
  8844. * @param result defines the Vector3 object where to store the result
  8845. * @returns the current Vector3
  8846. */
  8847. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  8848. /**
  8849. * Gets a new Vector3 set with the current Vector3 negated coordinates
  8850. * @returns a new Vector3
  8851. */
  8852. negate(): Vector3;
  8853. /**
  8854. * Multiplies the Vector3 coordinates by the float "scale"
  8855. * @param scale defines the multiplier factor
  8856. * @returns the current updated Vector3
  8857. */
  8858. scaleInPlace(scale: number): Vector3;
  8859. /**
  8860. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  8861. * @param scale defines the multiplier factor
  8862. * @returns a new Vector3
  8863. */
  8864. scale(scale: number): Vector3;
  8865. /**
  8866. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates
  8867. * @param scale defines the multiplier factor
  8868. * @param result defines the Vector3 object where to store the result
  8869. * @returns the current Vector3
  8870. */
  8871. scaleToRef(scale: number, result: Vector3): Vector3;
  8872. /**
  8873. * Returns true if the current Vector3 and the passed vector coordinates are strictly equal
  8874. * @param otherVector defines the second operand
  8875. * @returns true if both vectors are equals
  8876. */
  8877. equals(otherVector: Vector3): boolean;
  8878. /**
  8879. * Returns true if the current Vector3 and the passed vector coordinates are distant less than epsilon
  8880. * @param otherVector defines the second operand
  8881. * @param epsilon defines the minimal distance to define values as equals
  8882. * @returns true if both vectors are distant less than epsilon
  8883. */
  8884. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  8885. /**
  8886. * Returns true if the current Vector3 coordinates equals the passed floats
  8887. * @param x defines the x coordinate of the operand
  8888. * @param y defines the y coordinate of the operand
  8889. * @param z defines the z coordinate of the operand
  8890. * @returns true if both vectors are equals
  8891. */
  8892. equalsToFloats(x: number, y: number, z: number): boolean;
  8893. /**
  8894. * Multiplies the current Vector3 coordinates by the passed ones
  8895. * @param otherVector defines the second operand
  8896. * @returns the current updated Vector3
  8897. */
  8898. multiplyInPlace(otherVector: Vector3): Vector3;
  8899. /**
  8900. * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector
  8901. * @param otherVector defines the second operand
  8902. * @returns the new Vector3
  8903. */
  8904. multiply(otherVector: Vector3): Vector3;
  8905. /**
  8906. * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result"
  8907. * @param otherVector defines the second operand
  8908. * @param result defines the Vector3 object where to store the result
  8909. * @returns the current Vector3
  8910. */
  8911. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  8912. /**
  8913. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the passed floats
  8914. * @param x defines the x coordinate of the operand
  8915. * @param y defines the y coordinate of the operand
  8916. * @param z defines the z coordinate of the operand
  8917. * @returns the new Vector3
  8918. */
  8919. multiplyByFloats(x: number, y: number, z: number): Vector3;
  8920. /**
  8921. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the passed ones
  8922. * @param otherVector defines the second operand
  8923. * @returns the new Vector3
  8924. */
  8925. divide(otherVector: Vector3): Vector3;
  8926. /**
  8927. * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result"
  8928. * @param otherVector defines the second operand
  8929. * @param result defines the Vector3 object where to store the result
  8930. * @returns the current Vector3
  8931. */
  8932. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  8933. /**
  8934. * Divides the current Vector3 coordinates by the passed ones.
  8935. * @param otherVector defines the second operand
  8936. * @returns the current updated Vector3
  8937. */
  8938. divideInPlace(otherVector: Vector3): Vector3;
  8939. /**
  8940. * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones
  8941. * @param other defines the second operand
  8942. * @returns the current updated Vector3
  8943. */
  8944. minimizeInPlace(other: Vector3): Vector3;
  8945. /**
  8946. * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones.
  8947. * @param other defines the second operand
  8948. * @returns the current updated Vector3
  8949. */
  8950. maximizeInPlace(other: Vector3): Vector3;
  8951. /**
  8952. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  8953. */
  8954. readonly isNonUniform: boolean;
  8955. /**
  8956. * Gets the length of the Vector3
  8957. * @returns the length of the Vecto3
  8958. */
  8959. length(): number;
  8960. /**
  8961. * Gets the squared length of the Vector3
  8962. * @returns squared length of the Vector3
  8963. */
  8964. lengthSquared(): number;
  8965. /**
  8966. * Normalize the current Vector3.
  8967. * Please note that this is an in place operation.
  8968. * @returns the current updated Vector3
  8969. */
  8970. normalize(): Vector3;
  8971. /**
  8972. * Normalize the current Vector3 to a new vector
  8973. * @returns the new Vector3
  8974. */
  8975. normalizeToNew(): Vector3;
  8976. /**
  8977. * Normalize the current Vector3 to the reference
  8978. * @param reference define the Vector3 to update
  8979. * @returns the updated Vector3
  8980. */
  8981. normalizeToRef(reference: Vector3): Vector3;
  8982. /**
  8983. * Creates a new Vector3 copied from the current Vector3
  8984. * @returns the new Vector3
  8985. */
  8986. clone(): Vector3;
  8987. /**
  8988. * Copies the passed vector coordinates to the current Vector3 ones
  8989. * @param source defines the source Vector3
  8990. * @returns the current updated Vector3
  8991. */
  8992. copyFrom(source: Vector3): Vector3;
  8993. /**
  8994. * Copies the passed floats to the current Vector3 coordinates
  8995. * @param x defines the x coordinate of the operand
  8996. * @param y defines the y coordinate of the operand
  8997. * @param z defines the z coordinate of the operand
  8998. * @returns the current updated Vector3
  8999. */
  9000. copyFromFloats(x: number, y: number, z: number): Vector3;
  9001. /**
  9002. * Copies the passed floats to the current Vector3 coordinates
  9003. * @param x defines the x coordinate of the operand
  9004. * @param y defines the y coordinate of the operand
  9005. * @param z defines the z coordinate of the operand
  9006. * @returns the current updated Vector3
  9007. */
  9008. set(x: number, y: number, z: number): Vector3;
  9009. /**
  9010. * Get the clip factor between two vectors
  9011. * @param vector0 defines the first operand
  9012. * @param vector1 defines the second operand
  9013. * @param axis defines the axis to use
  9014. * @param size defines the size along the axis
  9015. * @returns the clip factor
  9016. */
  9017. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  9018. /**
  9019. * Get angle between two vectors
  9020. * @param vector0 angle between vector0 and vector1
  9021. * @param vector1 angle between vector0 and vector1
  9022. * @param normal direction of the normal
  9023. * @return the angle between vector0 and vector1
  9024. */
  9025. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  9026. /**
  9027. * Returns a new Vector3 set from the index "offset" of the passed array
  9028. * @param array defines the source array
  9029. * @param offset defines the offset in the source array
  9030. * @returns the new Vector3
  9031. */
  9032. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  9033. /**
  9034. * Returns a new Vector3 set from the index "offset" of the passed Float32Array
  9035. * This function is deprecated. Use FromArray instead
  9036. * @param array defines the source array
  9037. * @param offset defines the offset in the source array
  9038. * @returns the new Vector3
  9039. */
  9040. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  9041. /**
  9042. * Sets the passed vector "result" with the element values from the index "offset" of the passed array
  9043. * @param array defines the source array
  9044. * @param offset defines the offset in the source array
  9045. * @param result defines the Vector3 where to store the result
  9046. */
  9047. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  9048. /**
  9049. * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array
  9050. * This function is deprecated. Use FromArrayToRef instead.
  9051. * @param array defines the source array
  9052. * @param offset defines the offset in the source array
  9053. * @param result defines the Vector3 where to store the result
  9054. */
  9055. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  9056. /**
  9057. * Sets the passed vector "result" with the passed floats.
  9058. * @param x defines the x coordinate of the source
  9059. * @param y defines the y coordinate of the source
  9060. * @param z defines the z coordinate of the source
  9061. * @param result defines the Vector3 where to store the result
  9062. */
  9063. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  9064. /**
  9065. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  9066. * @returns a new empty Vector3
  9067. */
  9068. static Zero(): Vector3;
  9069. /**
  9070. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  9071. * @returns a new unit Vector3
  9072. */
  9073. static One(): Vector3;
  9074. /**
  9075. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  9076. * @returns a new up Vector3
  9077. */
  9078. static Up(): Vector3;
  9079. /**
  9080. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  9081. * @returns a new forward Vector3
  9082. */
  9083. static Forward(): Vector3;
  9084. /**
  9085. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  9086. * @returns a new right Vector3
  9087. */
  9088. static Right(): Vector3;
  9089. /**
  9090. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  9091. * @returns a new left Vector3
  9092. */
  9093. static Left(): Vector3;
  9094. /**
  9095. * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector.
  9096. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  9097. * @param vector defines the Vector3 to transform
  9098. * @param transformation defines the transformation matrix
  9099. * @returns the transformed Vector3
  9100. */
  9101. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  9102. /**
  9103. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector
  9104. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  9105. * @param vector defines the Vector3 to transform
  9106. * @param transformation defines the transformation matrix
  9107. * @param result defines the Vector3 where to store the result
  9108. */
  9109. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  9110. /**
  9111. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z)
  9112. * This method computes tranformed coordinates only, not transformed direction vectors
  9113. * @param x define the x coordinate of the source vector
  9114. * @param y define the y coordinate of the source vector
  9115. * @param z define the z coordinate of the source vector
  9116. * @param transformation defines the transformation matrix
  9117. * @param result defines the Vector3 where to store the result
  9118. */
  9119. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  9120. /**
  9121. * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector
  9122. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  9123. * @param vector defines the Vector3 to transform
  9124. * @param transformation defines the transformation matrix
  9125. * @returns the new Vector3
  9126. */
  9127. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  9128. /**
  9129. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector
  9130. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  9131. * @param vector defines the Vector3 to transform
  9132. * @param transformation defines the transformation matrix
  9133. * @param result defines the Vector3 where to store the result
  9134. */
  9135. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  9136. /**
  9137. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z)
  9138. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  9139. * @param x define the x coordinate of the source vector
  9140. * @param y define the y coordinate of the source vector
  9141. * @param z define the z coordinate of the source vector
  9142. * @param transformation defines the transformation matrix
  9143. * @param result defines the Vector3 where to store the result
  9144. */
  9145. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  9146. /**
  9147. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  9148. * @param value1 defines the first control point
  9149. * @param value2 defines the second control point
  9150. * @param value3 defines the third control point
  9151. * @param value4 defines the fourth control point
  9152. * @param amount defines the amount on the spline to use
  9153. * @returns the new Vector3
  9154. */
  9155. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  9156. /**
  9157. * 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"
  9158. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  9159. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  9160. * @param value defines the current value
  9161. * @param min defines the lower range value
  9162. * @param max defines the upper range value
  9163. * @returns the new Vector3
  9164. */
  9165. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  9166. /**
  9167. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  9168. * @param value1 defines the first control point
  9169. * @param tangent1 defines the first tangent vector
  9170. * @param value2 defines the second control point
  9171. * @param tangent2 defines the second tangent vector
  9172. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  9173. * @returns the new Vector3
  9174. */
  9175. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  9176. /**
  9177. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  9178. * @param start defines the start value
  9179. * @param end defines the end value
  9180. * @param amount max defines amount between both (between 0 and 1)
  9181. * @returns the new Vector3
  9182. */
  9183. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  9184. /**
  9185. * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  9186. * @param start defines the start value
  9187. * @param end defines the end value
  9188. * @param amount max defines amount between both (between 0 and 1)
  9189. * @param result defines the Vector3 where to store the result
  9190. */
  9191. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  9192. /**
  9193. * Returns the dot product (float) between the vectors "left" and "right"
  9194. * @param left defines the left operand
  9195. * @param right defines the right operand
  9196. * @returns the dot product
  9197. */
  9198. static Dot(left: Vector3, right: Vector3): number;
  9199. /**
  9200. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  9201. * The cross product is then orthogonal to both "left" and "right"
  9202. * @param left defines the left operand
  9203. * @param right defines the right operand
  9204. * @returns the cross product
  9205. */
  9206. static Cross(left: Vector3, right: Vector3): Vector3;
  9207. /**
  9208. * Sets the passed vector "result" with the cross product of "left" and "right"
  9209. * The cross product is then orthogonal to both "left" and "right"
  9210. * @param left defines the left operand
  9211. * @param right defines the right operand
  9212. * @param result defines the Vector3 where to store the result
  9213. */
  9214. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  9215. /**
  9216. * Returns a new Vector3 as the normalization of the passed vector
  9217. * @param vector defines the Vector3 to normalize
  9218. * @returns the new Vector3
  9219. */
  9220. static Normalize(vector: Vector3): Vector3;
  9221. /**
  9222. * Sets the passed vector "result" with the normalization of the passed first vector
  9223. * @param vector defines the Vector3 to normalize
  9224. * @param result defines the Vector3 where to store the result
  9225. */
  9226. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  9227. private static _viewportMatrixCache;
  9228. /**
  9229. * Project a Vector3 onto screen space
  9230. * @param vector defines the Vector3 to project
  9231. * @param world defines the world matrix to use
  9232. * @param transform defines the transform (view x projection) matrix to use
  9233. * @param viewport defines the screen viewport to use
  9234. * @returns the new Vector3
  9235. */
  9236. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  9237. /**
  9238. * Unproject from screen space to object space
  9239. * @param source defines the screen space Vector3 to use
  9240. * @param viewportWidth defines the current width of the viewport
  9241. * @param viewportHeight defines the current height of the viewport
  9242. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9243. * @param transform defines the transform (view x projection) matrix to use
  9244. * @returns the new Vector3
  9245. */
  9246. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  9247. /**
  9248. * Unproject from screen space to object space
  9249. * @param source defines the screen space Vector3 to use
  9250. * @param viewportWidth defines the current width of the viewport
  9251. * @param viewportHeight defines the current height of the viewport
  9252. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9253. * @param view defines the view matrix to use
  9254. * @param projection defines the projection matrix to use
  9255. * @returns the new Vector3
  9256. */
  9257. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  9258. /**
  9259. * Unproject from screen space to object space
  9260. * @param source defines the screen space Vector3 to use
  9261. * @param viewportWidth defines the current width of the viewport
  9262. * @param viewportHeight defines the current height of the viewport
  9263. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9264. * @param view defines the view matrix to use
  9265. * @param projection defines the projection matrix to use
  9266. * @param result defines the Vector3 where to store the result
  9267. */
  9268. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  9269. /**
  9270. * Unproject from screen space to object space
  9271. * @param sourceX defines the screen space x coordinate to use
  9272. * @param sourceY defines the screen space y coordinate to use
  9273. * @param sourceZ defines the screen space z coordinate to use
  9274. * @param viewportWidth defines the current width of the viewport
  9275. * @param viewportHeight defines the current height of the viewport
  9276. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9277. * @param view defines the view matrix to use
  9278. * @param projection defines the projection matrix to use
  9279. * @param result defines the Vector3 where to store the result
  9280. */
  9281. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  9282. /**
  9283. * Gets the minimal coordinate values between two Vector3
  9284. * @param left defines the first operand
  9285. * @param right defines the second operand
  9286. * @returns the new Vector3
  9287. */
  9288. static Minimize(left: Vector3, right: Vector3): Vector3;
  9289. /**
  9290. * Gets the maximal coordinate values between two Vector3
  9291. * @param left defines the first operand
  9292. * @param right defines the second operand
  9293. * @returns the new Vector3
  9294. */
  9295. static Maximize(left: Vector3, right: Vector3): Vector3;
  9296. /**
  9297. * Returns the distance between the vectors "value1" and "value2"
  9298. * @param value1 defines the first operand
  9299. * @param value2 defines the second operand
  9300. * @returns the distance
  9301. */
  9302. static Distance(value1: Vector3, value2: Vector3): number;
  9303. /**
  9304. * Returns the squared distance between the vectors "value1" and "value2"
  9305. * @param value1 defines the first operand
  9306. * @param value2 defines the second operand
  9307. * @returns the squared distance
  9308. */
  9309. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  9310. /**
  9311. * Returns a new Vector3 located at the center between "value1" and "value2"
  9312. * @param value1 defines the first operand
  9313. * @param value2 defines the second operand
  9314. * @returns the new Vector3
  9315. */
  9316. static Center(value1: Vector3, value2: Vector3): Vector3;
  9317. /**
  9318. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  9319. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  9320. * to something in order to rotate it from its local system to the given target system
  9321. * Note: axis1, axis2 and axis3 are normalized during this operation
  9322. * @param axis1 defines the first axis
  9323. * @param axis2 defines the second axis
  9324. * @param axis3 defines the third axis
  9325. * @returns a new Vector3
  9326. */
  9327. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  9328. /**
  9329. * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3
  9330. * @param axis1 defines the first axis
  9331. * @param axis2 defines the second axis
  9332. * @param axis3 defines the third axis
  9333. * @param ref defines the Vector3 where to store the result
  9334. */
  9335. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  9336. }
  9337. class Vector4 {
  9338. x: number;
  9339. y: number;
  9340. z: number;
  9341. w: number;
  9342. /**
  9343. * Creates a Vector4 object from the passed floats.
  9344. */
  9345. constructor(x: number, y: number, z: number, w: number);
  9346. /**
  9347. * Returns the string with the Vector4 coordinates.
  9348. */
  9349. toString(): string;
  9350. /**
  9351. * Returns the string "Vector4".
  9352. */
  9353. getClassName(): string;
  9354. /**
  9355. * Returns the Vector4 hash code.
  9356. */
  9357. getHashCode(): number;
  9358. /**
  9359. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  9360. */
  9361. asArray(): number[];
  9362. /**
  9363. * Populates the passed array from the passed index with the Vector4 coordinates.
  9364. * Returns the Vector4.
  9365. */
  9366. toArray(array: FloatArray, index?: number): Vector4;
  9367. /**
  9368. * Adds the passed vector to the current Vector4.
  9369. * Returns the updated Vector4.
  9370. */
  9371. addInPlace(otherVector: Vector4): Vector4;
  9372. /**
  9373. * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one.
  9374. */
  9375. add(otherVector: Vector4): Vector4;
  9376. /**
  9377. * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one.
  9378. * Returns the current Vector4.
  9379. */
  9380. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  9381. /**
  9382. * Subtract in place the passed vector from the current Vector4.
  9383. * Returns the updated Vector4.
  9384. */
  9385. subtractInPlace(otherVector: Vector4): Vector4;
  9386. /**
  9387. * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4.
  9388. */
  9389. subtract(otherVector: Vector4): Vector4;
  9390. /**
  9391. * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4.
  9392. * Returns the current Vector4.
  9393. */
  9394. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  9395. /**
  9396. * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  9397. */
  9398. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  9399. /**
  9400. * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  9401. * Returns the current Vector4.
  9402. */
  9403. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  9404. /**
  9405. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  9406. */
  9407. negate(): Vector4;
  9408. /**
  9409. * Multiplies the current Vector4 coordinates by scale (float).
  9410. * Returns the updated Vector4.
  9411. */
  9412. scaleInPlace(scale: number): Vector4;
  9413. /**
  9414. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  9415. */
  9416. scale(scale: number): Vector4;
  9417. /**
  9418. * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float).
  9419. * Returns the current Vector4.
  9420. */
  9421. scaleToRef(scale: number, result: Vector4): Vector4;
  9422. /**
  9423. * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones.
  9424. */
  9425. equals(otherVector: Vector4): boolean;
  9426. /**
  9427. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones.
  9428. */
  9429. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  9430. /**
  9431. * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates.
  9432. */
  9433. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  9434. /**
  9435. * Multiplies in place the current Vector4 by the passed one.
  9436. * Returns the updated Vector4.
  9437. */
  9438. multiplyInPlace(otherVector: Vector4): Vector4;
  9439. /**
  9440. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one.
  9441. */
  9442. multiply(otherVector: Vector4): Vector4;
  9443. /**
  9444. * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one.
  9445. * Returns the current Vector4.
  9446. */
  9447. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  9448. /**
  9449. * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates.
  9450. */
  9451. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  9452. /**
  9453. * Returns a new Vector4 set with the division result of the current Vector4 by the passed one.
  9454. */
  9455. divide(otherVector: Vector4): Vector4;
  9456. /**
  9457. * Updates the passed vector "result" with the division result of the current Vector4 by the passed one.
  9458. * Returns the current Vector4.
  9459. */
  9460. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  9461. /**
  9462. * Divides the current Vector3 coordinates by the passed ones.
  9463. * @returns the updated Vector3.
  9464. */
  9465. divideInPlace(otherVector: Vector4): Vector4;
  9466. /**
  9467. * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones
  9468. * @param other defines the second operand
  9469. * @returns the current updated Vector4
  9470. */
  9471. minimizeInPlace(other: Vector4): Vector4;
  9472. /**
  9473. * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones
  9474. * @param other defines the second operand
  9475. * @returns the current updated Vector4
  9476. */
  9477. maximizeInPlace(other: Vector4): Vector4;
  9478. /**
  9479. * Returns the Vector4 length (float).
  9480. */
  9481. length(): number;
  9482. /**
  9483. * Returns the Vector4 squared length (float).
  9484. */
  9485. lengthSquared(): number;
  9486. /**
  9487. * Normalizes in place the Vector4.
  9488. * Returns the updated Vector4.
  9489. */
  9490. normalize(): Vector4;
  9491. /**
  9492. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  9493. */
  9494. toVector3(): Vector3;
  9495. /**
  9496. * Returns a new Vector4 copied from the current one.
  9497. */
  9498. clone(): Vector4;
  9499. /**
  9500. * Updates the current Vector4 with the passed one coordinates.
  9501. * Returns the updated Vector4.
  9502. */
  9503. copyFrom(source: Vector4): Vector4;
  9504. /**
  9505. * Updates the current Vector4 coordinates with the passed floats.
  9506. * Returns the updated Vector4.
  9507. */
  9508. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  9509. /**
  9510. * Updates the current Vector4 coordinates with the passed floats.
  9511. * Returns the updated Vector4.
  9512. */
  9513. set(x: number, y: number, z: number, w: number): Vector4;
  9514. /**
  9515. * Returns a new Vector4 set from the starting index of the passed array.
  9516. */
  9517. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  9518. /**
  9519. * Updates the passed vector "result" from the starting index of the passed array.
  9520. */
  9521. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  9522. /**
  9523. * Updates the passed vector "result" from the starting index of the passed Float32Array.
  9524. */
  9525. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  9526. /**
  9527. * Updates the passed vector "result" coordinates from the passed floats.
  9528. */
  9529. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  9530. /**
  9531. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  9532. */
  9533. static Zero(): Vector4;
  9534. /**
  9535. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  9536. */
  9537. static One(): Vector4;
  9538. /**
  9539. * Returns a new normalized Vector4 from the passed one.
  9540. */
  9541. static Normalize(vector: Vector4): Vector4;
  9542. /**
  9543. * Updates the passed vector "result" from the normalization of the passed one.
  9544. */
  9545. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  9546. static Minimize(left: Vector4, right: Vector4): Vector4;
  9547. static Maximize(left: Vector4, right: Vector4): Vector4;
  9548. /**
  9549. * Returns the distance (float) between the vectors "value1" and "value2".
  9550. */
  9551. static Distance(value1: Vector4, value2: Vector4): number;
  9552. /**
  9553. * Returns the squared distance (float) between the vectors "value1" and "value2".
  9554. */
  9555. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  9556. /**
  9557. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  9558. */
  9559. static Center(value1: Vector4, value2: Vector4): Vector4;
  9560. /**
  9561. * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector.
  9562. * This methods computes transformed normalized direction vectors only.
  9563. */
  9564. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  9565. /**
  9566. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector.
  9567. * This methods computes transformed normalized direction vectors only.
  9568. */
  9569. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  9570. /**
  9571. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w).
  9572. * This methods computes transformed normalized direction vectors only.
  9573. */
  9574. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  9575. }
  9576. interface ISize {
  9577. width: number;
  9578. height: number;
  9579. }
  9580. class Size implements ISize {
  9581. width: number;
  9582. height: number;
  9583. /**
  9584. * Creates a Size object from the passed width and height (floats).
  9585. */
  9586. constructor(width: number, height: number);
  9587. toString(): string;
  9588. /**
  9589. * Returns the string "Size"
  9590. */
  9591. getClassName(): string;
  9592. /**
  9593. * Returns the Size hash code.
  9594. */
  9595. getHashCode(): number;
  9596. /**
  9597. * Updates the current size from the passed one.
  9598. * Returns the updated Size.
  9599. */
  9600. copyFrom(src: Size): void;
  9601. /**
  9602. * Updates in place the current Size from the passed floats.
  9603. * Returns the updated Size.
  9604. */
  9605. copyFromFloats(width: number, height: number): Size;
  9606. /**
  9607. * Updates in place the current Size from the passed floats.
  9608. * Returns the updated Size.
  9609. */
  9610. set(width: number, height: number): Size;
  9611. /**
  9612. * Returns a new Size set with the multiplication result of the current Size and the passed floats.
  9613. */
  9614. multiplyByFloats(w: number, h: number): Size;
  9615. /**
  9616. * Returns a new Size copied from the passed one.
  9617. */
  9618. clone(): Size;
  9619. /**
  9620. * Boolean : True if the current Size and the passed one width and height are strictly equal.
  9621. */
  9622. equals(other: Size): boolean;
  9623. /**
  9624. * Returns the surface of the Size : width * height (float).
  9625. */
  9626. readonly surface: number;
  9627. /**
  9628. * Returns a new Size set to (0.0, 0.0)
  9629. */
  9630. static Zero(): Size;
  9631. /**
  9632. * Returns a new Size set as the addition result of the current Size and the passed one.
  9633. */
  9634. add(otherSize: Size): Size;
  9635. /**
  9636. * Returns a new Size set as the subtraction result of the passed one from the current Size.
  9637. */
  9638. subtract(otherSize: Size): Size;
  9639. /**
  9640. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  9641. */
  9642. static Lerp(start: Size, end: Size, amount: number): Size;
  9643. }
  9644. class Quaternion {
  9645. x: number;
  9646. y: number;
  9647. z: number;
  9648. w: number;
  9649. /**
  9650. * Creates a new Quaternion from the passed floats.
  9651. */
  9652. constructor(x?: number, y?: number, z?: number, w?: number);
  9653. /**
  9654. * Returns a string with the Quaternion coordinates.
  9655. */
  9656. toString(): string;
  9657. /**
  9658. * Returns the string "Quaternion".
  9659. */
  9660. getClassName(): string;
  9661. /**
  9662. * Returns the Quaternion hash code.
  9663. */
  9664. getHashCode(): number;
  9665. /**
  9666. * Returns a new array populated with 4 elements : the Quaternion coordinates.
  9667. */
  9668. asArray(): number[];
  9669. /**
  9670. * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal.
  9671. */
  9672. equals(otherQuaternion: Quaternion): boolean;
  9673. /**
  9674. * Returns a new Quaternion copied from the current one.
  9675. */
  9676. clone(): Quaternion;
  9677. /**
  9678. * Updates the current Quaternion from the passed one coordinates.
  9679. * Returns the updated Quaterion.
  9680. */
  9681. copyFrom(other: Quaternion): Quaternion;
  9682. /**
  9683. * Updates the current Quaternion from the passed float coordinates.
  9684. * Returns the updated Quaterion.
  9685. */
  9686. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  9687. /**
  9688. * Updates the current Quaternion from the passed float coordinates.
  9689. * Returns the updated Quaterion.
  9690. */
  9691. set(x: number, y: number, z: number, w: number): Quaternion;
  9692. /**
  9693. * Returns a new Quaternion as the addition result of the passed one and the current Quaternion.
  9694. */
  9695. add(other: Quaternion): Quaternion;
  9696. /**
  9697. * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion.
  9698. */
  9699. subtract(other: Quaternion): Quaternion;
  9700. /**
  9701. * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale".
  9702. */
  9703. scale(value: number): Quaternion;
  9704. /**
  9705. * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1".
  9706. */
  9707. multiply(q1: Quaternion): Quaternion;
  9708. /**
  9709. * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1".
  9710. * Returns the current Quaternion.
  9711. */
  9712. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  9713. /**
  9714. * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1".
  9715. * Returns the updated Quaternion.
  9716. */
  9717. multiplyInPlace(q1: Quaternion): Quaternion;
  9718. /**
  9719. * Sets the passed "ref" with the conjugation of the current Quaternion.
  9720. * Returns the current Quaternion.
  9721. */
  9722. conjugateToRef(ref: Quaternion): Quaternion;
  9723. /**
  9724. * Conjugates in place the current Quaternion.
  9725. * Returns the updated Quaternion.
  9726. */
  9727. conjugateInPlace(): Quaternion;
  9728. /**
  9729. * Returns a new Quaternion as the conjugate of the current Quaternion.
  9730. */
  9731. conjugate(): Quaternion;
  9732. /**
  9733. * Returns the Quaternion length (float).
  9734. */
  9735. length(): number;
  9736. /**
  9737. * Normalize in place the current Quaternion.
  9738. * Returns the updated Quaternion.
  9739. */
  9740. normalize(): Quaternion;
  9741. /**
  9742. * Returns a new Vector3 set with the Euler angles translated from the current Quaternion.
  9743. */
  9744. toEulerAngles(order?: string): Vector3;
  9745. /**
  9746. * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion.
  9747. * Returns the current Quaternion.
  9748. */
  9749. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  9750. /**
  9751. * Updates the passed rotation matrix with the current Quaternion values.
  9752. * Returns the current Quaternion.
  9753. */
  9754. toRotationMatrix(result: Matrix): Quaternion;
  9755. /**
  9756. * Updates the current Quaternion from the passed rotation matrix values.
  9757. * Returns the updated Quaternion.
  9758. */
  9759. fromRotationMatrix(matrix: Matrix): Quaternion;
  9760. /**
  9761. * Returns a new Quaternion set from the passed rotation matrix values.
  9762. */
  9763. static FromRotationMatrix(matrix: Matrix): Quaternion;
  9764. /**
  9765. * Updates the passed quaternion "result" with the passed rotation matrix values.
  9766. */
  9767. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  9768. /**
  9769. * Returns a new Quaternion set to (0.0, 0.0, 0.0).
  9770. */
  9771. static Zero(): Quaternion;
  9772. /**
  9773. * Returns a new Quaternion as the inverted current Quaternion.
  9774. */
  9775. static Inverse(q: Quaternion): Quaternion;
  9776. /**
  9777. * Returns the identity Quaternion.
  9778. */
  9779. static Identity(): Quaternion;
  9780. static IsIdentity(quaternion: Quaternion): boolean;
  9781. /**
  9782. * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float).
  9783. */
  9784. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  9785. /**
  9786. * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float).
  9787. */
  9788. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  9789. /**
  9790. * Retuns a new Quaternion set from the starting index of the passed array.
  9791. */
  9792. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  9793. /**
  9794. * Returns a new Quaternion set from the passed Euler float angles (y, x, z).
  9795. */
  9796. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  9797. /**
  9798. * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z).
  9799. */
  9800. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  9801. /**
  9802. * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation
  9803. */
  9804. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  9805. /**
  9806. * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation
  9807. */
  9808. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  9809. /**
  9810. * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  9811. * cf to Vector3.RotationFromAxis() documentation.
  9812. * Note : axis1, axis2 and axis3 are normalized during this operation.
  9813. */
  9814. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion;
  9815. /**
  9816. * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  9817. * cf to Vector3.RotationFromAxis() documentation.
  9818. * Note : axis1, axis2 and axis3 are normalized during this operation.
  9819. */
  9820. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  9821. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  9822. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  9823. /**
  9824. * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2".
  9825. */
  9826. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  9827. }
  9828. class Matrix {
  9829. private static _tempQuaternion;
  9830. private static _xAxis;
  9831. private static _yAxis;
  9832. private static _zAxis;
  9833. private static _updateFlagSeed;
  9834. private static _identityReadOnly;
  9835. private _isIdentity;
  9836. private _isIdentityDirty;
  9837. updateFlag: number;
  9838. m: Float32Array;
  9839. _markAsUpdated(): void;
  9840. constructor();
  9841. /**
  9842. * Boolean : True is the matrix is the identity matrix
  9843. */
  9844. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  9845. /**
  9846. * Returns the matrix determinant (float).
  9847. */
  9848. determinant(): number;
  9849. /**
  9850. * Returns the matrix underlying array.
  9851. */
  9852. toArray(): Float32Array;
  9853. /**
  9854. * Returns the matrix underlying array.
  9855. */
  9856. asArray(): Float32Array;
  9857. /**
  9858. * Inverts in place the Matrix.
  9859. * Returns the Matrix inverted.
  9860. */
  9861. invert(): Matrix;
  9862. /**
  9863. * Sets all the matrix elements to zero.
  9864. * Returns the Matrix.
  9865. */
  9866. reset(): Matrix;
  9867. /**
  9868. * Returns a new Matrix as the addition result of the current Matrix and the passed one.
  9869. */
  9870. add(other: Matrix): Matrix;
  9871. /**
  9872. * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one.
  9873. * Returns the Matrix.
  9874. */
  9875. addToRef(other: Matrix, result: Matrix): Matrix;
  9876. /**
  9877. * Adds in place the passed matrix to the current Matrix.
  9878. * Returns the updated Matrix.
  9879. */
  9880. addToSelf(other: Matrix): Matrix;
  9881. /**
  9882. * Sets the passed matrix with the current inverted Matrix.
  9883. * Returns the unmodified current Matrix.
  9884. */
  9885. invertToRef(other: Matrix): Matrix;
  9886. /**
  9887. * Inserts the translation vector (using 3 x floats) in the current Matrix.
  9888. * Returns the updated Matrix.
  9889. */
  9890. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  9891. /**
  9892. * Inserts the translation vector in the current Matrix.
  9893. * Returns the updated Matrix.
  9894. */
  9895. setTranslation(vector3: Vector3): Matrix;
  9896. /**
  9897. * Returns a new Vector3 as the extracted translation from the Matrix.
  9898. */
  9899. getTranslation(): Vector3;
  9900. /**
  9901. * Fill a Vector3 with the extracted translation from the Matrix.
  9902. */
  9903. getTranslationToRef(result: Vector3): Matrix;
  9904. /**
  9905. * Remove rotation and scaling part from the Matrix.
  9906. * Returns the updated Matrix.
  9907. */
  9908. removeRotationAndScaling(): Matrix;
  9909. /**
  9910. * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one.
  9911. */
  9912. multiply(other: Matrix): Matrix;
  9913. /**
  9914. * Updates the current Matrix from the passed one values.
  9915. * Returns the updated Matrix.
  9916. */
  9917. copyFrom(other: Matrix): Matrix;
  9918. /**
  9919. * Populates the passed array from the starting index with the Matrix values.
  9920. * Returns the Matrix.
  9921. */
  9922. copyToArray(array: Float32Array, offset?: number): Matrix;
  9923. /**
  9924. * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one.
  9925. */
  9926. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  9927. /**
  9928. * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one.
  9929. */
  9930. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  9931. /**
  9932. * Boolean : True is the current Matrix and the passed one values are strictly equal.
  9933. */
  9934. equals(value: Matrix): boolean;
  9935. /**
  9936. * Returns a new Matrix from the current Matrix.
  9937. */
  9938. clone(): Matrix;
  9939. /**
  9940. * Returns the string "Matrix"
  9941. */
  9942. getClassName(): string;
  9943. /**
  9944. * Returns the Matrix hash code.
  9945. */
  9946. getHashCode(): number;
  9947. /**
  9948. * Decomposes the current Matrix into :
  9949. * - a scale vector3 passed as a reference to update,
  9950. * - a rotation quaternion passed as a reference to update,
  9951. * - a translation vector3 passed as a reference to update.
  9952. * Returns the true if operation was successful.
  9953. */
  9954. decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean;
  9955. /**
  9956. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  9957. * @param ref matrix to store the result
  9958. */
  9959. toNormalMatrix(ref: Matrix): void;
  9960. /**
  9961. * Returns a new Matrix as the extracted rotation matrix from the current one.
  9962. */
  9963. getRotationMatrix(): Matrix;
  9964. /**
  9965. * Extracts the rotation matrix from the current one and sets it as the passed "result".
  9966. * Returns the current Matrix.
  9967. */
  9968. getRotationMatrixToRef(result: Matrix): Matrix;
  9969. /**
  9970. * Returns a new Matrix set from the starting index of the passed array.
  9971. */
  9972. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  9973. /**
  9974. * Sets the passed "result" matrix from the starting index of the passed array.
  9975. */
  9976. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  9977. /**
  9978. * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale".
  9979. */
  9980. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  9981. /**
  9982. * Sets the passed matrix "result" with the 16 passed floats.
  9983. */
  9984. 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;
  9985. /**
  9986. * Returns the index-th row of the current matrix as a new Vector4.
  9987. */
  9988. getRow(index: number): Nullable<Vector4>;
  9989. /**
  9990. * Sets the index-th row of the current matrix with the passed Vector4 values.
  9991. * Returns the updated Matrix.
  9992. */
  9993. setRow(index: number, row: Vector4): Matrix;
  9994. /**
  9995. * Compute the transpose of the matrix.
  9996. * Returns a new Matrix.
  9997. */
  9998. transpose(): Matrix;
  9999. /**
  10000. * Compute the transpose of the matrix.
  10001. * Returns the current matrix.
  10002. */
  10003. transposeToRef(result: Matrix): Matrix;
  10004. /**
  10005. * Sets the index-th row of the current matrix with the passed 4 x float values.
  10006. * Returns the updated Matrix.
  10007. */
  10008. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  10009. /**
  10010. * Static identity matrix to be used as readonly matrix
  10011. * Must not be updated.
  10012. */
  10013. static readonly IdentityReadOnly: Matrix;
  10014. /**
  10015. * Returns a new Matrix set from the 16 passed floats.
  10016. */
  10017. 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;
  10018. /**
  10019. * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  10020. */
  10021. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  10022. /**
  10023. * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  10024. */
  10025. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  10026. /**
  10027. * Returns a new indentity Matrix.
  10028. */
  10029. static Identity(): Matrix;
  10030. /**
  10031. * Sets the passed "result" as an identity matrix.
  10032. */
  10033. static IdentityToRef(result: Matrix): void;
  10034. /**
  10035. * Returns a new zero Matrix.
  10036. */
  10037. static Zero(): Matrix;
  10038. /**
  10039. * Returns a new rotation matrix for "angle" radians around the X axis.
  10040. */
  10041. static RotationX(angle: number): Matrix;
  10042. /**
  10043. * Returns a new Matrix as the passed inverted one.
  10044. */
  10045. static Invert(source: Matrix): Matrix;
  10046. /**
  10047. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis.
  10048. */
  10049. static RotationXToRef(angle: number, result: Matrix): void;
  10050. /**
  10051. * Returns a new rotation matrix for "angle" radians around the Y axis.
  10052. */
  10053. static RotationY(angle: number): Matrix;
  10054. /**
  10055. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis.
  10056. */
  10057. static RotationYToRef(angle: number, result: Matrix): void;
  10058. /**
  10059. * Returns a new rotation matrix for "angle" radians around the Z axis.
  10060. */
  10061. static RotationZ(angle: number): Matrix;
  10062. /**
  10063. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis.
  10064. */
  10065. static RotationZToRef(angle: number, result: Matrix): void;
  10066. /**
  10067. * Returns a new rotation matrix for "angle" radians around the passed axis.
  10068. */
  10069. static RotationAxis(axis: Vector3, angle: number): Matrix;
  10070. /**
  10071. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis.
  10072. */
  10073. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  10074. /**
  10075. * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z).
  10076. */
  10077. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  10078. /**
  10079. * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z).
  10080. */
  10081. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  10082. /**
  10083. * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z).
  10084. */
  10085. static Scaling(x: number, y: number, z: number): Matrix;
  10086. /**
  10087. * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z).
  10088. */
  10089. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  10090. /**
  10091. * Returns a new Matrix as a translation matrix from the passed floats (x, y, z).
  10092. */
  10093. static Translation(x: number, y: number, z: number): Matrix;
  10094. /**
  10095. * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z).
  10096. */
  10097. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  10098. /**
  10099. * Returns a new Matrix whose values are the interpolated values for "gradien" (float) between the ones of the matrices "startValue" and "endValue".
  10100. */
  10101. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  10102. /**
  10103. * Returns a new Matrix whose values are computed by :
  10104. * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices,
  10105. * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end,
  10106. * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices.
  10107. */
  10108. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  10109. /**
  10110. * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  10111. * This methods works for a Left-Handed system.
  10112. */
  10113. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  10114. /**
  10115. * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  10116. * This methods works for a Left-Handed system.
  10117. */
  10118. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  10119. /**
  10120. * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  10121. * This methods works for a Right-Handed system.
  10122. */
  10123. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  10124. /**
  10125. * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  10126. * This methods works for a Left-Handed system.
  10127. */
  10128. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  10129. /**
  10130. * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  10131. */
  10132. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  10133. /**
  10134. * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  10135. */
  10136. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  10137. /**
  10138. * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  10139. */
  10140. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  10141. /**
  10142. * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  10143. */
  10144. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  10145. /**
  10146. * Returns a new Matrix as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  10147. */
  10148. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  10149. /**
  10150. * Sets the passed matrix "result" as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  10151. */
  10152. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  10153. /**
  10154. * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  10155. */
  10156. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  10157. /**
  10158. * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  10159. */
  10160. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  10161. /**
  10162. * Sets the passed matrix "result" as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  10163. */
  10164. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  10165. /**
  10166. * Returns a new Matrix as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  10167. */
  10168. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  10169. /**
  10170. * Sets the passed matrix "result" as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  10171. */
  10172. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  10173. /**
  10174. * Sets the passed matrix "result" as a left-handed perspective projection matrix for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  10175. */
  10176. static PerspectiveFovWebVRToRef(fov: {
  10177. upDegrees: number;
  10178. downDegrees: number;
  10179. leftDegrees: number;
  10180. rightDegrees: number;
  10181. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  10182. /**
  10183. * Returns the final transformation matrix : world * view * projection * viewport
  10184. */
  10185. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  10186. /**
  10187. * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix.
  10188. */
  10189. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  10190. /**
  10191. * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix.
  10192. */
  10193. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  10194. /**
  10195. * Compute the transpose of the passed Matrix.
  10196. * Returns a new Matrix.
  10197. */
  10198. static Transpose(matrix: Matrix): Matrix;
  10199. /**
  10200. * Compute the transpose of the passed Matrix and store it in the result matrix.
  10201. */
  10202. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  10203. /**
  10204. * Returns a new Matrix as the reflection matrix across the passed plane.
  10205. */
  10206. static Reflection(plane: Plane): Matrix;
  10207. /**
  10208. * Sets the passed matrix "result" as the reflection matrix across the passed plane.
  10209. */
  10210. static ReflectionToRef(plane: Plane, result: Matrix): void;
  10211. /**
  10212. * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis.
  10213. */
  10214. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  10215. /**
  10216. * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion.
  10217. */
  10218. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  10219. }
  10220. class Plane {
  10221. normal: Vector3;
  10222. d: number;
  10223. /**
  10224. * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  10225. */
  10226. constructor(a: number, b: number, c: number, d: number);
  10227. /**
  10228. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  10229. */
  10230. asArray(): number[];
  10231. /**
  10232. * Returns a new plane copied from the current Plane.
  10233. */
  10234. clone(): Plane;
  10235. /**
  10236. * Returns the string "Plane".
  10237. */
  10238. getClassName(): string;
  10239. /**
  10240. * Returns the Plane hash code.
  10241. */
  10242. getHashCode(): number;
  10243. /**
  10244. * Normalize the current Plane in place.
  10245. * Returns the updated Plane.
  10246. */
  10247. normalize(): Plane;
  10248. /**
  10249. * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix.
  10250. */
  10251. transform(transformation: Matrix): Plane;
  10252. /**
  10253. * Returns the dot product (float) of the point coordinates and the plane normal.
  10254. */
  10255. dotCoordinate(point: Vector3): number;
  10256. /**
  10257. * Updates the current Plane from the plane defined by the three passed points.
  10258. * Returns the updated Plane.
  10259. */
  10260. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  10261. /**
  10262. * Boolean : True is the vector "direction" is the same side than the plane normal.
  10263. */
  10264. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  10265. /**
  10266. * Returns the signed distance (float) from the passed point to the Plane.
  10267. */
  10268. signedDistanceTo(point: Vector3): number;
  10269. /**
  10270. * Returns a new Plane from the passed array.
  10271. */
  10272. static FromArray(array: ArrayLike<number>): Plane;
  10273. /**
  10274. * Returns a new Plane defined by the three passed points.
  10275. */
  10276. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  10277. /**
  10278. * Returns a new Plane the normal vector to this plane at the passed origin point.
  10279. * Note : the vector "normal" is updated because normalized.
  10280. */
  10281. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  10282. /**
  10283. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point.
  10284. */
  10285. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  10286. }
  10287. class Viewport {
  10288. x: number;
  10289. y: number;
  10290. width: number;
  10291. height: number;
  10292. /**
  10293. * Creates a Viewport object located at (x, y) and sized (width, height).
  10294. */
  10295. constructor(x: number, y: number, width: number, height: number);
  10296. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  10297. /**
  10298. * Returns a new Viewport copied from the current one.
  10299. */
  10300. clone(): Viewport;
  10301. }
  10302. class Frustum {
  10303. /**
  10304. * Returns a new array of 6 Frustum planes computed by the passed transformation matrix.
  10305. */
  10306. static GetPlanes(transform: Matrix): Plane[];
  10307. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10308. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10309. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10310. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10311. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10312. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10313. /**
  10314. * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix.
  10315. */
  10316. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  10317. }
  10318. enum Space {
  10319. LOCAL = 0,
  10320. WORLD = 1,
  10321. BONE = 2,
  10322. }
  10323. class Axis {
  10324. static X: Vector3;
  10325. static Y: Vector3;
  10326. static Z: Vector3;
  10327. }
  10328. class BezierCurve {
  10329. /**
  10330. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats.
  10331. */
  10332. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  10333. }
  10334. enum Orientation {
  10335. CW = 0,
  10336. CCW = 1,
  10337. }
  10338. class Angle {
  10339. private _radians;
  10340. /**
  10341. * Creates an Angle object of "radians" radians (float).
  10342. */
  10343. constructor(radians: number);
  10344. /**
  10345. * Returns the Angle value in degrees (float).
  10346. */
  10347. degrees: () => number;
  10348. /**
  10349. * Returns the Angle value in radians (float).
  10350. */
  10351. radians: () => number;
  10352. /**
  10353. * Returns a new Angle object valued with the angle value in radians between the two passed vectors.
  10354. */
  10355. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  10356. /**
  10357. * Returns a new Angle object from the passed float in radians.
  10358. */
  10359. static FromRadians(radians: number): Angle;
  10360. /**
  10361. * Returns a new Angle object from the passed float in degrees.
  10362. */
  10363. static FromDegrees(degrees: number): Angle;
  10364. }
  10365. class Arc2 {
  10366. startPoint: Vector2;
  10367. midPoint: Vector2;
  10368. endPoint: Vector2;
  10369. centerPoint: Vector2;
  10370. radius: number;
  10371. angle: Angle;
  10372. startAngle: Angle;
  10373. orientation: Orientation;
  10374. /**
  10375. * Creates an Arc object from the three passed points : start, middle and end.
  10376. */
  10377. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  10378. }
  10379. class Path2 {
  10380. private _points;
  10381. private _length;
  10382. closed: boolean;
  10383. /**
  10384. * Creates a Path2 object from the starting 2D coordinates x and y.
  10385. */
  10386. constructor(x: number, y: number);
  10387. /**
  10388. * Adds a new segment until the passed coordinates (x, y) to the current Path2.
  10389. * Returns the updated Path2.
  10390. */
  10391. addLineTo(x: number, y: number): Path2;
  10392. /**
  10393. * 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.
  10394. * Returns the updated Path2.
  10395. */
  10396. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  10397. /**
  10398. * Closes the Path2.
  10399. * Returns the Path2.
  10400. */
  10401. close(): Path2;
  10402. /**
  10403. * Returns the Path2 total length (float).
  10404. */
  10405. length(): number;
  10406. /**
  10407. * Returns the Path2 internal array of points.
  10408. */
  10409. getPoints(): Vector2[];
  10410. /**
  10411. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  10412. */
  10413. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  10414. /**
  10415. * Returns a new Path2 starting at the coordinates (x, y).
  10416. */
  10417. static StartingAt(x: number, y: number): Path2;
  10418. }
  10419. class Path3D {
  10420. path: Vector3[];
  10421. private _curve;
  10422. private _distances;
  10423. private _tangents;
  10424. private _normals;
  10425. private _binormals;
  10426. private _raw;
  10427. /**
  10428. * new Path3D(path, normal, raw)
  10429. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  10430. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  10431. * path : an array of Vector3, the curve axis of the Path3D
  10432. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  10433. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  10434. */
  10435. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  10436. /**
  10437. * Returns the Path3D array of successive Vector3 designing its curve.
  10438. */
  10439. getCurve(): Vector3[];
  10440. /**
  10441. * Returns an array populated with tangent vectors on each Path3D curve point.
  10442. */
  10443. getTangents(): Vector3[];
  10444. /**
  10445. * Returns an array populated with normal vectors on each Path3D curve point.
  10446. */
  10447. getNormals(): Vector3[];
  10448. /**
  10449. * Returns an array populated with binormal vectors on each Path3D curve point.
  10450. */
  10451. getBinormals(): Vector3[];
  10452. /**
  10453. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  10454. */
  10455. getDistances(): number[];
  10456. /**
  10457. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  10458. * Returns the same object updated.
  10459. */
  10460. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  10461. private _compute(firstNormal);
  10462. private _getFirstNonNullVector(index);
  10463. private _getLastNonNullVector(index);
  10464. private _normalVector(v0, vt, va);
  10465. }
  10466. class Curve3 {
  10467. private _points;
  10468. private _length;
  10469. /**
  10470. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  10471. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  10472. * @param v1 (Vector3) the control point
  10473. * @param v2 (Vector3) the end point of the Quadratic Bezier
  10474. * @param nbPoints (integer) the wanted number of points in the curve
  10475. */
  10476. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  10477. /**
  10478. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  10479. * @param v0 (Vector3) the origin point of the Cubic Bezier
  10480. * @param v1 (Vector3) the first control point
  10481. * @param v2 (Vector3) the second control point
  10482. * @param v3 (Vector3) the end point of the Cubic Bezier
  10483. * @param nbPoints (integer) the wanted number of points in the curve
  10484. */
  10485. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  10486. /**
  10487. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  10488. * @param p1 (Vector3) the origin point of the Hermite Spline
  10489. * @param t1 (Vector3) the tangent vector at the origin point
  10490. * @param p2 (Vector3) the end point of the Hermite Spline
  10491. * @param t2 (Vector3) the tangent vector at the end point
  10492. * @param nbPoints (integer) the wanted number of points in the curve
  10493. */
  10494. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  10495. /**
  10496. * Returns a Curve3 object along a CatmullRom Spline curve :
  10497. * @param points (array of Vector3) the points the spline must pass through. At least, four points required.
  10498. * @param nbPoints (integer) the wanted number of points between each curve control points.
  10499. */
  10500. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3;
  10501. /**
  10502. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  10503. * A Curve3 is designed from a series of successive Vector3.
  10504. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  10505. */
  10506. constructor(points: Vector3[]);
  10507. /**
  10508. * Returns the Curve3 stored array of successive Vector3
  10509. */
  10510. getPoints(): Vector3[];
  10511. /**
  10512. * Returns the computed length (float) of the curve.
  10513. */
  10514. length(): number;
  10515. /**
  10516. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  10517. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  10518. * curveA and curveB keep unchanged.
  10519. */
  10520. continue(curve: Curve3): Curve3;
  10521. private _computeLength(path);
  10522. }
  10523. class PositionNormalVertex {
  10524. position: Vector3;
  10525. normal: Vector3;
  10526. constructor(position?: Vector3, normal?: Vector3);
  10527. clone(): PositionNormalVertex;
  10528. }
  10529. class PositionNormalTextureVertex {
  10530. position: Vector3;
  10531. normal: Vector3;
  10532. uv: Vector2;
  10533. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  10534. clone(): PositionNormalTextureVertex;
  10535. }
  10536. class Tmp {
  10537. static Color3: Color3[];
  10538. static Vector2: Vector2[];
  10539. static Vector3: Vector3[];
  10540. static Vector4: Vector4[];
  10541. static Quaternion: Quaternion[];
  10542. static Matrix: Matrix[];
  10543. }
  10544. }
  10545. declare module BABYLON {
  10546. class SphericalPolynomial {
  10547. x: Vector3;
  10548. y: Vector3;
  10549. z: Vector3;
  10550. xx: Vector3;
  10551. yy: Vector3;
  10552. zz: Vector3;
  10553. xy: Vector3;
  10554. yz: Vector3;
  10555. zx: Vector3;
  10556. addAmbient(color: Color3): void;
  10557. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  10558. scale(scale: number): void;
  10559. }
  10560. class SphericalHarmonics {
  10561. L00: Vector3;
  10562. L1_1: Vector3;
  10563. L10: Vector3;
  10564. L11: Vector3;
  10565. L2_2: Vector3;
  10566. L2_1: Vector3;
  10567. L20: Vector3;
  10568. L21: Vector3;
  10569. L22: Vector3;
  10570. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  10571. scale(scale: number): void;
  10572. convertIncidentRadianceToIrradiance(): void;
  10573. convertIrradianceToLambertianRadiance(): void;
  10574. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  10575. }
  10576. }
  10577. declare module BABYLON {
  10578. /**
  10579. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  10580. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  10581. * 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;
  10582. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  10583. */
  10584. class ColorCurves {
  10585. private _dirty;
  10586. private _tempColor;
  10587. private _globalCurve;
  10588. private _highlightsCurve;
  10589. private _midtonesCurve;
  10590. private _shadowsCurve;
  10591. private _positiveCurve;
  10592. private _negativeCurve;
  10593. private _globalHue;
  10594. private _globalDensity;
  10595. private _globalSaturation;
  10596. private _globalExposure;
  10597. /**
  10598. * Gets the global Hue value.
  10599. * 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).
  10600. */
  10601. /**
  10602. * Sets the global Hue value.
  10603. * 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).
  10604. */
  10605. globalHue: number;
  10606. /**
  10607. * Gets the global Density value.
  10608. * 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.
  10609. * Values less than zero provide a filter of opposite hue.
  10610. */
  10611. /**
  10612. * Sets the global Density value.
  10613. * 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.
  10614. * Values less than zero provide a filter of opposite hue.
  10615. */
  10616. globalDensity: number;
  10617. /**
  10618. * Gets the global Saturation value.
  10619. * 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.
  10620. */
  10621. /**
  10622. * Sets the global Saturation value.
  10623. * 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.
  10624. */
  10625. globalSaturation: number;
  10626. private _highlightsHue;
  10627. private _highlightsDensity;
  10628. private _highlightsSaturation;
  10629. private _highlightsExposure;
  10630. /**
  10631. * Gets the highlights Hue value.
  10632. * 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).
  10633. */
  10634. /**
  10635. * Sets the highlights Hue value.
  10636. * 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).
  10637. */
  10638. highlightsHue: number;
  10639. /**
  10640. * Gets the highlights Density value.
  10641. * 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.
  10642. * Values less than zero provide a filter of opposite hue.
  10643. */
  10644. /**
  10645. * Sets the highlights Density value.
  10646. * 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.
  10647. * Values less than zero provide a filter of opposite hue.
  10648. */
  10649. highlightsDensity: number;
  10650. /**
  10651. * Gets the highlights Saturation value.
  10652. * 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.
  10653. */
  10654. /**
  10655. * Sets the highlights Saturation value.
  10656. * 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.
  10657. */
  10658. highlightsSaturation: number;
  10659. /**
  10660. * Gets the highlights Exposure value.
  10661. * 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.
  10662. */
  10663. /**
  10664. * Sets the highlights Exposure value.
  10665. * 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.
  10666. */
  10667. highlightsExposure: number;
  10668. private _midtonesHue;
  10669. private _midtonesDensity;
  10670. private _midtonesSaturation;
  10671. private _midtonesExposure;
  10672. /**
  10673. * Gets the midtones Hue value.
  10674. * 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).
  10675. */
  10676. /**
  10677. * Sets the midtones Hue value.
  10678. * 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).
  10679. */
  10680. midtonesHue: number;
  10681. /**
  10682. * Gets the midtones Density value.
  10683. * 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.
  10684. * Values less than zero provide a filter of opposite hue.
  10685. */
  10686. /**
  10687. * Sets the midtones Density value.
  10688. * 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.
  10689. * Values less than zero provide a filter of opposite hue.
  10690. */
  10691. midtonesDensity: number;
  10692. /**
  10693. * Gets the midtones Saturation value.
  10694. * 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.
  10695. */
  10696. /**
  10697. * Sets the midtones Saturation value.
  10698. * 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.
  10699. */
  10700. midtonesSaturation: number;
  10701. /**
  10702. * Gets the midtones Exposure value.
  10703. * 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.
  10704. */
  10705. /**
  10706. * Sets the midtones Exposure value.
  10707. * 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.
  10708. */
  10709. midtonesExposure: number;
  10710. private _shadowsHue;
  10711. private _shadowsDensity;
  10712. private _shadowsSaturation;
  10713. private _shadowsExposure;
  10714. /**
  10715. * Gets the shadows Hue value.
  10716. * 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).
  10717. */
  10718. /**
  10719. * Sets the shadows Hue value.
  10720. * 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).
  10721. */
  10722. shadowsHue: number;
  10723. /**
  10724. * Gets the shadows Density value.
  10725. * 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.
  10726. * Values less than zero provide a filter of opposite hue.
  10727. */
  10728. /**
  10729. * Sets the shadows Density value.
  10730. * 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.
  10731. * Values less than zero provide a filter of opposite hue.
  10732. */
  10733. shadowsDensity: number;
  10734. /**
  10735. * Gets the shadows Saturation value.
  10736. * 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.
  10737. */
  10738. /**
  10739. * Sets the shadows Saturation value.
  10740. * 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.
  10741. */
  10742. shadowsSaturation: number;
  10743. /**
  10744. * Gets the shadows Exposure value.
  10745. * 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.
  10746. */
  10747. /**
  10748. * Sets the shadows Exposure value.
  10749. * 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.
  10750. */
  10751. shadowsExposure: number;
  10752. getClassName(): string;
  10753. /**
  10754. * Binds the color curves to the shader.
  10755. * @param colorCurves The color curve to bind
  10756. * @param effect The effect to bind to
  10757. */
  10758. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  10759. /**
  10760. * Prepare the list of uniforms associated with the ColorCurves effects.
  10761. * @param uniformsList The list of uniforms used in the effect
  10762. */
  10763. static PrepareUniforms(uniformsList: string[]): void;
  10764. /**
  10765. * Returns color grading data based on a hue, density, saturation and exposure value.
  10766. * @param filterHue The hue of the color filter.
  10767. * @param filterDensity The density of the color filter.
  10768. * @param saturation The saturation.
  10769. * @param exposure The exposure.
  10770. * @param result The result data container.
  10771. */
  10772. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  10773. /**
  10774. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  10775. * @param value The input slider value in range [-100,100].
  10776. * @returns Adjusted value.
  10777. */
  10778. private static applyColorGradingSliderNonlinear(value);
  10779. /**
  10780. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  10781. * @param hue The hue (H) input.
  10782. * @param saturation The saturation (S) input.
  10783. * @param brightness The brightness (B) input.
  10784. * @result An RGBA color represented as Vector4.
  10785. */
  10786. private static fromHSBToRef(hue, saturation, brightness, result);
  10787. /**
  10788. * Returns a value clamped between min and max
  10789. * @param value The value to clamp
  10790. * @param min The minimum of value
  10791. * @param max The maximum of value
  10792. * @returns The clamped value.
  10793. */
  10794. private static clamp(value, min, max);
  10795. /**
  10796. * Clones the current color curve instance.
  10797. * @return The cloned curves
  10798. */
  10799. clone(): ColorCurves;
  10800. /**
  10801. * Serializes the current color curve instance to a json representation.
  10802. * @return a JSON representation
  10803. */
  10804. serialize(): any;
  10805. /**
  10806. * Parses the color curve from a json representation.
  10807. * @param source the JSON source to parse
  10808. * @return The parsed curves
  10809. */
  10810. static Parse(source: any): ColorCurves;
  10811. }
  10812. }
  10813. declare module BABYLON {
  10814. /**
  10815. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  10816. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  10817. */
  10818. class EffectFallbacks {
  10819. private _defines;
  10820. private _currentRank;
  10821. private _maxRank;
  10822. private _mesh;
  10823. /**
  10824. * Removes the fallback from the bound mesh.
  10825. */
  10826. unBindMesh(): void;
  10827. /**
  10828. * Adds a fallback on the specified property.
  10829. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  10830. * @param define The name of the define in the shader
  10831. */
  10832. addFallback(rank: number, define: string): void;
  10833. /**
  10834. * Sets the mesh to use CPU skinning when needing to fallback.
  10835. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  10836. * @param mesh The mesh to use the fallbacks.
  10837. */
  10838. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  10839. /**
  10840. * Checks to see if more fallbacks are still availible.
  10841. */
  10842. readonly isMoreFallbacks: boolean;
  10843. /**
  10844. * Removes the defines that shoould be removed when falling back.
  10845. * @param currentDefines defines the current define statements for the shader.
  10846. * @param effect defines the current effect we try to compile
  10847. * @returns The resulting defines with defines of the current rank removed.
  10848. */
  10849. reduce(currentDefines: string, effect: Effect): string;
  10850. }
  10851. /**
  10852. * Options to be used when creating an effect.
  10853. */
  10854. class EffectCreationOptions {
  10855. /**
  10856. * Atrributes that will be used in the shader.
  10857. */
  10858. attributes: string[];
  10859. /**
  10860. * Uniform varible names that will be set in the shader.
  10861. */
  10862. uniformsNames: string[];
  10863. /**
  10864. * Uniform buffer varible names that will be set in the shader.
  10865. */
  10866. uniformBuffersNames: string[];
  10867. /**
  10868. * Sampler texture variable names that will be set in the shader.
  10869. */
  10870. samplers: string[];
  10871. /**
  10872. * Define statements that will be set in the shader.
  10873. */
  10874. defines: any;
  10875. /**
  10876. * Possible fallbacks for this effect to improve performance when needed.
  10877. */
  10878. fallbacks: Nullable<EffectFallbacks>;
  10879. /**
  10880. * Callback that will be called when the shader is compiled.
  10881. */
  10882. onCompiled: Nullable<(effect: Effect) => void>;
  10883. /**
  10884. * Callback that will be called if an error occurs during shader compilation.
  10885. */
  10886. onError: Nullable<(effect: Effect, errors: string) => void>;
  10887. /**
  10888. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  10889. */
  10890. indexParameters: any;
  10891. /**
  10892. * Max number of lights that can be used in the shader.
  10893. */
  10894. maxSimultaneousLights: number;
  10895. /**
  10896. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  10897. */
  10898. transformFeedbackVaryings: Nullable<string[]>;
  10899. }
  10900. /**
  10901. * Effect containing vertex and fragment shader that can be executed on an object.
  10902. */
  10903. class Effect {
  10904. /**
  10905. * Name of the effect.
  10906. */
  10907. name: any;
  10908. /**
  10909. * String container all the define statements that should be set on the shader.
  10910. */
  10911. defines: string;
  10912. /**
  10913. * Callback that will be called when the shader is compiled.
  10914. */
  10915. onCompiled: Nullable<(effect: Effect) => void>;
  10916. /**
  10917. * Callback that will be called if an error occurs during shader compilation.
  10918. */
  10919. onError: Nullable<(effect: Effect, errors: string) => void>;
  10920. /**
  10921. * Callback that will be called when effect is bound.
  10922. */
  10923. onBind: Nullable<(effect: Effect) => void>;
  10924. /**
  10925. * Unique ID of the effect.
  10926. */
  10927. uniqueId: number;
  10928. /**
  10929. * Observable that will be called when the shader is compiled.
  10930. */
  10931. onCompileObservable: Observable<Effect>;
  10932. /**
  10933. * Observable that will be called if an error occurs during shader compilation.
  10934. */
  10935. onErrorObservable: Observable<Effect>;
  10936. /**
  10937. * Observable that will be called when effect is bound.
  10938. */
  10939. onBindObservable: Observable<Effect>;
  10940. private static _uniqueIdSeed;
  10941. private _engine;
  10942. private _uniformBuffersNames;
  10943. private _uniformsNames;
  10944. private _samplers;
  10945. private _isReady;
  10946. private _compilationError;
  10947. private _attributesNames;
  10948. private _attributes;
  10949. private _uniforms;
  10950. /**
  10951. * Key for the effect.
  10952. */
  10953. _key: string;
  10954. private _indexParameters;
  10955. private _fallbacks;
  10956. private _vertexSourceCode;
  10957. private _fragmentSourceCode;
  10958. private _vertexSourceCodeOverride;
  10959. private _fragmentSourceCodeOverride;
  10960. private _transformFeedbackVaryings;
  10961. /**
  10962. * Compiled shader to webGL program.
  10963. */
  10964. _program: WebGLProgram;
  10965. private _valueCache;
  10966. private static _baseCache;
  10967. /**
  10968. * Instantiates an effect.
  10969. * An effect can be used to create/manage/execute vertex and fragment shaders.
  10970. * @param baseName Name of the effect.
  10971. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  10972. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  10973. * @param samplers List of sampler variables that will be passed to the shader.
  10974. * @param engine Engine to be used to render the effect
  10975. * @param defines Define statements to be added to the shader.
  10976. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  10977. * @param onCompiled Callback that will be called when the shader is compiled.
  10978. * @param onError Callback that will be called if an error occurs during shader compilation.
  10979. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  10980. */
  10981. 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);
  10982. /**
  10983. * Unique key for this effect
  10984. */
  10985. readonly key: string;
  10986. /**
  10987. * If the effect has been compiled and prepared.
  10988. * @returns if the effect is compiled and prepared.
  10989. */
  10990. isReady(): boolean;
  10991. /**
  10992. * The engine the effect was initialized with.
  10993. * @returns the engine.
  10994. */
  10995. getEngine(): Engine;
  10996. /**
  10997. * The compiled webGL program for the effect
  10998. * @returns the webGL program.
  10999. */
  11000. getProgram(): WebGLProgram;
  11001. /**
  11002. * The set of names of attribute variables for the shader.
  11003. * @returns An array of attribute names.
  11004. */
  11005. getAttributesNames(): string[];
  11006. /**
  11007. * Returns the attribute at the given index.
  11008. * @param index The index of the attribute.
  11009. * @returns The location of the attribute.
  11010. */
  11011. getAttributeLocation(index: number): number;
  11012. /**
  11013. * Returns the attribute based on the name of the variable.
  11014. * @param name of the attribute to look up.
  11015. * @returns the attribute location.
  11016. */
  11017. getAttributeLocationByName(name: string): number;
  11018. /**
  11019. * The number of attributes.
  11020. * @returns the numnber of attributes.
  11021. */
  11022. getAttributesCount(): number;
  11023. /**
  11024. * Gets the index of a uniform variable.
  11025. * @param uniformName of the uniform to look up.
  11026. * @returns the index.
  11027. */
  11028. getUniformIndex(uniformName: string): number;
  11029. /**
  11030. * Returns the attribute based on the name of the variable.
  11031. * @param uniformName of the uniform to look up.
  11032. * @returns the location of the uniform.
  11033. */
  11034. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  11035. /**
  11036. * Returns an array of sampler variable names
  11037. * @returns The array of sampler variable neames.
  11038. */
  11039. getSamplers(): string[];
  11040. /**
  11041. * The error from the last compilation.
  11042. * @returns the error string.
  11043. */
  11044. getCompilationError(): string;
  11045. /**
  11046. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  11047. * @param func The callback to be used.
  11048. */
  11049. executeWhenCompiled(func: (effect: Effect) => void): void;
  11050. /** @ignore */
  11051. _loadVertexShaderAsync(vertex: any): Promise<any>;
  11052. /** @ignore */
  11053. _loadFragmentShaderAsync(fragment: any): Promise<any>;
  11054. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  11055. private _processShaderConversion(sourceCode, isFragment);
  11056. private _processIncludesAsync(sourceCode);
  11057. private _processPrecision(source);
  11058. /**
  11059. * Recompiles the webGL program
  11060. * @param vertexSourceCode The source code for the vertex shader.
  11061. * @param fragmentSourceCode The source code for the fragment shader.
  11062. * @param onCompiled Callback called when completed.
  11063. * @param onError Callback called on error.
  11064. */
  11065. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  11066. /**
  11067. * Gets the uniform locations of the the specified variable names
  11068. * @param names THe names of the variables to lookup.
  11069. * @returns Array of locations in the same order as variable names.
  11070. */
  11071. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  11072. /**
  11073. * Prepares the effect
  11074. */
  11075. _prepareEffect(): void;
  11076. /**
  11077. * Checks if the effect is supported. (Must be called after compilation)
  11078. */
  11079. readonly isSupported: boolean;
  11080. /**
  11081. * Binds a texture to the engine to be used as output of the shader.
  11082. * @param channel Name of the output variable.
  11083. * @param texture Texture to bind.
  11084. */
  11085. _bindTexture(channel: string, texture: InternalTexture): void;
  11086. /**
  11087. * Sets a texture on the engine to be used in the shader.
  11088. * @param channel Name of the sampler variable.
  11089. * @param texture Texture to set.
  11090. */
  11091. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  11092. /**
  11093. * Sets an array of textures on the engine to be used in the shader.
  11094. * @param channel Name of the variable.
  11095. * @param textures Textures to set.
  11096. */
  11097. setTextureArray(channel: string, textures: BaseTexture[]): void;
  11098. /**
  11099. * 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)
  11100. * @param channel Name of the sampler variable.
  11101. * @param postProcess Post process to get the input texture from.
  11102. */
  11103. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  11104. /** @ignore */
  11105. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  11106. /** @ignore */
  11107. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  11108. /** @ignore */
  11109. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  11110. /** @ignore */
  11111. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  11112. /**
  11113. * Binds a buffer to a uniform.
  11114. * @param buffer Buffer to bind.
  11115. * @param name Name of the uniform variable to bind to.
  11116. */
  11117. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  11118. /**
  11119. * Binds block to a uniform.
  11120. * @param blockName Name of the block to bind.
  11121. * @param index Index to bind.
  11122. */
  11123. bindUniformBlock(blockName: string, index: number): void;
  11124. /**
  11125. * Sets an interger value on a uniform variable.
  11126. * @param uniformName Name of the variable.
  11127. * @param value Value to be set.
  11128. * @returns this effect.
  11129. */
  11130. setInt(uniformName: string, value: number): Effect;
  11131. /**
  11132. * Sets an int array on a uniform variable.
  11133. * @param uniformName Name of the variable.
  11134. * @param array array to be set.
  11135. * @returns this effect.
  11136. */
  11137. setIntArray(uniformName: string, array: Int32Array): Effect;
  11138. /**
  11139. * 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)
  11140. * @param uniformName Name of the variable.
  11141. * @param array array to be set.
  11142. * @returns this effect.
  11143. */
  11144. setIntArray2(uniformName: string, array: Int32Array): Effect;
  11145. /**
  11146. * 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)
  11147. * @param uniformName Name of the variable.
  11148. * @param array array to be set.
  11149. * @returns this effect.
  11150. */
  11151. setIntArray3(uniformName: string, array: Int32Array): Effect;
  11152. /**
  11153. * 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)
  11154. * @param uniformName Name of the variable.
  11155. * @param array array to be set.
  11156. * @returns this effect.
  11157. */
  11158. setIntArray4(uniformName: string, array: Int32Array): Effect;
  11159. /**
  11160. * Sets an float array on a uniform variable.
  11161. * @param uniformName Name of the variable.
  11162. * @param array array to be set.
  11163. * @returns this effect.
  11164. */
  11165. setFloatArray(uniformName: string, array: Float32Array): Effect;
  11166. /**
  11167. * 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)
  11168. * @param uniformName Name of the variable.
  11169. * @param array array to be set.
  11170. * @returns this effect.
  11171. */
  11172. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  11173. /**
  11174. * 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)
  11175. * @param uniformName Name of the variable.
  11176. * @param array array to be set.
  11177. * @returns this effect.
  11178. */
  11179. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  11180. /**
  11181. * 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)
  11182. * @param uniformName Name of the variable.
  11183. * @param array array to be set.
  11184. * @returns this effect.
  11185. */
  11186. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  11187. /**
  11188. * Sets an array on a uniform variable.
  11189. * @param uniformName Name of the variable.
  11190. * @param array array to be set.
  11191. * @returns this effect.
  11192. */
  11193. setArray(uniformName: string, array: number[]): Effect;
  11194. /**
  11195. * 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)
  11196. * @param uniformName Name of the variable.
  11197. * @param array array to be set.
  11198. * @returns this effect.
  11199. */
  11200. setArray2(uniformName: string, array: number[]): Effect;
  11201. /**
  11202. * 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)
  11203. * @param uniformName Name of the variable.
  11204. * @param array array to be set.
  11205. * @returns this effect.
  11206. */
  11207. setArray3(uniformName: string, array: number[]): Effect;
  11208. /**
  11209. * 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)
  11210. * @param uniformName Name of the variable.
  11211. * @param array array to be set.
  11212. * @returns this effect.
  11213. */
  11214. setArray4(uniformName: string, array: number[]): Effect;
  11215. /**
  11216. * Sets matrices on a uniform variable.
  11217. * @param uniformName Name of the variable.
  11218. * @param matrices matrices to be set.
  11219. * @returns this effect.
  11220. */
  11221. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  11222. /**
  11223. * Sets matrix on a uniform variable.
  11224. * @param uniformName Name of the variable.
  11225. * @param matrix matrix to be set.
  11226. * @returns this effect.
  11227. */
  11228. setMatrix(uniformName: string, matrix: Matrix): Effect;
  11229. /**
  11230. * 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)
  11231. * @param uniformName Name of the variable.
  11232. * @param matrix matrix to be set.
  11233. * @returns this effect.
  11234. */
  11235. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  11236. /**
  11237. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  11238. * @param uniformName Name of the variable.
  11239. * @param matrix matrix to be set.
  11240. * @returns this effect.
  11241. */
  11242. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  11243. /**
  11244. * Sets a float on a uniform variable.
  11245. * @param uniformName Name of the variable.
  11246. * @param value value to be set.
  11247. * @returns this effect.
  11248. */
  11249. setFloat(uniformName: string, value: number): Effect;
  11250. /**
  11251. * Sets a boolean on a uniform variable.
  11252. * @param uniformName Name of the variable.
  11253. * @param bool value to be set.
  11254. * @returns this effect.
  11255. */
  11256. setBool(uniformName: string, bool: boolean): Effect;
  11257. /**
  11258. * Sets a Vector2 on a uniform variable.
  11259. * @param uniformName Name of the variable.
  11260. * @param vector2 vector2 to be set.
  11261. * @returns this effect.
  11262. */
  11263. setVector2(uniformName: string, vector2: Vector2): Effect;
  11264. /**
  11265. * Sets a float2 on a uniform variable.
  11266. * @param uniformName Name of the variable.
  11267. * @param x First float in float2.
  11268. * @param y Second float in float2.
  11269. * @returns this effect.
  11270. */
  11271. setFloat2(uniformName: string, x: number, y: number): Effect;
  11272. /**
  11273. * Sets a Vector3 on a uniform variable.
  11274. * @param uniformName Name of the variable.
  11275. * @param vector3 Value to be set.
  11276. * @returns this effect.
  11277. */
  11278. setVector3(uniformName: string, vector3: Vector3): Effect;
  11279. /**
  11280. * Sets a float3 on a uniform variable.
  11281. * @param uniformName Name of the variable.
  11282. * @param x First float in float3.
  11283. * @param y Second float in float3.
  11284. * @param z Third float in float3.
  11285. * @returns this effect.
  11286. */
  11287. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  11288. /**
  11289. * Sets a Vector4 on a uniform variable.
  11290. * @param uniformName Name of the variable.
  11291. * @param vector4 Value to be set.
  11292. * @returns this effect.
  11293. */
  11294. setVector4(uniformName: string, vector4: Vector4): Effect;
  11295. /**
  11296. * Sets a float4 on a uniform variable.
  11297. * @param uniformName Name of the variable.
  11298. * @param x First float in float4.
  11299. * @param y Second float in float4.
  11300. * @param z Third float in float4.
  11301. * @param w Fourth float in float4.
  11302. * @returns this effect.
  11303. */
  11304. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  11305. /**
  11306. * Sets a Color3 on a uniform variable.
  11307. * @param uniformName Name of the variable.
  11308. * @param color3 Value to be set.
  11309. * @returns this effect.
  11310. */
  11311. setColor3(uniformName: string, color3: Color3): Effect;
  11312. /**
  11313. * Sets a Color4 on a uniform variable.
  11314. * @param uniformName Name of the variable.
  11315. * @param color3 Value to be set.
  11316. * @param alpha Alpha value to be set.
  11317. * @returns this effect.
  11318. */
  11319. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  11320. /**
  11321. * Sets a Color4 on a uniform variable
  11322. * @param uniformName defines the name of the variable
  11323. * @param color4 defines the value to be set
  11324. * @returns this effect.
  11325. */
  11326. setDirectColor4(uniformName: string, color4: Color4): Effect;
  11327. /**
  11328. * Store of each shader (The can be looked up using effect.key)
  11329. */
  11330. static ShadersStore: {
  11331. [key: string]: string;
  11332. };
  11333. /**
  11334. * Store of each included file for a shader (The can be looked up using effect.key)
  11335. */
  11336. static IncludesShadersStore: {
  11337. [key: string]: string;
  11338. };
  11339. /**
  11340. * Resets the cache of effects.
  11341. */
  11342. static ResetCache(): void;
  11343. }
  11344. }
  11345. declare module BABYLON {
  11346. class FresnelParameters {
  11347. private _isEnabled;
  11348. isEnabled: boolean;
  11349. leftColor: Color3;
  11350. rightColor: Color3;
  11351. bias: number;
  11352. power: number;
  11353. clone(): FresnelParameters;
  11354. serialize(): any;
  11355. static Parse(parsedFresnelParameters: any): FresnelParameters;
  11356. }
  11357. }
  11358. declare module BABYLON {
  11359. /**
  11360. * Interface to follow in your material defines to integrate easily the
  11361. * Image proccessing functions.
  11362. * @ignore
  11363. */
  11364. interface IImageProcessingConfigurationDefines {
  11365. IMAGEPROCESSING: boolean;
  11366. VIGNETTE: boolean;
  11367. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11368. VIGNETTEBLENDMODEOPAQUE: boolean;
  11369. TONEMAPPING: boolean;
  11370. CONTRAST: boolean;
  11371. EXPOSURE: boolean;
  11372. COLORCURVES: boolean;
  11373. COLORGRADING: boolean;
  11374. COLORGRADING3D: boolean;
  11375. SAMPLER3DGREENDEPTH: boolean;
  11376. SAMPLER3DBGRMAP: boolean;
  11377. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11378. /**
  11379. * If the grain should be performed in the image processing shader.
  11380. */
  11381. GRAIN: boolean;
  11382. }
  11383. /**
  11384. * This groups together the common properties used for image processing either in direct forward pass
  11385. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11386. * or not.
  11387. */
  11388. class ImageProcessingConfiguration {
  11389. /**
  11390. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11391. */
  11392. colorCurves: Nullable<ColorCurves>;
  11393. private _colorCurvesEnabled;
  11394. /**
  11395. * Gets wether the color curves effect is enabled.
  11396. */
  11397. /**
  11398. * Sets wether the color curves effect is enabled.
  11399. */
  11400. colorCurvesEnabled: boolean;
  11401. /**
  11402. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11403. */
  11404. colorGradingTexture: Nullable<BaseTexture>;
  11405. private _colorGradingEnabled;
  11406. /**
  11407. * Gets wether the color grading effect is enabled.
  11408. */
  11409. /**
  11410. * Sets wether the color grading effect is enabled.
  11411. */
  11412. colorGradingEnabled: boolean;
  11413. private _colorGradingWithGreenDepth;
  11414. /**
  11415. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11416. */
  11417. /**
  11418. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11419. */
  11420. colorGradingWithGreenDepth: boolean;
  11421. private _colorGradingBGR;
  11422. /**
  11423. * Gets wether the color grading texture contains BGR values.
  11424. */
  11425. /**
  11426. * Sets wether the color grading texture contains BGR values.
  11427. */
  11428. colorGradingBGR: boolean;
  11429. _exposure: number;
  11430. /**
  11431. * Gets the Exposure used in the effect.
  11432. */
  11433. /**
  11434. * Sets the Exposure used in the effect.
  11435. */
  11436. exposure: number;
  11437. private _toneMappingEnabled;
  11438. /**
  11439. * Gets wether the tone mapping effect is enabled.
  11440. */
  11441. /**
  11442. * Sets wether the tone mapping effect is enabled.
  11443. */
  11444. toneMappingEnabled: boolean;
  11445. protected _contrast: number;
  11446. /**
  11447. * Gets the contrast used in the effect.
  11448. */
  11449. /**
  11450. * Sets the contrast used in the effect.
  11451. */
  11452. contrast: number;
  11453. /**
  11454. * Vignette stretch size.
  11455. */
  11456. vignetteStretch: number;
  11457. /**
  11458. * Vignette centre X Offset.
  11459. */
  11460. vignetteCentreX: number;
  11461. /**
  11462. * Vignette centre Y Offset.
  11463. */
  11464. vignetteCentreY: number;
  11465. /**
  11466. * Vignette weight or intensity of the vignette effect.
  11467. */
  11468. vignetteWeight: number;
  11469. /**
  11470. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11471. * if vignetteEnabled is set to true.
  11472. */
  11473. vignetteColor: Color4;
  11474. /**
  11475. * Camera field of view used by the Vignette effect.
  11476. */
  11477. vignetteCameraFov: number;
  11478. private _grainEnabled;
  11479. /**
  11480. * If the grain effect should be enabled.
  11481. */
  11482. grainEnabled: boolean;
  11483. private _grainIntensity;
  11484. /**
  11485. * Amount of grain to be applied by the grain effect.
  11486. */
  11487. grainIntensity: number;
  11488. private _grainAnimated;
  11489. /**
  11490. * If the grain effect should be animated.
  11491. */
  11492. grainAnimated: boolean;
  11493. private _vignetteBlendMode;
  11494. /**
  11495. * Gets the vignette blend mode allowing different kind of effect.
  11496. */
  11497. /**
  11498. * Sets the vignette blend mode allowing different kind of effect.
  11499. */
  11500. vignetteBlendMode: number;
  11501. private _vignetteEnabled;
  11502. /**
  11503. * Gets wether the vignette effect is enabled.
  11504. */
  11505. /**
  11506. * Sets wether the vignette effect is enabled.
  11507. */
  11508. vignetteEnabled: boolean;
  11509. private _applyByPostProcess;
  11510. /**
  11511. * Gets wether the image processing is applied through a post process or not.
  11512. */
  11513. /**
  11514. * Sets wether the image processing is applied through a post process or not.
  11515. */
  11516. applyByPostProcess: boolean;
  11517. private _isEnabled;
  11518. /**
  11519. * Gets wether the image processing is enabled or not.
  11520. */
  11521. /**
  11522. * Sets wether the image processing is enabled or not.
  11523. */
  11524. isEnabled: boolean;
  11525. /**
  11526. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11527. * @type {BABYLON.Observable}
  11528. */
  11529. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11530. /**
  11531. * Method called each time the image processing information changes requires to recompile the effect.
  11532. */
  11533. protected _updateParameters(): void;
  11534. getClassName(): string;
  11535. /**
  11536. * Prepare the list of uniforms associated with the Image Processing effects.
  11537. * @param uniformsList The list of uniforms used in the effect
  11538. * @param defines the list of defines currently in use
  11539. */
  11540. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11541. /**
  11542. * Prepare the list of samplers associated with the Image Processing effects.
  11543. * @param uniformsList The list of uniforms used in the effect
  11544. * @param defines the list of defines currently in use
  11545. */
  11546. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11547. /**
  11548. * Prepare the list of defines associated to the shader.
  11549. * @param defines the list of defines to complete
  11550. */
  11551. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11552. /**
  11553. * Returns true if all the image processing information are ready.
  11554. */
  11555. isReady(): boolean;
  11556. /**
  11557. * Binds the image processing to the shader.
  11558. * @param effect The effect to bind to
  11559. */
  11560. bind(effect: Effect, aspectRatio?: number): void;
  11561. /**
  11562. * Clones the current image processing instance.
  11563. * @return The cloned image processing
  11564. */
  11565. clone(): ImageProcessingConfiguration;
  11566. /**
  11567. * Serializes the current image processing instance to a json representation.
  11568. * @return a JSON representation
  11569. */
  11570. serialize(): any;
  11571. /**
  11572. * Parses the image processing from a json representation.
  11573. * @param source the JSON source to parse
  11574. * @return The parsed image processing
  11575. */
  11576. static Parse(source: any): ImageProcessingConfiguration;
  11577. private static _VIGNETTEMODE_MULTIPLY;
  11578. private static _VIGNETTEMODE_OPAQUE;
  11579. /**
  11580. * Used to apply the vignette as a mix with the pixel color.
  11581. */
  11582. static readonly VIGNETTEMODE_MULTIPLY: number;
  11583. /**
  11584. * Used to apply the vignette as a replacement of the pixel color.
  11585. */
  11586. static readonly VIGNETTEMODE_OPAQUE: number;
  11587. }
  11588. }
  11589. declare module BABYLON {
  11590. /**
  11591. * Manages the defines for the Material.
  11592. */
  11593. class MaterialDefines {
  11594. private _keys;
  11595. private _isDirty;
  11596. _renderId: number;
  11597. _areLightsDirty: boolean;
  11598. _areAttributesDirty: boolean;
  11599. _areTexturesDirty: boolean;
  11600. _areFresnelDirty: boolean;
  11601. _areMiscDirty: boolean;
  11602. _areImageProcessingDirty: boolean;
  11603. _normals: boolean;
  11604. _uvs: boolean;
  11605. _needNormals: boolean;
  11606. _needUVs: boolean;
  11607. /**
  11608. * Specifies if the material needs to be re-calculated.
  11609. */
  11610. readonly isDirty: boolean;
  11611. /**
  11612. * Marks the material to indicate that it has been re-calculated.
  11613. */
  11614. markAsProcessed(): void;
  11615. /**
  11616. * Marks the material to indicate that it needs to be re-calculated.
  11617. */
  11618. markAsUnprocessed(): void;
  11619. /**
  11620. * Marks the material to indicate all of its defines need to be re-calculated.
  11621. */
  11622. markAllAsDirty(): void;
  11623. /**
  11624. * Marks the material to indicate that image processing needs to be re-calculated.
  11625. */
  11626. markAsImageProcessingDirty(): void;
  11627. /**
  11628. * Marks the material to indicate the lights need to be re-calculated.
  11629. */
  11630. markAsLightDirty(): void;
  11631. /**
  11632. * Marks the attribute state as changed.
  11633. */
  11634. markAsAttributesDirty(): void;
  11635. /**
  11636. * Marks the texture state as changed.
  11637. */
  11638. markAsTexturesDirty(): void;
  11639. /**
  11640. * Marks the fresnel state as changed.
  11641. */
  11642. markAsFresnelDirty(): void;
  11643. /**
  11644. * Marks the misc state as changed.
  11645. */
  11646. markAsMiscDirty(): void;
  11647. /**
  11648. * Rebuilds the material defines.
  11649. */
  11650. rebuild(): void;
  11651. /**
  11652. * Specifies if two material defines are equal.
  11653. * @param other - A material define instance to compare to.
  11654. * @returns - Boolean indicating if the material defines are equal (true) or not (false).
  11655. */
  11656. isEqual(other: MaterialDefines): boolean;
  11657. /**
  11658. * Clones this instance's defines to another instance.
  11659. * @param other - material defines to clone values to.
  11660. */
  11661. cloneTo(other: MaterialDefines): void;
  11662. /**
  11663. * Resets the material define values.
  11664. */
  11665. reset(): void;
  11666. /**
  11667. * Converts the material define values to a string.
  11668. * @returns - String of material define information.
  11669. */
  11670. toString(): string;
  11671. }
  11672. /**
  11673. * This offers the main features of a material in BJS.
  11674. */
  11675. class Material implements IAnimatable {
  11676. private static _TriangleFillMode;
  11677. private static _WireFrameFillMode;
  11678. private static _PointFillMode;
  11679. private static _PointListDrawMode;
  11680. private static _LineListDrawMode;
  11681. private static _LineLoopDrawMode;
  11682. private static _LineStripDrawMode;
  11683. private static _TriangleStripDrawMode;
  11684. private static _TriangleFanDrawMode;
  11685. /**
  11686. * Returns the triangle fill mode.
  11687. */
  11688. static readonly TriangleFillMode: number;
  11689. /**
  11690. * Returns the wireframe mode.
  11691. */
  11692. static readonly WireFrameFillMode: number;
  11693. /**
  11694. * Returns the point fill mode.
  11695. */
  11696. static readonly PointFillMode: number;
  11697. /**
  11698. * Returns the point list draw mode.
  11699. */
  11700. static readonly PointListDrawMode: number;
  11701. /**
  11702. * Returns the line list draw mode.
  11703. */
  11704. static readonly LineListDrawMode: number;
  11705. /**
  11706. * Returns the line loop draw mode.
  11707. */
  11708. static readonly LineLoopDrawMode: number;
  11709. /**
  11710. * Returns the line strip draw mode.
  11711. */
  11712. static readonly LineStripDrawMode: number;
  11713. /**
  11714. * Returns the triangle strip draw mode.
  11715. */
  11716. static readonly TriangleStripDrawMode: number;
  11717. /**
  11718. * Returns the triangle fan draw mode.
  11719. */
  11720. static readonly TriangleFanDrawMode: number;
  11721. /**
  11722. * Stores the clock-wise side orientation.
  11723. */
  11724. private static _ClockWiseSideOrientation;
  11725. /**
  11726. * Stores the counter clock-wise side orientation.
  11727. */
  11728. private static _CounterClockWiseSideOrientation;
  11729. /**
  11730. * Returns the clock-wise side orientation.
  11731. */
  11732. static readonly ClockWiseSideOrientation: number;
  11733. /**
  11734. * Returns the counter clock-wise side orientation.
  11735. */
  11736. static readonly CounterClockWiseSideOrientation: number;
  11737. /**
  11738. * The dirty texture flag value.
  11739. */
  11740. private static _TextureDirtyFlag;
  11741. /**
  11742. * The dirty light flag value.
  11743. */
  11744. private static _LightDirtyFlag;
  11745. /**
  11746. * The dirty fresnel flag value.
  11747. */
  11748. private static _FresnelDirtyFlag;
  11749. /**
  11750. * The dirty attribute flag value.
  11751. */
  11752. private static _AttributesDirtyFlag;
  11753. /**
  11754. * The dirty misc flag value.
  11755. */
  11756. private static _MiscDirtyFlag;
  11757. /**
  11758. * Returns the dirty texture flag value.
  11759. */
  11760. static readonly TextureDirtyFlag: number;
  11761. /**
  11762. * Returns the dirty light flag value.
  11763. */
  11764. static readonly LightDirtyFlag: number;
  11765. /**
  11766. * Returns the dirty fresnel flag value.
  11767. */
  11768. static readonly FresnelDirtyFlag: number;
  11769. /**
  11770. * Returns the dirty attributes flag value.
  11771. */
  11772. static readonly AttributesDirtyFlag: number;
  11773. /**
  11774. * Returns the dirty misc flag value.
  11775. */
  11776. static readonly MiscDirtyFlag: number;
  11777. /**
  11778. * The ID of the material.
  11779. */
  11780. id: string;
  11781. /**
  11782. * The name of the material.
  11783. */
  11784. name: string;
  11785. /**
  11786. * Specifies if the ready state should be checked on each call.
  11787. */
  11788. checkReadyOnEveryCall: boolean;
  11789. /**
  11790. * Specifies if the ready state should be checked once.
  11791. */
  11792. checkReadyOnlyOnce: boolean;
  11793. /**
  11794. * The state of the material.
  11795. */
  11796. state: string;
  11797. /**
  11798. * The alpha value of the material.
  11799. */
  11800. protected _alpha: number;
  11801. /**
  11802. * Gets the alpha value of the material.
  11803. */
  11804. /**
  11805. * Sets the alpha value of the material.
  11806. */
  11807. alpha: number;
  11808. /**
  11809. * Specifies if back face culling is enabled.
  11810. */
  11811. protected _backFaceCulling: boolean;
  11812. /**
  11813. * Gets the back-face culling state.
  11814. */
  11815. /**
  11816. * Sets the back-face culling state.
  11817. */
  11818. backFaceCulling: boolean;
  11819. /**
  11820. * Stores the value for side orientation.
  11821. */
  11822. sideOrientation: number;
  11823. /**
  11824. * Callback triggered when the material is compiled.
  11825. */
  11826. onCompiled: (effect: Effect) => void;
  11827. /**
  11828. * Callback triggered when an error occurs.
  11829. */
  11830. onError: (effect: Effect, errors: string) => void;
  11831. /**
  11832. * Callback triggered to get the render target textures.
  11833. */
  11834. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  11835. /**
  11836. * Specifies if the material should be serialized.
  11837. */
  11838. doNotSerialize: boolean;
  11839. /**
  11840. * Specifies if the effect should be stored on sub meshes.
  11841. */
  11842. storeEffectOnSubMeshes: boolean;
  11843. /**
  11844. * Stores the animations for the material.
  11845. */
  11846. animations: Array<Animation>;
  11847. /**
  11848. * An event triggered when the material is disposed.
  11849. * @type {BABYLON.Observable}
  11850. */
  11851. onDisposeObservable: Observable<Material>;
  11852. /**
  11853. * An observer which watches for dispose events.
  11854. * @type {BABYLON.Observer}
  11855. */
  11856. private _onDisposeObserver;
  11857. /**
  11858. * Called during a dispose event.
  11859. */
  11860. onDispose: () => void;
  11861. /**
  11862. * An event triggered when the material is bound.
  11863. * @type {BABYLON.Observable}
  11864. */
  11865. onBindObservable: Observable<AbstractMesh>;
  11866. /**
  11867. * An observer which watches for bind events.
  11868. * @type {BABYLON.Observer}
  11869. */
  11870. private _onBindObserver;
  11871. /**
  11872. * Called during a bind event.
  11873. */
  11874. onBind: (Mesh: AbstractMesh) => void;
  11875. /**
  11876. * An event triggered when the material is unbound.
  11877. * @type {BABYLON.Observable}
  11878. */
  11879. onUnBindObservable: Observable<Material>;
  11880. /**
  11881. * Stores the value of the alpha mode.
  11882. */
  11883. private _alphaMode;
  11884. /**
  11885. * Gets the value of the alpha mode.
  11886. */
  11887. /**
  11888. * Sets the value of the alpha mode.
  11889. */
  11890. alphaMode: number;
  11891. /**
  11892. * Stores the state of the need depth pre-pass value.
  11893. */
  11894. private _needDepthPrePass;
  11895. /**
  11896. * Gets the depth pre-pass value.
  11897. */
  11898. /**
  11899. * Sets the need depth pre-pass value.
  11900. */
  11901. needDepthPrePass: boolean;
  11902. /**
  11903. * Specifies if depth writing should be disabled.
  11904. */
  11905. disableDepthWrite: boolean;
  11906. /**
  11907. * Specifies if depth writing should be forced.
  11908. */
  11909. forceDepthWrite: boolean;
  11910. /**
  11911. * Specifies if there should be a separate pass for culling.
  11912. */
  11913. separateCullingPass: boolean;
  11914. /**
  11915. * Stores the state specifing if fog should be enabled.
  11916. */
  11917. private _fogEnabled;
  11918. /**
  11919. * Gets the value of the fog enabled state.
  11920. */
  11921. /**
  11922. * Sets the state for enabling fog.
  11923. */
  11924. fogEnabled: boolean;
  11925. /**
  11926. * Stores the size of points.
  11927. */
  11928. pointSize: number;
  11929. /**
  11930. * Stores the z offset value.
  11931. */
  11932. zOffset: number;
  11933. /**
  11934. * Gets a value specifying if wireframe mode is enabled.
  11935. */
  11936. /**
  11937. * Sets the state of wireframe mode.
  11938. */
  11939. wireframe: boolean;
  11940. /**
  11941. * Gets the value specifying if point clouds are enabled.
  11942. */
  11943. /**
  11944. * Sets the state of point cloud mode.
  11945. */
  11946. pointsCloud: boolean;
  11947. /**
  11948. * Gets the material fill mode.
  11949. */
  11950. /**
  11951. * Sets the material fill mode.
  11952. */
  11953. fillMode: number;
  11954. /**
  11955. * Stores the effects for the material.
  11956. */
  11957. _effect: Nullable<Effect>;
  11958. /**
  11959. * Specifies if the material was previously ready.
  11960. */
  11961. _wasPreviouslyReady: boolean;
  11962. /**
  11963. * Specifies if uniform buffers should be used.
  11964. */
  11965. private _useUBO;
  11966. /**
  11967. * Stores a reference to the scene.
  11968. */
  11969. private _scene;
  11970. /**
  11971. * Stores the fill mode state.
  11972. */
  11973. private _fillMode;
  11974. /**
  11975. * Specifies if the depth write state should be cached.
  11976. */
  11977. private _cachedDepthWriteState;
  11978. /**
  11979. * Stores the uniform buffer.
  11980. */
  11981. protected _uniformBuffer: UniformBuffer;
  11982. /**
  11983. * Creates a material instance.
  11984. * @param name - The name of the material.
  11985. * @param scene - The BJS scene to reference.
  11986. * @param doNotAdd - Specifies if the material should be added to the scene.
  11987. */
  11988. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  11989. /**
  11990. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  11991. * subclasses should override adding information pertainent to themselves.
  11992. * @returns - String with material information.
  11993. */
  11994. toString(fullDetails?: boolean): string;
  11995. /**
  11996. * Gets the class name of the material.
  11997. * @returns - String with the class name of the material.
  11998. */
  11999. getClassName(): string;
  12000. /**
  12001. * Specifies if updates for the material been locked.
  12002. */
  12003. readonly isFrozen: boolean;
  12004. /**
  12005. * Locks updates for the material.
  12006. */
  12007. freeze(): void;
  12008. /**
  12009. * Unlocks updates for the material.
  12010. */
  12011. unfreeze(): void;
  12012. /**
  12013. * Specifies if the material is ready to be used.
  12014. * @param mesh - BJS mesh.
  12015. * @param useInstances - Specifies if instances should be used.
  12016. * @returns - Boolean indicating if the material is ready to be used.
  12017. */
  12018. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12019. /**
  12020. * Specifies that the submesh is ready to be used.
  12021. * @param mesh - BJS mesh.
  12022. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  12023. * @param useInstances - Specifies that instances should be used.
  12024. * @returns - boolean indicating that the submesh is ready or not.
  12025. */
  12026. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12027. /**
  12028. * Returns the material effect.
  12029. * @returns - Nullable material effect.
  12030. */
  12031. getEffect(): Nullable<Effect>;
  12032. /**
  12033. * Returns the BJS scene.
  12034. * @returns - BJS Scene.
  12035. */
  12036. getScene(): Scene;
  12037. /**
  12038. * Specifies if the material will require alpha blending
  12039. * @returns - Boolean specifying if alpha blending is needed.
  12040. */
  12041. needAlphaBlending(): boolean;
  12042. /**
  12043. * Specifies if the mesh will require alpha blending.
  12044. * @param mesh - BJS mesh.
  12045. * @returns - Boolean specifying if alpha blending is needed for the mesh.
  12046. */
  12047. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  12048. /**
  12049. * Specifies if this material should be rendered in alpha test mode.
  12050. * @returns - Boolean specifying if an alpha test is needed.
  12051. */
  12052. needAlphaTesting(): boolean;
  12053. /**
  12054. * Gets the texture used for the alpha test.
  12055. * @returns - Nullable alpha test texture.
  12056. */
  12057. getAlphaTestTexture(): Nullable<BaseTexture>;
  12058. /**
  12059. * Marks the material to indicate that it needs to be re-calculated.
  12060. */
  12061. markDirty(): void;
  12062. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  12063. /**
  12064. * Binds the material to the mesh.
  12065. * @param world - World transformation matrix.
  12066. * @param mesh - Mesh to bind the material to.
  12067. */
  12068. bind(world: Matrix, mesh?: Mesh): void;
  12069. /**
  12070. * Binds the submesh to the material.
  12071. * @param world - World transformation matrix.
  12072. * @param mesh - Mesh containing the submesh.
  12073. * @param subMesh - Submesh to bind the material to.
  12074. */
  12075. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  12076. /**
  12077. * Binds the world matrix to the material.
  12078. * @param world - World transformation matrix.
  12079. */
  12080. bindOnlyWorldMatrix(world: Matrix): void;
  12081. /**
  12082. * Binds the scene's uniform buffer to the effect.
  12083. * @param effect - Effect to bind to the scene uniform buffer.
  12084. * @param sceneUbo - Scene uniform buffer.
  12085. */
  12086. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  12087. /**
  12088. * Binds the view matrix to the effect.
  12089. * @param effect - Effect to bind the view matrix to.
  12090. */
  12091. bindView(effect: Effect): void;
  12092. /**
  12093. * Binds the view projection matrix to the effect.
  12094. * @param effect - Effect to bind the view projection matrix to.
  12095. */
  12096. bindViewProjection(effect: Effect): void;
  12097. /**
  12098. * Specifies if material alpha testing should be turned on for the mesh.
  12099. * @param mesh - BJS mesh.
  12100. */
  12101. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  12102. /**
  12103. * Processes to execute after binding the material to a mesh.
  12104. * @param mesh - BJS mesh.
  12105. */
  12106. protected _afterBind(mesh?: Mesh): void;
  12107. /**
  12108. * Unbinds the material from the mesh.
  12109. */
  12110. unbind(): void;
  12111. /**
  12112. * Gets the active textures from the material.
  12113. * @returns - Array of textures.
  12114. */
  12115. getActiveTextures(): BaseTexture[];
  12116. /**
  12117. * Specifies if the material uses a texture.
  12118. * @param texture - Texture to check against the material.
  12119. * @returns - Boolean specifying if the material uses the texture.
  12120. */
  12121. hasTexture(texture: BaseTexture): boolean;
  12122. /**
  12123. * Makes a duplicate of the material, and gives it a new name.
  12124. * @param name - Name to call the duplicated material.
  12125. * @returns - Nullable cloned material
  12126. */
  12127. clone(name: string): Nullable<Material>;
  12128. /**
  12129. * Gets the meshes bound to the material.
  12130. * @returns - Array of meshes bound to the material.
  12131. */
  12132. getBindedMeshes(): AbstractMesh[];
  12133. /**
  12134. * Force shader compilation
  12135. * @param mesh - BJS mesh.
  12136. * @param onCompiled - function to execute once the material is compiled.
  12137. * @param options - options to pass to this function.
  12138. */
  12139. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  12140. clipPlane: boolean;
  12141. }>): void;
  12142. /**
  12143. * Force shader compilation.
  12144. * @param mesh The mesh that will use this material
  12145. * @param options Additional options for compiling the shaders
  12146. * @returns A promise that resolves when the compilation completes
  12147. */
  12148. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  12149. clipPlane: boolean;
  12150. }>): Promise<void>;
  12151. /**
  12152. * Marks a define in the material to indicate that it needs to be re-computed.
  12153. * @param flag - Material define flag.
  12154. */
  12155. markAsDirty(flag: number): void;
  12156. /**
  12157. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated.
  12158. * @param func - function which checks material defines against the submeshes.
  12159. */
  12160. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  12161. /**
  12162. * Indicates that image processing needs to be re-calculated for all submeshes.
  12163. */
  12164. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  12165. /**
  12166. * Indicates that textures need to be re-calculated for all submeshes.
  12167. */
  12168. protected _markAllSubMeshesAsTexturesDirty(): void;
  12169. /**
  12170. * Indicates that fresnel needs to be re-calculated for all submeshes.
  12171. */
  12172. protected _markAllSubMeshesAsFresnelDirty(): void;
  12173. /**
  12174. * Indicates that fresnel and misc need to be re-calculated for all submeshes.
  12175. */
  12176. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  12177. /**
  12178. * Indicates that lights need to be re-calculated for all submeshes.
  12179. */
  12180. protected _markAllSubMeshesAsLightsDirty(): void;
  12181. /**
  12182. * Indicates that attributes need to be re-calculated for all submeshes.
  12183. */
  12184. protected _markAllSubMeshesAsAttributesDirty(): void;
  12185. /**
  12186. * Indicates that misc needs to be re-calculated for all submeshes.
  12187. */
  12188. protected _markAllSubMeshesAsMiscDirty(): void;
  12189. /**
  12190. * Indicates that textures and misc need to be re-calculated for all submeshes.
  12191. */
  12192. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  12193. /**
  12194. * Disposes the material.
  12195. * @param forceDisposeEffect - Specifies if effects should be force disposed.
  12196. * @param forceDisposeTextures - Specifies if textures should be force disposed.
  12197. */
  12198. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  12199. /**
  12200. * Serializes this material.
  12201. * @returns - serialized material object.
  12202. */
  12203. serialize(): any;
  12204. /**
  12205. * Creates a MultiMaterial from parse MultiMaterial data.
  12206. * @param parsedMultiMaterial - Parsed MultiMaterial data.
  12207. * @param scene - BJS scene.
  12208. * @returns - MultiMaterial.
  12209. */
  12210. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  12211. /**
  12212. * Creates a material from parsed material data.
  12213. * @param parsedMaterial - Parsed material data.
  12214. * @param scene - BJS scene.
  12215. * @param rootUrl - Root URL containing the material information.
  12216. * @returns - Parsed material.
  12217. */
  12218. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  12219. }
  12220. }
  12221. declare module BABYLON {
  12222. /**
  12223. * "Static Class" containing the most commonly used helper while dealing with material for
  12224. * rendering purpose.
  12225. *
  12226. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  12227. *
  12228. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12229. */
  12230. class MaterialHelper {
  12231. /**
  12232. * Bind the current view position to an effect.
  12233. * @param effect The effect to be bound
  12234. * @param scene The scene the eyes position is used from
  12235. */
  12236. static BindEyePosition(effect: Effect, scene: Scene): void;
  12237. /**
  12238. * Helps preparing the defines values about the UVs in used in the effect.
  12239. * UVs are shared as much as we can accross chanels in the shaders.
  12240. * @param texture The texture we are preparing the UVs for
  12241. * @param defines The defines to update
  12242. * @param key The chanel key "diffuse", "specular"... used in the shader
  12243. */
  12244. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  12245. /**
  12246. * Binds a texture matrix value to its corrsponding uniform
  12247. * @param texture The texture to bind the matrix for
  12248. * @param uniformBuffer The uniform buffer receivin the data
  12249. * @param key The chanel key "diffuse", "specular"... used in the shader
  12250. */
  12251. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  12252. /**
  12253. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  12254. * @param mesh defines the current mesh
  12255. * @param scene defines the current scene
  12256. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  12257. * @param pointsCloud defines if point cloud rendering has to be turned on
  12258. * @param fogEnabled defines if fog has to be turned on
  12259. * @param alphaTest defines if alpha testing has to be turned on
  12260. * @param defines defines the current list of defines
  12261. */
  12262. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  12263. /**
  12264. * Helper used to prepare the list of defines associated with frame values for shader compilation
  12265. * @param scene defines the current scene
  12266. * @param engine defines the current engine
  12267. * @param defines specifies the list of active defines
  12268. * @param useInstances defines if instances have to be turned on
  12269. * @param useClipPlane defines if clip plane have to be turned on
  12270. */
  12271. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  12272. /**
  12273. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  12274. * @param mesh The mesh containing the geometry data we will draw
  12275. * @param defines The defines to update
  12276. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  12277. * @param useBones Precise whether bones should be used or not (override mesh info)
  12278. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  12279. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  12280. * @returns false if defines are considered not dirty and have not been checked
  12281. */
  12282. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  12283. /**
  12284. * Prepares the defines related to the light information passed in parameter
  12285. * @param scene The scene we are intending to draw
  12286. * @param mesh The mesh the effect is compiling for
  12287. * @param defines The defines to update
  12288. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  12289. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  12290. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  12291. * @returns true if normals will be required for the rest of the effect
  12292. */
  12293. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  12294. /**
  12295. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  12296. * that won t be acctive due to defines being turned off.
  12297. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  12298. * @param samplersList The samplers list
  12299. * @param defines The defines helping in the list generation
  12300. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  12301. */
  12302. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  12303. /**
  12304. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  12305. * @param defines The defines to update while falling back
  12306. * @param fallbacks The authorized effect fallbacks
  12307. * @param maxSimultaneousLights The maximum number of lights allowed
  12308. * @param rank the current rank of the Effect
  12309. * @returns The newly affected rank
  12310. */
  12311. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  12312. /**
  12313. * Prepares the list of attributes required for morph targets according to the effect defines.
  12314. * @param attribs The current list of supported attribs
  12315. * @param mesh The mesh to prepare the morph targets attributes for
  12316. * @param defines The current Defines of the effect
  12317. */
  12318. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  12319. /**
  12320. * Prepares the list of attributes required for bones according to the effect defines.
  12321. * @param attribs The current list of supported attribs
  12322. * @param mesh The mesh to prepare the bones attributes for
  12323. * @param defines The current Defines of the effect
  12324. * @param fallbacks The current efffect fallback strategy
  12325. */
  12326. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  12327. /**
  12328. * Prepares the list of attributes required for instances according to the effect defines.
  12329. * @param attribs The current list of supported attribs
  12330. * @param defines The current Defines of the effect
  12331. */
  12332. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  12333. /**
  12334. * Binds the light shadow information to the effect for the given mesh.
  12335. * @param light The light containing the generator
  12336. * @param scene The scene the lights belongs to
  12337. * @param mesh The mesh we are binding the information to render
  12338. * @param lightIndex The light index in the effect used to render the mesh
  12339. * @param effect The effect we are binding the data to
  12340. */
  12341. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  12342. /**
  12343. * Binds the light information to the effect.
  12344. * @param light The light containing the generator
  12345. * @param effect The effect we are binding the data to
  12346. * @param lightIndex The light index in the effect used to render
  12347. */
  12348. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  12349. /**
  12350. * Binds the lights information from the scene to the effect for the given mesh.
  12351. * @param scene The scene the lights belongs to
  12352. * @param mesh The mesh we are binding the information to render
  12353. * @param effect The effect we are binding the data to
  12354. * @param defines The generated defines for the effect
  12355. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  12356. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  12357. */
  12358. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  12359. /**
  12360. * Binds the fog information from the scene to the effect for the given mesh.
  12361. * @param scene The scene the lights belongs to
  12362. * @param mesh The mesh we are binding the information to render
  12363. * @param effect The effect we are binding the data to
  12364. */
  12365. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  12366. /**
  12367. * Binds the bones information from the mesh to the effect.
  12368. * @param mesh The mesh we are binding the information to render
  12369. * @param effect The effect we are binding the data to
  12370. */
  12371. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  12372. /**
  12373. * Binds the morph targets information from the mesh to the effect.
  12374. * @param abstractMesh The mesh we are binding the information to render
  12375. * @param effect The effect we are binding the data to
  12376. */
  12377. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  12378. /**
  12379. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  12380. * @param defines The generated defines used in the effect
  12381. * @param effect The effect we are binding the data to
  12382. * @param scene The scene we are willing to render with logarithmic scale for
  12383. */
  12384. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  12385. /**
  12386. * Binds the clip plane information from the scene to the effect.
  12387. * @param scene The scene the clip plane information are extracted from
  12388. * @param effect The effect we are binding the data to
  12389. */
  12390. static BindClipPlane(effect: Effect, scene: Scene): void;
  12391. }
  12392. }
  12393. declare module BABYLON {
  12394. class MultiMaterial extends Material {
  12395. private _subMaterials;
  12396. subMaterials: Nullable<Material>[];
  12397. constructor(name: string, scene: Scene);
  12398. private _hookArray(array);
  12399. getSubMaterial(index: number): Nullable<Material>;
  12400. getActiveTextures(): BaseTexture[];
  12401. getClassName(): string;
  12402. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12403. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  12404. serialize(): any;
  12405. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  12406. }
  12407. }
  12408. declare module BABYLON {
  12409. class PushMaterial extends Material {
  12410. protected _activeEffect: Effect;
  12411. protected _normalMatrix: Matrix;
  12412. constructor(name: string, scene: Scene);
  12413. getEffect(): Effect;
  12414. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12415. /**
  12416. * Binds the given world matrix to the active effect
  12417. *
  12418. * @param world the matrix to bind
  12419. */
  12420. bindOnlyWorldMatrix(world: Matrix): void;
  12421. /**
  12422. * Binds the given normal matrix to the active effect
  12423. *
  12424. * @param normalMatrix the matrix to bind
  12425. */
  12426. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  12427. bind(world: Matrix, mesh?: Mesh): void;
  12428. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  12429. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  12430. }
  12431. }
  12432. declare module BABYLON {
  12433. class ShaderMaterial extends Material {
  12434. private _shaderPath;
  12435. private _options;
  12436. private _textures;
  12437. private _textureArrays;
  12438. private _floats;
  12439. private _ints;
  12440. private _floatsArrays;
  12441. private _colors3;
  12442. private _colors3Arrays;
  12443. private _colors4;
  12444. private _vectors2;
  12445. private _vectors3;
  12446. private _vectors4;
  12447. private _matrices;
  12448. private _matrices3x3;
  12449. private _matrices2x2;
  12450. private _vectors2Arrays;
  12451. private _vectors3Arrays;
  12452. private _cachedWorldViewMatrix;
  12453. private _renderId;
  12454. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  12455. getClassName(): string;
  12456. needAlphaBlending(): boolean;
  12457. needAlphaTesting(): boolean;
  12458. private _checkUniform(uniformName);
  12459. setTexture(name: string, texture: Texture): ShaderMaterial;
  12460. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12461. setFloat(name: string, value: number): ShaderMaterial;
  12462. setInt(name: string, value: number): ShaderMaterial;
  12463. setFloats(name: string, value: number[]): ShaderMaterial;
  12464. setColor3(name: string, value: Color3): ShaderMaterial;
  12465. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12466. setColor4(name: string, value: Color4): ShaderMaterial;
  12467. setVector2(name: string, value: Vector2): ShaderMaterial;
  12468. setVector3(name: string, value: Vector3): ShaderMaterial;
  12469. setVector4(name: string, value: Vector4): ShaderMaterial;
  12470. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12471. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12472. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12473. setArray2(name: string, value: number[]): ShaderMaterial;
  12474. setArray3(name: string, value: number[]): ShaderMaterial;
  12475. private _checkCache(scene, mesh?, useInstances?);
  12476. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12477. bindOnlyWorldMatrix(world: Matrix): void;
  12478. bind(world: Matrix, mesh?: Mesh): void;
  12479. getActiveTextures(): BaseTexture[];
  12480. hasTexture(texture: BaseTexture): boolean;
  12481. clone(name: string): ShaderMaterial;
  12482. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  12483. serialize(): any;
  12484. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12485. }
  12486. }
  12487. declare module BABYLON {
  12488. /** @ignore */
  12489. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  12490. MAINUV1: boolean;
  12491. MAINUV2: boolean;
  12492. DIFFUSE: boolean;
  12493. DIFFUSEDIRECTUV: number;
  12494. AMBIENT: boolean;
  12495. AMBIENTDIRECTUV: number;
  12496. OPACITY: boolean;
  12497. OPACITYDIRECTUV: number;
  12498. OPACITYRGB: boolean;
  12499. REFLECTION: boolean;
  12500. EMISSIVE: boolean;
  12501. EMISSIVEDIRECTUV: number;
  12502. SPECULAR: boolean;
  12503. SPECULARDIRECTUV: number;
  12504. BUMP: boolean;
  12505. BUMPDIRECTUV: number;
  12506. PARALLAX: boolean;
  12507. PARALLAXOCCLUSION: boolean;
  12508. SPECULAROVERALPHA: boolean;
  12509. CLIPPLANE: boolean;
  12510. ALPHATEST: boolean;
  12511. DEPTHPREPASS: boolean;
  12512. ALPHAFROMDIFFUSE: boolean;
  12513. POINTSIZE: boolean;
  12514. FOG: boolean;
  12515. SPECULARTERM: boolean;
  12516. DIFFUSEFRESNEL: boolean;
  12517. OPACITYFRESNEL: boolean;
  12518. REFLECTIONFRESNEL: boolean;
  12519. REFRACTIONFRESNEL: boolean;
  12520. EMISSIVEFRESNEL: boolean;
  12521. FRESNEL: boolean;
  12522. NORMAL: boolean;
  12523. UV1: boolean;
  12524. UV2: boolean;
  12525. VERTEXCOLOR: boolean;
  12526. VERTEXALPHA: boolean;
  12527. NUM_BONE_INFLUENCERS: number;
  12528. BonesPerMesh: number;
  12529. INSTANCES: boolean;
  12530. GLOSSINESS: boolean;
  12531. ROUGHNESS: boolean;
  12532. EMISSIVEASILLUMINATION: boolean;
  12533. LINKEMISSIVEWITHDIFFUSE: boolean;
  12534. REFLECTIONFRESNELFROMSPECULAR: boolean;
  12535. LIGHTMAP: boolean;
  12536. LIGHTMAPDIRECTUV: number;
  12537. OBJECTSPACE_NORMALMAP: boolean;
  12538. USELIGHTMAPASSHADOWMAP: boolean;
  12539. REFLECTIONMAP_3D: boolean;
  12540. REFLECTIONMAP_SPHERICAL: boolean;
  12541. REFLECTIONMAP_PLANAR: boolean;
  12542. REFLECTIONMAP_CUBIC: boolean;
  12543. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  12544. REFLECTIONMAP_PROJECTION: boolean;
  12545. REFLECTIONMAP_SKYBOX: boolean;
  12546. REFLECTIONMAP_EXPLICIT: boolean;
  12547. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  12548. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  12549. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  12550. INVERTCUBICMAP: boolean;
  12551. LOGARITHMICDEPTH: boolean;
  12552. REFRACTION: boolean;
  12553. REFRACTIONMAP_3D: boolean;
  12554. REFLECTIONOVERALPHA: boolean;
  12555. TWOSIDEDLIGHTING: boolean;
  12556. SHADOWFLOAT: boolean;
  12557. MORPHTARGETS: boolean;
  12558. MORPHTARGETS_NORMAL: boolean;
  12559. MORPHTARGETS_TANGENT: boolean;
  12560. NUM_MORPH_INFLUENCERS: number;
  12561. NONUNIFORMSCALING: boolean;
  12562. PREMULTIPLYALPHA: boolean;
  12563. IMAGEPROCESSING: boolean;
  12564. VIGNETTE: boolean;
  12565. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12566. VIGNETTEBLENDMODEOPAQUE: boolean;
  12567. TONEMAPPING: boolean;
  12568. CONTRAST: boolean;
  12569. COLORCURVES: boolean;
  12570. COLORGRADING: boolean;
  12571. COLORGRADING3D: boolean;
  12572. SAMPLER3DGREENDEPTH: boolean;
  12573. SAMPLER3DBGRMAP: boolean;
  12574. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12575. EXPOSURE: boolean;
  12576. GRAIN: boolean;
  12577. constructor();
  12578. setReflectionMode(modeToEnable: string): void;
  12579. }
  12580. class StandardMaterial extends PushMaterial {
  12581. private _diffuseTexture;
  12582. diffuseTexture: Nullable<BaseTexture>;
  12583. private _ambientTexture;
  12584. ambientTexture: Nullable<BaseTexture>;
  12585. private _opacityTexture;
  12586. opacityTexture: Nullable<BaseTexture>;
  12587. private _reflectionTexture;
  12588. reflectionTexture: Nullable<BaseTexture>;
  12589. private _emissiveTexture;
  12590. emissiveTexture: Nullable<BaseTexture>;
  12591. private _specularTexture;
  12592. specularTexture: Nullable<BaseTexture>;
  12593. private _bumpTexture;
  12594. bumpTexture: Nullable<BaseTexture>;
  12595. private _lightmapTexture;
  12596. lightmapTexture: Nullable<BaseTexture>;
  12597. private _refractionTexture;
  12598. refractionTexture: Nullable<BaseTexture>;
  12599. ambientColor: Color3;
  12600. diffuseColor: Color3;
  12601. specularColor: Color3;
  12602. emissiveColor: Color3;
  12603. specularPower: number;
  12604. private _useAlphaFromDiffuseTexture;
  12605. useAlphaFromDiffuseTexture: boolean;
  12606. private _useEmissiveAsIllumination;
  12607. useEmissiveAsIllumination: boolean;
  12608. private _linkEmissiveWithDiffuse;
  12609. linkEmissiveWithDiffuse: boolean;
  12610. private _useSpecularOverAlpha;
  12611. useSpecularOverAlpha: boolean;
  12612. private _useReflectionOverAlpha;
  12613. useReflectionOverAlpha: boolean;
  12614. private _disableLighting;
  12615. disableLighting: boolean;
  12616. private _useObjectSpaceNormalMap;
  12617. /**
  12618. * Allows using an object space normal map (instead of tangent space).
  12619. */
  12620. useObjectSpaceNormalMap: boolean;
  12621. private _useParallax;
  12622. useParallax: boolean;
  12623. private _useParallaxOcclusion;
  12624. useParallaxOcclusion: boolean;
  12625. parallaxScaleBias: number;
  12626. private _roughness;
  12627. roughness: number;
  12628. indexOfRefraction: number;
  12629. invertRefractionY: boolean;
  12630. private _useLightmapAsShadowmap;
  12631. useLightmapAsShadowmap: boolean;
  12632. private _diffuseFresnelParameters;
  12633. diffuseFresnelParameters: FresnelParameters;
  12634. private _opacityFresnelParameters;
  12635. opacityFresnelParameters: FresnelParameters;
  12636. private _reflectionFresnelParameters;
  12637. reflectionFresnelParameters: FresnelParameters;
  12638. private _refractionFresnelParameters;
  12639. refractionFresnelParameters: FresnelParameters;
  12640. private _emissiveFresnelParameters;
  12641. emissiveFresnelParameters: FresnelParameters;
  12642. private _useReflectionFresnelFromSpecular;
  12643. useReflectionFresnelFromSpecular: boolean;
  12644. private _useGlossinessFromSpecularMapAlpha;
  12645. useGlossinessFromSpecularMapAlpha: boolean;
  12646. private _maxSimultaneousLights;
  12647. maxSimultaneousLights: number;
  12648. /**
  12649. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  12650. */
  12651. private _invertNormalMapX;
  12652. invertNormalMapX: boolean;
  12653. /**
  12654. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  12655. */
  12656. private _invertNormalMapY;
  12657. invertNormalMapY: boolean;
  12658. /**
  12659. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  12660. */
  12661. private _twoSidedLighting;
  12662. twoSidedLighting: boolean;
  12663. /**
  12664. * Default configuration related to image processing available in the standard Material.
  12665. */
  12666. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12667. /**
  12668. * Gets the image processing configuration used either in this material.
  12669. */
  12670. /**
  12671. * Sets the Default image processing configuration used either in the this material.
  12672. *
  12673. * If sets to null, the scene one is in use.
  12674. */
  12675. imageProcessingConfiguration: ImageProcessingConfiguration;
  12676. /**
  12677. * Keep track of the image processing observer to allow dispose and replace.
  12678. */
  12679. private _imageProcessingObserver;
  12680. /**
  12681. * Attaches a new image processing configuration to the Standard Material.
  12682. * @param configuration
  12683. */
  12684. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12685. /**
  12686. * Gets wether the color curves effect is enabled.
  12687. */
  12688. /**
  12689. * Sets wether the color curves effect is enabled.
  12690. */
  12691. cameraColorCurvesEnabled: boolean;
  12692. /**
  12693. * Gets wether the color grading effect is enabled.
  12694. */
  12695. /**
  12696. * Gets wether the color grading effect is enabled.
  12697. */
  12698. cameraColorGradingEnabled: boolean;
  12699. /**
  12700. * Gets wether tonemapping is enabled or not.
  12701. */
  12702. /**
  12703. * Sets wether tonemapping is enabled or not
  12704. */
  12705. cameraToneMappingEnabled: boolean;
  12706. /**
  12707. * The camera exposure used on this material.
  12708. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  12709. * This corresponds to a photographic exposure.
  12710. */
  12711. /**
  12712. * The camera exposure used on this material.
  12713. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  12714. * This corresponds to a photographic exposure.
  12715. */
  12716. cameraExposure: number;
  12717. /**
  12718. * Gets The camera contrast used on this material.
  12719. */
  12720. /**
  12721. * Sets The camera contrast used on this material.
  12722. */
  12723. cameraContrast: number;
  12724. /**
  12725. * Gets the Color Grading 2D Lookup Texture.
  12726. */
  12727. /**
  12728. * Sets the Color Grading 2D Lookup Texture.
  12729. */
  12730. cameraColorGradingTexture: Nullable<BaseTexture>;
  12731. /**
  12732. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  12733. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  12734. * 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;
  12735. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  12736. */
  12737. /**
  12738. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  12739. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  12740. * 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;
  12741. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  12742. */
  12743. cameraColorCurves: Nullable<ColorCurves>;
  12744. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  12745. protected _renderTargets: SmartArray<RenderTargetTexture>;
  12746. protected _worldViewProjectionMatrix: Matrix;
  12747. protected _globalAmbientColor: Color3;
  12748. protected _useLogarithmicDepth: boolean;
  12749. constructor(name: string, scene: Scene);
  12750. getClassName(): string;
  12751. useLogarithmicDepth: boolean;
  12752. needAlphaBlending(): boolean;
  12753. needAlphaTesting(): boolean;
  12754. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  12755. getAlphaTestTexture(): Nullable<BaseTexture>;
  12756. /**
  12757. * Child classes can use it to update shaders
  12758. */
  12759. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  12760. buildUniformLayout(): void;
  12761. unbind(): void;
  12762. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  12763. getAnimatables(): IAnimatable[];
  12764. getActiveTextures(): BaseTexture[];
  12765. hasTexture(texture: BaseTexture): boolean;
  12766. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  12767. clone(name: string): StandardMaterial;
  12768. serialize(): any;
  12769. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  12770. static _DiffuseTextureEnabled: boolean;
  12771. static DiffuseTextureEnabled: boolean;
  12772. static _AmbientTextureEnabled: boolean;
  12773. static AmbientTextureEnabled: boolean;
  12774. static _OpacityTextureEnabled: boolean;
  12775. static OpacityTextureEnabled: boolean;
  12776. static _ReflectionTextureEnabled: boolean;
  12777. static ReflectionTextureEnabled: boolean;
  12778. static _EmissiveTextureEnabled: boolean;
  12779. static EmissiveTextureEnabled: boolean;
  12780. static _SpecularTextureEnabled: boolean;
  12781. static SpecularTextureEnabled: boolean;
  12782. static _BumpTextureEnabled: boolean;
  12783. static BumpTextureEnabled: boolean;
  12784. static _LightmapTextureEnabled: boolean;
  12785. static LightmapTextureEnabled: boolean;
  12786. static _RefractionTextureEnabled: boolean;
  12787. static RefractionTextureEnabled: boolean;
  12788. static _ColorGradingTextureEnabled: boolean;
  12789. static ColorGradingTextureEnabled: boolean;
  12790. static _FresnelEnabled: boolean;
  12791. static FresnelEnabled: boolean;
  12792. }
  12793. }
  12794. declare module BABYLON {
  12795. class UniformBuffer {
  12796. private _engine;
  12797. private _buffer;
  12798. private _data;
  12799. private _bufferData;
  12800. private _dynamic?;
  12801. private _uniformLocations;
  12802. private _uniformSizes;
  12803. private _uniformLocationPointer;
  12804. private _needSync;
  12805. private _noUBO;
  12806. private _currentEffect;
  12807. private static _MAX_UNIFORM_SIZE;
  12808. private static _tempBuffer;
  12809. /**
  12810. * Wrapper for updateUniform.
  12811. * @method updateMatrix3x3
  12812. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12813. * @param {Float32Array} matrix
  12814. */
  12815. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  12816. /**
  12817. * Wrapper for updateUniform.
  12818. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12819. * @param {Float32Array} matrix
  12820. */
  12821. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  12822. /**
  12823. * Wrapper for updateUniform.
  12824. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12825. * @param {number} x
  12826. */
  12827. updateFloat: (name: string, x: number) => void;
  12828. /**
  12829. * Wrapper for updateUniform.
  12830. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12831. * @param {number} x
  12832. * @param {number} y
  12833. * @param {string} [suffix] Suffix to add to the uniform name.
  12834. */
  12835. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  12836. /**
  12837. * Wrapper for updateUniform.
  12838. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12839. * @param {number} x
  12840. * @param {number} y
  12841. * @param {number} z
  12842. * @param {string} [suffix] Suffix to add to the uniform name.
  12843. */
  12844. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  12845. /**
  12846. * Wrapper for updateUniform.
  12847. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12848. * @param {number} x
  12849. * @param {number} y
  12850. * @param {number} z
  12851. * @param {number} w
  12852. * @param {string} [suffix] Suffix to add to the uniform name.
  12853. */
  12854. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  12855. /**
  12856. * Wrapper for updateUniform.
  12857. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12858. * @param {Matrix} A 4x4 matrix.
  12859. */
  12860. updateMatrix: (name: string, mat: Matrix) => void;
  12861. /**
  12862. * Wrapper for updateUniform.
  12863. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12864. * @param {Vector3} vector
  12865. */
  12866. updateVector3: (name: string, vector: Vector3) => void;
  12867. /**
  12868. * Wrapper for updateUniform.
  12869. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12870. * @param {Vector4} vector
  12871. */
  12872. updateVector4: (name: string, vector: Vector4) => void;
  12873. /**
  12874. * Wrapper for updateUniform.
  12875. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12876. * @param {Color3} color
  12877. * @param {string} [suffix] Suffix to add to the uniform name.
  12878. */
  12879. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  12880. /**
  12881. * Wrapper for updateUniform.
  12882. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12883. * @param {Color3} color
  12884. * @param {number} alpha
  12885. * @param {string} [suffix] Suffix to add to the uniform name.
  12886. */
  12887. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  12888. /**
  12889. * Uniform buffer objects.
  12890. *
  12891. * Handles blocks of uniform on the GPU.
  12892. *
  12893. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  12894. *
  12895. * For more information, please refer to :
  12896. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  12897. */
  12898. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  12899. /**
  12900. * Indicates if the buffer is using the WebGL2 UBO implementation,
  12901. * or just falling back on setUniformXXX calls.
  12902. */
  12903. readonly useUbo: boolean;
  12904. /**
  12905. * Indicates if the WebGL underlying uniform buffer is in sync
  12906. * with the javascript cache data.
  12907. */
  12908. readonly isSync: boolean;
  12909. /**
  12910. * Indicates if the WebGL underlying uniform buffer is dynamic.
  12911. * Also, a dynamic UniformBuffer will disable cache verification and always
  12912. * update the underlying WebGL uniform buffer to the GPU.
  12913. */
  12914. isDynamic(): boolean;
  12915. /**
  12916. * The data cache on JS side.
  12917. */
  12918. getData(): Float32Array;
  12919. /**
  12920. * The underlying WebGL Uniform buffer.
  12921. */
  12922. getBuffer(): Nullable<WebGLBuffer>;
  12923. /**
  12924. * std140 layout specifies how to align data within an UBO structure.
  12925. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  12926. * for specs.
  12927. */
  12928. private _fillAlignment(size);
  12929. /**
  12930. * Adds an uniform in the buffer.
  12931. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  12932. * for the layout to be correct !
  12933. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12934. * @param {number|number[]} size Data size, or data directly.
  12935. */
  12936. addUniform(name: string, size: number | number[]): void;
  12937. /**
  12938. * Wrapper for addUniform.
  12939. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12940. * @param {Matrix} mat A 4x4 matrix.
  12941. */
  12942. addMatrix(name: string, mat: Matrix): void;
  12943. /**
  12944. * Wrapper for addUniform.
  12945. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12946. * @param {number} x
  12947. * @param {number} y
  12948. */
  12949. addFloat2(name: string, x: number, y: number): void;
  12950. /**
  12951. * Wrapper for addUniform.
  12952. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12953. * @param {number} x
  12954. * @param {number} y
  12955. * @param {number} z
  12956. */
  12957. addFloat3(name: string, x: number, y: number, z: number): void;
  12958. /**
  12959. * Wrapper for addUniform.
  12960. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12961. * @param {Color3} color
  12962. */
  12963. addColor3(name: string, color: Color3): void;
  12964. /**
  12965. * Wrapper for addUniform.
  12966. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12967. * @param {Color3} color
  12968. * @param {number} alpha
  12969. */
  12970. addColor4(name: string, color: Color3, alpha: number): void;
  12971. /**
  12972. * Wrapper for addUniform.
  12973. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12974. * @param {Vector3} vector
  12975. */
  12976. addVector3(name: string, vector: Vector3): void;
  12977. /**
  12978. * Wrapper for addUniform.
  12979. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12980. */
  12981. addMatrix3x3(name: string): void;
  12982. /**
  12983. * Wrapper for addUniform.
  12984. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  12985. */
  12986. addMatrix2x2(name: string): void;
  12987. /**
  12988. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  12989. */
  12990. create(): void;
  12991. _rebuild(): void;
  12992. /**
  12993. * Updates the WebGL Uniform Buffer on the GPU.
  12994. * If the `dynamic` flag is set to true, no cache comparison is done.
  12995. * Otherwise, the buffer will be updated only if the cache differs.
  12996. */
  12997. update(): void;
  12998. /**
  12999. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  13000. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  13001. * @param {number[]|Float32Array} data Flattened data
  13002. * @param {number} size Size of the data.
  13003. */
  13004. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  13005. private _updateMatrix3x3ForUniform(name, matrix);
  13006. private _updateMatrix3x3ForEffect(name, matrix);
  13007. private _updateMatrix2x2ForEffect(name, matrix);
  13008. private _updateMatrix2x2ForUniform(name, matrix);
  13009. private _updateFloatForEffect(name, x);
  13010. private _updateFloatForUniform(name, x);
  13011. private _updateFloat2ForEffect(name, x, y, suffix?);
  13012. private _updateFloat2ForUniform(name, x, y, suffix?);
  13013. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  13014. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  13015. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  13016. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  13017. private _updateMatrixForEffect(name, mat);
  13018. private _updateMatrixForUniform(name, mat);
  13019. private _updateVector3ForEffect(name, vector);
  13020. private _updateVector3ForUniform(name, vector);
  13021. private _updateVector4ForEffect(name, vector);
  13022. private _updateVector4ForUniform(name, vector);
  13023. private _updateColor3ForEffect(name, color, suffix?);
  13024. private _updateColor3ForUniform(name, color, suffix?);
  13025. private _updateColor4ForEffect(name, color, alpha, suffix?);
  13026. private _updateColor4ForUniform(name, color, alpha, suffix?);
  13027. /**
  13028. * Sets a sampler uniform on the effect.
  13029. * @param {string} name Name of the sampler.
  13030. * @param {Texture} texture
  13031. */
  13032. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  13033. /**
  13034. * Directly updates the value of the uniform in the cache AND on the GPU.
  13035. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  13036. * @param {number[]|Float32Array} data Flattened data
  13037. */
  13038. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  13039. /**
  13040. * Binds this uniform buffer to an effect.
  13041. * @param {Effect} effect
  13042. * @param {string} name Name of the uniform block in the shader.
  13043. */
  13044. bindToEffect(effect: Effect, name: string): void;
  13045. /**
  13046. * Disposes the uniform buffer.
  13047. */
  13048. dispose(): void;
  13049. }
  13050. }
  13051. declare module BABYLON {
  13052. /**
  13053. * This represents a GPU particle system in Babylon
  13054. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  13055. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  13056. */
  13057. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  13058. /**
  13059. * The id of the Particle system.
  13060. */
  13061. id: string;
  13062. /**
  13063. * The friendly name of the Particle system.
  13064. */
  13065. name: string;
  13066. /**
  13067. * The emitter represents the Mesh or position we are attaching the particle system to.
  13068. */
  13069. emitter: Nullable<AbstractMesh | Vector3>;
  13070. /**
  13071. * The rendering group used by the Particle system to chose when to render.
  13072. */
  13073. renderingGroupId: number;
  13074. /**
  13075. * The layer mask we are rendering the particles through.
  13076. */
  13077. layerMask: number;
  13078. private _capacity;
  13079. private _activeCount;
  13080. private _currentActiveCount;
  13081. private _renderEffect;
  13082. private _updateEffect;
  13083. private _buffer0;
  13084. private _buffer1;
  13085. private _spriteBuffer;
  13086. private _updateVAO;
  13087. private _renderVAO;
  13088. private _targetIndex;
  13089. private _sourceBuffer;
  13090. private _targetBuffer;
  13091. private _scene;
  13092. private _engine;
  13093. private _currentRenderId;
  13094. private _started;
  13095. private _stopped;
  13096. private _timeDelta;
  13097. private _randomTexture;
  13098. private readonly _attributesStrideSize;
  13099. private _updateEffectOptions;
  13100. private _randomTextureSize;
  13101. private _actualFrame;
  13102. /**
  13103. * List of animations used by the particle system.
  13104. */
  13105. animations: Animation[];
  13106. /**
  13107. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  13108. */
  13109. static readonly IsSupported: boolean;
  13110. /**
  13111. * An event triggered when the system is disposed.
  13112. */
  13113. onDisposeObservable: Observable<GPUParticleSystem>;
  13114. /**
  13115. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13116. */
  13117. updateSpeed: number;
  13118. /**
  13119. * The amount of time the particle system is running (depends of the overall update speed).
  13120. */
  13121. targetStopDuration: number;
  13122. /**
  13123. * The texture used to render each particle. (this can be a spritesheet)
  13124. */
  13125. particleTexture: Nullable<Texture>;
  13126. /**
  13127. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  13128. */
  13129. blendMode: number;
  13130. /**
  13131. * Minimum life time of emitting particles.
  13132. */
  13133. minLifeTime: number;
  13134. /**
  13135. * Maximum life time of emitting particles.
  13136. */
  13137. maxLifeTime: number;
  13138. /**
  13139. * Minimum Size of emitting particles.
  13140. */
  13141. minSize: number;
  13142. /**
  13143. * Maximum Size of emitting particles.
  13144. */
  13145. maxSize: number;
  13146. /**
  13147. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13148. */
  13149. color1: Color4;
  13150. /**
  13151. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13152. */
  13153. color2: Color4;
  13154. /**
  13155. * Color the particle will have at the end of its lifetime.
  13156. */
  13157. colorDead: Color4;
  13158. /**
  13159. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13160. */
  13161. emitRate: number;
  13162. /**
  13163. * You can use gravity if you want to give an orientation to your particles.
  13164. */
  13165. gravity: Vector3;
  13166. /**
  13167. * Minimum power of emitting particles.
  13168. */
  13169. minEmitPower: number;
  13170. /**
  13171. * Maximum power of emitting particles.
  13172. */
  13173. maxEmitPower: number;
  13174. /**
  13175. * The particle emitter type defines the emitter used by the particle system.
  13176. * It can be for example box, sphere, or cone...
  13177. */
  13178. particleEmitterType: Nullable<IParticleEmitterType>;
  13179. /**
  13180. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13181. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13182. */
  13183. direction1: Vector3;
  13184. /**
  13185. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13186. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13187. */
  13188. direction2: Vector3;
  13189. /**
  13190. * 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.
  13191. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13192. */
  13193. minEmitBox: Vector3;
  13194. /**
  13195. * 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.
  13196. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13197. */
  13198. maxEmitBox: Vector3;
  13199. /**
  13200. * Gets the maximum number of particles active at the same time.
  13201. * @returns The max number of active particles.
  13202. */
  13203. getCapacity(): number;
  13204. /**
  13205. * Gets or set the number of active particles
  13206. */
  13207. activeParticleCount: number;
  13208. /**
  13209. * Gets Wether the system has been started.
  13210. * @returns True if it has been started, otherwise false.
  13211. */
  13212. isStarted(): boolean;
  13213. /**
  13214. * Starts the particle system and begins to emit.
  13215. */
  13216. start(): void;
  13217. /**
  13218. * Stops the particle system.
  13219. */
  13220. stop(): void;
  13221. /**
  13222. * Remove all active particles
  13223. */
  13224. reset(): void;
  13225. /**
  13226. * Returns the string "GPUParticleSystem"
  13227. * @returns a string containing the class name
  13228. */
  13229. getClassName(): string;
  13230. /**
  13231. * Instantiates a GPU particle system.
  13232. * 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.
  13233. * @param name The name of the particle system
  13234. * @param capacity The max number of particles alive at the same time
  13235. * @param scene The scene the particle system belongs to
  13236. */
  13237. constructor(name: string, options: Partial<{
  13238. capacity: number;
  13239. randomTextureSize: number;
  13240. }>, scene: Scene);
  13241. private _createUpdateVAO(source);
  13242. private _createRenderVAO(source, spriteSource);
  13243. private _initialize(force?);
  13244. /** @ignore */
  13245. _recreateUpdateEffect(): void;
  13246. /** @ignore */
  13247. _recreateRenderEffect(): void;
  13248. /**
  13249. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13250. */
  13251. animate(): void;
  13252. /**
  13253. * Renders the particle system in its current state.
  13254. * @returns the current number of particles
  13255. */
  13256. render(): number;
  13257. /**
  13258. * Rebuilds the particle system
  13259. */
  13260. rebuild(): void;
  13261. private _releaseBuffers();
  13262. private _releaseVAOs();
  13263. /**
  13264. * Disposes the particle system and free the associated resources
  13265. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13266. */
  13267. dispose(disposeTexture?: boolean): void;
  13268. /**
  13269. * Clones the particle system.
  13270. * @param name The name of the cloned object
  13271. * @param newEmitter The new emitter to use
  13272. * @returns the cloned particle system
  13273. */
  13274. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  13275. /**
  13276. * Serializes the particle system to a JSON object.
  13277. * @returns the JSON object
  13278. */
  13279. serialize(): any;
  13280. /**
  13281. * Parses a JSON object to create a GPU particle system.
  13282. * @param parsedParticleSystem The JSON object to parse
  13283. * @param scene The scene to create the particle system in
  13284. * @param rootUrl The root url to use to load external dependencies like texture
  13285. * @returns the parsed GPU particle system
  13286. */
  13287. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  13288. }
  13289. }
  13290. declare module BABYLON {
  13291. /**
  13292. * Interface representing a particle system in Babylon.
  13293. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13294. * A particle system represents a way to manage particles (@see Particle) from their emission to their animation and rendering.
  13295. */
  13296. interface IParticleSystem {
  13297. /**
  13298. * The id of the Particle system.
  13299. */
  13300. id: string;
  13301. /**
  13302. * The name of the Particle system.
  13303. */
  13304. name: string;
  13305. /**
  13306. * The emitter represents the Mesh or position we are attaching the particle system to.
  13307. */
  13308. emitter: Nullable<AbstractMesh | Vector3>;
  13309. /**
  13310. * The rendering group used by the Particle system to chose when to render.
  13311. */
  13312. renderingGroupId: number;
  13313. /**
  13314. * The layer mask we are rendering the particles through.
  13315. */
  13316. layerMask: number;
  13317. /**
  13318. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13319. */
  13320. updateSpeed: number;
  13321. /**
  13322. * The amount of time the particle system is running (depends of the overall update speed).
  13323. */
  13324. targetStopDuration: number;
  13325. /**
  13326. * The texture used to render each particle. (this can be a spritesheet)
  13327. */
  13328. particleTexture: Nullable<Texture>;
  13329. /**
  13330. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  13331. */
  13332. blendMode: number;
  13333. /**
  13334. * Minimum life time of emitting particles.
  13335. */
  13336. minLifeTime: number;
  13337. /**
  13338. * Maximum life time of emitting particles.
  13339. */
  13340. maxLifeTime: number;
  13341. /**
  13342. * Minimum Size of emitting particles.
  13343. */
  13344. minSize: number;
  13345. /**
  13346. * Maximum Size of emitting particles.
  13347. */
  13348. maxSize: number;
  13349. /**
  13350. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13351. */
  13352. color1: Color4;
  13353. /**
  13354. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13355. */
  13356. color2: Color4;
  13357. /**
  13358. * Color the particle will have at the end of its lifetime.
  13359. */
  13360. colorDead: Color4;
  13361. /**
  13362. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13363. */
  13364. emitRate: number;
  13365. /**
  13366. * You can use gravity if you want to give an orientation to your particles.
  13367. */
  13368. gravity: Vector3;
  13369. /**
  13370. * Minimum power of emitting particles.
  13371. */
  13372. minEmitPower: number;
  13373. /**
  13374. * Maximum power of emitting particles.
  13375. */
  13376. maxEmitPower: number;
  13377. /**
  13378. * The particle emitter type defines the emitter used by the particle system.
  13379. * It can be for example box, sphere, or cone...
  13380. */
  13381. particleEmitterType: Nullable<IParticleEmitterType>;
  13382. /**
  13383. * Gets the maximum number of particles active at the same time.
  13384. * @returns The max number of active particles.
  13385. */
  13386. getCapacity(): number;
  13387. /**
  13388. * Gets Wether the system has been started.
  13389. * @returns True if it has been started, otherwise false.
  13390. */
  13391. isStarted(): boolean;
  13392. /**
  13393. * Gets if the particle system has been started.
  13394. * @return true if the system has been started, otherwise false.
  13395. */
  13396. isStarted(): boolean;
  13397. /**
  13398. * Animates the particle system for this frame.
  13399. */
  13400. animate(): void;
  13401. /**
  13402. * Renders the particle system in its current state.
  13403. * @returns the current number of particles
  13404. */
  13405. render(): number;
  13406. /**
  13407. * Dispose the particle system and frees its associated resources.
  13408. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13409. */
  13410. dispose(disposeTexture?: boolean): void;
  13411. /**
  13412. * Clones the particle system.
  13413. * @param name The name of the cloned object
  13414. * @param newEmitter The new emitter to use
  13415. * @returns the cloned particle system
  13416. */
  13417. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13418. /**
  13419. * Serializes the particle system to a JSON object.
  13420. * @returns the JSON object
  13421. */
  13422. serialize(): any;
  13423. /**
  13424. * Rebuild the particle system
  13425. */
  13426. rebuild(): void;
  13427. /**
  13428. * Starts the particle system and begins to emit.
  13429. */
  13430. start(): void;
  13431. /**
  13432. * Stops the particle system.
  13433. */
  13434. stop(): void;
  13435. /**
  13436. * Remove all active particles
  13437. */
  13438. reset(): void;
  13439. }
  13440. }
  13441. declare module BABYLON {
  13442. /**
  13443. * A particle represents one of the element emitted by a particle system.
  13444. * This is mainly define by its coordinates, direction, velocity and age.
  13445. */
  13446. class Particle {
  13447. private particleSystem;
  13448. /**
  13449. * The world position of the particle in the scene.
  13450. */
  13451. position: Vector3;
  13452. /**
  13453. * The world direction of the particle in the scene.
  13454. */
  13455. direction: Vector3;
  13456. /**
  13457. * The color of the particle.
  13458. */
  13459. color: Color4;
  13460. /**
  13461. * The color change of the particle per step.
  13462. */
  13463. colorStep: Color4;
  13464. /**
  13465. * Defines how long will the life of the particle be.
  13466. */
  13467. lifeTime: number;
  13468. /**
  13469. * The current age of the particle.
  13470. */
  13471. age: number;
  13472. /**
  13473. * The current size of the particle.
  13474. */
  13475. size: number;
  13476. /**
  13477. * The current angle of the particle.
  13478. */
  13479. angle: number;
  13480. /**
  13481. * Defines how fast is the angle changing.
  13482. */
  13483. angularSpeed: number;
  13484. /**
  13485. * Defines the cell index used by the particle to be rendered from a sprite.
  13486. */
  13487. cellIndex: number;
  13488. private _currentFrameCounter;
  13489. /**
  13490. * Creates a new instance of @see Particle
  13491. * @param particleSystem the particle system the particle belongs to
  13492. */
  13493. constructor(particleSystem: ParticleSystem);
  13494. /**
  13495. * Defines how the sprite cell index is updated for the particle. This is
  13496. * defined as a callback.
  13497. */
  13498. updateCellIndex: (scaledUpdateSpeed: number) => void;
  13499. private updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  13500. private updateCellIndexWithCustomSpeed();
  13501. /**
  13502. * Copy the properties of particle to another one.
  13503. * @param other the particle to copy the information to.
  13504. */
  13505. copyTo(other: Particle): void;
  13506. }
  13507. }
  13508. declare module BABYLON {
  13509. /**
  13510. * This represents a particle system in Babylon.
  13511. * 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.
  13512. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13513. * @example https://doc.babylonjs.com/babylon101/particles
  13514. */
  13515. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  13516. /**
  13517. * Source color is added to the destination color without alpha affecting the result.
  13518. */
  13519. static BLENDMODE_ONEONE: number;
  13520. /**
  13521. * Blend current color and particle color using particle’s alpha.
  13522. */
  13523. static BLENDMODE_STANDARD: number;
  13524. /**
  13525. * List of animations used by the particle system.
  13526. */
  13527. animations: Animation[];
  13528. /**
  13529. * The id of the Particle system.
  13530. */
  13531. id: string;
  13532. /**
  13533. * The friendly name of the Particle system.
  13534. */
  13535. name: string;
  13536. /**
  13537. * The rendering group used by the Particle system to chose when to render.
  13538. */
  13539. renderingGroupId: number;
  13540. /**
  13541. * The emitter represents the Mesh or position we are attaching the particle system to.
  13542. */
  13543. emitter: Nullable<AbstractMesh | Vector3>;
  13544. /**
  13545. * The maximum number of particles to emit per frame
  13546. */
  13547. emitRate: number;
  13548. /**
  13549. * If you want to launch only a few particles at once, that can be done, as well.
  13550. */
  13551. manualEmitCount: number;
  13552. /**
  13553. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13554. */
  13555. updateSpeed: number;
  13556. /**
  13557. * The amount of time the particle system is running (depends of the overall update speed).
  13558. */
  13559. targetStopDuration: number;
  13560. /**
  13561. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13562. */
  13563. disposeOnStop: boolean;
  13564. /**
  13565. * Minimum power of emitting particles.
  13566. */
  13567. minEmitPower: number;
  13568. /**
  13569. * Maximum power of emitting particles.
  13570. */
  13571. maxEmitPower: number;
  13572. /**
  13573. * Minimum life time of emitting particles.
  13574. */
  13575. minLifeTime: number;
  13576. /**
  13577. * Maximum life time of emitting particles.
  13578. */
  13579. maxLifeTime: number;
  13580. /**
  13581. * Minimum Size of emitting particles.
  13582. */
  13583. minSize: number;
  13584. /**
  13585. * Maximum Size of emitting particles.
  13586. */
  13587. maxSize: number;
  13588. /**
  13589. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13590. */
  13591. minAngularSpeed: number;
  13592. /**
  13593. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13594. */
  13595. maxAngularSpeed: number;
  13596. /**
  13597. * The texture used to render each particle. (this can be a spritesheet)
  13598. */
  13599. particleTexture: Nullable<Texture>;
  13600. /**
  13601. * The layer mask we are rendering the particles through.
  13602. */
  13603. layerMask: number;
  13604. /**
  13605. * This can help using your own shader to render the particle system.
  13606. * The according effect will be created
  13607. */
  13608. customShader: any;
  13609. /**
  13610. * By default particle system starts as soon as they are created. This prevents the
  13611. * automatic start to happen and let you decide when to start emitting particles.
  13612. */
  13613. preventAutoStart: boolean;
  13614. /**
  13615. * This function can be defined to provide custom update for active particles.
  13616. * This function will be called instead of regular update (age, position, color, etc.).
  13617. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  13618. */
  13619. updateFunction: (particles: Particle[]) => void;
  13620. /**
  13621. * Callback triggered when the particle animation is ending.
  13622. */
  13623. onAnimationEnd: Nullable<() => void>;
  13624. /**
  13625. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  13626. */
  13627. blendMode: number;
  13628. /**
  13629. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  13630. * to override the particles.
  13631. */
  13632. forceDepthWrite: boolean;
  13633. /**
  13634. * You can use gravity if you want to give an orientation to your particles.
  13635. */
  13636. gravity: Vector3;
  13637. /**
  13638. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13639. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13640. */
  13641. direction1: Vector3;
  13642. /**
  13643. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13644. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13645. */
  13646. direction2: Vector3;
  13647. /**
  13648. * 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.
  13649. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13650. */
  13651. minEmitBox: Vector3;
  13652. /**
  13653. * 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.
  13654. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13655. */
  13656. maxEmitBox: Vector3;
  13657. /**
  13658. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13659. */
  13660. color1: Color4;
  13661. /**
  13662. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13663. */
  13664. color2: Color4;
  13665. /**
  13666. * Color the particle will have at the end of its lifetime.
  13667. */
  13668. colorDead: Color4;
  13669. /**
  13670. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  13671. */
  13672. textureMask: Color4;
  13673. /**
  13674. * The particle emitter type defines the emitter used by the particle system.
  13675. * It can be for example box, sphere, or cone...
  13676. */
  13677. particleEmitterType: IParticleEmitterType;
  13678. /**
  13679. * This function can be defined to specify initial direction for every new particle.
  13680. * It by default use the emitterType defined function.
  13681. */
  13682. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  13683. /**
  13684. * This function can be defined to specify initial position for every new particle.
  13685. * It by default use the emitterType defined function.
  13686. */
  13687. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  13688. /**
  13689. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  13690. */
  13691. spriteCellLoop: boolean;
  13692. /**
  13693. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  13694. */
  13695. spriteCellChangeSpeed: number;
  13696. /**
  13697. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  13698. */
  13699. startSpriteCellID: number;
  13700. /**
  13701. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  13702. */
  13703. endSpriteCellID: number;
  13704. /**
  13705. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  13706. */
  13707. spriteCellWidth: number;
  13708. /**
  13709. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  13710. */
  13711. spriteCellHeight: number;
  13712. /**
  13713. * An event triggered when the system is disposed.
  13714. */
  13715. onDisposeObservable: Observable<ParticleSystem>;
  13716. private _onDisposeObserver;
  13717. /**
  13718. * Sets a callback that will be triggered when the system is disposed.
  13719. */
  13720. onDispose: () => void;
  13721. /**
  13722. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  13723. */
  13724. readonly isAnimationSheetEnabled: Boolean;
  13725. private _particles;
  13726. private _epsilon;
  13727. private _capacity;
  13728. private _scene;
  13729. private _stockParticles;
  13730. private _newPartsExcess;
  13731. private _vertexData;
  13732. private _vertexBuffer;
  13733. private _vertexBuffers;
  13734. private _indexBuffer;
  13735. private _effect;
  13736. private _customEffect;
  13737. private _cachedDefines;
  13738. private _scaledColorStep;
  13739. private _colorDiff;
  13740. private _scaledDirection;
  13741. private _scaledGravity;
  13742. private _currentRenderId;
  13743. private _alive;
  13744. private _started;
  13745. private _stopped;
  13746. private _actualFrame;
  13747. private _scaledUpdateSpeed;
  13748. private _vertexBufferSize;
  13749. private _isAnimationSheetEnabled;
  13750. /**
  13751. * Gets the current list of active particles
  13752. */
  13753. readonly particles: Particle[];
  13754. /**
  13755. * Returns the string "ParticleSystem"
  13756. * @returns a string containing the class name
  13757. */
  13758. getClassName(): string;
  13759. /**
  13760. * Instantiates a particle system.
  13761. * 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.
  13762. * @param name The name of the particle system
  13763. * @param capacity The max number of particles alive at the same time
  13764. * @param scene The scene the particle system belongs to
  13765. * @param customEffect a custom effect used to change the way particles are rendered by default
  13766. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13767. * @param epsilon Offset used to render the particles
  13768. */
  13769. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13770. private _createIndexBuffer();
  13771. /**
  13772. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13773. * Its lifetime will start back at 0.
  13774. * @param particle The particle to recycle
  13775. */
  13776. recycleParticle(particle: Particle): void;
  13777. /**
  13778. * Gets the maximum number of particles active at the same time.
  13779. * @returns The max number of active particles.
  13780. */
  13781. getCapacity(): number;
  13782. /**
  13783. * Gets Wether there are still active particles in the system.
  13784. * @returns True if it is alive, otherwise false.
  13785. */
  13786. isAlive(): boolean;
  13787. /**
  13788. * Gets Wether the system has been started.
  13789. * @returns True if it has been started, otherwise false.
  13790. */
  13791. isStarted(): boolean;
  13792. /**
  13793. * Starts the particle system and begins to emit.
  13794. */
  13795. start(): void;
  13796. /**
  13797. * Stops the particle system.
  13798. */
  13799. stop(): void;
  13800. /**
  13801. * Remove all active particles
  13802. */
  13803. reset(): void;
  13804. /**
  13805. * @ignore (for internal use only)
  13806. */
  13807. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13808. /**
  13809. * @ignore (for internal use only)
  13810. */
  13811. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13812. private _update(newParticles);
  13813. private _getEffect();
  13814. /**
  13815. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13816. */
  13817. animate(): void;
  13818. private _appendParticleVertexes;
  13819. private _appenedParticleVertexesWithSheet(offset, particle);
  13820. private _appenedParticleVertexesNoSheet(offset, particle);
  13821. /**
  13822. * Rebuilds the particle system.
  13823. */
  13824. rebuild(): void;
  13825. /**
  13826. * Renders the particle system in its current state.
  13827. * @returns the current number of particles
  13828. */
  13829. render(): number;
  13830. /**
  13831. * Disposes the particle system and free the associated resources
  13832. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13833. */
  13834. dispose(disposeTexture?: boolean): void;
  13835. /**
  13836. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  13837. * @param radius The radius of the sphere to emit from
  13838. * @returns the emitter
  13839. */
  13840. createSphereEmitter(radius?: number): SphereParticleEmitter;
  13841. /**
  13842. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  13843. * @param radius The radius of the sphere to emit from
  13844. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13845. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13846. * @returns the emitter
  13847. */
  13848. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  13849. /**
  13850. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  13851. * @param radius The radius of the cone to emit from
  13852. * @param angle The base angle of the cone
  13853. * @returns the emitter
  13854. */
  13855. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  13856. /**
  13857. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13858. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13859. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13860. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13861. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13862. * @returns the emitter
  13863. */
  13864. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13865. /**
  13866. * Clones the particle system.
  13867. * @param name The name of the cloned object
  13868. * @param newEmitter The new emitter to use
  13869. * @returns the cloned particle system
  13870. */
  13871. clone(name: string, newEmitter: any): ParticleSystem;
  13872. /**
  13873. * Serializes the particle system to a JSON object.
  13874. * @returns the JSON object
  13875. */
  13876. serialize(): any;
  13877. /**
  13878. * Parses a JSON object to create a particle system.
  13879. * @param parsedParticleSystem The JSON object to parse
  13880. * @param scene The scene to create the particle system in
  13881. * @param rootUrl The root url to use to load external dependencies like texture
  13882. * @returns the Parsed particle system
  13883. */
  13884. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  13885. }
  13886. }
  13887. declare module BABYLON {
  13888. /**
  13889. * Represents one particle of a solid particle system.
  13890. * @see SolidParticleSystem
  13891. */
  13892. class SolidParticle {
  13893. /**
  13894. * particle global index
  13895. */
  13896. idx: number;
  13897. /**
  13898. * The color of the particle
  13899. */
  13900. color: Nullable<Color4>;
  13901. /**
  13902. * The world space position of the particle.
  13903. */
  13904. position: Vector3;
  13905. /**
  13906. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  13907. */
  13908. rotation: Vector3;
  13909. /**
  13910. * The world space rotation quaternion of the particle.
  13911. */
  13912. rotationQuaternion: Nullable<Quaternion>;
  13913. /**
  13914. * The scaling of the particle.
  13915. */
  13916. scaling: Vector3;
  13917. /**
  13918. * The uvs of the particle.
  13919. */
  13920. uvs: Vector4;
  13921. /**
  13922. * The current speed of the particle.
  13923. */
  13924. velocity: Vector3;
  13925. /**
  13926. * The pivot point in the particle local space.
  13927. */
  13928. pivot: Vector3;
  13929. /**
  13930. * Must the particle be translated from its pivot point in its local space ?
  13931. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  13932. * Default : false
  13933. */
  13934. translateFromPivot: boolean;
  13935. /**
  13936. * Is the particle active or not ?
  13937. */
  13938. alive: boolean;
  13939. /**
  13940. * Is the particle visible or not ?
  13941. */
  13942. isVisible: boolean;
  13943. /**
  13944. * Index of this particle in the global "positions" array (Internal use)
  13945. */
  13946. _pos: number;
  13947. /**
  13948. * Index of this particle in the global "indices" array (Internal use)
  13949. */
  13950. _ind: number;
  13951. /**
  13952. * ModelShape of this particle (Internal use)
  13953. */
  13954. _model: ModelShape;
  13955. /**
  13956. * ModelShape id of this particle
  13957. */
  13958. shapeId: number;
  13959. /**
  13960. * Index of the particle in its shape id (Internal use)
  13961. */
  13962. idxInShape: number;
  13963. /**
  13964. * Reference to the shape model BoundingInfo object (Internal use)
  13965. */
  13966. _modelBoundingInfo: BoundingInfo;
  13967. /**
  13968. * Particle BoundingInfo object (Internal use)
  13969. */
  13970. _boundingInfo: BoundingInfo;
  13971. /**
  13972. * Reference to the SPS what the particle belongs to (Internal use)
  13973. */
  13974. _sps: SolidParticleSystem;
  13975. /**
  13976. * Still set as invisible in order to skip useless computations (Internal use)
  13977. */
  13978. _stillInvisible: boolean;
  13979. /**
  13980. * Last computed particle rotation matrix
  13981. */
  13982. _rotationMatrix: number[];
  13983. /**
  13984. * Parent particle Id, if any.
  13985. * Default null.
  13986. */
  13987. parentId: Nullable<number>;
  13988. /**
  13989. * Internal global position in the SPS.
  13990. */
  13991. _globalPosition: Vector3;
  13992. /**
  13993. * Creates a Solid Particle object.
  13994. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  13995. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  13996. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  13997. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  13998. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  13999. * @param shapeId (integer) is the model shape identifier in the SPS.
  14000. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  14001. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  14002. */
  14003. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  14004. /**
  14005. * Legacy support, changed scale to scaling
  14006. */
  14007. /**
  14008. * Legacy support, changed scale to scaling
  14009. */
  14010. scale: Vector3;
  14011. /**
  14012. * Legacy support, changed quaternion to rotationQuaternion
  14013. */
  14014. /**
  14015. * Legacy support, changed quaternion to rotationQuaternion
  14016. */
  14017. quaternion: Nullable<Quaternion>;
  14018. /**
  14019. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  14020. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  14021. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  14022. * @returns true if it intersects
  14023. */
  14024. intersectsMesh(target: Mesh | SolidParticle): boolean;
  14025. }
  14026. /**
  14027. * Represents the shape of the model used by one particle of a solid particle system.
  14028. * SPS internal tool, don't use it manually.
  14029. * @see SolidParticleSystem
  14030. */
  14031. class ModelShape {
  14032. /**
  14033. * The shape id.
  14034. */
  14035. shapeID: number;
  14036. /**
  14037. * flat array of model positions (internal use)
  14038. */
  14039. _shape: Vector3[];
  14040. /**
  14041. * flat array of model UVs (internal use)
  14042. */
  14043. _shapeUV: number[];
  14044. /**
  14045. * length of the shape in the model indices array (internal use)
  14046. */
  14047. _indicesLength: number;
  14048. /**
  14049. * Custom position function (internal use)
  14050. */
  14051. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  14052. /**
  14053. * Custom vertex function (internal use)
  14054. */
  14055. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  14056. /**
  14057. * 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.
  14058. * SPS internal tool, don't use it manually.
  14059. * @ignore
  14060. */
  14061. 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>);
  14062. }
  14063. /**
  14064. * Represents a Depth Sorted Particle in the solid particle system.
  14065. * @see SolidParticleSystem
  14066. */
  14067. class DepthSortedParticle {
  14068. /**
  14069. * Index of the particle in the "indices" array
  14070. */
  14071. ind: number;
  14072. /**
  14073. * Length of the particle shape in the "indices" array
  14074. */
  14075. indicesLength: number;
  14076. /**
  14077. * Squared distance from the particle to the camera
  14078. */
  14079. sqDistance: number;
  14080. }
  14081. }
  14082. declare module BABYLON {
  14083. /**
  14084. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  14085. *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.
  14086. * The SPS is also a particle system. It provides some methods to manage the particles.
  14087. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  14088. *
  14089. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  14090. */
  14091. class SolidParticleSystem implements IDisposable {
  14092. /**
  14093. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  14094. * Example : var p = SPS.particles[i];
  14095. */
  14096. particles: SolidParticle[];
  14097. /**
  14098. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  14099. */
  14100. nbParticles: number;
  14101. /**
  14102. * If the particles must ever face the camera (default false). Useful for planar particles.
  14103. */
  14104. billboard: boolean;
  14105. /**
  14106. * Recompute normals when adding a shape
  14107. */
  14108. recomputeNormals: boolean;
  14109. /**
  14110. * This a counter ofr your own usage. It's not set by any SPS functions.
  14111. */
  14112. counter: number;
  14113. /**
  14114. * The SPS name. This name is also given to the underlying mesh.
  14115. */
  14116. name: string;
  14117. /**
  14118. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  14119. */
  14120. mesh: Mesh;
  14121. /**
  14122. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  14123. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  14124. */
  14125. vars: any;
  14126. /**
  14127. * This array is populated when the SPS is set as 'pickable'.
  14128. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  14129. * Each element of this array is an object `{idx: int, faceId: int}`.
  14130. * `idx` is the picked particle index in the `SPS.particles` array
  14131. * `faceId` is the picked face index counted within this particle.
  14132. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  14133. */
  14134. pickedParticles: {
  14135. idx: number;
  14136. faceId: number;
  14137. }[];
  14138. /**
  14139. * This array is populated when `enableDepthSort` is set to true.
  14140. * Each element of this array is an instance of the class DepthSortedParticle.
  14141. */
  14142. depthSortedParticles: DepthSortedParticle[];
  14143. /**
  14144. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  14145. */
  14146. _bSphereOnly: boolean;
  14147. /**
  14148. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  14149. */
  14150. _bSphereRadiusFactor: number;
  14151. private _scene;
  14152. private _positions;
  14153. private _indices;
  14154. private _normals;
  14155. private _colors;
  14156. private _uvs;
  14157. private _indices32;
  14158. private _positions32;
  14159. private _normals32;
  14160. private _fixedNormal32;
  14161. private _colors32;
  14162. private _uvs32;
  14163. private _index;
  14164. private _updatable;
  14165. private _pickable;
  14166. private _isVisibilityBoxLocked;
  14167. private _alwaysVisible;
  14168. private _depthSort;
  14169. private _shapeCounter;
  14170. private _copy;
  14171. private _shape;
  14172. private _shapeUV;
  14173. private _color;
  14174. private _computeParticleColor;
  14175. private _computeParticleTexture;
  14176. private _computeParticleRotation;
  14177. private _computeParticleVertex;
  14178. private _computeBoundingBox;
  14179. private _depthSortParticles;
  14180. private _cam_axisZ;
  14181. private _cam_axisY;
  14182. private _cam_axisX;
  14183. private _axisZ;
  14184. private _camera;
  14185. private _particle;
  14186. private _camDir;
  14187. private _camInvertedPosition;
  14188. private _rotMatrix;
  14189. private _invertMatrix;
  14190. private _rotated;
  14191. private _quaternion;
  14192. private _vertex;
  14193. private _normal;
  14194. private _yaw;
  14195. private _pitch;
  14196. private _roll;
  14197. private _halfroll;
  14198. private _halfpitch;
  14199. private _halfyaw;
  14200. private _sinRoll;
  14201. private _cosRoll;
  14202. private _sinPitch;
  14203. private _cosPitch;
  14204. private _sinYaw;
  14205. private _cosYaw;
  14206. private _mustUnrotateFixedNormals;
  14207. private _minimum;
  14208. private _maximum;
  14209. private _minBbox;
  14210. private _maxBbox;
  14211. private _particlesIntersect;
  14212. private _depthSortFunction;
  14213. private _needs32Bits;
  14214. private _pivotBackTranslation;
  14215. private _scaledPivot;
  14216. private _particleHasParent;
  14217. private _parent;
  14218. /**
  14219. * Creates a SPS (Solid Particle System) object.
  14220. * @param name (String) is the SPS name, this will be the underlying mesh name.
  14221. * @param scene (Scene) is the scene in which the SPS is added.
  14222. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  14223. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  14224. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  14225. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  14226. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  14227. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  14228. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  14229. */
  14230. constructor(name: string, scene: Scene, options?: {
  14231. updatable?: boolean;
  14232. isPickable?: boolean;
  14233. enableDepthSort?: boolean;
  14234. particleIntersection?: boolean;
  14235. boundingSphereOnly?: boolean;
  14236. bSphereRadiusFactor?: number;
  14237. });
  14238. /**
  14239. * Builds the SPS underlying mesh. Returns a standard Mesh.
  14240. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  14241. * @returns the created mesh
  14242. */
  14243. buildMesh(): Mesh;
  14244. /**
  14245. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  14246. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  14247. * Thus the particles generated from `digest()` have their property `position` set yet.
  14248. * @param mesh ( Mesh ) is the mesh to be digested
  14249. * @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
  14250. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  14251. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  14252. * @returns the current SPS
  14253. */
  14254. digest(mesh: Mesh, options?: {
  14255. facetNb?: number;
  14256. number?: number;
  14257. delta?: number;
  14258. }): SolidParticleSystem;
  14259. private _unrotateFixedNormals();
  14260. private _resetCopy();
  14261. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  14262. private _posToShape(positions);
  14263. private _uvsToShapeUV(uvs);
  14264. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  14265. /**
  14266. * Adds some particles to the SPS from the model shape. Returns the shape id.
  14267. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  14268. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  14269. * @param nb (positive integer) the number of particles to be created from this model
  14270. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  14271. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  14272. * @returns the number of shapes in the system
  14273. */
  14274. addShape(mesh: Mesh, nb: number, options?: {
  14275. positionFunction?: any;
  14276. vertexFunction?: any;
  14277. }): number;
  14278. private _rebuildParticle(particle);
  14279. /**
  14280. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  14281. * @returns the SPS.
  14282. */
  14283. rebuildMesh(): SolidParticleSystem;
  14284. /**
  14285. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  14286. * This method calls `updateParticle()` for each particle of the SPS.
  14287. * For an animated SPS, it is usually called within the render loop.
  14288. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  14289. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  14290. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  14291. * @returns the SPS.
  14292. */
  14293. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  14294. private _quaternionRotationYPR();
  14295. private _quaternionToRotationMatrix();
  14296. /**
  14297. * Disposes the SPS.
  14298. */
  14299. dispose(): void;
  14300. /**
  14301. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  14302. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  14303. * @returns the SPS.
  14304. */
  14305. refreshVisibleSize(): SolidParticleSystem;
  14306. /**
  14307. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  14308. * @param size the size (float) of the visibility box
  14309. * note : this doesn't lock the SPS mesh bounding box.
  14310. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  14311. */
  14312. setVisibilityBox(size: number): void;
  14313. /**
  14314. * Gets whether the SPS as always visible or not
  14315. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  14316. */
  14317. /**
  14318. * Sets the SPS as always visible or not
  14319. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  14320. */
  14321. isAlwaysVisible: boolean;
  14322. /**
  14323. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  14324. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  14325. */
  14326. /**
  14327. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  14328. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  14329. */
  14330. isVisibilityBoxLocked: boolean;
  14331. /**
  14332. * Gets if `setParticles()` computes the particle rotations or not.
  14333. * Default value : true. The SPS is faster when it's set to false.
  14334. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  14335. */
  14336. /**
  14337. * Tells to `setParticles()` to compute the particle rotations or not.
  14338. * Default value : true. The SPS is faster when it's set to false.
  14339. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  14340. */
  14341. computeParticleRotation: boolean;
  14342. /**
  14343. * Gets if `setParticles()` computes the particle colors or not.
  14344. * Default value : true. The SPS is faster when it's set to false.
  14345. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  14346. */
  14347. /**
  14348. * Tells to `setParticles()` to compute the particle colors or not.
  14349. * Default value : true. The SPS is faster when it's set to false.
  14350. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  14351. */
  14352. computeParticleColor: boolean;
  14353. /**
  14354. * Gets if `setParticles()` computes the particle textures or not.
  14355. * Default value : true. The SPS is faster when it's set to false.
  14356. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  14357. */
  14358. computeParticleTexture: boolean;
  14359. /**
  14360. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  14361. * Default value : false. The SPS is faster when it's set to false.
  14362. * Note : the particle custom vertex positions aren't stored values.
  14363. */
  14364. /**
  14365. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  14366. * Default value : false. The SPS is faster when it's set to false.
  14367. * Note : the particle custom vertex positions aren't stored values.
  14368. */
  14369. computeParticleVertex: boolean;
  14370. /**
  14371. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  14372. */
  14373. /**
  14374. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  14375. */
  14376. computeBoundingBox: boolean;
  14377. /**
  14378. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  14379. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  14380. * Default : `true`
  14381. */
  14382. /**
  14383. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  14384. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  14385. * Default : `true`
  14386. */
  14387. depthSortParticles: boolean;
  14388. /**
  14389. * This function does nothing. It may be overwritten to set all the particle first values.
  14390. * The SPS doesn't call this function, you may have to call it by your own.
  14391. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  14392. */
  14393. initParticles(): void;
  14394. /**
  14395. * This function does nothing. It may be overwritten to recycle a particle.
  14396. * The SPS doesn't call this function, you may have to call it by your own.
  14397. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  14398. * @param particle The particle to recycle
  14399. * @returns the recycled particle
  14400. */
  14401. recycleParticle(particle: SolidParticle): SolidParticle;
  14402. /**
  14403. * Updates a particle : this function should be overwritten by the user.
  14404. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  14405. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  14406. * @example : just set a particle position or velocity and recycle conditions
  14407. * @param particle The particle to update
  14408. * @returns the updated particle
  14409. */
  14410. updateParticle(particle: SolidParticle): SolidParticle;
  14411. /**
  14412. * Updates a vertex of a particle : it can be overwritten by the user.
  14413. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  14414. * @param particle the current particle
  14415. * @param vertex the current index of the current particle
  14416. * @param pt the index of the current vertex in the particle shape
  14417. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  14418. * @example : just set a vertex particle position
  14419. * @returns the updated vertex
  14420. */
  14421. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  14422. /**
  14423. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  14424. * This does nothing and may be overwritten by the user.
  14425. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  14426. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  14427. * @param update the boolean update value actually passed to setParticles()
  14428. */
  14429. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  14430. /**
  14431. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  14432. * This will be passed three parameters.
  14433. * This does nothing and may be overwritten by the user.
  14434. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  14435. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  14436. * @param update the boolean update value actually passed to setParticles()
  14437. */
  14438. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  14439. }
  14440. }
  14441. declare module BABYLON {
  14442. class MorphTarget {
  14443. name: string;
  14444. animations: Animation[];
  14445. private _positions;
  14446. private _normals;
  14447. private _tangents;
  14448. private _influence;
  14449. onInfluenceChanged: Observable<boolean>;
  14450. influence: number;
  14451. constructor(name: string, influence?: number);
  14452. readonly hasPositions: boolean;
  14453. readonly hasNormals: boolean;
  14454. readonly hasTangents: boolean;
  14455. setPositions(data: Nullable<FloatArray>): void;
  14456. getPositions(): Nullable<FloatArray>;
  14457. setNormals(data: Nullable<FloatArray>): void;
  14458. getNormals(): Nullable<FloatArray>;
  14459. setTangents(data: Nullable<FloatArray>): void;
  14460. getTangents(): Nullable<FloatArray>;
  14461. /**
  14462. * Serializes the current target into a Serialization object.
  14463. * Returns the serialized object.
  14464. */
  14465. serialize(): any;
  14466. static Parse(serializationObject: any): MorphTarget;
  14467. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  14468. }
  14469. }
  14470. declare module BABYLON {
  14471. class MorphTargetManager {
  14472. private _targets;
  14473. private _targetObservable;
  14474. private _activeTargets;
  14475. private _scene;
  14476. private _influences;
  14477. private _supportsNormals;
  14478. private _supportsTangents;
  14479. private _vertexCount;
  14480. private _uniqueId;
  14481. private _tempInfluences;
  14482. constructor(scene?: Nullable<Scene>);
  14483. readonly uniqueId: number;
  14484. readonly vertexCount: number;
  14485. readonly supportsNormals: boolean;
  14486. readonly supportsTangents: boolean;
  14487. readonly numTargets: number;
  14488. readonly numInfluencers: number;
  14489. readonly influences: Float32Array;
  14490. getActiveTarget(index: number): MorphTarget;
  14491. getTarget(index: number): MorphTarget;
  14492. addTarget(target: MorphTarget): void;
  14493. removeTarget(target: MorphTarget): void;
  14494. /**
  14495. * Serializes the current manager into a Serialization object.
  14496. * Returns the serialized object.
  14497. */
  14498. serialize(): any;
  14499. private _syncActiveTargets(needUpdate);
  14500. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  14501. }
  14502. }
  14503. declare module BABYLON {
  14504. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  14505. static OCCLUSION_TYPE_NONE: number;
  14506. static OCCLUSION_TYPE_OPTIMISTIC: number;
  14507. static OCCLUSION_TYPE_STRICT: number;
  14508. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  14509. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  14510. static readonly BILLBOARDMODE_NONE: number;
  14511. static readonly BILLBOARDMODE_X: number;
  14512. static readonly BILLBOARDMODE_Y: number;
  14513. static readonly BILLBOARDMODE_Z: number;
  14514. static readonly BILLBOARDMODE_ALL: number;
  14515. private _facetPositions;
  14516. private _facetNormals;
  14517. private _facetPartitioning;
  14518. private _facetNb;
  14519. private _partitioningSubdivisions;
  14520. private _partitioningBBoxRatio;
  14521. private _facetDataEnabled;
  14522. private _facetParameters;
  14523. private _bbSize;
  14524. private _subDiv;
  14525. private _facetDepthSort;
  14526. private _facetDepthSortEnabled;
  14527. private _depthSortedIndices;
  14528. private _depthSortedFacets;
  14529. private _facetDepthSortFunction;
  14530. private _facetDepthSortFrom;
  14531. private _facetDepthSortOrigin;
  14532. private _invertedMatrix;
  14533. /**
  14534. * Read-only : the number of facets in the mesh
  14535. */
  14536. readonly facetNb: number;
  14537. /**
  14538. * The number (integer) of subdivisions per axis in the partioning space
  14539. */
  14540. partitioningSubdivisions: number;
  14541. /**
  14542. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  14543. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box.
  14544. */
  14545. partitioningBBoxRatio: number;
  14546. /**
  14547. * Boolean : must the facet be depth sorted on next call to `updateFacetData()` ?
  14548. * Works only for updatable meshes.
  14549. * Doesn't work with multi-materials.
  14550. */
  14551. mustDepthSortFacets: boolean;
  14552. /**
  14553. * The location (Vector3) where the facet depth sort must be computed from.
  14554. * By default, the active camera position.
  14555. * Used only when facet depth sort is enabled.
  14556. */
  14557. facetDepthSortFrom: Vector3;
  14558. /**
  14559. * Read-only boolean : is the feature facetData enabled ?
  14560. */
  14561. readonly isFacetDataEnabled: boolean;
  14562. _updateNonUniformScalingState(value: boolean): boolean;
  14563. /**
  14564. * An event triggered when this mesh collides with another one
  14565. * @type {BABYLON.Observable}
  14566. */
  14567. onCollideObservable: Observable<AbstractMesh>;
  14568. private _onCollideObserver;
  14569. onCollide: () => void;
  14570. /**
  14571. * An event triggered when the collision's position changes
  14572. * @type {BABYLON.Observable}
  14573. */
  14574. onCollisionPositionChangeObservable: Observable<Vector3>;
  14575. private _onCollisionPositionChangeObserver;
  14576. onCollisionPositionChange: () => void;
  14577. /**
  14578. * An event triggered when material is changed
  14579. * @type {BABYLON.Observable}
  14580. */
  14581. onMaterialChangedObservable: Observable<AbstractMesh>;
  14582. definedFacingForward: boolean;
  14583. /**
  14584. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  14585. * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  14586. * or
  14587. * 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.
  14588. * for more info check WebGl documentations
  14589. */
  14590. occlusionQueryAlgorithmType: number;
  14591. /**
  14592. * 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:
  14593. * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  14594. * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  14595. * 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.
  14596. */
  14597. occlusionType: number;
  14598. /**
  14599. * 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.
  14600. * The default value is -1 which means don't break the query and wait till the result.
  14601. */
  14602. occlusionRetryCount: number;
  14603. private _occlusionInternalRetryCounter;
  14604. protected _isOccluded: boolean;
  14605. /**
  14606. * Property isOccluded : Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not.
  14607. */
  14608. isOccluded: boolean;
  14609. private _isOcclusionQueryInProgress;
  14610. /**
  14611. * Flag to check the progress status of the query
  14612. */
  14613. readonly isOcclusionQueryInProgress: boolean;
  14614. private _occlusionQuery;
  14615. private _visibility;
  14616. /**
  14617. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  14618. */
  14619. /**
  14620. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  14621. */
  14622. visibility: number;
  14623. alphaIndex: number;
  14624. isVisible: boolean;
  14625. isPickable: boolean;
  14626. showBoundingBox: boolean;
  14627. showSubMeshesBoundingBox: boolean;
  14628. isBlocker: boolean;
  14629. enablePointerMoveEvents: boolean;
  14630. renderingGroupId: number;
  14631. private _material;
  14632. material: Nullable<Material>;
  14633. private _receiveShadows;
  14634. receiveShadows: boolean;
  14635. renderOutline: boolean;
  14636. outlineColor: Color3;
  14637. outlineWidth: number;
  14638. renderOverlay: boolean;
  14639. overlayColor: Color3;
  14640. overlayAlpha: number;
  14641. private _hasVertexAlpha;
  14642. hasVertexAlpha: boolean;
  14643. private _useVertexColors;
  14644. useVertexColors: boolean;
  14645. private _computeBonesUsingShaders;
  14646. computeBonesUsingShaders: boolean;
  14647. private _numBoneInfluencers;
  14648. numBoneInfluencers: number;
  14649. private _applyFog;
  14650. applyFog: boolean;
  14651. useOctreeForRenderingSelection: boolean;
  14652. useOctreeForPicking: boolean;
  14653. useOctreeForCollisions: boolean;
  14654. private _layerMask;
  14655. layerMask: number;
  14656. /**
  14657. * True if the mesh must be rendered in any case.
  14658. */
  14659. alwaysSelectAsActiveMesh: boolean;
  14660. /**
  14661. * This scene's action manager
  14662. * @type {BABYLON.ActionManager}
  14663. */
  14664. actionManager: Nullable<ActionManager>;
  14665. physicsImpostor: Nullable<PhysicsImpostor>;
  14666. private _checkCollisions;
  14667. private _collisionMask;
  14668. private _collisionGroup;
  14669. ellipsoid: Vector3;
  14670. ellipsoidOffset: Vector3;
  14671. private _collider;
  14672. private _oldPositionForCollisions;
  14673. private _diffPositionForCollisions;
  14674. collisionMask: number;
  14675. collisionGroup: number;
  14676. edgesWidth: number;
  14677. edgesColor: Color4;
  14678. _edgesRenderer: Nullable<EdgesRenderer>;
  14679. private _collisionsTransformMatrix;
  14680. private _collisionsScalingMatrix;
  14681. _masterMesh: Nullable<AbstractMesh>;
  14682. _boundingInfo: Nullable<BoundingInfo>;
  14683. _renderId: number;
  14684. subMeshes: SubMesh[];
  14685. _submeshesOctree: Octree<SubMesh>;
  14686. _intersectionsInProgress: AbstractMesh[];
  14687. _unIndexed: boolean;
  14688. _lightSources: Light[];
  14689. readonly _positions: Nullable<Vector3[]>;
  14690. _waitingActions: any;
  14691. _waitingFreezeWorldMatrix: Nullable<boolean>;
  14692. private _skeleton;
  14693. _bonesTransformMatrices: Nullable<Float32Array>;
  14694. skeleton: Nullable<Skeleton>;
  14695. constructor(name: string, scene?: Nullable<Scene>);
  14696. /**
  14697. * Returns the string "AbstractMesh"
  14698. */
  14699. getClassName(): string;
  14700. /**
  14701. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  14702. */
  14703. toString(fullDetails?: boolean): string;
  14704. _rebuild(): void;
  14705. _resyncLightSources(): void;
  14706. _resyncLighSource(light: Light): void;
  14707. _removeLightSource(light: Light): void;
  14708. private _markSubMeshesAsDirty(func);
  14709. _markSubMeshesAsLightDirty(): void;
  14710. _markSubMeshesAsAttributesDirty(): void;
  14711. _markSubMeshesAsMiscDirty(): void;
  14712. /**
  14713. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  14714. * Default : (1.0, 1.0, 1.0)
  14715. */
  14716. /**
  14717. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  14718. * Default : (1.0, 1.0, 1.0)
  14719. */
  14720. scaling: Vector3;
  14721. /**
  14722. * Disables the mesh edger rendering mode.
  14723. * Returns the AbstractMesh.
  14724. */
  14725. disableEdgesRendering(): AbstractMesh;
  14726. /**
  14727. * Enables the edge rendering mode on the mesh.
  14728. * This mode makes the mesh edges visible.
  14729. * Returns the AbstractMesh.
  14730. */
  14731. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  14732. /**
  14733. * Returns true if the mesh is blocked. Used by the class Mesh.
  14734. * Returns the boolean `false` by default.
  14735. */
  14736. readonly isBlocked: boolean;
  14737. /**
  14738. * Returns the mesh itself by default, used by the class Mesh.
  14739. * Returned type : AbstractMesh
  14740. */
  14741. getLOD(camera: Camera): AbstractMesh;
  14742. /**
  14743. * Returns 0 by default, used by the class Mesh.
  14744. * Returns an integer.
  14745. */
  14746. getTotalVertices(): number;
  14747. /**
  14748. * Returns null by default, used by the class Mesh.
  14749. * Returned type : integer array
  14750. */
  14751. getIndices(): Nullable<IndicesArray>;
  14752. /**
  14753. * Returns the array of the requested vertex data kind. Used by the class Mesh. Returns null here.
  14754. * Returned type : float array or Float32Array
  14755. */
  14756. getVerticesData(kind: string): Nullable<FloatArray>;
  14757. /**
  14758. * Sets the vertex data of the mesh geometry for the requested `kind`.
  14759. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  14760. * The `data` are either a numeric array either a Float32Array.
  14761. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  14762. * 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).
  14763. * Note that a new underlying VertexBuffer object is created each call.
  14764. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  14765. *
  14766. * Possible `kind` values :
  14767. * - BABYLON.VertexBuffer.PositionKind
  14768. * - BABYLON.VertexBuffer.UVKind
  14769. * - BABYLON.VertexBuffer.UV2Kind
  14770. * - BABYLON.VertexBuffer.UV3Kind
  14771. * - BABYLON.VertexBuffer.UV4Kind
  14772. * - BABYLON.VertexBuffer.UV5Kind
  14773. * - BABYLON.VertexBuffer.UV6Kind
  14774. * - BABYLON.VertexBuffer.ColorKind
  14775. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14776. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14777. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14778. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14779. *
  14780. * Returns the Mesh.
  14781. */
  14782. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  14783. /**
  14784. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  14785. * If the mesh has no geometry, it is simply returned as it is.
  14786. * The `data` are either a numeric array either a Float32Array.
  14787. * No new underlying VertexBuffer object is created.
  14788. * 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.
  14789. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  14790. *
  14791. * Possible `kind` values :
  14792. * - BABYLON.VertexBuffer.PositionKind
  14793. * - BABYLON.VertexBuffer.UVKind
  14794. * - BABYLON.VertexBuffer.UV2Kind
  14795. * - BABYLON.VertexBuffer.UV3Kind
  14796. * - BABYLON.VertexBuffer.UV4Kind
  14797. * - BABYLON.VertexBuffer.UV5Kind
  14798. * - BABYLON.VertexBuffer.UV6Kind
  14799. * - BABYLON.VertexBuffer.ColorKind
  14800. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14801. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14802. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14803. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14804. *
  14805. * Returns the Mesh.
  14806. */
  14807. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  14808. /**
  14809. * Sets the mesh indices.
  14810. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  14811. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  14812. * This method creates a new index buffer each call.
  14813. * Returns the Mesh.
  14814. */
  14815. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  14816. /** Returns false by default, used by the class Mesh.
  14817. * Returns a boolean
  14818. */
  14819. isVerticesDataPresent(kind: string): boolean;
  14820. /**
  14821. * Returns the mesh BoundingInfo object or creates a new one and returns it if undefined.
  14822. * Returns a BoundingInfo
  14823. */
  14824. getBoundingInfo(): BoundingInfo;
  14825. /**
  14826. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units).
  14827. * @param includeDescendants Take the hierarchy's bounding box instead of the mesh's bounding box.
  14828. */
  14829. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  14830. /**
  14831. * Sets a mesh new object BoundingInfo.
  14832. * Returns the AbstractMesh.
  14833. */
  14834. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  14835. readonly useBones: boolean;
  14836. _preActivate(): void;
  14837. _preActivateForIntermediateRendering(renderId: number): void;
  14838. _activate(renderId: number): void;
  14839. /**
  14840. * Returns the latest update of the World matrix
  14841. * Returns a Matrix.
  14842. */
  14843. getWorldMatrix(): Matrix;
  14844. /**
  14845. * Returns the latest update of the World matrix determinant.
  14846. */
  14847. protected _getWorldMatrixDeterminant(): number;
  14848. /**
  14849. * Perform relative position change from the point of view of behind the front of the mesh.
  14850. * This is performed taking into account the meshes current rotation, so you do not have to care.
  14851. * Supports definition of mesh facing forward or backward.
  14852. * @param {number} amountRight
  14853. * @param {number} amountUp
  14854. * @param {number} amountForward
  14855. *
  14856. * Returns the AbstractMesh.
  14857. */
  14858. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  14859. /**
  14860. * Calculate relative position change from the point of view of behind the front of the mesh.
  14861. * This is performed taking into account the meshes current rotation, so you do not have to care.
  14862. * Supports definition of mesh facing forward or backward.
  14863. * @param {number} amountRight
  14864. * @param {number} amountUp
  14865. * @param {number} amountForward
  14866. *
  14867. * Returns a new Vector3.
  14868. */
  14869. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  14870. /**
  14871. * Perform relative rotation change from the point of view of behind the front of the mesh.
  14872. * Supports definition of mesh facing forward or backward.
  14873. * @param {number} flipBack
  14874. * @param {number} twirlClockwise
  14875. * @param {number} tiltRight
  14876. *
  14877. * Returns the AbstractMesh.
  14878. */
  14879. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  14880. /**
  14881. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  14882. * Supports definition of mesh facing forward or backward.
  14883. * @param {number} flipBack
  14884. * @param {number} twirlClockwise
  14885. * @param {number} tiltRight
  14886. *
  14887. * Returns a new Vector3.
  14888. */
  14889. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  14890. /**
  14891. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  14892. * @param includeDescendants Include bounding info from descendants as well (true by default).
  14893. */
  14894. getHierarchyBoundingVectors(includeDescendants?: boolean): {
  14895. min: Vector3;
  14896. max: Vector3;
  14897. };
  14898. /**
  14899. * Updates the mesh BoundingInfo object and all its children BoundingInfo objects also.
  14900. * Returns the AbstractMesh.
  14901. */
  14902. _updateBoundingInfo(): AbstractMesh;
  14903. /**
  14904. * Update a mesh's children BoundingInfo objects only.
  14905. * Returns the AbstractMesh.
  14906. */
  14907. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  14908. protected _afterComputeWorldMatrix(): void;
  14909. /**
  14910. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14911. * A mesh is in the frustum if its bounding box intersects the frustum.
  14912. * Boolean returned.
  14913. */
  14914. isInFrustum(frustumPlanes: Plane[]): boolean;
  14915. /**
  14916. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  14917. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  14918. * Boolean returned.
  14919. */
  14920. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  14921. /**
  14922. * True if the mesh intersects another mesh or a SolidParticle object.
  14923. * 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)
  14924. * includeDescendants can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  14925. * Returns a boolean.
  14926. */
  14927. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  14928. /**
  14929. * Returns true if the passed point (Vector3) is inside the mesh bounding box.
  14930. * Returns a boolean.
  14931. */
  14932. intersectsPoint(point: Vector3): boolean;
  14933. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  14934. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14935. /**
  14936. * Returns the distance from the mesh to the active camera.
  14937. * Returns a float.
  14938. */
  14939. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14940. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  14941. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  14942. /**
  14943. * Property checkCollisions : Boolean, whether the camera should check the collisions against the mesh.
  14944. * Default `false`.
  14945. */
  14946. checkCollisions: boolean;
  14947. /**
  14948. * Gets Collider object used to compute collisions (not physics)
  14949. */
  14950. readonly collider: Collider;
  14951. moveWithCollisions(displacement: Vector3): AbstractMesh;
  14952. private _onCollisionPositionChange;
  14953. /**
  14954. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  14955. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree.
  14956. * Returns an Octree of submeshes.
  14957. */
  14958. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  14959. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  14960. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  14961. _checkCollision(collider: Collider): AbstractMesh;
  14962. _generatePointsArray(): boolean;
  14963. /**
  14964. * Checks if the passed Ray intersects with the mesh.
  14965. * Returns an object PickingInfo.
  14966. */
  14967. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  14968. /**
  14969. * Clones the mesh, used by the class Mesh.
  14970. * Just returns `null` for an AbstractMesh.
  14971. */
  14972. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  14973. /**
  14974. * Disposes all the mesh submeshes.
  14975. * Returns the AbstractMesh.
  14976. */
  14977. releaseSubMeshes(): AbstractMesh;
  14978. /**
  14979. * Disposes the AbstractMesh.
  14980. * By default, all the mesh children are also disposed unless the parameter `doNotRecurse` is set to `true`.
  14981. * Returns nothing.
  14982. */
  14983. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14984. /**
  14985. * Adds the passed mesh as a child to the current mesh.
  14986. * Returns the AbstractMesh.
  14987. */
  14988. addChild(mesh: AbstractMesh): AbstractMesh;
  14989. /**
  14990. * Removes the passed mesh from the current mesh children list.
  14991. * Returns the AbstractMesh.
  14992. */
  14993. removeChild(mesh: AbstractMesh): AbstractMesh;
  14994. /**
  14995. * Initialize the facet data arrays : facetNormals, facetPositions and facetPartitioning.
  14996. * Returns the AbstractMesh.
  14997. */
  14998. private _initFacetData();
  14999. /**
  15000. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  15001. * This method can be called within the render loop.
  15002. * 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.
  15003. * Returns the AbstractMesh.
  15004. */
  15005. updateFacetData(): AbstractMesh;
  15006. /**
  15007. * Returns the facetLocalNormals array.
  15008. * The normals are expressed in the mesh local space.
  15009. */
  15010. getFacetLocalNormals(): Vector3[];
  15011. /**
  15012. * Returns the facetLocalPositions array.
  15013. * The facet positions are expressed in the mesh local space.
  15014. */
  15015. getFacetLocalPositions(): Vector3[];
  15016. /**
  15017. * Returns the facetLocalPartioning array.
  15018. */
  15019. getFacetLocalPartitioning(): number[][];
  15020. /**
  15021. * Returns the i-th facet position in the world system.
  15022. * This method allocates a new Vector3 per call.
  15023. */
  15024. getFacetPosition(i: number): Vector3;
  15025. /**
  15026. * Sets the reference Vector3 with the i-th facet position in the world system.
  15027. * Returns the AbstractMesh.
  15028. */
  15029. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  15030. /**
  15031. * Returns the i-th facet normal in the world system.
  15032. * This method allocates a new Vector3 per call.
  15033. */
  15034. getFacetNormal(i: number): Vector3;
  15035. /**
  15036. * Sets the reference Vector3 with the i-th facet normal in the world system.
  15037. * Returns the AbstractMesh.
  15038. */
  15039. getFacetNormalToRef(i: number, ref: Vector3): this;
  15040. /**
  15041. * 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).
  15042. */
  15043. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  15044. /**
  15045. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found.
  15046. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) World projection on the facet.
  15047. * If checkFace is true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned.
  15048. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  15049. * 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.
  15050. */
  15051. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  15052. /**
  15053. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found.
  15054. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) local projection on the facet.
  15055. * If checkFace is true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned.
  15056. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  15057. * 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.
  15058. */
  15059. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  15060. /**
  15061. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  15062. */
  15063. getFacetDataParameters(): any;
  15064. /**
  15065. * Disables the feature FacetData and frees the related memory.
  15066. * Returns the AbstractMesh.
  15067. */
  15068. disableFacetData(): AbstractMesh;
  15069. /**
  15070. * Updates the AbstractMesh indices array. Actually, used by the Mesh object.
  15071. * Returns the mesh.
  15072. */
  15073. updateIndices(indices: IndicesArray): AbstractMesh;
  15074. /**
  15075. * The mesh Geometry. Actually used by the Mesh object.
  15076. * Returns a blank geometry object.
  15077. */
  15078. /**
  15079. * Creates new normals data for the mesh.
  15080. * @param updatable.
  15081. */
  15082. createNormals(updatable: boolean): void;
  15083. /**
  15084. * Align the mesh with a normal.
  15085. * Returns the mesh.
  15086. */
  15087. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  15088. protected checkOcclusionQuery(): void;
  15089. }
  15090. }
  15091. declare module BABYLON {
  15092. class Buffer {
  15093. private _engine;
  15094. private _buffer;
  15095. private _data;
  15096. private _updatable;
  15097. private _strideSize;
  15098. private _instanced;
  15099. constructor(engine: any, data: FloatArray, updatable: boolean, stride: number, postponeInternalCreation?: boolean, instanced?: boolean);
  15100. /**
  15101. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  15102. * @param kind defines the vertex buffer kind (position, normal, etc.)
  15103. * @param offset defines offset in the buffer (0 by default)
  15104. * @param size defines the size in floats of attributes (position is 3 for instance)
  15105. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  15106. * @param instanced defines if the vertex buffer contains indexed data
  15107. * @returns the new vertex buffer
  15108. */
  15109. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean): VertexBuffer;
  15110. isUpdatable(): boolean;
  15111. getData(): Nullable<FloatArray>;
  15112. getBuffer(): Nullable<WebGLBuffer>;
  15113. getStrideSize(): number;
  15114. create(data?: Nullable<FloatArray>): void;
  15115. _rebuild(): void;
  15116. update(data: FloatArray): void;
  15117. updateDirectly(data: Float32Array, offset: number, vertexCount?: number): void;
  15118. dispose(): void;
  15119. }
  15120. }
  15121. declare module BABYLON {
  15122. class CSG {
  15123. private polygons;
  15124. matrix: Matrix;
  15125. position: Vector3;
  15126. rotation: Vector3;
  15127. rotationQuaternion: Nullable<Quaternion>;
  15128. scaling: Vector3;
  15129. static FromMesh(mesh: Mesh): CSG;
  15130. private static FromPolygons(polygons);
  15131. clone(): CSG;
  15132. union(csg: CSG): CSG;
  15133. unionInPlace(csg: CSG): void;
  15134. subtract(csg: CSG): CSG;
  15135. subtractInPlace(csg: CSG): void;
  15136. intersect(csg: CSG): CSG;
  15137. intersectInPlace(csg: CSG): void;
  15138. inverse(): CSG;
  15139. inverseInPlace(): void;
  15140. copyTransformAttributes(csg: CSG): CSG;
  15141. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  15142. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  15143. }
  15144. }
  15145. declare module BABYLON {
  15146. /**
  15147. * Class used to store geometry data (vertex buffers + index buffer)
  15148. */
  15149. class Geometry implements IGetSetVerticesData {
  15150. /**
  15151. * Gets or sets the unique ID of the geometry
  15152. */
  15153. id: string;
  15154. /**
  15155. * Gets the delay loading state of the geometry (none by default which means not delayed)
  15156. */
  15157. delayLoadState: number;
  15158. /**
  15159. * Gets the file containing the data to load when running in delay load state
  15160. */
  15161. delayLoadingFile: Nullable<string>;
  15162. /**
  15163. * Callback called when the geometry is updated
  15164. */
  15165. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  15166. private _scene;
  15167. private _engine;
  15168. private _meshes;
  15169. private _totalVertices;
  15170. private _indices;
  15171. private _vertexBuffers;
  15172. private _isDisposed;
  15173. private _extend;
  15174. private _boundingBias;
  15175. /** @ignore */
  15176. _delayInfo: Array<string>;
  15177. private _indexBuffer;
  15178. private _indexBufferIsUpdatable;
  15179. /** @ignore */
  15180. _boundingInfo: Nullable<BoundingInfo>;
  15181. /** @ignore */
  15182. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  15183. /** @ignore */
  15184. _softwareSkinningRenderId: number;
  15185. private _vertexArrayObjects;
  15186. private _updatable;
  15187. /** @ignore */
  15188. _positions: Nullable<Vector3[]>;
  15189. /**
  15190. * 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
  15191. */
  15192. /**
  15193. * 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
  15194. */
  15195. boundingBias: Vector2;
  15196. /**
  15197. * Static function used to attach a new empty geometry to a mesh
  15198. * @param mesh defines the mesh to attach the geometry to
  15199. * @returns the new {BABYLON.Geometry}
  15200. */
  15201. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  15202. /**
  15203. * Creates a new geometry
  15204. * @param id defines the unique ID
  15205. * @param scene defines the hosting scene
  15206. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  15207. * @param updatable defines if geometry must be updatable (false by default)
  15208. * @param mesh defines the mesh that will be associated with the geometry
  15209. */
  15210. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  15211. /**
  15212. * Gets the current extend of the geometry
  15213. */
  15214. readonly extend: {
  15215. minimum: Vector3;
  15216. maximum: Vector3;
  15217. };
  15218. /**
  15219. * Gets the hosting scene
  15220. * @returns the hosting {BABYLON.Scene}
  15221. */
  15222. getScene(): Scene;
  15223. /**
  15224. * Gets the hosting engine
  15225. * @returns the hosting {BABYLON.Engine}
  15226. */
  15227. getEngine(): Engine;
  15228. /**
  15229. * Defines if the geometry is ready to use
  15230. * @returns true if the geometry is ready to be used
  15231. */
  15232. isReady(): boolean;
  15233. /**
  15234. * Gets a value indicating that the geometry should not be serialized
  15235. */
  15236. readonly doNotSerialize: boolean;
  15237. /** @ignore */
  15238. _rebuild(): void;
  15239. /**
  15240. * Affects all gemetry data in one call
  15241. * @param vertexData defines the geometry data
  15242. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  15243. */
  15244. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  15245. /**
  15246. * Set specific vertex data
  15247. * @param kind defines the data kind (Position, normal, etc...)
  15248. * @param data defines the vertex data to use
  15249. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  15250. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  15251. */
  15252. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  15253. /**
  15254. * Removes a specific vertex data
  15255. * @param kind defines the data kind (Position, normal, etc...)
  15256. */
  15257. removeVerticesData(kind: string): void;
  15258. /**
  15259. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  15260. * @param buffer defines the vertex buffer to use
  15261. */
  15262. setVerticesBuffer(buffer: VertexBuffer): void;
  15263. /**
  15264. * Update a specific vertex buffer
  15265. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  15266. * It will do nothing if the buffer is not updatable
  15267. * @param kind defines the data kind (Position, normal, etc...)
  15268. * @param data defines the data to use
  15269. * @param offset defines the offset in the target buffer where to store the data
  15270. */
  15271. updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void;
  15272. /**
  15273. * Update a specific vertex buffer
  15274. * This function will create a new buffer if the current one is not updatable
  15275. * @param kind defines the data kind (Position, normal, etc...)
  15276. * @param data defines the data to use
  15277. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  15278. */
  15279. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  15280. private updateBoundingInfo(updateExtends, data);
  15281. /** @ignore */
  15282. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  15283. /**
  15284. * Gets total number of vertices
  15285. * @returns the total number of vertices
  15286. */
  15287. getTotalVertices(): number;
  15288. /**
  15289. * Gets a specific vertex data attached to this geometry
  15290. * @param kind defines the data kind (Position, normal, etc...)
  15291. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  15292. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  15293. * @returns a float array containing vertex data
  15294. */
  15295. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  15296. /**
  15297. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  15298. * @param kind defines the data kind (Position, normal, etc...)
  15299. * @returns true if the vertex buffer with the specified kind is updatable
  15300. */
  15301. isVertexBufferUpdatable(kind: string): boolean;
  15302. /**
  15303. * Gets a specific vertex buffer
  15304. * @param kind defines the data kind (Position, normal, etc...)
  15305. * @returns a {BABYLON.VertexBuffer}
  15306. */
  15307. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  15308. /**
  15309. * Returns all vertex buffers
  15310. * @return an object holding all vertex buffers indexed by kind
  15311. */
  15312. getVertexBuffers(): Nullable<{
  15313. [key: string]: VertexBuffer;
  15314. }>;
  15315. /**
  15316. * Gets a boolean indicating if specific vertex buffer is present
  15317. * @param kind defines the data kind (Position, normal, etc...)
  15318. * @returns true if data is present
  15319. */
  15320. isVerticesDataPresent(kind: string): boolean;
  15321. /**
  15322. * Gets a list of all attached data kinds (Position, normal, etc...)
  15323. * @returns a list of string containing all kinds
  15324. */
  15325. getVerticesDataKinds(): string[];
  15326. /**
  15327. * Update index buffer
  15328. * @param indices defines the indices to store in the index buffer
  15329. * @param offset defines the offset in the target buffer where to store the data
  15330. */
  15331. updateIndices(indices: IndicesArray, offset?: number): void;
  15332. /**
  15333. * Creates a new index buffer
  15334. * @param indices defines the indices to store in the index buffer
  15335. * @param totalVertices defines the total number of vertices (could be null)
  15336. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  15337. */
  15338. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  15339. /**
  15340. * Return the total number of indices
  15341. * @returns the total number of indices
  15342. */
  15343. getTotalIndices(): number;
  15344. /**
  15345. * Gets the index buffer array
  15346. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  15347. * @returns the index buffer array
  15348. */
  15349. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  15350. /**
  15351. * Gets the index buffer
  15352. * @return the index buffer
  15353. */
  15354. getIndexBuffer(): Nullable<WebGLBuffer>;
  15355. /** @ignore */
  15356. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  15357. /**
  15358. * Release the associated resources for a specific mesh
  15359. * @param mesh defines the source mesh
  15360. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  15361. */
  15362. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  15363. /**
  15364. * Apply current geometry to a given mesh
  15365. * @param mesh defines the mesh to apply geometry to
  15366. */
  15367. applyToMesh(mesh: Mesh): void;
  15368. private updateExtend(data?, stride?);
  15369. private _applyToMesh(mesh);
  15370. private notifyUpdate(kind?);
  15371. /**
  15372. * Load the geometry if it was flagged as delay loaded
  15373. * @param scene defines the hosting scene
  15374. * @param onLoaded defines a callback called when the geometry is loaded
  15375. */
  15376. load(scene: Scene, onLoaded?: () => void): void;
  15377. private _queueLoad(scene, onLoaded?);
  15378. /**
  15379. * Invert the geometry to move from a right handed system to a left handed one.
  15380. */
  15381. toLeftHanded(): void;
  15382. /** @ignore */
  15383. _resetPointsArrayCache(): void;
  15384. /** @ignore */
  15385. _generatePointsArray(): boolean;
  15386. /**
  15387. * Gets a value indicating if the geometry is disposed
  15388. * @returns true if the geometry was disposed
  15389. */
  15390. isDisposed(): boolean;
  15391. private _disposeVertexArrayObjects();
  15392. /**
  15393. * Free all associated resources
  15394. */
  15395. dispose(): void;
  15396. /**
  15397. * Clone the current geometry into a new geometry
  15398. * @param id defines the unique ID of the new geometry
  15399. * @returns a new geometry object
  15400. */
  15401. copy(id: string): Geometry;
  15402. /**
  15403. * Serialize the current geometry info (and not the vertices data) into a JSON object
  15404. * @return a JSON representation of the current geometry data (without the vertices data)
  15405. */
  15406. serialize(): any;
  15407. private toNumberArray(origin);
  15408. /**
  15409. * Serialize all vertices data into a JSON oject
  15410. * @returns a JSON representation of the current geometry data
  15411. */
  15412. serializeVerticeData(): any;
  15413. /**
  15414. * Extracts a clone of a mesh geometry
  15415. * @param mesh defines the source mesh
  15416. * @param id defines the unique ID of the new geometry object
  15417. * @returns the new geometry object
  15418. */
  15419. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  15420. /**
  15421. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  15422. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  15423. * Be aware Math.random() could cause collisions, but:
  15424. * "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"
  15425. * @returns a string containing a new GUID
  15426. */
  15427. static RandomId(): string;
  15428. /** @ignore */
  15429. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  15430. private static _CleanMatricesWeights(parsedGeometry, mesh);
  15431. /**
  15432. * Create a new geometry from persisted data (Using .babylon file format)
  15433. * @param parsedVertexData defines the persisted data
  15434. * @param scene defines the hosting scene
  15435. * @param rootUrl defines the root url to use to load assets (like delayed data)
  15436. * @returns the new geometry object
  15437. */
  15438. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  15439. }
  15440. /**
  15441. * Abstract class used to provide common services for all typed geometries
  15442. */
  15443. class _PrimitiveGeometry extends Geometry {
  15444. private _canBeRegenerated;
  15445. private _beingRegenerated;
  15446. /**
  15447. * Creates a new typed geometry
  15448. * @param id defines the unique ID of the geometry
  15449. * @param scene defines the hosting scene
  15450. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15451. * @param mesh defines the hosting mesh (can be null)
  15452. */
  15453. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  15454. /**
  15455. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  15456. * @returns true if the geometry can be regenerated
  15457. */
  15458. canBeRegenerated(): boolean;
  15459. /**
  15460. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  15461. */
  15462. regenerate(): void;
  15463. /**
  15464. * Clone the geometry
  15465. * @param id defines the unique ID of the new geometry
  15466. * @returns the new geometry
  15467. */
  15468. asNewGeometry(id: string): Geometry;
  15469. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  15470. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  15471. /** @ignore */
  15472. _regenerateVertexData(): VertexData;
  15473. copy(id: string): Geometry;
  15474. serialize(): any;
  15475. }
  15476. /**
  15477. * Creates a ribbon geometry
  15478. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  15479. */
  15480. class RibbonGeometry extends _PrimitiveGeometry {
  15481. /**
  15482. * Defines the array of paths to use
  15483. */
  15484. pathArray: Vector3[][];
  15485. /**
  15486. * Defines if the last and first points of each path in your pathArray must be joined
  15487. */
  15488. closeArray: boolean;
  15489. /**
  15490. * Defines if the last and first points of each path in your pathArray must be joined
  15491. */
  15492. closePath: boolean;
  15493. /**
  15494. * Defines the offset between points
  15495. */
  15496. offset: number;
  15497. /**
  15498. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15499. */
  15500. side: number;
  15501. /**
  15502. * Creates a ribbon geometry
  15503. * @param id defines the unique ID of the geometry
  15504. * @param scene defines the hosting scene
  15505. * @param pathArray defines the array of paths to use
  15506. * @param closeArray defines if the last path and the first path must be joined
  15507. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  15508. * @param offset defines the offset between points
  15509. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15510. * @param mesh defines the hosting mesh (can be null)
  15511. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15512. */
  15513. constructor(id: string, scene: Scene,
  15514. /**
  15515. * Defines the array of paths to use
  15516. */
  15517. pathArray: Vector3[][],
  15518. /**
  15519. * Defines if the last and first points of each path in your pathArray must be joined
  15520. */
  15521. closeArray: boolean,
  15522. /**
  15523. * Defines if the last and first points of each path in your pathArray must be joined
  15524. */
  15525. closePath: boolean,
  15526. /**
  15527. * Defines the offset between points
  15528. */
  15529. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  15530. /**
  15531. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15532. */
  15533. side?: number);
  15534. /** @ignore */
  15535. _regenerateVertexData(): VertexData;
  15536. copy(id: string): Geometry;
  15537. }
  15538. /**
  15539. * Creates a box geometry
  15540. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  15541. */
  15542. class BoxGeometry extends _PrimitiveGeometry {
  15543. /**
  15544. * Defines the zise of the box (width, height and depth are the same)
  15545. */
  15546. size: number;
  15547. /**
  15548. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15549. */
  15550. side: number;
  15551. /**
  15552. * Creates a box geometry
  15553. * @param id defines the unique ID of the geometry
  15554. * @param scene defines the hosting scene
  15555. * @param size defines the zise of the box (width, height and depth are the same)
  15556. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15557. * @param mesh defines the hosting mesh (can be null)
  15558. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15559. */
  15560. constructor(id: string, scene: Scene,
  15561. /**
  15562. * Defines the zise of the box (width, height and depth are the same)
  15563. */
  15564. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  15565. /**
  15566. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15567. */
  15568. side?: number);
  15569. _regenerateVertexData(): VertexData;
  15570. copy(id: string): Geometry;
  15571. serialize(): any;
  15572. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  15573. }
  15574. /**
  15575. * Creates a sphere geometry
  15576. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  15577. */
  15578. class SphereGeometry extends _PrimitiveGeometry {
  15579. /**
  15580. * Defines the number of segments to use to create the sphere
  15581. */
  15582. segments: number;
  15583. /**
  15584. * Defines the diameter of the sphere
  15585. */
  15586. diameter: number;
  15587. /**
  15588. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15589. */
  15590. side: number;
  15591. /**
  15592. * Create a new sphere geometry
  15593. * @param id defines the unique ID of the geometry
  15594. * @param scene defines the hosting scene
  15595. * @param segments defines the number of segments to use to create the sphere
  15596. * @param diameter defines the diameter of the sphere
  15597. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15598. * @param mesh defines the hosting mesh (can be null)
  15599. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15600. */
  15601. constructor(id: string, scene: Scene,
  15602. /**
  15603. * Defines the number of segments to use to create the sphere
  15604. */
  15605. segments: number,
  15606. /**
  15607. * Defines the diameter of the sphere
  15608. */
  15609. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  15610. /**
  15611. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15612. */
  15613. side?: number);
  15614. _regenerateVertexData(): VertexData;
  15615. copy(id: string): Geometry;
  15616. serialize(): any;
  15617. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  15618. }
  15619. /**
  15620. * Creates a disc geometry
  15621. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  15622. */
  15623. class DiscGeometry extends _PrimitiveGeometry {
  15624. /**
  15625. * Defines the radius of the disc
  15626. */
  15627. radius: number;
  15628. /**
  15629. * Defines the tesselation factor to apply to the disc
  15630. */
  15631. tessellation: number;
  15632. /**
  15633. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15634. */
  15635. side: number;
  15636. /**
  15637. * Creates a new disc geometry
  15638. * @param id defines the unique ID of the geometry
  15639. * @param scene defines the hosting scene
  15640. * @param radius defines the radius of the disc
  15641. * @param tessellation defines the tesselation factor to apply to the disc
  15642. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15643. * @param mesh defines the hosting mesh (can be null)
  15644. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15645. */
  15646. constructor(id: string, scene: Scene,
  15647. /**
  15648. * Defines the radius of the disc
  15649. */
  15650. radius: number,
  15651. /**
  15652. * Defines the tesselation factor to apply to the disc
  15653. */
  15654. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  15655. /**
  15656. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15657. */
  15658. side?: number);
  15659. _regenerateVertexData(): VertexData;
  15660. copy(id: string): Geometry;
  15661. }
  15662. /**
  15663. * Creates a new cylinder geometry
  15664. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  15665. */
  15666. class CylinderGeometry extends _PrimitiveGeometry {
  15667. /**
  15668. * Defines the height of the cylinder
  15669. */
  15670. height: number;
  15671. /**
  15672. * Defines the diameter of the cylinder's top cap
  15673. */
  15674. diameterTop: number;
  15675. /**
  15676. * Defines the diameter of the cylinder's bottom cap
  15677. */
  15678. diameterBottom: number;
  15679. /**
  15680. * Defines the tessellation factor to apply to the cylinder
  15681. */
  15682. tessellation: number;
  15683. /**
  15684. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  15685. */
  15686. subdivisions: number;
  15687. /**
  15688. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15689. */
  15690. side: number;
  15691. /**
  15692. * Creates a new cylinder geometry
  15693. * @param id defines the unique ID of the geometry
  15694. * @param scene defines the hosting scene
  15695. * @param height defines the height of the cylinder
  15696. * @param diameterTop defines the diameter of the cylinder's top cap
  15697. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  15698. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  15699. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  15700. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15701. * @param mesh defines the hosting mesh (can be null)
  15702. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15703. */
  15704. constructor(id: string, scene: Scene,
  15705. /**
  15706. * Defines the height of the cylinder
  15707. */
  15708. height: number,
  15709. /**
  15710. * Defines the diameter of the cylinder's top cap
  15711. */
  15712. diameterTop: number,
  15713. /**
  15714. * Defines the diameter of the cylinder's bottom cap
  15715. */
  15716. diameterBottom: number,
  15717. /**
  15718. * Defines the tessellation factor to apply to the cylinder
  15719. */
  15720. tessellation: number,
  15721. /**
  15722. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  15723. */
  15724. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  15725. /**
  15726. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15727. */
  15728. side?: number);
  15729. _regenerateVertexData(): VertexData;
  15730. copy(id: string): Geometry;
  15731. serialize(): any;
  15732. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  15733. }
  15734. /**
  15735. * Creates a new torus geometry
  15736. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  15737. */
  15738. class TorusGeometry extends _PrimitiveGeometry {
  15739. /**
  15740. * Defines the diameter of the torus
  15741. */
  15742. diameter: number;
  15743. /**
  15744. * Defines the thickness of the torus (ie. internal diameter)
  15745. */
  15746. thickness: number;
  15747. /**
  15748. * Defines the tesselation factor to apply to the torus
  15749. */
  15750. tessellation: number;
  15751. /**
  15752. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15753. */
  15754. side: number;
  15755. /**
  15756. * Creates a new torus geometry
  15757. * @param id defines the unique ID of the geometry
  15758. * @param scene defines the hosting scene
  15759. * @param diameter defines the diameter of the torus
  15760. * @param thickness defines the thickness of the torus (ie. internal diameter)
  15761. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  15762. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15763. * @param mesh defines the hosting mesh (can be null)
  15764. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15765. */
  15766. constructor(id: string, scene: Scene,
  15767. /**
  15768. * Defines the diameter of the torus
  15769. */
  15770. diameter: number,
  15771. /**
  15772. * Defines the thickness of the torus (ie. internal diameter)
  15773. */
  15774. thickness: number,
  15775. /**
  15776. * Defines the tesselation factor to apply to the torus
  15777. */
  15778. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  15779. /**
  15780. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15781. */
  15782. side?: number);
  15783. _regenerateVertexData(): VertexData;
  15784. copy(id: string): Geometry;
  15785. serialize(): any;
  15786. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  15787. }
  15788. /**
  15789. * Creates a new ground geometry
  15790. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  15791. */
  15792. class GroundGeometry extends _PrimitiveGeometry {
  15793. /**
  15794. * Defines the width of the ground
  15795. */
  15796. width: number;
  15797. /**
  15798. * Defines the height of the ground
  15799. */
  15800. height: number;
  15801. /**
  15802. * Defines the subdivisions to apply to the ground
  15803. */
  15804. subdivisions: number;
  15805. /**
  15806. * Creates a new ground geometry
  15807. * @param id defines the unique ID of the geometry
  15808. * @param scene defines the hosting scene
  15809. * @param width defines the width of the ground
  15810. * @param height defines the height of the ground
  15811. * @param subdivisions defines the subdivisions to apply to the ground
  15812. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15813. * @param mesh defines the hosting mesh (can be null)
  15814. */
  15815. constructor(id: string, scene: Scene,
  15816. /**
  15817. * Defines the width of the ground
  15818. */
  15819. width: number,
  15820. /**
  15821. * Defines the height of the ground
  15822. */
  15823. height: number,
  15824. /**
  15825. * Defines the subdivisions to apply to the ground
  15826. */
  15827. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  15828. _regenerateVertexData(): VertexData;
  15829. copy(id: string): Geometry;
  15830. serialize(): any;
  15831. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  15832. }
  15833. /**
  15834. * Creates a tiled ground geometry
  15835. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  15836. */
  15837. class TiledGroundGeometry extends _PrimitiveGeometry {
  15838. /**
  15839. * Defines the minimum value on X axis
  15840. */
  15841. xmin: number;
  15842. /**
  15843. * Defines the minimum value on Z axis
  15844. */
  15845. zmin: number;
  15846. /**
  15847. * Defines the maximum value on X axis
  15848. */
  15849. xmax: number;
  15850. /**
  15851. * Defines the maximum value on Z axis
  15852. */
  15853. zmax: number;
  15854. /**
  15855. * Defines the subdivisions to apply to the ground
  15856. */
  15857. subdivisions: {
  15858. w: number;
  15859. h: number;
  15860. };
  15861. /**
  15862. * Defines the precision to use when computing the tiles
  15863. */
  15864. precision: {
  15865. w: number;
  15866. h: number;
  15867. };
  15868. /**
  15869. * Creates a tiled ground geometry
  15870. * @param id defines the unique ID of the geometry
  15871. * @param scene defines the hosting scene
  15872. * @param xmin defines the minimum value on X axis
  15873. * @param zmin defines the minimum value on Z axis
  15874. * @param xmax defines the maximum value on X axis
  15875. * @param zmax defines the maximum value on Z axis
  15876. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  15877. * @param precision defines the precision to use when computing the tiles
  15878. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15879. * @param mesh defines the hosting mesh (can be null)
  15880. */
  15881. constructor(id: string, scene: Scene,
  15882. /**
  15883. * Defines the minimum value on X axis
  15884. */
  15885. xmin: number,
  15886. /**
  15887. * Defines the minimum value on Z axis
  15888. */
  15889. zmin: number,
  15890. /**
  15891. * Defines the maximum value on X axis
  15892. */
  15893. xmax: number,
  15894. /**
  15895. * Defines the maximum value on Z axis
  15896. */
  15897. zmax: number,
  15898. /**
  15899. * Defines the subdivisions to apply to the ground
  15900. */
  15901. subdivisions: {
  15902. w: number;
  15903. h: number;
  15904. },
  15905. /**
  15906. * Defines the precision to use when computing the tiles
  15907. */
  15908. precision: {
  15909. w: number;
  15910. h: number;
  15911. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  15912. _regenerateVertexData(): VertexData;
  15913. copy(id: string): Geometry;
  15914. }
  15915. /**
  15916. * Creates a plane geometry
  15917. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  15918. */
  15919. class PlaneGeometry extends _PrimitiveGeometry {
  15920. /**
  15921. * Defines the size of the plane (width === height)
  15922. */
  15923. size: number;
  15924. /**
  15925. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15926. */
  15927. side: number;
  15928. /**
  15929. * Creates a plane geometry
  15930. * @param id defines the unique ID of the geometry
  15931. * @param scene defines the hosting scene
  15932. * @param size defines the size of the plane (width === height)
  15933. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15934. * @param mesh defines the hosting mesh (can be null)
  15935. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15936. */
  15937. constructor(id: string, scene: Scene,
  15938. /**
  15939. * Defines the size of the plane (width === height)
  15940. */
  15941. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  15942. /**
  15943. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15944. */
  15945. side?: number);
  15946. _regenerateVertexData(): VertexData;
  15947. copy(id: string): Geometry;
  15948. serialize(): any;
  15949. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  15950. }
  15951. /**
  15952. * Creates a torus knot geometry
  15953. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  15954. */
  15955. class TorusKnotGeometry extends _PrimitiveGeometry {
  15956. /**
  15957. * Defines the radius of the torus knot
  15958. */
  15959. radius: number;
  15960. /**
  15961. * Defines the thickness of the torus knot tube
  15962. */
  15963. tube: number;
  15964. /**
  15965. * Defines the number of radial segments
  15966. */
  15967. radialSegments: number;
  15968. /**
  15969. * Defines the number of tubular segments
  15970. */
  15971. tubularSegments: number;
  15972. /**
  15973. * Defines the first number of windings
  15974. */
  15975. p: number;
  15976. /**
  15977. * Defines the second number of windings
  15978. */
  15979. q: number;
  15980. /**
  15981. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15982. */
  15983. side: number;
  15984. /**
  15985. * Creates a torus knot geometry
  15986. * @param id defines the unique ID of the geometry
  15987. * @param scene defines the hosting scene
  15988. * @param radius defines the radius of the torus knot
  15989. * @param tube defines the thickness of the torus knot tube
  15990. * @param radialSegments defines the number of radial segments
  15991. * @param tubularSegments defines the number of tubular segments
  15992. * @param p defines the first number of windings
  15993. * @param q defines the second number of windings
  15994. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  15995. * @param mesh defines the hosting mesh (can be null)
  15996. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  15997. */
  15998. constructor(id: string, scene: Scene,
  15999. /**
  16000. * Defines the radius of the torus knot
  16001. */
  16002. radius: number,
  16003. /**
  16004. * Defines the thickness of the torus knot tube
  16005. */
  16006. tube: number,
  16007. /**
  16008. * Defines the number of radial segments
  16009. */
  16010. radialSegments: number,
  16011. /**
  16012. * Defines the number of tubular segments
  16013. */
  16014. tubularSegments: number,
  16015. /**
  16016. * Defines the first number of windings
  16017. */
  16018. p: number,
  16019. /**
  16020. * Defines the second number of windings
  16021. */
  16022. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  16023. /**
  16024. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16025. */
  16026. side?: number);
  16027. _regenerateVertexData(): VertexData;
  16028. copy(id: string): Geometry;
  16029. serialize(): any;
  16030. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  16031. }
  16032. }
  16033. declare module BABYLON {
  16034. class GroundMesh extends Mesh {
  16035. generateOctree: boolean;
  16036. private _heightQuads;
  16037. _subdivisionsX: number;
  16038. _subdivisionsY: number;
  16039. _width: number;
  16040. _height: number;
  16041. _minX: number;
  16042. _maxX: number;
  16043. _minZ: number;
  16044. _maxZ: number;
  16045. constructor(name: string, scene: Scene);
  16046. getClassName(): string;
  16047. readonly subdivisions: number;
  16048. readonly subdivisionsX: number;
  16049. readonly subdivisionsY: number;
  16050. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  16051. /**
  16052. * Returns a height (y) value in the Worl system :
  16053. * the ground altitude at the coordinates (x, z) expressed in the World system.
  16054. * Returns the ground y position if (x, z) are outside the ground surface.
  16055. */
  16056. getHeightAtCoordinates(x: number, z: number): number;
  16057. /**
  16058. * Returns a normalized vector (Vector3) orthogonal to the ground
  16059. * at the ground coordinates (x, z) expressed in the World system.
  16060. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  16061. */
  16062. getNormalAtCoordinates(x: number, z: number): Vector3;
  16063. /**
  16064. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  16065. * at the ground coordinates (x, z) expressed in the World system.
  16066. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  16067. * Returns the GroundMesh.
  16068. */
  16069. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  16070. /**
  16071. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  16072. * if the ground has been updated.
  16073. * This can be used in the render loop.
  16074. * Returns the GroundMesh.
  16075. */
  16076. updateCoordinateHeights(): GroundMesh;
  16077. private _getFacetAt(x, z);
  16078. private _initHeightQuads();
  16079. private _computeHeightQuads();
  16080. serialize(serializationObject: any): void;
  16081. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  16082. }
  16083. }
  16084. declare module BABYLON {
  16085. /**
  16086. * Creates an instance based on a source mesh.
  16087. */
  16088. class InstancedMesh extends AbstractMesh {
  16089. private _sourceMesh;
  16090. private _currentLOD;
  16091. constructor(name: string, source: Mesh);
  16092. /**
  16093. * Returns the string "InstancedMesh".
  16094. */
  16095. getClassName(): string;
  16096. readonly receiveShadows: boolean;
  16097. readonly material: Nullable<Material>;
  16098. readonly visibility: number;
  16099. readonly skeleton: Nullable<Skeleton>;
  16100. readonly renderingGroupId: number;
  16101. /**
  16102. * Returns the total number of vertices (integer).
  16103. */
  16104. getTotalVertices(): number;
  16105. readonly sourceMesh: Mesh;
  16106. /**
  16107. * Is this node ready to be used/rendered
  16108. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16109. * @return {boolean} is it ready
  16110. */
  16111. isReady(completeCheck?: boolean): boolean;
  16112. /**
  16113. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16114. */
  16115. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16116. /**
  16117. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16118. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16119. * The `data` are either a numeric array either a Float32Array.
  16120. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16121. * 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).
  16122. * Note that a new underlying VertexBuffer object is created each call.
  16123. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16124. *
  16125. * Possible `kind` values :
  16126. * - BABYLON.VertexBuffer.PositionKind
  16127. * - BABYLON.VertexBuffer.UVKind
  16128. * - BABYLON.VertexBuffer.UV2Kind
  16129. * - BABYLON.VertexBuffer.UV3Kind
  16130. * - BABYLON.VertexBuffer.UV4Kind
  16131. * - BABYLON.VertexBuffer.UV5Kind
  16132. * - BABYLON.VertexBuffer.UV6Kind
  16133. * - BABYLON.VertexBuffer.ColorKind
  16134. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16135. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16136. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16137. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16138. *
  16139. * Returns the Mesh.
  16140. */
  16141. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16142. /**
  16143. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16144. * If the mesh has no geometry, it is simply returned as it is.
  16145. * The `data` are either a numeric array either a Float32Array.
  16146. * No new underlying VertexBuffer object is created.
  16147. * 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.
  16148. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16149. *
  16150. * Possible `kind` values :
  16151. * - BABYLON.VertexBuffer.PositionKind
  16152. * - BABYLON.VertexBuffer.UVKind
  16153. * - BABYLON.VertexBuffer.UV2Kind
  16154. * - BABYLON.VertexBuffer.UV3Kind
  16155. * - BABYLON.VertexBuffer.UV4Kind
  16156. * - BABYLON.VertexBuffer.UV5Kind
  16157. * - BABYLON.VertexBuffer.UV6Kind
  16158. * - BABYLON.VertexBuffer.ColorKind
  16159. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16160. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16161. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16162. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16163. *
  16164. * Returns the Mesh.
  16165. */
  16166. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16167. /**
  16168. * Sets the mesh indices.
  16169. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16170. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16171. * This method creates a new index buffer each call.
  16172. * Returns the Mesh.
  16173. */
  16174. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16175. /**
  16176. * Boolean : True if the mesh owns the requested kind of data.
  16177. */
  16178. isVerticesDataPresent(kind: string): boolean;
  16179. /**
  16180. * Returns an array of indices (IndicesArray).
  16181. */
  16182. getIndices(): Nullable<IndicesArray>;
  16183. readonly _positions: Nullable<Vector3[]>;
  16184. /**
  16185. * Sets a new updated BoundingInfo to the mesh.
  16186. * Returns the mesh.
  16187. */
  16188. refreshBoundingInfo(): InstancedMesh;
  16189. _preActivate(): InstancedMesh;
  16190. _activate(renderId: number): InstancedMesh;
  16191. /**
  16192. * Returns the current associated LOD AbstractMesh.
  16193. */
  16194. getLOD(camera: Camera): AbstractMesh;
  16195. _syncSubMeshes(): InstancedMesh;
  16196. _generatePointsArray(): boolean;
  16197. /**
  16198. * Creates a new InstancedMesh from the current mesh.
  16199. * - name (string) : the cloned mesh name
  16200. * - newParent (optional Node) : the optional Node to parent the clone to.
  16201. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16202. *
  16203. * Returns the clone.
  16204. */
  16205. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16206. /**
  16207. * Disposes the InstancedMesh.
  16208. * Returns nothing.
  16209. */
  16210. dispose(doNotRecurse?: boolean): void;
  16211. }
  16212. }
  16213. declare module BABYLON {
  16214. class LinesMesh extends Mesh {
  16215. useVertexColor: boolean | undefined;
  16216. useVertexAlpha: boolean | undefined;
  16217. color: Color3;
  16218. alpha: number;
  16219. /**
  16220. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16221. * This margin is expressed in world space coordinates, so its value may vary.
  16222. * Default value is 0.1
  16223. * @returns the intersection Threshold value.
  16224. */
  16225. /**
  16226. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16227. * This margin is expressed in world space coordinates, so its value may vary.
  16228. * @param value the new threshold to apply
  16229. */
  16230. intersectionThreshold: number;
  16231. private _intersectionThreshold;
  16232. private _colorShader;
  16233. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  16234. /**
  16235. * Returns the string "LineMesh"
  16236. */
  16237. getClassName(): string;
  16238. material: Material;
  16239. readonly checkCollisions: boolean;
  16240. createInstance(name: string): InstancedMesh;
  16241. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16242. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16243. dispose(doNotRecurse?: boolean): void;
  16244. /**
  16245. * Returns a new LineMesh object cloned from the current one.
  16246. */
  16247. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16248. }
  16249. }
  16250. declare module BABYLON {
  16251. class _InstancesBatch {
  16252. mustReturn: boolean;
  16253. visibleInstances: Nullable<InstancedMesh[]>[];
  16254. renderSelf: boolean[];
  16255. }
  16256. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  16257. static _FRONTSIDE: number;
  16258. static _BACKSIDE: number;
  16259. static _DOUBLESIDE: number;
  16260. static _DEFAULTSIDE: number;
  16261. static _NO_CAP: number;
  16262. static _CAP_START: number;
  16263. static _CAP_END: number;
  16264. static _CAP_ALL: number;
  16265. /**
  16266. * Mesh side orientation : usually the external or front surface
  16267. */
  16268. static readonly FRONTSIDE: number;
  16269. /**
  16270. * Mesh side orientation : usually the internal or back surface
  16271. */
  16272. static readonly BACKSIDE: number;
  16273. /**
  16274. * Mesh side orientation : both internal and external or front and back surfaces
  16275. */
  16276. static readonly DOUBLESIDE: number;
  16277. /**
  16278. * Mesh side orientation : by default, `FRONTSIDE`
  16279. */
  16280. static readonly DEFAULTSIDE: number;
  16281. /**
  16282. * Mesh cap setting : no cap
  16283. */
  16284. static readonly NO_CAP: number;
  16285. /**
  16286. * Mesh cap setting : one cap at the beginning of the mesh
  16287. */
  16288. static readonly CAP_START: number;
  16289. /**
  16290. * Mesh cap setting : one cap at the end of the mesh
  16291. */
  16292. static readonly CAP_END: number;
  16293. /**
  16294. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  16295. */
  16296. static readonly CAP_ALL: number;
  16297. /**
  16298. * An event triggered before rendering the mesh
  16299. * @type {BABYLON.Observable}
  16300. */
  16301. onBeforeRenderObservable: Observable<Mesh>;
  16302. /**
  16303. * An event triggered after rendering the mesh
  16304. * @type {BABYLON.Observable}
  16305. */
  16306. onAfterRenderObservable: Observable<Mesh>;
  16307. /**
  16308. * An event triggered before drawing the mesh
  16309. * @type {BABYLON.Observable}
  16310. */
  16311. onBeforeDrawObservable: Observable<Mesh>;
  16312. private _onBeforeDrawObserver;
  16313. onBeforeDraw: () => void;
  16314. delayLoadState: number;
  16315. instances: InstancedMesh[];
  16316. delayLoadingFile: string;
  16317. _binaryInfo: any;
  16318. private _LODLevels;
  16319. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  16320. private _morphTargetManager;
  16321. morphTargetManager: Nullable<MorphTargetManager>;
  16322. _geometry: Nullable<Geometry>;
  16323. _delayInfo: Array<string>;
  16324. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  16325. _visibleInstances: any;
  16326. private _renderIdForInstances;
  16327. private _batchCache;
  16328. private _instancesBufferSize;
  16329. private _instancesBuffer;
  16330. private _instancesData;
  16331. private _overridenInstanceCount;
  16332. private _effectiveMaterial;
  16333. _shouldGenerateFlatShading: boolean;
  16334. private _preActivateId;
  16335. _originalBuilderSideOrientation: number;
  16336. overrideMaterialSideOrientation: Nullable<number>;
  16337. private _areNormalsFrozen;
  16338. private _sourcePositions;
  16339. private _sourceNormals;
  16340. private _source;
  16341. readonly source: Nullable<Mesh>;
  16342. isUnIndexed: boolean;
  16343. /**
  16344. * @constructor
  16345. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  16346. * @param {Scene} scene The scene to add this mesh to.
  16347. * @param {Node} parent The parent of this mesh, if it has one
  16348. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  16349. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16350. * When false, achieved by calling a clone(), also passing False.
  16351. * This will make creation of children, recursive.
  16352. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  16353. */
  16354. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  16355. /**
  16356. * Returns the string "Mesh".
  16357. */
  16358. getClassName(): string;
  16359. /**
  16360. * Returns a string.
  16361. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  16362. */
  16363. toString(fullDetails?: boolean): string;
  16364. /**
  16365. * True if the mesh has some Levels Of Details (LOD).
  16366. * Returns a boolean.
  16367. */
  16368. readonly hasLODLevels: boolean;
  16369. /**
  16370. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  16371. * @returns an array of {BABYLON.MeshLODLevel}
  16372. */
  16373. getLODLevels(): MeshLODLevel[];
  16374. private _sortLODLevels();
  16375. /**
  16376. * Add a mesh as LOD level triggered at the given distance.
  16377. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  16378. * @param {number} distance The distance from the center of the object to show this level
  16379. * @param {Mesh} mesh The mesh to be added as LOD level
  16380. * @return {Mesh} This mesh (for chaining)
  16381. */
  16382. addLODLevel(distance: number, mesh: Mesh): Mesh;
  16383. /**
  16384. * Returns the LOD level mesh at the passed distance or null if not found.
  16385. * It is related to the method `addLODLevel(distance, mesh)`.
  16386. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  16387. * Returns an object Mesh or `null`.
  16388. */
  16389. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  16390. /**
  16391. * Remove a mesh from the LOD array
  16392. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  16393. * @param {Mesh} mesh The mesh to be removed.
  16394. * @return {Mesh} This mesh (for chaining)
  16395. */
  16396. removeLODLevel(mesh: Mesh): Mesh;
  16397. /**
  16398. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  16399. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  16400. */
  16401. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  16402. /**
  16403. * Returns the mesh internal Geometry object.
  16404. */
  16405. readonly geometry: Nullable<Geometry>;
  16406. /**
  16407. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  16408. */
  16409. getTotalVertices(): number;
  16410. /**
  16411. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  16412. * 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.
  16413. * You can force the copy with forceCopy === true
  16414. * Returns null if the mesh has no geometry or no vertex buffer.
  16415. * Possible `kind` values :
  16416. * - BABYLON.VertexBuffer.PositionKind
  16417. * - BABYLON.VertexBuffer.UVKind
  16418. * - BABYLON.VertexBuffer.UV2Kind
  16419. * - BABYLON.VertexBuffer.UV3Kind
  16420. * - BABYLON.VertexBuffer.UV4Kind
  16421. * - BABYLON.VertexBuffer.UV5Kind
  16422. * - BABYLON.VertexBuffer.UV6Kind
  16423. * - BABYLON.VertexBuffer.ColorKind
  16424. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16425. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16426. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16427. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16428. */
  16429. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  16430. /**
  16431. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  16432. * Returns `null` if the mesh has no geometry.
  16433. * Possible `kind` values :
  16434. * - BABYLON.VertexBuffer.PositionKind
  16435. * - BABYLON.VertexBuffer.UVKind
  16436. * - BABYLON.VertexBuffer.UV2Kind
  16437. * - BABYLON.VertexBuffer.UV3Kind
  16438. * - BABYLON.VertexBuffer.UV4Kind
  16439. * - BABYLON.VertexBuffer.UV5Kind
  16440. * - BABYLON.VertexBuffer.UV6Kind
  16441. * - BABYLON.VertexBuffer.ColorKind
  16442. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16443. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16444. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16445. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16446. */
  16447. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  16448. /**
  16449. * Returns a boolean depending on the existence of the Vertex Data for the requested `kind`.
  16450. * Possible `kind` values :
  16451. * - BABYLON.VertexBuffer.PositionKind
  16452. * - BABYLON.VertexBuffer.UVKind
  16453. * - BABYLON.VertexBuffer.UV2Kind
  16454. * - BABYLON.VertexBuffer.UV3Kind
  16455. * - BABYLON.VertexBuffer.UV4Kind
  16456. * - BABYLON.VertexBuffer.UV5Kind
  16457. * - BABYLON.VertexBuffer.UV6Kind
  16458. * - BABYLON.VertexBuffer.ColorKind
  16459. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16460. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16461. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16462. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16463. */
  16464. isVerticesDataPresent(kind: string): boolean;
  16465. /**
  16466. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  16467. * Possible `kind` values :
  16468. * - BABYLON.VertexBuffer.PositionKind
  16469. * - BABYLON.VertexBuffer.UVKind
  16470. * - BABYLON.VertexBuffer.UV2Kind
  16471. * - BABYLON.VertexBuffer.UV3Kind
  16472. * - BABYLON.VertexBuffer.UV4Kind
  16473. * - BABYLON.VertexBuffer.UV5Kind
  16474. * - BABYLON.VertexBuffer.UV6Kind
  16475. * - BABYLON.VertexBuffer.ColorKind
  16476. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16477. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16478. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16479. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16480. */
  16481. isVertexBufferUpdatable(kind: string): boolean;
  16482. /**
  16483. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  16484. * Possible `kind` values :
  16485. * - BABYLON.VertexBuffer.PositionKind
  16486. * - BABYLON.VertexBuffer.UVKind
  16487. * - BABYLON.VertexBuffer.UV2Kind
  16488. * - BABYLON.VertexBuffer.UV3Kind
  16489. * - BABYLON.VertexBuffer.UV4Kind
  16490. * - BABYLON.VertexBuffer.UV5Kind
  16491. * - BABYLON.VertexBuffer.UV6Kind
  16492. * - BABYLON.VertexBuffer.ColorKind
  16493. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16494. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16495. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16496. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16497. */
  16498. getVerticesDataKinds(): string[];
  16499. /**
  16500. * Returns a positive integer : the total number of indices in this mesh geometry.
  16501. * Returns zero if the mesh has no geometry.
  16502. */
  16503. getTotalIndices(): number;
  16504. /**
  16505. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16506. * 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.
  16507. * Returns an empty array if the mesh has no geometry.
  16508. */
  16509. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  16510. readonly isBlocked: boolean;
  16511. /**
  16512. * Determine if the current mesh is ready to be rendered
  16513. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16514. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  16515. * @returns true if all associated assets are ready (material, textures, shaders)
  16516. */
  16517. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  16518. /**
  16519. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  16520. * This property is pertinent only for updatable parametric shapes.
  16521. */
  16522. readonly areNormalsFrozen: boolean;
  16523. /**
  16524. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  16525. * It has no effect at all on other shapes.
  16526. * It prevents the mesh normals from being recomputed on next `positions` array update.
  16527. * Returns the Mesh.
  16528. */
  16529. freezeNormals(): Mesh;
  16530. /**
  16531. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  16532. * It has no effect at all on other shapes.
  16533. * It reactivates the mesh normals computation if it was previously frozen.
  16534. * Returns the Mesh.
  16535. */
  16536. unfreezeNormals(): Mesh;
  16537. /**
  16538. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  16539. */
  16540. overridenInstanceCount: number;
  16541. _preActivate(): Mesh;
  16542. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16543. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  16544. /**
  16545. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16546. * This means the mesh underlying bounding box and sphere are recomputed.
  16547. * Returns the Mesh.
  16548. */
  16549. refreshBoundingInfo(): Mesh;
  16550. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  16551. private _getPositionData(applySkeleton);
  16552. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  16553. subdivide(count: number): void;
  16554. /**
  16555. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16556. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16557. * The `data` are either a numeric array either a Float32Array.
  16558. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16559. * 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).
  16560. * Note that a new underlying VertexBuffer object is created each call.
  16561. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16562. *
  16563. * Possible `kind` values :
  16564. * - BABYLON.VertexBuffer.PositionKind
  16565. * - BABYLON.VertexBuffer.UVKind
  16566. * - BABYLON.VertexBuffer.UV2Kind
  16567. * - BABYLON.VertexBuffer.UV3Kind
  16568. * - BABYLON.VertexBuffer.UV4Kind
  16569. * - BABYLON.VertexBuffer.UV5Kind
  16570. * - BABYLON.VertexBuffer.UV6Kind
  16571. * - BABYLON.VertexBuffer.ColorKind
  16572. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16573. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16574. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16575. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16576. *
  16577. * Returns the Mesh.
  16578. */
  16579. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16580. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  16581. /**
  16582. * Sets the mesh VertexBuffer.
  16583. * Returns the Mesh.
  16584. */
  16585. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  16586. /**
  16587. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16588. * If the mesh has no geometry, it is simply returned as it is.
  16589. * The `data` are either a numeric array either a Float32Array.
  16590. * No new underlying VertexBuffer object is created.
  16591. * 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.
  16592. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16593. *
  16594. * Possible `kind` values :
  16595. * - BABYLON.VertexBuffer.PositionKind
  16596. * - BABYLON.VertexBuffer.UVKind
  16597. * - BABYLON.VertexBuffer.UV2Kind
  16598. * - BABYLON.VertexBuffer.UV3Kind
  16599. * - BABYLON.VertexBuffer.UV4Kind
  16600. * - BABYLON.VertexBuffer.UV5Kind
  16601. * - BABYLON.VertexBuffer.UV6Kind
  16602. * - BABYLON.VertexBuffer.ColorKind
  16603. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16604. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16605. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16606. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16607. *
  16608. * Returns the Mesh.
  16609. */
  16610. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16611. /**
  16612. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  16613. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  16614. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  16615. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  16616. * Returns the Mesh.
  16617. */
  16618. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  16619. /**
  16620. * Creates a un-shared specific occurence of the geometry for the mesh.
  16621. * Returns the Mesh.
  16622. */
  16623. makeGeometryUnique(): Mesh;
  16624. /**
  16625. * Sets the mesh indices.
  16626. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16627. * Type is Uint16Array by default unless the mesh has more than 65536 vertices.
  16628. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16629. * This method creates a new index buffer each call.
  16630. * Returns the Mesh.
  16631. */
  16632. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  16633. /**
  16634. * Update the current index buffer
  16635. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  16636. * Returns the Mesh.
  16637. */
  16638. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  16639. /**
  16640. * Invert the geometry to move from a right handed system to a left handed one.
  16641. * Returns the Mesh.
  16642. */
  16643. toLeftHanded(): Mesh;
  16644. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16645. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  16646. /**
  16647. * Registers for this mesh a javascript function called just before the rendering process.
  16648. * This function is passed the current mesh.
  16649. * Return the Mesh.
  16650. */
  16651. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  16652. /**
  16653. * Disposes a previously registered javascript function called before the rendering.
  16654. * This function is passed the current mesh.
  16655. * Returns the Mesh.
  16656. */
  16657. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  16658. /**
  16659. * Registers for this mesh a javascript function called just after the rendering is complete.
  16660. * This function is passed the current mesh.
  16661. * Returns the Mesh.
  16662. */
  16663. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  16664. /**
  16665. * Disposes a previously registered javascript function called after the rendering.
  16666. * This function is passed the current mesh.
  16667. * Return the Mesh.
  16668. */
  16669. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  16670. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  16671. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  16672. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  16673. /**
  16674. * Triggers the draw call for the mesh.
  16675. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  16676. * Returns the Mesh.
  16677. */
  16678. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  16679. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  16680. /**
  16681. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  16682. */
  16683. getEmittedParticleSystems(): IParticleSystem[];
  16684. /**
  16685. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  16686. */
  16687. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  16688. _checkDelayState(): Mesh;
  16689. private _queueLoad(scene);
  16690. /**
  16691. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  16692. */
  16693. isInFrustum(frustumPlanes: Plane[]): boolean;
  16694. /**
  16695. * Sets the mesh material by the material or multiMaterial `id` property.
  16696. * The material `id` is a string identifying the material or the multiMaterial.
  16697. * This method returns the Mesh.
  16698. */
  16699. setMaterialByID(id: string): Mesh;
  16700. /**
  16701. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  16702. */
  16703. getAnimatables(): IAnimatable[];
  16704. /**
  16705. * Modifies the mesh geometry according to the passed transformation matrix.
  16706. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  16707. * The mesh normals are modified accordingly the same transformation.
  16708. * tuto : http://doc.babylonjs.com/tutorials/How_Rotations_and_Translations_Work#baking-transform
  16709. * Note that, under the hood, this method sets a new VertexBuffer each call.
  16710. * Returns the Mesh.
  16711. */
  16712. bakeTransformIntoVertices(transform: Matrix): Mesh;
  16713. /**
  16714. * Modifies the mesh geometry according to its own current World Matrix.
  16715. * The mesh World Matrix is then reset.
  16716. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  16717. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  16718. * Note that, under the hood, this method sets a new VertexBuffer each call.
  16719. * Returns the Mesh.
  16720. */
  16721. bakeCurrentTransformIntoVertices(): Mesh;
  16722. readonly _positions: Nullable<Vector3[]>;
  16723. _resetPointsArrayCache(): Mesh;
  16724. _generatePointsArray(): boolean;
  16725. /**
  16726. * Returns a new Mesh object generated from the current mesh properties.
  16727. * This method must not get confused with createInstance().
  16728. * The parameter `name` is a string, the name given to the new mesh.
  16729. * The optional parameter `newParent` can be any Node object (default `null`).
  16730. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  16731. * 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.
  16732. */
  16733. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  16734. /**
  16735. * Disposes the Mesh.
  16736. * By default, all the mesh children are also disposed unless the parameter `doNotRecurse` is set to `true`.
  16737. * Returns nothing.
  16738. */
  16739. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16740. /**
  16741. * Modifies the mesh geometry according to a displacement map.
  16742. * 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.
  16743. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  16744. * This method returns nothing.
  16745. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  16746. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  16747. * 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.
  16748. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  16749. * The parameter `uvScale` is an optional vector2 used to scale UV.
  16750. *
  16751. * Returns the Mesh.
  16752. */
  16753. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  16754. /**
  16755. * Modifies the mesh geometry according to a displacementMap buffer.
  16756. * 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.
  16757. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  16758. * This method returns nothing.
  16759. * 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.
  16760. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  16761. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  16762. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  16763. * The parameter `uvScale` is an optional vector2 used to scale UV.
  16764. *
  16765. * Returns the Mesh.
  16766. */
  16767. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  16768. /**
  16769. * Modify the mesh to get a flat shading rendering.
  16770. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  16771. * This method returns the Mesh.
  16772. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  16773. */
  16774. convertToFlatShadedMesh(): Mesh;
  16775. /**
  16776. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  16777. * In other words, more vertices, no more indices and a single bigger VBO.
  16778. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  16779. * Returns the Mesh.
  16780. */
  16781. convertToUnIndexedMesh(): Mesh;
  16782. /**
  16783. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  16784. * This method returns the Mesh.
  16785. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  16786. */
  16787. flipFaces(flipNormals?: boolean): Mesh;
  16788. /**
  16789. * Creates a new InstancedMesh object from the mesh model.
  16790. * An instance shares the same properties and the same material than its model.
  16791. * Only these properties of each instance can then be set individually :
  16792. * - position
  16793. * - rotation
  16794. * - rotationQuaternion
  16795. * - setPivotMatrix
  16796. * - scaling
  16797. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  16798. * Warning : this method is not supported for Line mesh and LineSystem
  16799. */
  16800. createInstance(name: string): InstancedMesh;
  16801. /**
  16802. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  16803. * After this call, all the mesh instances have the same submeshes than the current mesh.
  16804. * This method returns the Mesh.
  16805. */
  16806. synchronizeInstances(): Mesh;
  16807. /**
  16808. * Simplify the mesh according to the given array of settings.
  16809. * Function will return immediately and will simplify async. It returns the Mesh.
  16810. * @param settings a collection of simplification settings.
  16811. * @param parallelProcessing should all levels calculate parallel or one after the other.
  16812. * @param type the type of simplification to run.
  16813. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  16814. */
  16815. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  16816. /**
  16817. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  16818. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  16819. * This should be used together with the simplification to avoid disappearing triangles.
  16820. * Returns the Mesh.
  16821. * @param successCallback an optional success callback to be called after the optimization finished.
  16822. */
  16823. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  16824. serialize(serializationObject: any): void;
  16825. _syncGeometryWithMorphTargetManager(): void;
  16826. /**
  16827. * Returns a new Mesh object parsed from the source provided.
  16828. * The parameter `parsedMesh` is the source.
  16829. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  16830. */
  16831. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  16832. /**
  16833. * Creates a ribbon mesh.
  16834. * Please consider using the same method from the MeshBuilder class instead.
  16835. * 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.
  16836. *
  16837. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  16838. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  16839. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  16840. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  16841. * 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.
  16842. * 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.
  16843. * 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
  16844. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16845. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16846. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16847. */
  16848. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  16849. /**
  16850. * Creates a plane polygonal mesh. By default, this is a disc.
  16851. * Please consider using the same method from the MeshBuilder class instead.
  16852. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  16853. * 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.
  16854. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16855. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16856. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16857. */
  16858. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  16859. /**
  16860. * Creates a box mesh.
  16861. * Please consider using the same method from the MeshBuilder class instead.
  16862. * The parameter `size` sets the size (float) of each box side (default 1).
  16863. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16864. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16865. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16866. */
  16867. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  16868. /**
  16869. * Creates a sphere mesh.
  16870. * Please consider using the same method from the MeshBuilder class instead.
  16871. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  16872. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  16873. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16874. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16875. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16876. */
  16877. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  16878. /**
  16879. * Creates a cylinder or a cone mesh.
  16880. * Please consider using the same method from the MeshBuilder class instead.
  16881. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  16882. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  16883. * 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.
  16884. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  16885. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  16886. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16887. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16888. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16889. */
  16890. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  16891. /**
  16892. * Creates a torus mesh.
  16893. * Please consider using the same method from the MeshBuilder class instead.
  16894. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  16895. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  16896. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  16897. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16898. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16899. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16900. */
  16901. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  16902. /**
  16903. * Creates a torus knot mesh.
  16904. * Please consider using the same method from the MeshBuilder class instead.
  16905. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  16906. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  16907. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  16908. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  16909. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16910. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16911. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16912. */
  16913. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  16914. /**
  16915. * Creates a line mesh.
  16916. * Please consider using the same method from the MeshBuilder class instead.
  16917. * 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.
  16918. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  16919. * The parameter `points` is an array successive Vector3.
  16920. * 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
  16921. * When updating an instance, remember that only point positions can change, not the number of points.
  16922. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16923. */
  16924. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  16925. /**
  16926. * Creates a dashed line mesh.
  16927. * Please consider using the same method from the MeshBuilder class instead.
  16928. * 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.
  16929. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  16930. * The parameter `points` is an array successive Vector3.
  16931. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  16932. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  16933. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  16934. * 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
  16935. * When updating an instance, remember that only point positions can change, not the number of points.
  16936. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16937. */
  16938. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  16939. /**
  16940. * Creates a polygon mesh.
  16941. * Please consider using the same method from the MeshBuilder class instead.
  16942. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  16943. * 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.
  16944. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16945. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16946. * Remember you can only change the shape positions, not their number when updating a polygon.
  16947. */
  16948. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  16949. /**
  16950. * Creates an extruded polygon mesh, with depth in the Y direction.
  16951. * Please consider using the same method from the MeshBuilder class instead.
  16952. */
  16953. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  16954. /**
  16955. * Creates an extruded shape mesh.
  16956. * 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.
  16957. * Please consider using the same method from the MeshBuilder class instead.
  16958. *
  16959. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  16960. * 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
  16961. * extruded along the Z axis.
  16962. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  16963. * 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.
  16964. * The parameter `scale` (float, default 1) is the value to scale the shape.
  16965. * 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
  16966. * 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
  16967. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  16968. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16969. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16970. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16971. */
  16972. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  16973. /**
  16974. * Creates an custom extruded shape mesh.
  16975. * 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.
  16976. * Please consider using the same method from the MeshBuilder class instead.
  16977. *
  16978. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  16979. * 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
  16980. * extruded along the Z axis.
  16981. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  16982. * 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
  16983. * and the distance of this point from the begining of the path :
  16984. * ```javascript
  16985. * var rotationFunction = function(i, distance) {
  16986. * // do things
  16987. * return rotationValue; }
  16988. * ```
  16989. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  16990. * 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
  16991. * and the distance of this point from the begining of the path :
  16992. * ```javascript
  16993. * var scaleFunction = function(i, distance) {
  16994. * // do things
  16995. * return scaleValue;}
  16996. * ```
  16997. * It must returns a float value that will be the scale value applied to the shape on each path point.
  16998. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  16999. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  17000. * 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
  17001. * 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
  17002. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  17003. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17004. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17005. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17006. */
  17007. 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;
  17008. /**
  17009. * Creates lathe mesh.
  17010. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  17011. * Please consider using the same method from the MeshBuilder class instead.
  17012. * 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
  17013. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  17014. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  17015. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  17016. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17017. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17018. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17019. */
  17020. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  17021. /**
  17022. * Creates a plane mesh.
  17023. * Please consider using the same method from the MeshBuilder class instead.
  17024. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  17025. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17026. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17027. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17028. */
  17029. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  17030. /**
  17031. * Creates a ground mesh.
  17032. * Please consider using the same method from the MeshBuilder class instead.
  17033. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  17034. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  17035. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17036. */
  17037. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  17038. /**
  17039. * Creates a tiled ground mesh.
  17040. * Please consider using the same method from the MeshBuilder class instead.
  17041. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  17042. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  17043. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  17044. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  17045. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  17046. * numbers of subdivisions on the ground width and height of each tile.
  17047. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17048. */
  17049. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  17050. w: number;
  17051. h: number;
  17052. }, precision: {
  17053. w: number;
  17054. h: number;
  17055. }, scene: Scene, updatable?: boolean): Mesh;
  17056. /**
  17057. * Creates a ground mesh from a height map.
  17058. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  17059. * Please consider using the same method from the MeshBuilder class instead.
  17060. * The parameter `url` sets the URL of the height map image resource.
  17061. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  17062. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  17063. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  17064. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  17065. * 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).
  17066. * This function is passed the newly built mesh :
  17067. * ```javascript
  17068. * function(mesh) { // do things
  17069. * return; }
  17070. * ```
  17071. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17072. */
  17073. 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;
  17074. /**
  17075. * Creates a tube mesh.
  17076. * 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.
  17077. * Please consider using the same method from the MeshBuilder class instead.
  17078. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  17079. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  17080. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  17081. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  17082. * 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.
  17083. * It must return a radius value (positive float) :
  17084. * ```javascript
  17085. * var radiusFunction = function(i, distance) {
  17086. * // do things
  17087. * return radius; }
  17088. * ```
  17089. * 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
  17090. * 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
  17091. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17092. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17093. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17094. */
  17095. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  17096. (i: number, distance: number): number;
  17097. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  17098. /**
  17099. * Creates a polyhedron mesh.
  17100. * Please consider using the same method from the MeshBuilder class instead.
  17101. * 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
  17102. * to choose the wanted type.
  17103. * The parameter `size` (positive float, default 1) sets the polygon size.
  17104. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  17105. * 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`.
  17106. * 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
  17107. * 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)`).
  17108. * 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
  17109. * 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.
  17110. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17111. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17112. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17113. */
  17114. static CreatePolyhedron(name: string, options: {
  17115. type?: number;
  17116. size?: number;
  17117. sizeX?: number;
  17118. sizeY?: number;
  17119. sizeZ?: number;
  17120. custom?: any;
  17121. faceUV?: Vector4[];
  17122. faceColors?: Color4[];
  17123. updatable?: boolean;
  17124. sideOrientation?: number;
  17125. }, scene: Scene): Mesh;
  17126. /**
  17127. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  17128. * Please consider using the same method from the MeshBuilder class instead.
  17129. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  17130. * 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`).
  17131. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  17132. * 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.
  17133. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17134. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17135. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17136. */
  17137. static CreateIcoSphere(name: string, options: {
  17138. radius?: number;
  17139. flat?: boolean;
  17140. subdivisions?: number;
  17141. sideOrientation?: number;
  17142. updatable?: boolean;
  17143. }, scene: Scene): Mesh;
  17144. /**
  17145. * Creates a decal mesh.
  17146. * Please consider using the same method from the MeshBuilder class instead.
  17147. * 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.
  17148. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  17149. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  17150. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  17151. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  17152. */
  17153. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  17154. /**
  17155. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  17156. */
  17157. setPositionsForCPUSkinning(): Float32Array;
  17158. /**
  17159. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  17160. */
  17161. setNormalsForCPUSkinning(): Float32Array;
  17162. /**
  17163. * Updates the vertex buffer by applying transformation from the bones.
  17164. * Returns the Mesh.
  17165. *
  17166. * @param {skeleton} skeleton to apply
  17167. */
  17168. applySkeleton(skeleton: Skeleton): Mesh;
  17169. /**
  17170. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  17171. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  17172. */
  17173. static MinMax(meshes: AbstractMesh[]): {
  17174. min: Vector3;
  17175. max: Vector3;
  17176. };
  17177. /**
  17178. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  17179. */
  17180. static Center(meshesOrMinMaxVector: {
  17181. min: Vector3;
  17182. max: Vector3;
  17183. } | AbstractMesh[]): Vector3;
  17184. /**
  17185. * Merge the array of meshes into a single mesh for performance reasons.
  17186. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  17187. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  17188. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  17189. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  17190. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  17191. */
  17192. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  17193. }
  17194. }
  17195. declare module BABYLON {
  17196. interface IGetSetVerticesData {
  17197. isVerticesDataPresent(kind: string): boolean;
  17198. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  17199. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  17200. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  17201. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  17202. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  17203. }
  17204. class VertexData {
  17205. positions: Nullable<FloatArray>;
  17206. normals: Nullable<FloatArray>;
  17207. tangents: Nullable<FloatArray>;
  17208. uvs: Nullable<FloatArray>;
  17209. uvs2: Nullable<FloatArray>;
  17210. uvs3: Nullable<FloatArray>;
  17211. uvs4: Nullable<FloatArray>;
  17212. uvs5: Nullable<FloatArray>;
  17213. uvs6: Nullable<FloatArray>;
  17214. colors: Nullable<FloatArray>;
  17215. matricesIndices: Nullable<FloatArray>;
  17216. matricesWeights: Nullable<FloatArray>;
  17217. matricesIndicesExtra: Nullable<FloatArray>;
  17218. matricesWeightsExtra: Nullable<FloatArray>;
  17219. indices: Nullable<IndicesArray>;
  17220. set(data: FloatArray, kind: string): void;
  17221. /**
  17222. * Associates the vertexData to the passed Mesh.
  17223. * Sets it as updatable or not (default `false`).
  17224. * Returns the VertexData.
  17225. */
  17226. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  17227. /**
  17228. * Associates the vertexData to the passed Geometry.
  17229. * Sets it as updatable or not (default `false`).
  17230. * Returns the VertexData.
  17231. */
  17232. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  17233. /**
  17234. * Updates the associated mesh.
  17235. * Returns the VertexData.
  17236. */
  17237. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  17238. /**
  17239. * Updates the associated geometry.
  17240. * Returns the VertexData.
  17241. */
  17242. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  17243. private _applyTo(meshOrGeometry, updatable?);
  17244. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  17245. /**
  17246. * Transforms each position and each normal of the vertexData according to the passed Matrix.
  17247. * Returns the VertexData.
  17248. */
  17249. transform(matrix: Matrix): VertexData;
  17250. /**
  17251. * Merges the passed VertexData into the current one.
  17252. * Returns the modified VertexData.
  17253. */
  17254. merge(other: VertexData): VertexData;
  17255. private _mergeElement(source, other);
  17256. private _validate();
  17257. /**
  17258. * Serializes the VertexData.
  17259. * Returns a serialized object.
  17260. */
  17261. serialize(): any;
  17262. /**
  17263. * Returns the object VertexData associated to the passed mesh.
  17264. */
  17265. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  17266. /**
  17267. * Returns the object VertexData associated to the passed geometry.
  17268. */
  17269. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  17270. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  17271. /**
  17272. * Creates the vertexData of the Ribbon.
  17273. */
  17274. static CreateRibbon(options: {
  17275. pathArray: Vector3[][];
  17276. closeArray?: boolean;
  17277. closePath?: boolean;
  17278. offset?: number;
  17279. sideOrientation?: number;
  17280. frontUVs?: Vector4;
  17281. backUVs?: Vector4;
  17282. invertUV?: boolean;
  17283. uvs?: Vector2[];
  17284. colors?: Color4[];
  17285. }): VertexData;
  17286. /**
  17287. * Creates the VertexData of the Box.
  17288. */
  17289. static CreateBox(options: {
  17290. size?: number;
  17291. width?: number;
  17292. height?: number;
  17293. depth?: number;
  17294. faceUV?: Vector4[];
  17295. faceColors?: Color4[];
  17296. sideOrientation?: number;
  17297. frontUVs?: Vector4;
  17298. backUVs?: Vector4;
  17299. }): VertexData;
  17300. /**
  17301. * Creates the VertexData of the Sphere.
  17302. */
  17303. static CreateSphere(options: {
  17304. segments?: number;
  17305. diameter?: number;
  17306. diameterX?: number;
  17307. diameterY?: number;
  17308. diameterZ?: number;
  17309. arc?: number;
  17310. slice?: number;
  17311. sideOrientation?: number;
  17312. frontUVs?: Vector4;
  17313. backUVs?: Vector4;
  17314. }): VertexData;
  17315. /**
  17316. * Creates the VertexData of the Cylinder or Cone.
  17317. */
  17318. static CreateCylinder(options: {
  17319. height?: number;
  17320. diameterTop?: number;
  17321. diameterBottom?: number;
  17322. diameter?: number;
  17323. tessellation?: number;
  17324. subdivisions?: number;
  17325. arc?: number;
  17326. faceColors?: Color4[];
  17327. faceUV?: Vector4[];
  17328. hasRings?: boolean;
  17329. enclose?: boolean;
  17330. sideOrientation?: number;
  17331. frontUVs?: Vector4;
  17332. backUVs?: Vector4;
  17333. }): VertexData;
  17334. /**
  17335. * Creates the VertexData of the Torus.
  17336. */
  17337. static CreateTorus(options: {
  17338. diameter?: number;
  17339. thickness?: number;
  17340. tessellation?: number;
  17341. sideOrientation?: number;
  17342. frontUVs?: Vector4;
  17343. backUVs?: Vector4;
  17344. }): VertexData;
  17345. /**
  17346. * Creates the VertexData of the LineSystem.
  17347. */
  17348. static CreateLineSystem(options: {
  17349. lines: Vector3[][];
  17350. colors?: Nullable<Color4[][]>;
  17351. }): VertexData;
  17352. /**
  17353. * Create the VertexData of the DashedLines.
  17354. */
  17355. static CreateDashedLines(options: {
  17356. points: Vector3[];
  17357. dashSize?: number;
  17358. gapSize?: number;
  17359. dashNb?: number;
  17360. }): VertexData;
  17361. /**
  17362. * Creates the VertexData of the Ground.
  17363. */
  17364. static CreateGround(options: {
  17365. width?: number;
  17366. height?: number;
  17367. subdivisions?: number;
  17368. subdivisionsX?: number;
  17369. subdivisionsY?: number;
  17370. }): VertexData;
  17371. /**
  17372. * Creates the VertexData of the TiledGround.
  17373. */
  17374. static CreateTiledGround(options: {
  17375. xmin: number;
  17376. zmin: number;
  17377. xmax: number;
  17378. zmax: number;
  17379. subdivisions?: {
  17380. w: number;
  17381. h: number;
  17382. };
  17383. precision?: {
  17384. w: number;
  17385. h: number;
  17386. };
  17387. }): VertexData;
  17388. /**
  17389. * Creates the VertexData of the Ground designed from a heightmap.
  17390. */
  17391. static CreateGroundFromHeightMap(options: {
  17392. width: number;
  17393. height: number;
  17394. subdivisions: number;
  17395. minHeight: number;
  17396. maxHeight: number;
  17397. colorFilter: Color3;
  17398. buffer: Uint8Array;
  17399. bufferWidth: number;
  17400. bufferHeight: number;
  17401. }): VertexData;
  17402. /**
  17403. * Creates the VertexData of the Plane.
  17404. */
  17405. static CreatePlane(options: {
  17406. size?: number;
  17407. width?: number;
  17408. height?: number;
  17409. sideOrientation?: number;
  17410. frontUVs?: Vector4;
  17411. backUVs?: Vector4;
  17412. }): VertexData;
  17413. /**
  17414. * Creates the VertexData of the Disc or regular Polygon.
  17415. */
  17416. static CreateDisc(options: {
  17417. radius?: number;
  17418. tessellation?: number;
  17419. arc?: number;
  17420. sideOrientation?: number;
  17421. frontUVs?: Vector4;
  17422. backUVs?: Vector4;
  17423. }): VertexData;
  17424. /**
  17425. * Re-creates the VertexData of the Polygon for sideOrientation.
  17426. */
  17427. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  17428. /**
  17429. * Creates the VertexData of the IcoSphere.
  17430. */
  17431. static CreateIcoSphere(options: {
  17432. radius?: number;
  17433. radiusX?: number;
  17434. radiusY?: number;
  17435. radiusZ?: number;
  17436. flat?: boolean;
  17437. subdivisions?: number;
  17438. sideOrientation?: number;
  17439. frontUVs?: Vector4;
  17440. backUVs?: Vector4;
  17441. }): VertexData;
  17442. /**
  17443. * Creates the VertexData of the Polyhedron.
  17444. */
  17445. static CreatePolyhedron(options: {
  17446. type?: number;
  17447. size?: number;
  17448. sizeX?: number;
  17449. sizeY?: number;
  17450. sizeZ?: number;
  17451. custom?: any;
  17452. faceUV?: Vector4[];
  17453. faceColors?: Color4[];
  17454. flat?: boolean;
  17455. sideOrientation?: number;
  17456. frontUVs?: Vector4;
  17457. backUVs?: Vector4;
  17458. }): VertexData;
  17459. /**
  17460. * Creates the VertexData of the Torus Knot.
  17461. */
  17462. static CreateTorusKnot(options: {
  17463. radius?: number;
  17464. tube?: number;
  17465. radialSegments?: number;
  17466. tubularSegments?: number;
  17467. p?: number;
  17468. q?: number;
  17469. sideOrientation?: number;
  17470. frontUVs?: Vector4;
  17471. backUVs?: Vector4;
  17472. }): VertexData;
  17473. /**
  17474. * @param {any} - positions (number[] or Float32Array)
  17475. * @param {any} - indices (number[] or Uint16Array)
  17476. * @param {any} - normals (number[] or Float32Array)
  17477. * options (optional) :
  17478. * facetPositions : optional array of facet positions (vector3)
  17479. * facetNormals : optional array of facet normals (vector3)
  17480. * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  17481. * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  17482. * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  17483. * bbSize : optional bounding box size data, required for facetPartitioning computation
  17484. * bInfo : optional bounding info, required for facetPartitioning computation
  17485. * useRightHandedSystem: optional boolean to for right handed system computation
  17486. * depthSort : optional boolean to enable the facet depth sort computation
  17487. * distanceTo : optional Vector3 to compute the facet depth from this location
  17488. * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  17489. */
  17490. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  17491. facetNormals?: any;
  17492. facetPositions?: any;
  17493. facetPartitioning?: any;
  17494. ratio?: number;
  17495. bInfo?: any;
  17496. bbSize?: Vector3;
  17497. subDiv?: any;
  17498. useRightHandedSystem?: boolean;
  17499. depthSort?: boolean;
  17500. distanceTo?: Vector3;
  17501. depthSortedFacets?: any;
  17502. }): void;
  17503. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  17504. /**
  17505. * Creates a new VertexData from the imported parameters.
  17506. */
  17507. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  17508. }
  17509. }
  17510. declare module BABYLON {
  17511. class MeshBuilder {
  17512. private static updateSideOrientation(orientation?);
  17513. /**
  17514. * Creates a box mesh.
  17515. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  17516. * The parameter `size` sets the size (float) of each box side (default 1).
  17517. * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`).
  17518. * 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).
  17519. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  17520. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17521. * 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).
  17522. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17523. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17524. */
  17525. static CreateBox(name: string, options: {
  17526. size?: number;
  17527. width?: number;
  17528. height?: number;
  17529. depth?: number;
  17530. faceUV?: Vector4[];
  17531. faceColors?: Color4[];
  17532. sideOrientation?: number;
  17533. frontUVs?: Vector4;
  17534. backUVs?: Vector4;
  17535. updatable?: boolean;
  17536. }, scene?: Nullable<Scene>): Mesh;
  17537. /**
  17538. * Creates a sphere mesh.
  17539. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  17540. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  17541. * 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`).
  17542. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  17543. * 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
  17544. * 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).
  17545. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17546. * 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).
  17547. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17548. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17549. */
  17550. static CreateSphere(name: string, options: {
  17551. segments?: number;
  17552. diameter?: number;
  17553. diameterX?: number;
  17554. diameterY?: number;
  17555. diameterZ?: number;
  17556. arc?: number;
  17557. slice?: number;
  17558. sideOrientation?: number;
  17559. frontUVs?: Vector4;
  17560. backUVs?: Vector4;
  17561. updatable?: boolean;
  17562. }, scene: any): Mesh;
  17563. /**
  17564. * Creates a plane polygonal mesh. By default, this is a disc.
  17565. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#disc
  17566. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  17567. * 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.
  17568. * 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
  17569. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17570. * 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).
  17571. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17572. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17573. */
  17574. static CreateDisc(name: string, options: {
  17575. radius?: number;
  17576. tessellation?: number;
  17577. arc?: number;
  17578. updatable?: boolean;
  17579. sideOrientation?: number;
  17580. frontUVs?: Vector4;
  17581. backUVs?: Vector4;
  17582. }, scene?: Nullable<Scene>): Mesh;
  17583. /**
  17584. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  17585. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#icosphere
  17586. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  17587. * 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`).
  17588. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  17589. * 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.
  17590. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17591. * 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).
  17592. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17593. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17594. */
  17595. static CreateIcoSphere(name: string, options: {
  17596. radius?: number;
  17597. radiusX?: number;
  17598. radiusY?: number;
  17599. radiusZ?: number;
  17600. flat?: boolean;
  17601. subdivisions?: number;
  17602. sideOrientation?: number;
  17603. frontUVs?: Vector4;
  17604. backUVs?: Vector4;
  17605. updatable?: boolean;
  17606. }, scene: Scene): Mesh;
  17607. /**
  17608. * Creates a ribbon mesh.
  17609. * 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.
  17610. *
  17611. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  17612. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  17613. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  17614. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  17615. * 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.
  17616. * 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.
  17617. * 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
  17618. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17619. * 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).
  17620. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17621. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  17622. * 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.
  17623. * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values.
  17624. * 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
  17625. * if you set `closePath` to `true`, there's one extra vertex per path in the geometry.
  17626. * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time.
  17627. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17628. */
  17629. static CreateRibbon(name: string, options: {
  17630. pathArray: Vector3[][];
  17631. closeArray?: boolean;
  17632. closePath?: boolean;
  17633. offset?: number;
  17634. updatable?: boolean;
  17635. sideOrientation?: number;
  17636. frontUVs?: Vector4;
  17637. backUVs?: Vector4;
  17638. instance?: Mesh;
  17639. invertUV?: boolean;
  17640. uvs?: Vector2[];
  17641. colors?: Color4[];
  17642. }, scene?: Nullable<Scene>): Mesh;
  17643. /**
  17644. * Creates a cylinder or a cone mesh.
  17645. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  17646. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  17647. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  17648. * 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.
  17649. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  17650. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  17651. * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  17652. * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  17653. * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  17654. * 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).
  17655. * 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
  17656. * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  17657. * 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
  17658. * 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.
  17659. * If `enclose` is false, a ring surface is one element.
  17660. * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  17661. * 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
  17662. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17663. * 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).
  17664. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17665. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17666. */
  17667. static CreateCylinder(name: string, options: {
  17668. height?: number;
  17669. diameterTop?: number;
  17670. diameterBottom?: number;
  17671. diameter?: number;
  17672. tessellation?: number;
  17673. subdivisions?: number;
  17674. arc?: number;
  17675. faceColors?: Color4[];
  17676. faceUV?: Vector4[];
  17677. updatable?: boolean;
  17678. hasRings?: boolean;
  17679. enclose?: boolean;
  17680. sideOrientation?: number;
  17681. frontUVs?: Vector4;
  17682. backUVs?: Vector4;
  17683. }, scene: any): Mesh;
  17684. /**
  17685. * Creates a torus mesh.
  17686. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  17687. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  17688. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  17689. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  17690. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17691. * 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).
  17692. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17693. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17694. */
  17695. static CreateTorus(name: string, options: {
  17696. diameter?: number;
  17697. thickness?: number;
  17698. tessellation?: number;
  17699. updatable?: boolean;
  17700. sideOrientation?: number;
  17701. frontUVs?: Vector4;
  17702. backUVs?: Vector4;
  17703. }, scene: any): Mesh;
  17704. /**
  17705. * Creates a torus knot mesh.
  17706. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  17707. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  17708. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  17709. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  17710. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  17711. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17712. * 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).
  17713. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17714. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17715. */
  17716. static CreateTorusKnot(name: string, options: {
  17717. radius?: number;
  17718. tube?: number;
  17719. radialSegments?: number;
  17720. tubularSegments?: number;
  17721. p?: number;
  17722. q?: number;
  17723. updatable?: boolean;
  17724. sideOrientation?: number;
  17725. frontUVs?: Vector4;
  17726. backUVs?: Vector4;
  17727. }, scene: any): Mesh;
  17728. /**
  17729. * Creates a line system mesh.
  17730. * A line system is a pool of many lines gathered in a single mesh.
  17731. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#linesystem
  17732. * 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.
  17733. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function.
  17734. * The parameter `lines` is an array of lines, each line being an array of successive Vector3.
  17735. * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter. The way to update it is the same than for
  17736. * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point.
  17737. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need the alpha blending (faster).
  17738. * 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
  17739. * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines.
  17740. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17741. */
  17742. static CreateLineSystem(name: string, options: {
  17743. lines: Vector3[][];
  17744. updatable: boolean;
  17745. instance: Nullable<LinesMesh>;
  17746. colors?: Nullable<Color4[][]>;
  17747. useVertexAlpha?: boolean;
  17748. }, scene: Nullable<Scene>): LinesMesh;
  17749. /**
  17750. * Creates a line mesh.
  17751. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lines
  17752. * 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.
  17753. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  17754. * The parameter `points` is an array successive Vector3.
  17755. * 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
  17756. * The optional parameter `colors` is an array of successive Color4, one per line point.
  17757. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need alpha blending (faster).
  17758. * When updating an instance, remember that only point positions can change, not the number of points.
  17759. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17760. */
  17761. static CreateLines(name: string, options: {
  17762. points: Vector3[];
  17763. updatable: boolean;
  17764. instance: Nullable<LinesMesh>;
  17765. colors?: Color4[];
  17766. useVertexAlpha?: boolean;
  17767. }, scene?: Nullable<Scene>): LinesMesh;
  17768. /**
  17769. * Creates a dashed line mesh.
  17770. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#dashed-lines
  17771. * 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.
  17772. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  17773. * The parameter `points` is an array successive Vector3.
  17774. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  17775. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  17776. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  17777. * 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
  17778. * When updating an instance, remember that only point positions can change, not the number of points.
  17779. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17780. */
  17781. static CreateDashedLines(name: string, options: {
  17782. points: Vector3[];
  17783. dashSize?: number;
  17784. gapSize?: number;
  17785. dashNb?: number;
  17786. updatable?: boolean;
  17787. instance?: LinesMesh;
  17788. }, scene?: Nullable<Scene>): LinesMesh;
  17789. /**
  17790. * Creates an extruded shape mesh.
  17791. * 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.
  17792. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#extruded-shapes
  17793. *
  17794. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  17795. * 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
  17796. * extruded along the Z axis.
  17797. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  17798. * 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.
  17799. * The parameter `scale` (float, default 1) is the value to scale the shape.
  17800. * 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
  17801. * 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
  17802. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  17803. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17804. * 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).
  17805. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17806. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  17807. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17808. */
  17809. static ExtrudeShape(name: string, options: {
  17810. shape: Vector3[];
  17811. path: Vector3[];
  17812. scale?: number;
  17813. rotation?: number;
  17814. cap?: number;
  17815. updatable?: boolean;
  17816. sideOrientation?: number;
  17817. frontUVs?: Vector4;
  17818. backUVs?: Vector4;
  17819. instance?: Mesh;
  17820. invertUV?: boolean;
  17821. }, scene?: Nullable<Scene>): Mesh;
  17822. /**
  17823. * Creates an custom extruded shape mesh.
  17824. * 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.
  17825. * tuto :http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#custom-extruded-shapes
  17826. *
  17827. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  17828. * 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
  17829. * extruded along the Z axis.
  17830. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  17831. * 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
  17832. * and the distance of this point from the begining of the path :
  17833. * ```javascript
  17834. * var rotationFunction = function(i, distance) {
  17835. * // do things
  17836. * return rotationValue; }
  17837. * ```
  17838. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  17839. * 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
  17840. * and the distance of this point from the begining of the path :
  17841. * ```javascript
  17842. * var scaleFunction = function(i, distance) {
  17843. * // do things
  17844. * return scaleValue;}
  17845. * ```
  17846. * It must returns a float value that will be the scale value applied to the shape on each path point.
  17847. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  17848. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  17849. * 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
  17850. * 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
  17851. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  17852. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17853. * 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).
  17854. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17855. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  17856. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17857. */
  17858. static ExtrudeShapeCustom(name: string, options: {
  17859. shape: Vector3[];
  17860. path: Vector3[];
  17861. scaleFunction?: any;
  17862. rotationFunction?: any;
  17863. ribbonCloseArray?: boolean;
  17864. ribbonClosePath?: boolean;
  17865. cap?: number;
  17866. updatable?: boolean;
  17867. sideOrientation?: number;
  17868. frontUVs?: Vector4;
  17869. backUVs?: Vector4;
  17870. instance?: Mesh;
  17871. invertUV?: boolean;
  17872. }, scene: Scene): Mesh;
  17873. /**
  17874. * Creates lathe mesh.
  17875. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  17876. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lathe
  17877. *
  17878. * 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
  17879. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  17880. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  17881. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  17882. * 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.
  17883. * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc".
  17884. * 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
  17885. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17886. * 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).
  17887. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17888. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  17889. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17890. */
  17891. static CreateLathe(name: string, options: {
  17892. shape: Vector3[];
  17893. radius?: number;
  17894. tessellation?: number;
  17895. arc?: number;
  17896. closed?: boolean;
  17897. updatable?: boolean;
  17898. sideOrientation?: number;
  17899. frontUVs?: Vector4;
  17900. backUVs?: Vector4;
  17901. cap?: number;
  17902. invertUV?: boolean;
  17903. }, scene: Scene): Mesh;
  17904. /**
  17905. * Creates a plane mesh.
  17906. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  17907. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  17908. * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`).
  17909. * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane.
  17910. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17911. * 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).
  17912. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17913. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17914. */
  17915. static CreatePlane(name: string, options: {
  17916. size?: number;
  17917. width?: number;
  17918. height?: number;
  17919. sideOrientation?: number;
  17920. frontUVs?: Vector4;
  17921. backUVs?: Vector4;
  17922. updatable?: boolean;
  17923. sourcePlane?: Plane;
  17924. }, scene: Scene): Mesh;
  17925. /**
  17926. * Creates a ground mesh.
  17927. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  17928. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  17929. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  17930. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17931. */
  17932. static CreateGround(name: string, options: {
  17933. width?: number;
  17934. height?: number;
  17935. subdivisions?: number;
  17936. subdivisionsX?: number;
  17937. subdivisionsY?: number;
  17938. updatable?: boolean;
  17939. }, scene: any): Mesh;
  17940. /**
  17941. * Creates a tiled ground mesh.
  17942. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  17943. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  17944. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  17945. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  17946. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  17947. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  17948. * numbers of subdivisions on the ground width and height of each tile.
  17949. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17950. */
  17951. static CreateTiledGround(name: string, options: {
  17952. xmin: number;
  17953. zmin: number;
  17954. xmax: number;
  17955. zmax: number;
  17956. subdivisions?: {
  17957. w: number;
  17958. h: number;
  17959. };
  17960. precision?: {
  17961. w: number;
  17962. h: number;
  17963. };
  17964. updatable?: boolean;
  17965. }, scene: Scene): Mesh;
  17966. /**
  17967. * Creates a ground mesh from a height map.
  17968. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  17969. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  17970. * The parameter `url` sets the URL of the height map image resource.
  17971. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  17972. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  17973. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  17974. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  17975. * 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.
  17976. * 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).
  17977. * This function is passed the newly built mesh :
  17978. * ```javascript
  17979. * function(mesh) { // do things
  17980. * return; }
  17981. * ```
  17982. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17983. */
  17984. static CreateGroundFromHeightMap(name: string, url: string, options: {
  17985. width?: number;
  17986. height?: number;
  17987. subdivisions?: number;
  17988. minHeight?: number;
  17989. maxHeight?: number;
  17990. colorFilter?: Color3;
  17991. updatable?: boolean;
  17992. onReady?: (mesh: GroundMesh) => void;
  17993. }, scene: Scene): GroundMesh;
  17994. /**
  17995. * Creates a polygon mesh.
  17996. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  17997. * 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.
  17998. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17999. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18000. * 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).
  18001. * Remember you can only change the shape positions, not their number when updating a polygon.
  18002. */
  18003. static CreatePolygon(name: string, options: {
  18004. shape: Vector3[];
  18005. holes?: Vector3[][];
  18006. depth?: number;
  18007. faceUV?: Vector4[];
  18008. faceColors?: Color4[];
  18009. updatable?: boolean;
  18010. sideOrientation?: number;
  18011. frontUVs?: Vector4;
  18012. backUVs?: Vector4;
  18013. }, scene: Scene): Mesh;
  18014. /**
  18015. * Creates an extruded polygon mesh, with depth in the Y direction.
  18016. * 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).
  18017. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  18018. */
  18019. static ExtrudePolygon(name: string, options: {
  18020. shape: Vector3[];
  18021. holes?: Vector3[][];
  18022. depth?: number;
  18023. faceUV?: Vector4[];
  18024. faceColors?: Color4[];
  18025. updatable?: boolean;
  18026. sideOrientation?: number;
  18027. frontUVs?: Vector4;
  18028. backUVs?: Vector4;
  18029. }, scene: Scene): Mesh;
  18030. /**
  18031. * Creates a tube mesh.
  18032. * 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.
  18033. *
  18034. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  18035. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  18036. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  18037. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  18038. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  18039. * 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.
  18040. * It must return a radius value (positive float) :
  18041. * ```javascript
  18042. * var radiusFunction = function(i, distance) {
  18043. * // do things
  18044. * return radius; }
  18045. * ```
  18046. * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc.
  18047. * 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
  18048. * 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
  18049. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18050. * 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).
  18051. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18052. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  18053. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18054. */
  18055. static CreateTube(name: string, options: {
  18056. path: Vector3[];
  18057. radius?: number;
  18058. tessellation?: number;
  18059. radiusFunction?: {
  18060. (i: number, distance: number): number;
  18061. };
  18062. cap?: number;
  18063. arc?: number;
  18064. updatable?: boolean;
  18065. sideOrientation?: number;
  18066. frontUVs?: Vector4;
  18067. backUVs?: Vector4;
  18068. instance?: Mesh;
  18069. invertUV?: boolean;
  18070. }, scene: Scene): Mesh;
  18071. /**
  18072. * Creates a polyhedron mesh.
  18073. *
  18074. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#polyhedron
  18075. * 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
  18076. * to choose the wanted type.
  18077. * The parameter `size` (positive float, default 1) sets the polygon size.
  18078. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  18079. * 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`.
  18080. * 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
  18081. * 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)`).
  18082. * 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
  18083. * 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.
  18084. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18085. * 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).
  18086. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18087. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18088. */
  18089. static CreatePolyhedron(name: string, options: {
  18090. type?: number;
  18091. size?: number;
  18092. sizeX?: number;
  18093. sizeY?: number;
  18094. sizeZ?: number;
  18095. custom?: any;
  18096. faceUV?: Vector4[];
  18097. faceColors?: Color4[];
  18098. flat?: boolean;
  18099. updatable?: boolean;
  18100. sideOrientation?: number;
  18101. frontUVs?: Vector4;
  18102. backUVs?: Vector4;
  18103. }, scene: Scene): Mesh;
  18104. /**
  18105. * Creates a decal mesh.
  18106. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#decals
  18107. * 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.
  18108. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  18109. * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates.
  18110. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  18111. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  18112. */
  18113. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  18114. position?: Vector3;
  18115. normal?: Vector3;
  18116. size?: Vector3;
  18117. angle?: number;
  18118. }): Mesh;
  18119. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  18120. }
  18121. }
  18122. declare module BABYLON {
  18123. class MeshLODLevel {
  18124. distance: number;
  18125. mesh: Mesh;
  18126. constructor(distance: number, mesh: Mesh);
  18127. }
  18128. }
  18129. declare module BABYLON {
  18130. /**
  18131. * A simplifier interface for future simplification implementations.
  18132. */
  18133. interface ISimplifier {
  18134. /**
  18135. * Simplification of a given mesh according to the given settings.
  18136. * Since this requires computation, it is assumed that the function runs async.
  18137. * @param settings The settings of the simplification, including quality and distance
  18138. * @param successCallback A callback that will be called after the mesh was simplified.
  18139. * @param errorCallback in case of an error, this callback will be called. optional.
  18140. */
  18141. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  18142. }
  18143. /**
  18144. * Expected simplification settings.
  18145. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  18146. */
  18147. interface ISimplificationSettings {
  18148. quality: number;
  18149. distance: number;
  18150. optimizeMesh?: boolean;
  18151. }
  18152. class SimplificationSettings implements ISimplificationSettings {
  18153. quality: number;
  18154. distance: number;
  18155. optimizeMesh: boolean | undefined;
  18156. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  18157. }
  18158. interface ISimplificationTask {
  18159. settings: Array<ISimplificationSettings>;
  18160. simplificationType: SimplificationType;
  18161. mesh: Mesh;
  18162. successCallback?: () => void;
  18163. parallelProcessing: boolean;
  18164. }
  18165. class SimplificationQueue {
  18166. private _simplificationArray;
  18167. running: boolean;
  18168. constructor();
  18169. addTask(task: ISimplificationTask): void;
  18170. executeNext(): void;
  18171. runSimplification(task: ISimplificationTask): void;
  18172. private getSimplifier(task);
  18173. }
  18174. /**
  18175. * The implemented types of simplification.
  18176. * At the moment only Quadratic Error Decimation is implemented.
  18177. */
  18178. enum SimplificationType {
  18179. QUADRATIC = 0,
  18180. }
  18181. class DecimationTriangle {
  18182. vertices: Array<DecimationVertex>;
  18183. normal: Vector3;
  18184. error: Array<number>;
  18185. deleted: boolean;
  18186. isDirty: boolean;
  18187. borderFactor: number;
  18188. deletePending: boolean;
  18189. originalOffset: number;
  18190. constructor(vertices: Array<DecimationVertex>);
  18191. }
  18192. class DecimationVertex {
  18193. position: Vector3;
  18194. id: number;
  18195. q: QuadraticMatrix;
  18196. isBorder: boolean;
  18197. triangleStart: number;
  18198. triangleCount: number;
  18199. originalOffsets: Array<number>;
  18200. constructor(position: Vector3, id: number);
  18201. updatePosition(newPosition: Vector3): void;
  18202. }
  18203. class QuadraticMatrix {
  18204. data: Array<number>;
  18205. constructor(data?: Array<number>);
  18206. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  18207. addInPlace(matrix: QuadraticMatrix): void;
  18208. addArrayInPlace(data: Array<number>): void;
  18209. add(matrix: QuadraticMatrix): QuadraticMatrix;
  18210. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  18211. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  18212. }
  18213. class Reference {
  18214. vertexId: number;
  18215. triangleId: number;
  18216. constructor(vertexId: number, triangleId: number);
  18217. }
  18218. /**
  18219. * An implementation of the Quadratic Error simplification algorithm.
  18220. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  18221. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  18222. * @author RaananW
  18223. */
  18224. class QuadraticErrorSimplification implements ISimplifier {
  18225. private _mesh;
  18226. private triangles;
  18227. private vertices;
  18228. private references;
  18229. private _reconstructedMesh;
  18230. syncIterations: number;
  18231. aggressiveness: number;
  18232. decimationIterations: number;
  18233. boundingBoxEpsilon: number;
  18234. constructor(_mesh: Mesh);
  18235. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  18236. private runDecimation(settings, submeshIndex, successCallback);
  18237. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  18238. private init(callback);
  18239. private reconstructMesh(submeshIndex);
  18240. private initDecimatedMesh();
  18241. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  18242. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  18243. private identifyBorder();
  18244. private updateMesh(identifyBorders?);
  18245. private vertexError(q, point);
  18246. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  18247. }
  18248. }
  18249. declare module BABYLON {
  18250. class Polygon {
  18251. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  18252. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  18253. static Parse(input: string): Vector2[];
  18254. static StartingAt(x: number, y: number): Path2;
  18255. }
  18256. class PolygonMeshBuilder {
  18257. private _points;
  18258. private _outlinepoints;
  18259. private _holes;
  18260. private _name;
  18261. private _scene;
  18262. private _epoints;
  18263. private _eholes;
  18264. private _addToepoint(points);
  18265. constructor(name: string, contours: Path2, scene: Scene);
  18266. constructor(name: string, contours: Vector2[], scene: Scene);
  18267. addHole(hole: Vector2[]): PolygonMeshBuilder;
  18268. build(updatable?: boolean, depth?: number): Mesh;
  18269. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  18270. }
  18271. }
  18272. declare module BABYLON {
  18273. class BaseSubMesh {
  18274. _materialDefines: Nullable<MaterialDefines>;
  18275. _materialEffect: Nullable<Effect>;
  18276. readonly effect: Nullable<Effect>;
  18277. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  18278. }
  18279. class SubMesh extends BaseSubMesh implements ICullable {
  18280. materialIndex: number;
  18281. verticesStart: number;
  18282. verticesCount: number;
  18283. indexStart: number;
  18284. indexCount: number;
  18285. linesIndexCount: number;
  18286. private _mesh;
  18287. private _renderingMesh;
  18288. private _boundingInfo;
  18289. private _linesIndexBuffer;
  18290. _lastColliderWorldVertices: Nullable<Vector3[]>;
  18291. _trianglePlanes: Plane[];
  18292. _lastColliderTransformMatrix: Matrix;
  18293. _renderId: number;
  18294. _alphaIndex: number;
  18295. _distanceToCamera: number;
  18296. _id: number;
  18297. private _currentMaterial;
  18298. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  18299. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  18300. readonly IsGlobal: boolean;
  18301. /**
  18302. * Returns the submesh BoudingInfo object.
  18303. */
  18304. getBoundingInfo(): BoundingInfo;
  18305. /**
  18306. * Sets the submesh BoundingInfo.
  18307. * Return the SubMesh.
  18308. */
  18309. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  18310. /**
  18311. * Returns the mesh of the current submesh.
  18312. */
  18313. getMesh(): AbstractMesh;
  18314. /**
  18315. * Returns the rendering mesh of the submesh.
  18316. */
  18317. getRenderingMesh(): Mesh;
  18318. /**
  18319. * Returns the submesh material.
  18320. */
  18321. getMaterial(): Nullable<Material>;
  18322. /**
  18323. * Sets a new updated BoundingInfo object to the submesh.
  18324. * Returns the SubMesh.
  18325. */
  18326. refreshBoundingInfo(): SubMesh;
  18327. _checkCollision(collider: Collider): boolean;
  18328. /**
  18329. * Updates the submesh BoundingInfo.
  18330. * Returns the Submesh.
  18331. */
  18332. updateBoundingInfo(world: Matrix): SubMesh;
  18333. /**
  18334. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  18335. * Boolean returned.
  18336. */
  18337. isInFrustum(frustumPlanes: Plane[]): boolean;
  18338. /**
  18339. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  18340. * Boolean returned.
  18341. */
  18342. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  18343. /**
  18344. * Renders the submesh.
  18345. * Returns it.
  18346. */
  18347. render(enableAlphaMode: boolean): SubMesh;
  18348. /**
  18349. * Returns a new Index Buffer.
  18350. * Type returned : WebGLBuffer.
  18351. */
  18352. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  18353. /**
  18354. * True is the passed Ray intersects the submesh bounding box.
  18355. * Boolean returned.
  18356. */
  18357. canIntersects(ray: Ray): boolean;
  18358. /**
  18359. * Returns an object IntersectionInfo.
  18360. */
  18361. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  18362. _rebuild(): void;
  18363. /**
  18364. * Creates a new Submesh from the passed Mesh.
  18365. */
  18366. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  18367. /**
  18368. * Disposes the Submesh.
  18369. * Returns nothing.
  18370. */
  18371. dispose(): void;
  18372. /**
  18373. * Creates a new Submesh from the passed parameters :
  18374. * - materialIndex (integer) : the index of the main mesh material.
  18375. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  18376. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  18377. * - mesh (Mesh) : the main mesh to create the submesh from.
  18378. * - renderingMesh (optional Mesh) : rendering mesh.
  18379. */
  18380. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  18381. }
  18382. }
  18383. declare module BABYLON {
  18384. class TransformNode extends Node {
  18385. static BILLBOARDMODE_NONE: number;
  18386. static BILLBOARDMODE_X: number;
  18387. static BILLBOARDMODE_Y: number;
  18388. static BILLBOARDMODE_Z: number;
  18389. static BILLBOARDMODE_ALL: number;
  18390. private _rotation;
  18391. private _rotationQuaternion;
  18392. protected _scaling: Vector3;
  18393. protected _isDirty: boolean;
  18394. private _transformToBoneReferal;
  18395. billboardMode: number;
  18396. scalingDeterminant: number;
  18397. infiniteDistance: boolean;
  18398. position: Vector3;
  18399. _poseMatrix: Matrix;
  18400. private _localWorld;
  18401. _worldMatrix: Matrix;
  18402. _worldMatrixDeterminant: number;
  18403. private _absolutePosition;
  18404. private _pivotMatrix;
  18405. private _pivotMatrixInverse;
  18406. private _postMultiplyPivotMatrix;
  18407. protected _isWorldMatrixFrozen: boolean;
  18408. /**
  18409. * An event triggered after the world matrix is updated
  18410. * @type {BABYLON.Observable}
  18411. */
  18412. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  18413. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  18414. /**
  18415. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  18416. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  18417. * Default : (0.0, 0.0, 0.0)
  18418. */
  18419. rotation: Vector3;
  18420. /**
  18421. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  18422. * Default : (1.0, 1.0, 1.0)
  18423. */
  18424. /**
  18425. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  18426. * Default : (1.0, 1.0, 1.0)
  18427. */
  18428. scaling: Vector3;
  18429. /**
  18430. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  18431. * It's null by default.
  18432. * 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)
  18433. */
  18434. rotationQuaternion: Nullable<Quaternion>;
  18435. /**
  18436. * Returns the latest update of the World matrix
  18437. * Returns a Matrix.
  18438. */
  18439. getWorldMatrix(): Matrix;
  18440. /**
  18441. * Returns the latest update of the World matrix determinant.
  18442. */
  18443. protected _getWorldMatrixDeterminant(): number;
  18444. /**
  18445. * Returns directly the latest state of the mesh World matrix.
  18446. * A Matrix is returned.
  18447. */
  18448. readonly worldMatrixFromCache: Matrix;
  18449. /**
  18450. * Copies the paramater passed Matrix into the mesh Pose matrix.
  18451. * Returns the AbstractMesh.
  18452. */
  18453. updatePoseMatrix(matrix: Matrix): TransformNode;
  18454. /**
  18455. * Returns the mesh Pose matrix.
  18456. * Returned object : Matrix
  18457. */
  18458. getPoseMatrix(): Matrix;
  18459. _isSynchronized(): boolean;
  18460. _initCache(): void;
  18461. markAsDirty(property: string): TransformNode;
  18462. /**
  18463. * Returns the current mesh absolute position.
  18464. * Retuns a Vector3.
  18465. */
  18466. readonly absolutePosition: Vector3;
  18467. /**
  18468. * Sets a new matrix to apply before all other transformation
  18469. * @param matrix defines the transform matrix
  18470. * @returns the current TransformNode
  18471. */
  18472. setPreTransformMatrix(matrix: Matrix): TransformNode;
  18473. /**
  18474. * Sets a new pivot matrix to the current node
  18475. * @param matrix defines the new pivot matrix to use
  18476. * @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
  18477. * @returns the current TransformNode
  18478. */
  18479. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  18480. /**
  18481. * Returns the mesh pivot matrix.
  18482. * Default : Identity.
  18483. * A Matrix is returned.
  18484. */
  18485. getPivotMatrix(): Matrix;
  18486. /**
  18487. * Prevents the World matrix to be computed any longer.
  18488. * Returns the AbstractMesh.
  18489. */
  18490. freezeWorldMatrix(): TransformNode;
  18491. /**
  18492. * Allows back the World matrix computation.
  18493. * Returns the AbstractMesh.
  18494. */
  18495. unfreezeWorldMatrix(): this;
  18496. /**
  18497. * True if the World matrix has been frozen.
  18498. * Returns a boolean.
  18499. */
  18500. readonly isWorldMatrixFrozen: boolean;
  18501. /**
  18502. * Retuns the mesh absolute position in the World.
  18503. * Returns a Vector3.
  18504. */
  18505. getAbsolutePosition(): Vector3;
  18506. /**
  18507. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  18508. * Returns the AbstractMesh.
  18509. */
  18510. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  18511. /**
  18512. * Sets the mesh position in its local space.
  18513. * Returns the AbstractMesh.
  18514. */
  18515. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  18516. /**
  18517. * Returns the mesh position in the local space from the current World matrix values.
  18518. * Returns a new Vector3.
  18519. */
  18520. getPositionExpressedInLocalSpace(): Vector3;
  18521. /**
  18522. * Translates the mesh along the passed Vector3 in its local space.
  18523. * Returns the AbstractMesh.
  18524. */
  18525. locallyTranslate(vector3: Vector3): TransformNode;
  18526. private static _lookAtVectorCache;
  18527. /**
  18528. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  18529. * @param targetPoint the position (must be in same space as current mesh) to look at
  18530. * @param yawCor optional yaw (y-axis) correction in radians
  18531. * @param pitchCor optional pitch (x-axis) correction in radians
  18532. * @param rollCor optional roll (z-axis) correction in radians
  18533. * @param space the choosen space of the target
  18534. * @returns the TransformNode.
  18535. */
  18536. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  18537. /**
  18538. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  18539. * This Vector3 is expressed in the World space.
  18540. */
  18541. getDirection(localAxis: Vector3): Vector3;
  18542. /**
  18543. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  18544. * localAxis is expressed in the mesh local space.
  18545. * result is computed in the Wordl space from the mesh World matrix.
  18546. * Returns the AbstractMesh.
  18547. */
  18548. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  18549. /**
  18550. * Sets a new pivot point to the current node
  18551. * @param point defines the new pivot point to use
  18552. * @param space defines if the point is in world or local space (local by default)
  18553. * @returns the current TransformNode
  18554. */
  18555. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  18556. /**
  18557. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  18558. */
  18559. getPivotPoint(): Vector3;
  18560. /**
  18561. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  18562. * Returns the AbstractMesh.
  18563. */
  18564. getPivotPointToRef(result: Vector3): TransformNode;
  18565. /**
  18566. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  18567. */
  18568. getAbsolutePivotPoint(): Vector3;
  18569. /**
  18570. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  18571. * Returns the AbstractMesh.
  18572. */
  18573. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  18574. /**
  18575. * Defines the passed node as the parent of the current node.
  18576. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  18577. * Returns the TransformNode.
  18578. */
  18579. setParent(node: Nullable<Node>): TransformNode;
  18580. private _nonUniformScaling;
  18581. readonly nonUniformScaling: boolean;
  18582. _updateNonUniformScalingState(value: boolean): boolean;
  18583. /**
  18584. * Attach the current TransformNode to another TransformNode associated with a bone
  18585. * @param bone Bone affecting the TransformNode
  18586. * @param affectedTransformNode TransformNode associated with the bone
  18587. */
  18588. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  18589. detachFromBone(): TransformNode;
  18590. private static _rotationAxisCache;
  18591. /**
  18592. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  18593. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  18594. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  18595. * The passed axis is also normalized.
  18596. * Returns the AbstractMesh.
  18597. */
  18598. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  18599. /**
  18600. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  18601. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  18602. * The passed axis is also normalized.
  18603. * Returns the AbstractMesh.
  18604. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  18605. */
  18606. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  18607. /**
  18608. * Translates the mesh along the axis vector for the passed distance in the given space.
  18609. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  18610. * Returns the AbstractMesh.
  18611. */
  18612. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  18613. /**
  18614. * Adds a rotation step to the mesh current rotation.
  18615. * x, y, z are Euler angles expressed in radians.
  18616. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  18617. * This means this rotation is made in the mesh local space only.
  18618. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  18619. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  18620. * ```javascript
  18621. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  18622. * ```
  18623. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  18624. * 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.
  18625. * Returns the AbstractMesh.
  18626. */
  18627. addRotation(x: number, y: number, z: number): TransformNode;
  18628. /**
  18629. * Computes the mesh World matrix and returns it.
  18630. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  18631. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  18632. * If the parameter `force`is set to `true`, the actual computation is done.
  18633. * Returns the mesh World Matrix.
  18634. */
  18635. computeWorldMatrix(force?: boolean): Matrix;
  18636. protected _afterComputeWorldMatrix(): void;
  18637. /**
  18638. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  18639. * @param func: callback function to add
  18640. *
  18641. * Returns the TransformNode.
  18642. */
  18643. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  18644. /**
  18645. * Removes a registered callback function.
  18646. * Returns the TransformNode.
  18647. */
  18648. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  18649. /**
  18650. * Clone the current transform node
  18651. * Returns the new transform node
  18652. * @param name Name of the new clone
  18653. * @param newParent New parent for the clone
  18654. * @param doNotCloneChildren Do not clone children hierarchy
  18655. */
  18656. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  18657. serialize(currentSerializationObject?: any): any;
  18658. /**
  18659. * Returns a new TransformNode object parsed from the source provided.
  18660. * The parameter `parsedMesh` is the source.
  18661. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  18662. */
  18663. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  18664. /**
  18665. * Disposes the TransformNode.
  18666. * By default, all the children are also disposed unless the parameter `doNotRecurse` is set to `true`.
  18667. * Returns nothing.
  18668. */
  18669. dispose(doNotRecurse?: boolean): void;
  18670. }
  18671. }
  18672. declare module BABYLON {
  18673. class VertexBuffer {
  18674. private _buffer;
  18675. private _kind;
  18676. private _offset;
  18677. private _size;
  18678. private _stride;
  18679. private _ownsBuffer;
  18680. private _instanced;
  18681. private _instanceDivisor;
  18682. /**
  18683. * Gets or sets the instance divisor when in instanced mode
  18684. */
  18685. instanceDivisor: number;
  18686. constructor(engine: any, data: FloatArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number);
  18687. _rebuild(): void;
  18688. /**
  18689. * Returns the kind of the VertexBuffer (string).
  18690. */
  18691. getKind(): string;
  18692. /**
  18693. * Boolean : is the VertexBuffer updatable ?
  18694. */
  18695. isUpdatable(): boolean;
  18696. /**
  18697. * Returns an array of numbers or a Float32Array containing the VertexBuffer data.
  18698. */
  18699. getData(): Nullable<FloatArray>;
  18700. /**
  18701. * Returns the WebGLBuffer associated to the VertexBuffer.
  18702. */
  18703. getBuffer(): Nullable<WebGLBuffer>;
  18704. /**
  18705. * Returns the stride of the VertexBuffer (integer).
  18706. */
  18707. getStrideSize(): number;
  18708. /**
  18709. * Returns the offset (integer).
  18710. */
  18711. getOffset(): number;
  18712. /**
  18713. * Returns the VertexBuffer total size (integer).
  18714. */
  18715. getSize(): number;
  18716. /**
  18717. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  18718. */
  18719. getIsInstanced(): boolean;
  18720. /**
  18721. * Returns the instancing divisor, zero for non-instanced (integer).
  18722. */
  18723. getInstanceDivisor(): number;
  18724. /**
  18725. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  18726. * Returns the created WebGLBuffer.
  18727. */
  18728. create(data?: FloatArray): void;
  18729. /**
  18730. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  18731. * This function will create a new buffer if the current one is not updatable
  18732. * Returns the updated WebGLBuffer.
  18733. */
  18734. update(data: FloatArray): void;
  18735. /**
  18736. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  18737. * Returns the directly updated WebGLBuffer.
  18738. */
  18739. updateDirectly(data: Float32Array, offset: number): void;
  18740. /**
  18741. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  18742. */
  18743. dispose(): void;
  18744. private static _PositionKind;
  18745. private static _NormalKind;
  18746. private static _TangentKind;
  18747. private static _UVKind;
  18748. private static _UV2Kind;
  18749. private static _UV3Kind;
  18750. private static _UV4Kind;
  18751. private static _UV5Kind;
  18752. private static _UV6Kind;
  18753. private static _ColorKind;
  18754. private static _MatricesIndicesKind;
  18755. private static _MatricesWeightsKind;
  18756. private static _MatricesIndicesExtraKind;
  18757. private static _MatricesWeightsExtraKind;
  18758. static readonly PositionKind: string;
  18759. static readonly NormalKind: string;
  18760. static readonly TangentKind: string;
  18761. static readonly UVKind: string;
  18762. static readonly UV2Kind: string;
  18763. static readonly UV3Kind: string;
  18764. static readonly UV4Kind: string;
  18765. static readonly UV5Kind: string;
  18766. static readonly UV6Kind: string;
  18767. static readonly ColorKind: string;
  18768. static readonly MatricesIndicesKind: string;
  18769. static readonly MatricesWeightsKind: string;
  18770. static readonly MatricesIndicesExtraKind: string;
  18771. static readonly MatricesWeightsExtraKind: string;
  18772. /**
  18773. * Deduces the stride given a kind.
  18774. * @param kind The kind string to deduce
  18775. * @returns The deduced stride
  18776. */
  18777. static DeduceStride(kind: string): number;
  18778. }
  18779. }
  18780. declare module BABYLON {
  18781. class ReflectionProbe {
  18782. name: string;
  18783. private _scene;
  18784. private _renderTargetTexture;
  18785. private _projectionMatrix;
  18786. private _viewMatrix;
  18787. private _target;
  18788. private _add;
  18789. private _attachedMesh;
  18790. private _invertYAxis;
  18791. position: Vector3;
  18792. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  18793. samples: number;
  18794. refreshRate: number;
  18795. getScene(): Scene;
  18796. readonly cubeTexture: RenderTargetTexture;
  18797. readonly renderList: Nullable<AbstractMesh[]>;
  18798. attachToMesh(mesh: AbstractMesh): void;
  18799. /**
  18800. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18801. *
  18802. * @param renderingGroupId The rendering group id corresponding to its index
  18803. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18804. */
  18805. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18806. dispose(): void;
  18807. }
  18808. }
  18809. declare module BABYLON {
  18810. interface PhysicsImpostorJoint {
  18811. mainImpostor: PhysicsImpostor;
  18812. connectedImpostor: PhysicsImpostor;
  18813. joint: PhysicsJoint;
  18814. }
  18815. class PhysicsEngine {
  18816. private _physicsPlugin;
  18817. gravity: Vector3;
  18818. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  18819. setGravity(gravity: Vector3): void;
  18820. /**
  18821. * Set the time step of the physics engine.
  18822. * default is 1/60.
  18823. * To slow it down, enter 1/600 for example.
  18824. * To speed it up, 1/30
  18825. * @param {number} newTimeStep the new timestep to apply to this world.
  18826. */
  18827. setTimeStep(newTimeStep?: number): void;
  18828. /**
  18829. * Get the time step of the physics engine.
  18830. */
  18831. getTimeStep(): number;
  18832. dispose(): void;
  18833. getPhysicsPluginName(): string;
  18834. static Epsilon: number;
  18835. private _impostors;
  18836. private _joints;
  18837. /**
  18838. * Adding a new impostor for the impostor tracking.
  18839. * This will be done by the impostor itself.
  18840. * @param {PhysicsImpostor} impostor the impostor to add
  18841. */
  18842. addImpostor(impostor: PhysicsImpostor): void;
  18843. /**
  18844. * Remove an impostor from the engine.
  18845. * This impostor and its mesh will not longer be updated by the physics engine.
  18846. * @param {PhysicsImpostor} impostor the impostor to remove
  18847. */
  18848. removeImpostor(impostor: PhysicsImpostor): void;
  18849. /**
  18850. * Add a joint to the physics engine
  18851. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  18852. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  18853. * @param {PhysicsJoint} the joint that will connect both impostors.
  18854. */
  18855. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18856. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18857. /**
  18858. * Called by the scene. no need to call it.
  18859. */
  18860. _step(delta: number): void;
  18861. getPhysicsPlugin(): IPhysicsEnginePlugin;
  18862. getImpostors(): Array<PhysicsImpostor>;
  18863. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18864. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  18865. }
  18866. interface IPhysicsEnginePlugin {
  18867. world: any;
  18868. name: string;
  18869. setGravity(gravity: Vector3): void;
  18870. setTimeStep(timeStep: number): void;
  18871. getTimeStep(): number;
  18872. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18873. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18874. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18875. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18876. removePhysicsBody(impostor: PhysicsImpostor): void;
  18877. generateJoint(joint: PhysicsImpostorJoint): void;
  18878. removeJoint(joint: PhysicsImpostorJoint): void;
  18879. isSupported(): boolean;
  18880. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18881. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18882. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18883. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18884. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18885. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18886. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18887. getBodyMass(impostor: PhysicsImpostor): number;
  18888. getBodyFriction(impostor: PhysicsImpostor): number;
  18889. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18890. getBodyRestitution(impostor: PhysicsImpostor): number;
  18891. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18892. sleepBody(impostor: PhysicsImpostor): void;
  18893. wakeUpBody(impostor: PhysicsImpostor): void;
  18894. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18895. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18896. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18897. getRadius(impostor: PhysicsImpostor): number;
  18898. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18899. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18900. dispose(): void;
  18901. }
  18902. }
  18903. declare module BABYLON {
  18904. class PhysicsHelper {
  18905. private _scene;
  18906. private _physicsEngine;
  18907. constructor(scene: Scene);
  18908. /**
  18909. * @param {Vector3} origin the origin of the explosion
  18910. * @param {number} radius the explosion radius
  18911. * @param {number} strength the explosion strength
  18912. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  18913. */
  18914. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  18915. /**
  18916. * @param {Vector3} origin the origin of the explosion
  18917. * @param {number} radius the explosion radius
  18918. * @param {number} strength the explosion strength
  18919. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  18920. */
  18921. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  18922. /**
  18923. * @param {Vector3} origin the origin of the explosion
  18924. * @param {number} radius the explosion radius
  18925. * @param {number} strength the explosion strength
  18926. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  18927. */
  18928. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  18929. /**
  18930. * @param {Vector3} origin the origin of the updraft
  18931. * @param {number} radius the radius of the updraft
  18932. * @param {number} strength the strength of the updraft
  18933. * @param {number} height the height of the updraft
  18934. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  18935. */
  18936. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  18937. /**
  18938. * @param {Vector3} origin the of the vortex
  18939. * @param {number} radius the radius of the vortex
  18940. * @param {number} strength the strength of the vortex
  18941. * @param {number} height the height of the vortex
  18942. */
  18943. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  18944. }
  18945. /***** Radial explosion *****/
  18946. class PhysicsRadialExplosionEvent {
  18947. private _scene;
  18948. private _sphere;
  18949. private _sphereOptions;
  18950. private _rays;
  18951. private _dataFetched;
  18952. constructor(scene: Scene);
  18953. /**
  18954. * Returns the data related to the radial explosion event (sphere & rays).
  18955. * @returns {PhysicsRadialExplosionEventData}
  18956. */
  18957. getData(): PhysicsRadialExplosionEventData;
  18958. /**
  18959. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  18960. * @param impostor
  18961. * @param {Vector3} origin the origin of the explosion
  18962. * @param {number} radius the explosion radius
  18963. * @param {number} strength the explosion strength
  18964. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  18965. * @returns {Nullable<PhysicsForceAndContactPoint>}
  18966. */
  18967. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  18968. /**
  18969. * Disposes the sphere.
  18970. * @param {bolean} force
  18971. */
  18972. dispose(force?: boolean): void;
  18973. /*** Helpers ***/
  18974. private _prepareSphere();
  18975. private _intersectsWithSphere(impostor, origin, radius);
  18976. }
  18977. /***** Gravitational Field *****/
  18978. class PhysicsGravitationalFieldEvent {
  18979. private _physicsHelper;
  18980. private _scene;
  18981. private _origin;
  18982. private _radius;
  18983. private _strength;
  18984. private _falloff;
  18985. private _tickCallback;
  18986. private _sphere;
  18987. private _dataFetched;
  18988. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  18989. /**
  18990. * Returns the data related to the gravitational field event (sphere).
  18991. * @returns {PhysicsGravitationalFieldEventData}
  18992. */
  18993. getData(): PhysicsGravitationalFieldEventData;
  18994. /**
  18995. * Enables the gravitational field.
  18996. */
  18997. enable(): void;
  18998. /**
  18999. * Disables the gravitational field.
  19000. */
  19001. disable(): void;
  19002. /**
  19003. * Disposes the sphere.
  19004. * @param {bolean} force
  19005. */
  19006. dispose(force?: boolean): void;
  19007. private _tick();
  19008. }
  19009. /***** Updraft *****/
  19010. class PhysicsUpdraftEvent {
  19011. private _scene;
  19012. private _origin;
  19013. private _radius;
  19014. private _strength;
  19015. private _height;
  19016. private _updraftMode;
  19017. private _physicsEngine;
  19018. private _originTop;
  19019. private _originDirection;
  19020. private _tickCallback;
  19021. private _cylinder;
  19022. private _cylinderPosition;
  19023. private _dataFetched;
  19024. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  19025. /**
  19026. * Returns the data related to the updraft event (cylinder).
  19027. * @returns {PhysicsUpdraftEventData}
  19028. */
  19029. getData(): PhysicsUpdraftEventData;
  19030. /**
  19031. * Enables the updraft.
  19032. */
  19033. enable(): void;
  19034. /**
  19035. * Disables the cortex.
  19036. */
  19037. disable(): void;
  19038. /**
  19039. * Disposes the sphere.
  19040. * @param {bolean} force
  19041. */
  19042. dispose(force?: boolean): void;
  19043. private getImpostorForceAndContactPoint(impostor);
  19044. private _tick();
  19045. /*** Helpers ***/
  19046. private _prepareCylinder();
  19047. private _intersectsWithCylinder(impostor);
  19048. }
  19049. /***** Vortex *****/
  19050. class PhysicsVortexEvent {
  19051. private _scene;
  19052. private _origin;
  19053. private _radius;
  19054. private _strength;
  19055. private _height;
  19056. private _physicsEngine;
  19057. private _originTop;
  19058. private _centripetalForceThreshold;
  19059. private _updraftMultiplier;
  19060. private _tickCallback;
  19061. private _cylinder;
  19062. private _cylinderPosition;
  19063. private _dataFetched;
  19064. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  19065. /**
  19066. * Returns the data related to the vortex event (cylinder).
  19067. * @returns {PhysicsVortexEventData}
  19068. */
  19069. getData(): PhysicsVortexEventData;
  19070. /**
  19071. * Enables the vortex.
  19072. */
  19073. enable(): void;
  19074. /**
  19075. * Disables the cortex.
  19076. */
  19077. disable(): void;
  19078. /**
  19079. * Disposes the sphere.
  19080. * @param {bolean} force
  19081. */
  19082. dispose(force?: boolean): void;
  19083. private getImpostorForceAndContactPoint(impostor);
  19084. private _tick();
  19085. /*** Helpers ***/
  19086. private _prepareCylinder();
  19087. private _intersectsWithCylinder(impostor);
  19088. }
  19089. /***** Enums *****/
  19090. /**
  19091. * The strenght of the force in correspondence to the distance of the affected object
  19092. */
  19093. enum PhysicsRadialImpulseFalloff {
  19094. Constant = 0,
  19095. Linear = 1,
  19096. }
  19097. /**
  19098. * The strenght of the force in correspondence to the distance of the affected object
  19099. */
  19100. enum PhysicsUpdraftMode {
  19101. Center = 0,
  19102. Perpendicular = 1,
  19103. }
  19104. /***** Data interfaces *****/
  19105. interface PhysicsForceAndContactPoint {
  19106. force: Vector3;
  19107. contactPoint: Vector3;
  19108. }
  19109. interface PhysicsRadialExplosionEventData {
  19110. sphere: Mesh;
  19111. rays: Array<Ray>;
  19112. }
  19113. interface PhysicsGravitationalFieldEventData {
  19114. sphere: Mesh;
  19115. }
  19116. interface PhysicsUpdraftEventData {
  19117. cylinder: Mesh;
  19118. }
  19119. interface PhysicsVortexEventData {
  19120. cylinder: Mesh;
  19121. }
  19122. }
  19123. declare module BABYLON {
  19124. interface PhysicsImpostorParameters {
  19125. mass: number;
  19126. friction?: number;
  19127. restitution?: number;
  19128. nativeOptions?: any;
  19129. ignoreParent?: boolean;
  19130. disableBidirectionalTransformation?: boolean;
  19131. }
  19132. interface IPhysicsEnabledObject {
  19133. position: Vector3;
  19134. rotationQuaternion: Nullable<Quaternion>;
  19135. scaling: Vector3;
  19136. rotation?: Vector3;
  19137. parent?: any;
  19138. getBoundingInfo(): BoundingInfo;
  19139. computeWorldMatrix(force: boolean): Matrix;
  19140. getWorldMatrix?(): Matrix;
  19141. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19142. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19143. getIndices?(): Nullable<IndicesArray>;
  19144. getScene?(): Scene;
  19145. getAbsolutePosition(): Vector3;
  19146. getAbsolutePivotPoint(): Vector3;
  19147. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19148. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19149. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19150. getClassName(): string;
  19151. }
  19152. class PhysicsImpostor {
  19153. object: IPhysicsEnabledObject;
  19154. type: number;
  19155. private _options;
  19156. private _scene;
  19157. static DEFAULT_OBJECT_SIZE: Vector3;
  19158. static IDENTITY_QUATERNION: Quaternion;
  19159. private _physicsEngine;
  19160. private _physicsBody;
  19161. private _bodyUpdateRequired;
  19162. private _onBeforePhysicsStepCallbacks;
  19163. private _onAfterPhysicsStepCallbacks;
  19164. private _onPhysicsCollideCallbacks;
  19165. private _deltaPosition;
  19166. private _deltaRotation;
  19167. private _deltaRotationConjugated;
  19168. private _parent;
  19169. private _isDisposed;
  19170. private static _tmpVecs;
  19171. private static _tmpQuat;
  19172. readonly isDisposed: boolean;
  19173. mass: number;
  19174. friction: number;
  19175. restitution: number;
  19176. uniqueId: number;
  19177. private _joints;
  19178. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19179. /**
  19180. * This function will completly initialize this impostor.
  19181. * It will create a new body - but only if this mesh has no parent.
  19182. * If it has, this impostor will not be used other than to define the impostor
  19183. * of the child mesh.
  19184. */
  19185. _init(): void;
  19186. private _getPhysicsParent();
  19187. /**
  19188. * Should a new body be generated.
  19189. */
  19190. isBodyInitRequired(): boolean;
  19191. setScalingUpdated(updated: boolean): void;
  19192. /**
  19193. * Force a regeneration of this or the parent's impostor's body.
  19194. * Use under cautious - This will remove all joints already implemented.
  19195. */
  19196. forceUpdate(): void;
  19197. /**
  19198. * Gets the body that holds this impostor. Either its own, or its parent.
  19199. */
  19200. /**
  19201. * Set the physics body. Used mainly by the physics engine/plugin
  19202. */
  19203. physicsBody: any;
  19204. parent: Nullable<PhysicsImpostor>;
  19205. resetUpdateFlags(): void;
  19206. getObjectExtendSize(): Vector3;
  19207. getObjectCenter(): Vector3;
  19208. /**
  19209. * Get a specific parametes from the options parameter.
  19210. */
  19211. getParam(paramName: string): any;
  19212. /**
  19213. * Sets a specific parameter in the options given to the physics plugin
  19214. */
  19215. setParam(paramName: string, value: number): void;
  19216. /**
  19217. * Specifically change the body's mass option. Won't recreate the physics body object
  19218. */
  19219. setMass(mass: number): void;
  19220. getLinearVelocity(): Nullable<Vector3>;
  19221. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19222. getAngularVelocity(): Nullable<Vector3>;
  19223. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19224. /**
  19225. * Execute a function with the physics plugin native code.
  19226. * Provide a function the will have two variables - the world object and the physics body object.
  19227. */
  19228. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19229. /**
  19230. * Register a function that will be executed before the physics world is stepping forward.
  19231. */
  19232. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19233. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19234. /**
  19235. * Register a function that will be executed after the physics step
  19236. */
  19237. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19238. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19239. /**
  19240. * register a function that will be executed when this impostor collides against a different body.
  19241. */
  19242. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19243. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19244. private _tmpQuat;
  19245. private _tmpQuat2;
  19246. getParentsRotation(): Quaternion;
  19247. /**
  19248. * this function is executed by the physics engine.
  19249. */
  19250. beforeStep: () => void;
  19251. /**
  19252. * this function is executed by the physics engine.
  19253. */
  19254. afterStep: () => void;
  19255. /**
  19256. * Legacy collision detection event support
  19257. */
  19258. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19259. onCollide: (e: {
  19260. body: any;
  19261. }) => void;
  19262. /**
  19263. * Apply a force
  19264. */
  19265. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19266. /**
  19267. * Apply an impulse
  19268. */
  19269. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19270. /**
  19271. * A help function to create a joint.
  19272. */
  19273. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19274. /**
  19275. * Add a joint to this impostor with a different impostor.
  19276. */
  19277. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19278. /**
  19279. * Will keep this body still, in a sleep mode.
  19280. */
  19281. sleep(): PhysicsImpostor;
  19282. /**
  19283. * Wake the body up.
  19284. */
  19285. wakeUp(): PhysicsImpostor;
  19286. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19287. dispose(): void;
  19288. setDeltaPosition(position: Vector3): void;
  19289. setDeltaRotation(rotation: Quaternion): void;
  19290. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19291. getRadius(): number;
  19292. /**
  19293. * Sync a bone with this impostor
  19294. * @param bone The bone to sync to the impostor.
  19295. * @param boneMesh The mesh that the bone is influencing.
  19296. * @param jointPivot The pivot of the joint / bone in local space.
  19297. * @param distToJoint Optional distance from the impostor to the joint.
  19298. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19299. */
  19300. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19301. /**
  19302. * Sync impostor to a bone
  19303. * @param bone The bone that the impostor will be synced to.
  19304. * @param boneMesh The mesh that the bone is influencing.
  19305. * @param jointPivot The pivot of the joint / bone in local space.
  19306. * @param distToJoint Optional distance from the impostor to the joint.
  19307. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19308. * @param boneAxis Optional vector3 axis the bone is aligned with
  19309. */
  19310. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19311. static NoImpostor: number;
  19312. static SphereImpostor: number;
  19313. static BoxImpostor: number;
  19314. static PlaneImpostor: number;
  19315. static MeshImpostor: number;
  19316. static CylinderImpostor: number;
  19317. static ParticleImpostor: number;
  19318. static HeightmapImpostor: number;
  19319. }
  19320. }
  19321. declare module BABYLON {
  19322. interface PhysicsJointData {
  19323. mainPivot?: Vector3;
  19324. connectedPivot?: Vector3;
  19325. mainAxis?: Vector3;
  19326. connectedAxis?: Vector3;
  19327. collision?: boolean;
  19328. nativeParams?: any;
  19329. }
  19330. /**
  19331. * This is a holder class for the physics joint created by the physics plugin.
  19332. * It holds a set of functions to control the underlying joint.
  19333. */
  19334. class PhysicsJoint {
  19335. type: number;
  19336. jointData: PhysicsJointData;
  19337. private _physicsJoint;
  19338. protected _physicsPlugin: IPhysicsEnginePlugin;
  19339. constructor(type: number, jointData: PhysicsJointData);
  19340. physicsJoint: any;
  19341. physicsPlugin: IPhysicsEnginePlugin;
  19342. /**
  19343. * Execute a function that is physics-plugin specific.
  19344. * @param {Function} func the function that will be executed.
  19345. * It accepts two parameters: the physics world and the physics joint.
  19346. */
  19347. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19348. static DistanceJoint: number;
  19349. static HingeJoint: number;
  19350. static BallAndSocketJoint: number;
  19351. static WheelJoint: number;
  19352. static SliderJoint: number;
  19353. static PrismaticJoint: number;
  19354. static UniversalJoint: number;
  19355. static Hinge2Joint: number;
  19356. static PointToPointJoint: number;
  19357. static SpringJoint: number;
  19358. static LockJoint: number;
  19359. }
  19360. /**
  19361. * A class representing a physics distance joint.
  19362. */
  19363. class DistanceJoint extends PhysicsJoint {
  19364. constructor(jointData: DistanceJointData);
  19365. /**
  19366. * Update the predefined distance.
  19367. */
  19368. updateDistance(maxDistance: number, minDistance?: number): void;
  19369. }
  19370. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19371. constructor(type: number, jointData: PhysicsJointData);
  19372. /**
  19373. * Set the motor values.
  19374. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19375. * @param {number} force the force to apply
  19376. * @param {number} maxForce max force for this motor.
  19377. */
  19378. setMotor(force?: number, maxForce?: number): void;
  19379. /**
  19380. * Set the motor's limits.
  19381. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19382. */
  19383. setLimit(upperLimit: number, lowerLimit?: number): void;
  19384. }
  19385. /**
  19386. * This class represents a single hinge physics joint
  19387. */
  19388. class HingeJoint extends MotorEnabledJoint {
  19389. constructor(jointData: PhysicsJointData);
  19390. /**
  19391. * Set the motor values.
  19392. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19393. * @param {number} force the force to apply
  19394. * @param {number} maxForce max force for this motor.
  19395. */
  19396. setMotor(force?: number, maxForce?: number): void;
  19397. /**
  19398. * Set the motor's limits.
  19399. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19400. */
  19401. setLimit(upperLimit: number, lowerLimit?: number): void;
  19402. }
  19403. /**
  19404. * This class represents a dual hinge physics joint (same as wheel joint)
  19405. */
  19406. class Hinge2Joint extends MotorEnabledJoint {
  19407. constructor(jointData: PhysicsJointData);
  19408. /**
  19409. * Set the motor values.
  19410. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19411. * @param {number} force the force to apply
  19412. * @param {number} maxForce max force for this motor.
  19413. * @param {motorIndex} the motor's index, 0 or 1.
  19414. */
  19415. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19416. /**
  19417. * Set the motor limits.
  19418. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19419. * @param {number} upperLimit the upper limit
  19420. * @param {number} lowerLimit lower limit
  19421. * @param {motorIndex} the motor's index, 0 or 1.
  19422. */
  19423. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19424. }
  19425. interface IMotorEnabledJoint {
  19426. physicsJoint: any;
  19427. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19428. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19429. }
  19430. interface DistanceJointData extends PhysicsJointData {
  19431. maxDistance: number;
  19432. }
  19433. interface SpringJointData extends PhysicsJointData {
  19434. length: number;
  19435. stiffness: number;
  19436. damping: number;
  19437. }
  19438. }
  19439. declare module BABYLON {
  19440. class Sprite {
  19441. name: string;
  19442. position: Vector3;
  19443. color: Color4;
  19444. width: number;
  19445. height: number;
  19446. angle: number;
  19447. cellIndex: number;
  19448. invertU: number;
  19449. invertV: number;
  19450. disposeWhenFinishedAnimating: boolean;
  19451. animations: Animation[];
  19452. isPickable: boolean;
  19453. actionManager: ActionManager;
  19454. private _animationStarted;
  19455. private _loopAnimation;
  19456. private _fromIndex;
  19457. private _toIndex;
  19458. private _delay;
  19459. private _direction;
  19460. private _manager;
  19461. private _time;
  19462. private _onAnimationEnd;
  19463. size: number;
  19464. constructor(name: string, manager: SpriteManager);
  19465. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  19466. stopAnimation(): void;
  19467. _animate(deltaTime: number): void;
  19468. dispose(): void;
  19469. }
  19470. }
  19471. declare module BABYLON {
  19472. class SpriteManager {
  19473. name: string;
  19474. sprites: Sprite[];
  19475. renderingGroupId: number;
  19476. layerMask: number;
  19477. fogEnabled: boolean;
  19478. isPickable: boolean;
  19479. cellWidth: number;
  19480. cellHeight: number;
  19481. /**
  19482. * An event triggered when the manager is disposed.
  19483. * @type {BABYLON.Observable}
  19484. */
  19485. onDisposeObservable: Observable<SpriteManager>;
  19486. private _onDisposeObserver;
  19487. onDispose: () => void;
  19488. private _capacity;
  19489. private _spriteTexture;
  19490. private _epsilon;
  19491. private _scene;
  19492. private _vertexData;
  19493. private _buffer;
  19494. private _vertexBuffers;
  19495. private _indexBuffer;
  19496. private _effectBase;
  19497. private _effectFog;
  19498. texture: Texture;
  19499. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  19500. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  19501. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  19502. render(): void;
  19503. dispose(): void;
  19504. }
  19505. }
  19506. declare module BABYLON {
  19507. class AnaglyphPostProcess extends PostProcess {
  19508. private _passedProcess;
  19509. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  19510. }
  19511. }
  19512. declare module BABYLON {
  19513. class BlackAndWhitePostProcess extends PostProcess {
  19514. degree: number;
  19515. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  19516. }
  19517. }
  19518. declare module BABYLON {
  19519. /**
  19520. * The Blur Post Process which blurs an image based on a kernel and direction.
  19521. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19522. */
  19523. class BlurPostProcess extends PostProcess {
  19524. /** The direction in which to blur the image. */ direction: Vector2;
  19525. protected _kernel: number;
  19526. protected _idealKernel: number;
  19527. protected _packedFloat: boolean;
  19528. private _staticDefines;
  19529. /**
  19530. * Gets the length in pixels of the blur sample region
  19531. */
  19532. /**
  19533. * Sets the length in pixels of the blur sample region
  19534. */
  19535. kernel: number;
  19536. /**
  19537. * Gets wether or not the blur is unpacking/repacking floats
  19538. */
  19539. /**
  19540. * Sets wether or not the blur needs to unpack/repack floats
  19541. */
  19542. packedFloat: boolean;
  19543. /**
  19544. * Creates a new instance of @see BlurPostProcess
  19545. * @param name The name of the effect.
  19546. * @param direction The direction in which to blur the image.
  19547. * @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.
  19548. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19549. * @param camera The camera to apply the render pass to.
  19550. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19551. * @param engine The engine which the post process will be applied. (default: current engine)
  19552. * @param reusable If the post process can be reused on the same frame. (default: false)
  19553. * @param textureType Type of textures used when performing the post process. (default: 0)
  19554. */
  19555. constructor(name: string, /** The direction in which to blur the image. */ direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string);
  19556. protected _updateParameters(): void;
  19557. /**
  19558. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  19559. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  19560. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  19561. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  19562. * The gaps between physical kernels are compensated for in the weighting of the samples
  19563. * @param idealKernel Ideal blur kernel.
  19564. * @return Nearest best kernel.
  19565. */
  19566. protected _nearestBestKernel(idealKernel: number): number;
  19567. /**
  19568. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  19569. * @param x The point on the Gaussian distribution to sample.
  19570. * @return the value of the Gaussian function at x.
  19571. */
  19572. protected _gaussianWeight(x: number): number;
  19573. /**
  19574. * Generates a string that can be used as a floating point number in GLSL.
  19575. * @param x Value to print.
  19576. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  19577. * @return GLSL float string.
  19578. */
  19579. protected _glslFloat(x: number, decimalFigures?: number): string;
  19580. }
  19581. }
  19582. declare module BABYLON {
  19583. /**
  19584. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  19585. */
  19586. class ChromaticAberrationPostProcess extends PostProcess {
  19587. /**
  19588. * The amount of seperation of rgb channels (default: 0)
  19589. */
  19590. aberrationAmount: number;
  19591. /**
  19592. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  19593. */
  19594. radialIntensity: number;
  19595. /**
  19596. * 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))
  19597. */
  19598. direction: Vector2;
  19599. /**
  19600. * 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))
  19601. */
  19602. centerPosition: Vector2;
  19603. /**
  19604. * Creates a new instance of @see ChromaticAberrationPostProcess
  19605. * @param name The name of the effect.
  19606. * @param screenWidth The width of the screen to apply the effect on.
  19607. * @param screenHeight The height of the screen to apply the effect on.
  19608. * @param options The required width/height ratio to downsize to before computing the render pass.
  19609. * @param camera The camera to apply the render pass to.
  19610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19611. * @param engine The engine which the post process will be applied. (default: current engine)
  19612. * @param reusable If the post process can be reused on the same frame. (default: false)
  19613. * @param textureType Type of textures used when performing the post process. (default: 0)
  19614. */
  19615. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  19616. }
  19617. }
  19618. declare module BABYLON {
  19619. /**
  19620. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  19621. */
  19622. class CircleOfConfusionPostProcess extends PostProcess {
  19623. /**
  19624. * 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.
  19625. */
  19626. lensSize: number;
  19627. /**
  19628. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  19629. */
  19630. fStop: number;
  19631. /**
  19632. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  19633. */
  19634. focusDistance: number;
  19635. /**
  19636. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  19637. */
  19638. focalLength: number;
  19639. /**
  19640. * Creates a new instance of @see CircleOfConfusionPostProcess
  19641. * @param name The name of the effect.
  19642. * @param depthTexture The depth texture of the scene to compute the circle of confusion.
  19643. * @param options The required width/height ratio to downsize to before computing the render pass.
  19644. * @param camera The camera to apply the render pass to.
  19645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19646. * @param engine The engine which the post process will be applied. (default: current engine)
  19647. * @param reusable If the post process can be reused on the same frame. (default: false)
  19648. * @param textureType Type of textures used when performing the post process. (default: 0)
  19649. */
  19650. constructor(name: string, depthTexture: RenderTargetTexture, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  19651. }
  19652. }
  19653. declare module BABYLON {
  19654. class ColorCorrectionPostProcess extends PostProcess {
  19655. private _colorTableTexture;
  19656. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  19657. }
  19658. }
  19659. declare module BABYLON {
  19660. /**
  19661. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  19662. * input texture to perform effects such as edge detection or sharpening
  19663. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  19664. */
  19665. class ConvolutionPostProcess extends PostProcess {
  19666. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  19667. /**
  19668. * Creates a new instance of @see ConvolutionPostProcess
  19669. * @param name The name of the effect.
  19670. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  19671. * @param options The required width/height ratio to downsize to before computing the render pass.
  19672. * @param camera The camera to apply the render pass to.
  19673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19674. * @param engine The engine which the post process will be applied. (default: current engine)
  19675. * @param reusable If the post process can be reused on the same frame. (default: false)
  19676. * @param textureType Type of textures used when performing the post process. (default: 0)
  19677. */
  19678. constructor(name: string, /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  19679. /**
  19680. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  19681. */
  19682. static EdgeDetect0Kernel: number[];
  19683. /**
  19684. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  19685. */
  19686. static EdgeDetect1Kernel: number[];
  19687. /**
  19688. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  19689. */
  19690. static EdgeDetect2Kernel: number[];
  19691. /**
  19692. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  19693. */
  19694. static SharpenKernel: number[];
  19695. /**
  19696. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  19697. */
  19698. static EmbossKernel: number[];
  19699. /**
  19700. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  19701. */
  19702. static GaussianKernel: number[];
  19703. }
  19704. }
  19705. declare module BABYLON {
  19706. /**
  19707. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  19708. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  19709. * based on samples that have a large difference in distance than the center pixel.
  19710. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  19711. */
  19712. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  19713. direction: Vector2;
  19714. /**
  19715. * Creates a new instance of @see CircleOfConfusionPostProcess
  19716. * @param name The name of the effect.
  19717. * @param scene The scene the effect belongs to.
  19718. * @param direction The direction the blur should be applied.
  19719. * @param kernel The size of the kernel used to blur.
  19720. * @param options The required width/height ratio to downsize to before computing the render pass.
  19721. * @param camera The camera to apply the render pass to.
  19722. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  19723. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  19724. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19725. * @param engine The engine which the post process will be applied. (default: current engine)
  19726. * @param reusable If the post process can be reused on the same frame. (default: false)
  19727. * @param textureType Type of textures used when performing the post process. (default: 0)
  19728. */
  19729. 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);
  19730. }
  19731. }
  19732. declare module BABYLON {
  19733. /**
  19734. * Specifies the level of max blur that should be applied when using the depth of field effect
  19735. */
  19736. enum DepthOfFieldEffectBlurLevel {
  19737. /**
  19738. * Subtle blur
  19739. */
  19740. Low = 0,
  19741. /**
  19742. * Medium blur
  19743. */
  19744. Medium = 1,
  19745. /**
  19746. * Large blur
  19747. */
  19748. High = 2,
  19749. }
  19750. /**
  19751. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  19752. */
  19753. class DepthOfFieldEffect extends PostProcessRenderEffect {
  19754. private _depthOfFieldPass;
  19755. private _circleOfConfusion;
  19756. private _depthOfFieldBlurX;
  19757. private _depthOfFieldBlurY;
  19758. private _depthOfFieldMerge;
  19759. /**
  19760. * The focal the length of the camera used in the effect
  19761. */
  19762. focalLength: number;
  19763. /**
  19764. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  19765. */
  19766. fStop: number;
  19767. /**
  19768. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  19769. */
  19770. focusDistance: number;
  19771. /**
  19772. * 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.
  19773. */
  19774. lensSize: number;
  19775. /**
  19776. * Creates a new instance of @see DepthOfFieldEffect
  19777. * @param scene The scene the effect belongs to.
  19778. * @param depthTexture The depth texture of the scene to compute the circle of confusion.
  19779. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  19780. */
  19781. constructor(scene: Scene, depthTexture: RenderTargetTexture, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number);
  19782. /**
  19783. * Disposes each of the internal effects for a given camera.
  19784. * @param camera The camera to dispose the effect on.
  19785. */
  19786. disposeEffects(camera: Camera): void;
  19787. }
  19788. }
  19789. declare module BABYLON {
  19790. /**
  19791. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  19792. */
  19793. class DepthOfFieldMergePostProcess extends PostProcess {
  19794. /**
  19795. * Creates a new instance of @see CircleOfConfusionPostProcess
  19796. * @param name The name of the effect.
  19797. * @param original The non-blurred image to be modified
  19798. * @param circleOfConfusion The circle of confusion post process that will determine how blurred each pixel should become.
  19799. * @param blurSteps Incrimental bluring post processes.
  19800. * @param options The required width/height ratio to downsize to before computing the render pass.
  19801. * @param camera The camera to apply the render pass to.
  19802. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19803. * @param engine The engine which the post process will be applied. (default: current engine)
  19804. * @param reusable If the post process can be reused on the same frame. (default: false)
  19805. * @param textureType Type of textures used when performing the post process. (default: 0)
  19806. */
  19807. constructor(name: string, original: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  19808. }
  19809. }
  19810. declare module BABYLON {
  19811. class DisplayPassPostProcess extends PostProcess {
  19812. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  19813. }
  19814. }
  19815. declare module BABYLON {
  19816. class FilterPostProcess extends PostProcess {
  19817. kernelMatrix: Matrix;
  19818. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  19819. }
  19820. }
  19821. declare module BABYLON {
  19822. class FxaaPostProcess extends PostProcess {
  19823. texelWidth: number;
  19824. texelHeight: number;
  19825. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  19826. }
  19827. }
  19828. declare module BABYLON {
  19829. class HighlightsPostProcess extends PostProcess {
  19830. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  19831. }
  19832. }
  19833. declare module BABYLON {
  19834. class ImageProcessingPostProcess extends PostProcess {
  19835. /**
  19836. * Default configuration related to image processing available in the PBR Material.
  19837. */
  19838. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19839. /**
  19840. * Gets the image processing configuration used either in this material.
  19841. */
  19842. /**
  19843. * Sets the Default image processing configuration used either in the this material.
  19844. *
  19845. * If sets to null, the scene one is in use.
  19846. */
  19847. imageProcessingConfiguration: ImageProcessingConfiguration;
  19848. /**
  19849. * Keep track of the image processing observer to allow dispose and replace.
  19850. */
  19851. private _imageProcessingObserver;
  19852. /**
  19853. * Attaches a new image processing configuration to the PBR Material.
  19854. * @param configuration
  19855. */
  19856. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  19857. /**
  19858. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  19859. */
  19860. /**
  19861. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  19862. */
  19863. colorCurves: Nullable<ColorCurves>;
  19864. /**
  19865. * Gets wether the color curves effect is enabled.
  19866. */
  19867. /**
  19868. * Sets wether the color curves effect is enabled.
  19869. */
  19870. colorCurvesEnabled: boolean;
  19871. /**
  19872. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  19873. */
  19874. /**
  19875. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  19876. */
  19877. colorGradingTexture: Nullable<BaseTexture>;
  19878. /**
  19879. * Gets wether the color grading effect is enabled.
  19880. */
  19881. /**
  19882. * Gets wether the color grading effect is enabled.
  19883. */
  19884. colorGradingEnabled: boolean;
  19885. /**
  19886. * Gets exposure used in the effect.
  19887. */
  19888. /**
  19889. * Sets exposure used in the effect.
  19890. */
  19891. exposure: number;
  19892. /**
  19893. * Gets wether tonemapping is enabled or not.
  19894. */
  19895. /**
  19896. * Sets wether tonemapping is enabled or not
  19897. */
  19898. toneMappingEnabled: boolean;
  19899. /**
  19900. * Gets contrast used in the effect.
  19901. */
  19902. /**
  19903. * Sets contrast used in the effect.
  19904. */
  19905. contrast: number;
  19906. /**
  19907. * Gets Vignette stretch size.
  19908. */
  19909. /**
  19910. * Sets Vignette stretch size.
  19911. */
  19912. vignetteStretch: number;
  19913. /**
  19914. * Gets Vignette centre X Offset.
  19915. */
  19916. /**
  19917. * Sets Vignette centre X Offset.
  19918. */
  19919. vignetteCentreX: number;
  19920. /**
  19921. * Gets Vignette centre Y Offset.
  19922. */
  19923. /**
  19924. * Sets Vignette centre Y Offset.
  19925. */
  19926. vignetteCentreY: number;
  19927. /**
  19928. * Gets Vignette weight or intensity of the vignette effect.
  19929. */
  19930. /**
  19931. * Sets Vignette weight or intensity of the vignette effect.
  19932. */
  19933. vignetteWeight: number;
  19934. /**
  19935. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  19936. * if vignetteEnabled is set to true.
  19937. */
  19938. /**
  19939. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  19940. * if vignetteEnabled is set to true.
  19941. */
  19942. vignetteColor: Color4;
  19943. /**
  19944. * Gets Camera field of view used by the Vignette effect.
  19945. */
  19946. /**
  19947. * Sets Camera field of view used by the Vignette effect.
  19948. */
  19949. vignetteCameraFov: number;
  19950. /**
  19951. * Gets the vignette blend mode allowing different kind of effect.
  19952. */
  19953. /**
  19954. * Sets the vignette blend mode allowing different kind of effect.
  19955. */
  19956. vignetteBlendMode: number;
  19957. /**
  19958. * Gets wether the vignette effect is enabled.
  19959. */
  19960. /**
  19961. * Sets wether the vignette effect is enabled.
  19962. */
  19963. vignetteEnabled: boolean;
  19964. private _fromLinearSpace;
  19965. /**
  19966. * Gets wether the input of the processing is in Gamma or Linear Space.
  19967. */
  19968. /**
  19969. * Sets wether the input of the processing is in Gamma or Linear Space.
  19970. */
  19971. fromLinearSpace: boolean;
  19972. /**
  19973. * Defines cache preventing GC.
  19974. */
  19975. private _defines;
  19976. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  19977. getClassName(): string;
  19978. protected _updateParameters(): void;
  19979. dispose(camera?: Camera): void;
  19980. }
  19981. }
  19982. declare module BABYLON {
  19983. class PassPostProcess extends PostProcess {
  19984. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  19985. }
  19986. }
  19987. declare module BABYLON {
  19988. type PostProcessOptions = {
  19989. width: number;
  19990. height: number;
  19991. };
  19992. /**
  19993. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19994. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19995. */
  19996. class PostProcess {
  19997. /** Name of the PostProcess. */ name: string;
  19998. /**
  19999. * Width of the texture to apply the post process on
  20000. */
  20001. width: number;
  20002. /**
  20003. * Height of the texture to apply the post process on
  20004. */
  20005. height: number;
  20006. /**
  20007. * Sampling mode used by the shader
  20008. * See https://doc.babylonjs.com/classes/3.1/texture
  20009. */
  20010. renderTargetSamplingMode: number;
  20011. /**
  20012. * Clear color to use when screen clearing
  20013. */
  20014. clearColor: Color4;
  20015. /**
  20016. * If the buffer needs to be cleared before applying the post process. (default: true)
  20017. * Should be set to false if shader will overwrite all previous pixels.
  20018. */
  20019. autoClear: boolean;
  20020. /**
  20021. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20022. */
  20023. alphaMode: number;
  20024. /**
  20025. * Sets the setAlphaBlendConstants of the babylon engine
  20026. */
  20027. alphaConstants: Color4;
  20028. /**
  20029. * Animations to be used for the post processing
  20030. */
  20031. animations: Animation[];
  20032. /**
  20033. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20034. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20035. */
  20036. enablePixelPerfectMode: boolean;
  20037. /**
  20038. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20039. */
  20040. scaleMode: number;
  20041. /**
  20042. * Force textures to be a power of two (default: false)
  20043. */
  20044. alwaysForcePOT: boolean;
  20045. /**
  20046. * Number of sample textures (default: 1)
  20047. */
  20048. samples: number;
  20049. /**
  20050. * Modify the scale of the post process to be the same as the viewport (default: false)
  20051. */
  20052. adaptScaleToCurrentViewport: boolean;
  20053. private _camera;
  20054. private _scene;
  20055. private _engine;
  20056. private _options;
  20057. private _reusable;
  20058. private _textureType;
  20059. /**
  20060. * Smart array of input and output textures for the post process.
  20061. */
  20062. _textures: SmartArray<InternalTexture>;
  20063. /**
  20064. * The index in _textures that corresponds to the output texture.
  20065. */
  20066. _currentRenderTextureInd: number;
  20067. private _effect;
  20068. private _samplers;
  20069. private _fragmentUrl;
  20070. private _vertexUrl;
  20071. private _parameters;
  20072. private _scaleRatio;
  20073. protected _indexParameters: any;
  20074. private _shareOutputWithPostProcess;
  20075. private _texelSize;
  20076. private _forcedOutputTexture;
  20077. /**
  20078. * An event triggered when the postprocess is activated.
  20079. * @type {BABYLON.Observable}
  20080. */
  20081. onActivateObservable: Observable<Camera>;
  20082. private _onActivateObserver;
  20083. /**
  20084. * A function that is added to the onActivateObservable
  20085. */
  20086. onActivate: Nullable<(camera: Camera) => void>;
  20087. /**
  20088. * An event triggered when the postprocess changes its size.
  20089. * @type {BABYLON.Observable}
  20090. */
  20091. onSizeChangedObservable: Observable<PostProcess>;
  20092. private _onSizeChangedObserver;
  20093. /**
  20094. * A function that is added to the onSizeChangedObservable
  20095. */
  20096. onSizeChanged: (postProcess: PostProcess) => void;
  20097. /**
  20098. * An event triggered when the postprocess applies its effect.
  20099. * @type {BABYLON.Observable}
  20100. */
  20101. onApplyObservable: Observable<Effect>;
  20102. private _onApplyObserver;
  20103. /**
  20104. * A function that is added to the onApplyObservable
  20105. */
  20106. onApply: (effect: Effect) => void;
  20107. /**
  20108. * An event triggered before rendering the postprocess
  20109. * @type {BABYLON.Observable}
  20110. */
  20111. onBeforeRenderObservable: Observable<Effect>;
  20112. private _onBeforeRenderObserver;
  20113. /**
  20114. * A function that is added to the onBeforeRenderObservable
  20115. */
  20116. onBeforeRender: (effect: Effect) => void;
  20117. /**
  20118. * An event triggered after rendering the postprocess
  20119. * @type {BABYLON.Observable}
  20120. */
  20121. onAfterRenderObservable: Observable<Effect>;
  20122. private _onAfterRenderObserver;
  20123. /**
  20124. * A function that is added to the onAfterRenderObservable
  20125. */
  20126. onAfterRender: (efect: Effect) => void;
  20127. /**
  20128. * 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
  20129. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20130. */
  20131. inputTexture: InternalTexture;
  20132. /**
  20133. * Gets the camera which post process is applied to.
  20134. * @returns The camera the post process is applied to.
  20135. */
  20136. getCamera(): Camera;
  20137. /**
  20138. * Gets the texel size of the postprocess.
  20139. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20140. */
  20141. readonly texelSize: Vector2;
  20142. /**
  20143. * Creates a new instance of @see PostProcess
  20144. * @param name The name of the PostProcess.
  20145. * @param fragmentUrl The url of the fragment shader to be used.
  20146. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20147. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20148. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20149. * @param camera The camera to apply the render pass to.
  20150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20151. * @param engine The engine which the post process will be applied. (default: current engine)
  20152. * @param reusable If the post process can be reused on the same frame. (default: false)
  20153. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20154. * @param textureType Type of textures used when performing the post process. (default: 0)
  20155. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20156. * @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
  20157. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20158. */
  20159. constructor(/** Name of the PostProcess. */ name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  20160. /**
  20161. * Gets the engine which this post process belongs to.
  20162. * @returns The engine the post process was enabled with.
  20163. */
  20164. getEngine(): Engine;
  20165. /**
  20166. * The effect that is created when initializing the post process.
  20167. * @returns The created effect corrisponding the the postprocess.
  20168. */
  20169. getEffect(): Effect;
  20170. /**
  20171. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20172. * @param postProcess The post process to share the output with.
  20173. * @returns This post process.
  20174. */
  20175. shareOutputWith(postProcess: PostProcess): PostProcess;
  20176. /**
  20177. * Updates the effect with the current post process compile time values and recompiles the shader.
  20178. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20179. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20180. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20181. * @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
  20182. * @param onCompiled Called when the shader has been compiled.
  20183. * @param onError Called if there is an error when compiling a shader.
  20184. */
  20185. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20186. /**
  20187. * The post process is reusable if it can be used multiple times within one frame.
  20188. * @returns If the post process is reusable
  20189. */
  20190. isReusable(): boolean;
  20191. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20192. markTextureDirty(): void;
  20193. /**
  20194. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20195. * 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.
  20196. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20197. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20198. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20199. */
  20200. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): void;
  20201. /**
  20202. * If the post process is supported.
  20203. */
  20204. readonly isSupported: boolean;
  20205. /**
  20206. * The aspect ratio of the output texture.
  20207. */
  20208. readonly aspectRatio: number;
  20209. /**
  20210. * Get a value indicating if the post-process is ready to be used
  20211. * @returns true if the post-process is ready (shader is compiled)
  20212. */
  20213. isReady(): boolean;
  20214. /**
  20215. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20216. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  20217. */
  20218. apply(): Nullable<Effect>;
  20219. private _disposeTextures();
  20220. /**
  20221. * Disposes the post process.
  20222. * @param camera The camera to dispose the post process on.
  20223. */
  20224. dispose(camera?: Camera): void;
  20225. }
  20226. }
  20227. declare module BABYLON {
  20228. /**
  20229. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20230. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20231. */
  20232. class PostProcessManager {
  20233. private _scene;
  20234. private _indexBuffer;
  20235. private _vertexBuffers;
  20236. /**
  20237. * Creates a new instance of @see PostProcess
  20238. * @param scene The scene that the post process is associated with.
  20239. */
  20240. constructor(scene: Scene);
  20241. private _prepareBuffers();
  20242. private _buildIndexBuffer();
  20243. /**
  20244. * Rebuilds the vertex buffers of the manager.
  20245. */
  20246. _rebuild(): void;
  20247. /**
  20248. * Prepares a frame to be run through a post process.
  20249. * @param sourceTexture The input texture to the post procesess. (default: null)
  20250. * @param postProcesses An array of post processes to be run. (default: null)
  20251. * @returns True if the post processes were able to be run.
  20252. */
  20253. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20254. /**
  20255. * Manually render a set of post processes to a texture.
  20256. * @param postProcesses An array of post processes to be run.
  20257. * @param targetTexture The target texture to render to.
  20258. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20259. */
  20260. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  20261. /**
  20262. * Finalize the result of the output of the postprocesses.
  20263. * @param doNotPresent If true the result will not be displayed to the screen.
  20264. * @param targetTexture The target texture to render to.
  20265. * @param faceIndex The index of the face to bind the target texture to.
  20266. * @param postProcesses The array of post processes to render.
  20267. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20268. */
  20269. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: PostProcess[], forceFullscreenViewport?: boolean): void;
  20270. /**
  20271. * Disposes of the post process manager.
  20272. */
  20273. dispose(): void;
  20274. }
  20275. }
  20276. declare module BABYLON {
  20277. class RefractionPostProcess extends PostProcess {
  20278. color: Color3;
  20279. depth: number;
  20280. colorLevel: number;
  20281. private _refTexture;
  20282. private _ownRefractionTexture;
  20283. /**
  20284. * Gets or sets the refraction texture
  20285. * Please note that you are responsible for disposing the texture if you set it manually
  20286. */
  20287. refractionTexture: Texture;
  20288. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  20289. dispose(camera: Camera): void;
  20290. }
  20291. }
  20292. declare module BABYLON {
  20293. /**
  20294. * The SharpenPostProcess applies a sharpen kernel to every pixel
  20295. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  20296. */
  20297. class SharpenPostProcess extends PostProcess {
  20298. /**
  20299. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  20300. */
  20301. colorAmount: number;
  20302. /**
  20303. * How much sharpness should be applied (default: 0.3)
  20304. */
  20305. edgeAmount: number;
  20306. /**
  20307. * Creates a new instance of @see ConvolutionPostProcess
  20308. * @param name The name of the effect.
  20309. * @param options The required width/height ratio to downsize to before computing the render pass.
  20310. * @param camera The camera to apply the render pass to.
  20311. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20312. * @param engine The engine which the post process will be applied. (default: current engine)
  20313. * @param reusable If the post process can be reused on the same frame. (default: false)
  20314. * @param textureType Type of textures used when performing the post process. (default: 0)
  20315. */
  20316. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  20317. }
  20318. }
  20319. declare module BABYLON {
  20320. class StereoscopicInterlacePostProcess extends PostProcess {
  20321. private _stepSize;
  20322. private _passedProcess;
  20323. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  20324. }
  20325. }
  20326. declare module BABYLON {
  20327. enum TonemappingOperator {
  20328. Hable = 0,
  20329. Reinhard = 1,
  20330. HejiDawson = 2,
  20331. Photographic = 3,
  20332. }
  20333. class TonemapPostProcess extends PostProcess {
  20334. private _operator;
  20335. exposureAdjustment: number;
  20336. constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  20337. }
  20338. }
  20339. declare module BABYLON {
  20340. class VolumetricLightScatteringPostProcess extends PostProcess {
  20341. private _volumetricLightScatteringPass;
  20342. private _volumetricLightScatteringRTT;
  20343. private _viewPort;
  20344. private _screenCoordinates;
  20345. private _cachedDefines;
  20346. /**
  20347. * If not undefined, the mesh position is computed from the attached node position
  20348. * @type {{position: Vector3}}
  20349. */
  20350. attachedNode: {
  20351. position: Vector3;
  20352. };
  20353. /**
  20354. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  20355. * @type {Vector3}
  20356. */
  20357. customMeshPosition: Vector3;
  20358. /**
  20359. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  20360. * @type {boolean}
  20361. */
  20362. useCustomMeshPosition: boolean;
  20363. /**
  20364. * If the post-process should inverse the light scattering direction
  20365. * @type {boolean}
  20366. */
  20367. invert: boolean;
  20368. /**
  20369. * The internal mesh used by the post-process
  20370. * @type {boolean}
  20371. */
  20372. mesh: Mesh;
  20373. useDiffuseColor: boolean;
  20374. /**
  20375. * Array containing the excluded meshes not rendered in the internal pass
  20376. */
  20377. excludedMeshes: AbstractMesh[];
  20378. /**
  20379. * Controls the overall intensity of the post-process
  20380. * @type {number}
  20381. */
  20382. exposure: number;
  20383. /**
  20384. * Dissipates each sample's contribution in range [0, 1]
  20385. * @type {number}
  20386. */
  20387. decay: number;
  20388. /**
  20389. * Controls the overall intensity of each sample
  20390. * @type {number}
  20391. */
  20392. weight: number;
  20393. /**
  20394. * Controls the density of each sample
  20395. * @type {number}
  20396. */
  20397. density: number;
  20398. /**
  20399. * @constructor
  20400. * @param {string} name - The post-process name
  20401. * @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)
  20402. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  20403. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  20404. * @param {number} samples - The post-process quality, default 100
  20405. * @param {number} samplingMode - The post-process filtering mode
  20406. * @param {BABYLON.Engine} engine - The babylon engine
  20407. * @param {boolean} reusable - If the post-process is reusable
  20408. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  20409. */
  20410. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  20411. getClassName(): string;
  20412. private _isReady(subMesh, useInstances);
  20413. /**
  20414. * Sets the new light position for light scattering effect
  20415. * @param {BABYLON.Vector3} The new custom light position
  20416. */
  20417. setCustomMeshPosition(position: Vector3): void;
  20418. /**
  20419. * Returns the light position for light scattering effect
  20420. * @return {BABYLON.Vector3} The custom light position
  20421. */
  20422. getCustomMeshPosition(): Vector3;
  20423. /**
  20424. * Disposes the internal assets and detaches the post-process from the camera
  20425. */
  20426. dispose(camera: Camera): void;
  20427. /**
  20428. * Returns the render target texture used by the post-process
  20429. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  20430. */
  20431. getPass(): RenderTargetTexture;
  20432. private _meshExcluded(mesh);
  20433. private _createPass(scene, ratio);
  20434. private _updateMeshScreenCoordinates(scene);
  20435. /**
  20436. * Creates a default mesh for the Volumeric Light Scattering post-process
  20437. * @param {string} The mesh name
  20438. * @param {BABYLON.Scene} The scene where to create the mesh
  20439. * @return {BABYLON.Mesh} the default mesh
  20440. */
  20441. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  20442. }
  20443. }
  20444. declare module BABYLON {
  20445. class VRDistortionCorrectionPostProcess extends PostProcess {
  20446. aspectRatio: number;
  20447. private _isRightEye;
  20448. private _distortionFactors;
  20449. private _postProcessScaleFactor;
  20450. private _lensCenterOffset;
  20451. private _scaleIn;
  20452. private _scaleFactor;
  20453. private _lensCenter;
  20454. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  20455. }
  20456. }
  20457. declare module BABYLON {
  20458. class BoundingBoxRenderer {
  20459. frontColor: Color3;
  20460. backColor: Color3;
  20461. showBackLines: boolean;
  20462. renderList: SmartArray<BoundingBox>;
  20463. private _scene;
  20464. private _colorShader;
  20465. private _vertexBuffers;
  20466. private _indexBuffer;
  20467. constructor(scene: Scene);
  20468. private _prepareRessources();
  20469. private _createIndexBuffer();
  20470. _rebuild(): void;
  20471. reset(): void;
  20472. render(): void;
  20473. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  20474. dispose(): void;
  20475. }
  20476. }
  20477. declare module BABYLON {
  20478. /**
  20479. * This represents a depth renderer in Babylon.
  20480. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  20481. */
  20482. class DepthRenderer {
  20483. private _scene;
  20484. private _depthMap;
  20485. private _effect;
  20486. private _cachedDefines;
  20487. private _camera;
  20488. /**
  20489. * Instantiates a depth renderer
  20490. * @param scene The scene the renderer belongs to
  20491. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  20492. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  20493. */
  20494. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  20495. /**
  20496. * Creates the depth rendering effect and checks if the effect is ready.
  20497. * @param subMesh The submesh to be used to render the depth map of
  20498. * @param useInstances If multiple world instances should be used
  20499. * @returns if the depth renderer is ready to render the depth map
  20500. */
  20501. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  20502. /**
  20503. * Gets the texture which the depth map will be written to.
  20504. * @returns The depth map texture
  20505. */
  20506. getDepthMap(): RenderTargetTexture;
  20507. /**
  20508. * Disposes of the depth renderer.
  20509. */
  20510. dispose(): void;
  20511. }
  20512. }
  20513. declare module BABYLON {
  20514. class EdgesRenderer {
  20515. edgesWidthScalerForOrthographic: number;
  20516. edgesWidthScalerForPerspective: number;
  20517. private _source;
  20518. private _linesPositions;
  20519. private _linesNormals;
  20520. private _linesIndices;
  20521. private _epsilon;
  20522. private _indicesCount;
  20523. private _lineShader;
  20524. private _ib;
  20525. private _buffers;
  20526. private _checkVerticesInsteadOfIndices;
  20527. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20528. private _prepareRessources();
  20529. _rebuild(): void;
  20530. dispose(): void;
  20531. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  20532. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  20533. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  20534. _generateEdgesLines(): void;
  20535. render(): void;
  20536. }
  20537. }
  20538. declare module BABYLON {
  20539. /**
  20540. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  20541. */
  20542. class GeometryBufferRenderer {
  20543. private _scene;
  20544. private _multiRenderTarget;
  20545. private _ratio;
  20546. private _enablePosition;
  20547. protected _effect: Effect;
  20548. protected _cachedDefines: string;
  20549. /**
  20550. * Set the render list (meshes to be rendered) used in the G buffer.
  20551. */
  20552. renderList: Mesh[];
  20553. /**
  20554. * Gets wether or not G buffer are supported by the running hardware.
  20555. * This requires draw buffer supports
  20556. */
  20557. readonly isSupported: boolean;
  20558. /**
  20559. * Gets wether or not position are enabled for the G buffer.
  20560. */
  20561. /**
  20562. * Sets wether or not position are enabled for the G buffer.
  20563. */
  20564. enablePosition: boolean;
  20565. /**
  20566. * Gets the scene associated with the buffer.
  20567. */
  20568. readonly scene: Scene;
  20569. /**
  20570. * Gets the ratio used by the buffer during its creation.
  20571. * How big is the buffer related to the main canvas.
  20572. */
  20573. readonly ratio: number;
  20574. /**
  20575. * Creates a new G Buffer for the scene. @see GeometryBufferRenderer
  20576. * @param scene The scene the buffer belongs to
  20577. * @param ratio How big is the buffer related to the main canvas.
  20578. */
  20579. constructor(scene: Scene, ratio?: number);
  20580. /**
  20581. * Checks wether everything is ready to render a submesh to the G buffer.
  20582. * @param subMesh the submesh to check readiness for
  20583. * @param useInstances is the mesh drawn using instance or not
  20584. * @returns true if ready otherwise false
  20585. */
  20586. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  20587. /**
  20588. * Gets the current underlying G Buffer.
  20589. * @returns the buffer
  20590. */
  20591. getGBuffer(): MultiRenderTarget;
  20592. /**
  20593. * Gets the number of samples used to render the buffer (anti aliasing).
  20594. */
  20595. /**
  20596. * Sets the number of samples used to render the buffer (anti aliasing).
  20597. */
  20598. samples: number;
  20599. /**
  20600. * Disposes the renderer and frees up associated resources.
  20601. */
  20602. dispose(): void;
  20603. protected _createRenderTargets(): void;
  20604. }
  20605. }
  20606. declare module BABYLON {
  20607. class OutlineRenderer {
  20608. private _scene;
  20609. private _effect;
  20610. private _cachedDefines;
  20611. zOffset: number;
  20612. constructor(scene: Scene);
  20613. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  20614. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  20615. }
  20616. }
  20617. declare module BABYLON {
  20618. class RenderingGroup {
  20619. index: number;
  20620. private _scene;
  20621. private _opaqueSubMeshes;
  20622. private _transparentSubMeshes;
  20623. private _alphaTestSubMeshes;
  20624. private _depthOnlySubMeshes;
  20625. private _particleSystems;
  20626. private _spriteManagers;
  20627. private _opaqueSortCompareFn;
  20628. private _alphaTestSortCompareFn;
  20629. private _transparentSortCompareFn;
  20630. private _renderOpaque;
  20631. private _renderAlphaTest;
  20632. private _renderTransparent;
  20633. private _edgesRenderers;
  20634. onBeforeTransparentRendering: () => void;
  20635. /**
  20636. * Set the opaque sort comparison function.
  20637. * If null the sub meshes will be render in the order they were created
  20638. */
  20639. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20640. /**
  20641. * Set the alpha test sort comparison function.
  20642. * If null the sub meshes will be render in the order they were created
  20643. */
  20644. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20645. /**
  20646. * Set the transparent sort comparison function.
  20647. * If null the sub meshes will be render in the order they were created
  20648. */
  20649. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20650. /**
  20651. * Creates a new rendering group.
  20652. * @param index The rendering group index
  20653. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20654. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20655. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20656. */
  20657. 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>);
  20658. /**
  20659. * Render all the sub meshes contained in the group.
  20660. * @param customRenderFunction Used to override the default render behaviour of the group.
  20661. * @returns true if rendered some submeshes.
  20662. */
  20663. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20664. /**
  20665. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20666. * @param subMeshes The submeshes to render
  20667. */
  20668. private renderOpaqueSorted(subMeshes);
  20669. /**
  20670. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20671. * @param subMeshes The submeshes to render
  20672. */
  20673. private renderAlphaTestSorted(subMeshes);
  20674. /**
  20675. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20676. * @param subMeshes The submeshes to render
  20677. */
  20678. private renderTransparentSorted(subMeshes);
  20679. /**
  20680. * Renders the submeshes in a specified order.
  20681. * @param subMeshes The submeshes to sort before render
  20682. * @param sortCompareFn The comparison function use to sort
  20683. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20684. * @param transparent Specifies to activate blending if true
  20685. */
  20686. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  20687. /**
  20688. * Renders the submeshes in the order they were dispatched (no sort applied).
  20689. * @param subMeshes The submeshes to render
  20690. */
  20691. private static renderUnsorted(subMeshes);
  20692. /**
  20693. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20694. * are rendered back to front if in the same alpha index.
  20695. *
  20696. * @param a The first submesh
  20697. * @param b The second submesh
  20698. * @returns The result of the comparison
  20699. */
  20700. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20701. /**
  20702. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20703. * are rendered back to front.
  20704. *
  20705. * @param a The first submesh
  20706. * @param b The second submesh
  20707. * @returns The result of the comparison
  20708. */
  20709. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20710. /**
  20711. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20712. * are rendered front to back (prevent overdraw).
  20713. *
  20714. * @param a The first submesh
  20715. * @param b The second submesh
  20716. * @returns The result of the comparison
  20717. */
  20718. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20719. /**
  20720. * Resets the different lists of submeshes to prepare a new frame.
  20721. */
  20722. prepare(): void;
  20723. dispose(): void;
  20724. /**
  20725. * Inserts the submesh in its correct queue depending on its material.
  20726. * @param subMesh The submesh to dispatch
  20727. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20728. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20729. */
  20730. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20731. dispatchSprites(spriteManager: SpriteManager): void;
  20732. dispatchParticles(particleSystem: IParticleSystem): void;
  20733. private _renderParticles(activeMeshes);
  20734. private _renderSprites();
  20735. }
  20736. }
  20737. declare module BABYLON {
  20738. class RenderingManager {
  20739. /**
  20740. * The max id used for rendering groups (not included)
  20741. */
  20742. static MAX_RENDERINGGROUPS: number;
  20743. /**
  20744. * The min id used for rendering groups (included)
  20745. */
  20746. static MIN_RENDERINGGROUPS: number;
  20747. /**
  20748. * Used to globally prevent autoclearing scenes.
  20749. */
  20750. static AUTOCLEAR: boolean;
  20751. private _scene;
  20752. private _renderingGroups;
  20753. private _depthStencilBufferAlreadyCleaned;
  20754. private _autoClearDepthStencil;
  20755. private _customOpaqueSortCompareFn;
  20756. private _customAlphaTestSortCompareFn;
  20757. private _customTransparentSortCompareFn;
  20758. private _renderinGroupInfo;
  20759. constructor(scene: Scene);
  20760. private _clearDepthStencilBuffer(depth?, stencil?);
  20761. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20762. reset(): void;
  20763. dispose(): void;
  20764. private _prepareRenderingGroup(renderingGroupId);
  20765. dispatchSprites(spriteManager: SpriteManager): void;
  20766. dispatchParticles(particleSystem: IParticleSystem): void;
  20767. /**
  20768. * @param subMesh The submesh to dispatch
  20769. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20770. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20771. */
  20772. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20773. /**
  20774. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20775. * This allowed control for front to back rendering or reversly depending of the special needs.
  20776. *
  20777. * @param renderingGroupId The rendering group id corresponding to its index
  20778. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20779. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20780. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20781. */
  20782. 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;
  20783. /**
  20784. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20785. *
  20786. * @param renderingGroupId The rendering group id corresponding to its index
  20787. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20788. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20789. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20790. */
  20791. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20792. }
  20793. }
  20794. declare module BABYLON {
  20795. class _AlphaState {
  20796. private _isAlphaBlendDirty;
  20797. private _isBlendFunctionParametersDirty;
  20798. private _isBlendEquationParametersDirty;
  20799. private _isBlendConstantsDirty;
  20800. private _alphaBlend;
  20801. private _blendFunctionParameters;
  20802. private _blendEquationParameters;
  20803. private _blendConstants;
  20804. /**
  20805. * Initializes the state.
  20806. */
  20807. constructor();
  20808. readonly isDirty: boolean;
  20809. alphaBlend: boolean;
  20810. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  20811. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  20812. setAlphaEquationParameters(rgb: number, alpha: number): void;
  20813. reset(): void;
  20814. apply(gl: WebGLRenderingContext): void;
  20815. }
  20816. }
  20817. declare module BABYLON {
  20818. class _DepthCullingState {
  20819. private _isDepthTestDirty;
  20820. private _isDepthMaskDirty;
  20821. private _isDepthFuncDirty;
  20822. private _isCullFaceDirty;
  20823. private _isCullDirty;
  20824. private _isZOffsetDirty;
  20825. private _isFrontFaceDirty;
  20826. private _depthTest;
  20827. private _depthMask;
  20828. private _depthFunc;
  20829. private _cull;
  20830. private _cullFace;
  20831. private _zOffset;
  20832. private _frontFace;
  20833. /**
  20834. * Initializes the state.
  20835. */
  20836. constructor();
  20837. readonly isDirty: boolean;
  20838. zOffset: number;
  20839. cullFace: Nullable<number>;
  20840. cull: Nullable<boolean>;
  20841. depthFunc: Nullable<number>;
  20842. depthMask: boolean;
  20843. depthTest: boolean;
  20844. frontFace: Nullable<number>;
  20845. reset(): void;
  20846. apply(gl: WebGLRenderingContext): void;
  20847. }
  20848. }
  20849. declare module BABYLON {
  20850. class _StencilState {
  20851. private _isStencilTestDirty;
  20852. private _isStencilMaskDirty;
  20853. private _isStencilFuncDirty;
  20854. private _isStencilOpDirty;
  20855. private _stencilTest;
  20856. private _stencilMask;
  20857. private _stencilFunc;
  20858. private _stencilFuncRef;
  20859. private _stencilFuncMask;
  20860. private _stencilOpStencilFail;
  20861. private _stencilOpDepthFail;
  20862. private _stencilOpStencilDepthPass;
  20863. readonly isDirty: boolean;
  20864. stencilFunc: number;
  20865. stencilFuncRef: number;
  20866. stencilFuncMask: number;
  20867. stencilOpStencilFail: number;
  20868. stencilOpDepthFail: number;
  20869. stencilOpStencilDepthPass: number;
  20870. stencilMask: number;
  20871. stencilTest: boolean;
  20872. constructor();
  20873. reset(): void;
  20874. apply(gl: WebGLRenderingContext): void;
  20875. }
  20876. }
  20877. declare module BABYLON {
  20878. class AndOrNotEvaluator {
  20879. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  20880. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  20881. private static _SimplifyNegation(booleanString);
  20882. }
  20883. }
  20884. declare module BABYLON {
  20885. /**
  20886. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  20887. */
  20888. enum AssetTaskState {
  20889. /**
  20890. * Initialization
  20891. */
  20892. INIT = 0,
  20893. /**
  20894. * Running
  20895. */
  20896. RUNNING = 1,
  20897. /**
  20898. * Done
  20899. */
  20900. DONE = 2,
  20901. /**
  20902. * Error
  20903. */
  20904. ERROR = 3,
  20905. }
  20906. /**
  20907. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  20908. */
  20909. abstract class AbstractAssetTask {
  20910. /**
  20911. * Task name
  20912. */ name: string;
  20913. /**
  20914. * Callback called when the task is successful
  20915. */
  20916. onSuccess: (task: any) => void;
  20917. /**
  20918. * Callback called when the task is successful
  20919. */
  20920. onError: (task: any, message?: string, exception?: any) => void;
  20921. /**
  20922. * Creates a new {BABYLON.AssetsManager}
  20923. * @param name defines the name of the task
  20924. */
  20925. constructor(
  20926. /**
  20927. * Task name
  20928. */ name: string);
  20929. private _isCompleted;
  20930. private _taskState;
  20931. private _errorObject;
  20932. /**
  20933. * Get if the task is completed
  20934. */
  20935. readonly isCompleted: boolean;
  20936. /**
  20937. * Gets the current state of the task
  20938. */
  20939. readonly taskState: AssetTaskState;
  20940. /**
  20941. * Gets the current error object (if task is in error)
  20942. */
  20943. readonly errorObject: {
  20944. message?: string;
  20945. exception?: any;
  20946. };
  20947. /**
  20948. * Internal only
  20949. * @ignore
  20950. */
  20951. _setErrorObject(message?: string, exception?: any): void;
  20952. /**
  20953. * Execute the current task
  20954. * @param scene defines the scene where you want your assets to be loaded
  20955. * @param onSuccess is a callback called when the task is successfully executed
  20956. * @param onError is a callback called if an error occurs
  20957. */
  20958. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  20959. /**
  20960. * Execute the current task
  20961. * @param scene defines the scene where you want your assets to be loaded
  20962. * @param onSuccess is a callback called when the task is successfully executed
  20963. * @param onError is a callback called if an error occurs
  20964. */
  20965. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  20966. private onErrorCallback(onError, message?, exception?);
  20967. private onDoneCallback(onSuccess, onError);
  20968. }
  20969. /**
  20970. * Define the interface used by progress events raised during assets loading
  20971. */
  20972. interface IAssetsProgressEvent {
  20973. /**
  20974. * Defines the number of remaining tasks to process
  20975. */
  20976. remainingCount: number;
  20977. /**
  20978. * Defines the total number of tasks
  20979. */
  20980. totalCount: number;
  20981. /**
  20982. * Defines the task that was just processed
  20983. */
  20984. task: AbstractAssetTask;
  20985. }
  20986. /**
  20987. * Class used to share progress information about assets loading
  20988. */
  20989. class AssetsProgressEvent implements IAssetsProgressEvent {
  20990. /**
  20991. * Defines the number of remaining tasks to process
  20992. */
  20993. remainingCount: number;
  20994. /**
  20995. * Defines the total number of tasks
  20996. */
  20997. totalCount: number;
  20998. /**
  20999. * Defines the task that was just processed
  21000. */
  21001. task: AbstractAssetTask;
  21002. /**
  21003. * Creates a {BABYLON.AssetsProgressEvent}
  21004. * @param remainingCount defines the number of remaining tasks to process
  21005. * @param totalCount defines the total number of tasks
  21006. * @param task defines the task that was just processed
  21007. */
  21008. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  21009. }
  21010. /**
  21011. * Define a task used by {BABYLON.AssetsManager} to load meshes
  21012. */
  21013. class MeshAssetTask extends AbstractAssetTask {
  21014. /**
  21015. * Defines the name of the task
  21016. */
  21017. name: string;
  21018. /**
  21019. * Defines the list of mesh's names you want to load
  21020. */
  21021. meshesNames: any;
  21022. /**
  21023. * Defines the root url to use as a base to load your meshes and associated resources
  21024. */
  21025. rootUrl: string;
  21026. /**
  21027. * Defines the filename of the scene to load from
  21028. */
  21029. sceneFilename: string;
  21030. /**
  21031. * Gets the list of loaded meshes
  21032. */
  21033. loadedMeshes: Array<AbstractMesh>;
  21034. /**
  21035. * Gets the list of loaded particle systems
  21036. */
  21037. loadedParticleSystems: Array<ParticleSystem>;
  21038. /**
  21039. * Gets the list of loaded skeletons
  21040. */
  21041. loadedSkeletons: Array<Skeleton>;
  21042. /**
  21043. * Callback called when the task is successful
  21044. */
  21045. onSuccess: (task: MeshAssetTask) => void;
  21046. /**
  21047. * Callback called when the task is successful
  21048. */
  21049. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  21050. /**
  21051. * Creates a new {BABYLON.MeshAssetTask}
  21052. * @param name defines the name of the task
  21053. * @param meshesNames defines the list of mesh's names you want to load
  21054. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  21055. * @param sceneFilename defines the filename of the scene to load from
  21056. */
  21057. constructor(
  21058. /**
  21059. * Defines the name of the task
  21060. */
  21061. name: string,
  21062. /**
  21063. * Defines the list of mesh's names you want to load
  21064. */
  21065. meshesNames: any,
  21066. /**
  21067. * Defines the root url to use as a base to load your meshes and associated resources
  21068. */
  21069. rootUrl: string,
  21070. /**
  21071. * Defines the filename of the scene to load from
  21072. */
  21073. sceneFilename: string);
  21074. /**
  21075. * Execute the current task
  21076. * @param scene defines the scene where you want your assets to be loaded
  21077. * @param onSuccess is a callback called when the task is successfully executed
  21078. * @param onError is a callback called if an error occurs
  21079. */
  21080. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21081. }
  21082. /**
  21083. * Define a task used by {BABYLON.AssetsManager} to load text content
  21084. */
  21085. class TextFileAssetTask extends AbstractAssetTask {
  21086. /**
  21087. * Defines the name of the task
  21088. */
  21089. name: string;
  21090. /**
  21091. * Defines the location of the file to load
  21092. */
  21093. url: string;
  21094. /**
  21095. * Gets the loaded text string
  21096. */
  21097. text: string;
  21098. /**
  21099. * Callback called when the task is successful
  21100. */
  21101. onSuccess: (task: TextFileAssetTask) => void;
  21102. /**
  21103. * Callback called when the task is successful
  21104. */
  21105. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  21106. /**
  21107. * Creates a new TextFileAssetTask object
  21108. * @param name defines the name of the task
  21109. * @param url defines the location of the file to load
  21110. */
  21111. constructor(
  21112. /**
  21113. * Defines the name of the task
  21114. */
  21115. name: string,
  21116. /**
  21117. * Defines the location of the file to load
  21118. */
  21119. url: string);
  21120. /**
  21121. * Execute the current task
  21122. * @param scene defines the scene where you want your assets to be loaded
  21123. * @param onSuccess is a callback called when the task is successfully executed
  21124. * @param onError is a callback called if an error occurs
  21125. */
  21126. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21127. }
  21128. /**
  21129. * Define a task used by {BABYLON.AssetsManager} to load binary data
  21130. */
  21131. class BinaryFileAssetTask extends AbstractAssetTask {
  21132. /**
  21133. * Defines the name of the task
  21134. */
  21135. name: string;
  21136. /**
  21137. * Defines the location of the file to load
  21138. */
  21139. url: string;
  21140. /**
  21141. * Gets the lodaded data (as an array buffer)
  21142. */
  21143. data: ArrayBuffer;
  21144. /**
  21145. * Callback called when the task is successful
  21146. */
  21147. onSuccess: (task: BinaryFileAssetTask) => void;
  21148. /**
  21149. * Callback called when the task is successful
  21150. */
  21151. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  21152. /**
  21153. * Creates a new BinaryFileAssetTask object
  21154. * @param name defines the name of the new task
  21155. * @param url defines the location of the file to load
  21156. */
  21157. constructor(
  21158. /**
  21159. * Defines the name of the task
  21160. */
  21161. name: string,
  21162. /**
  21163. * Defines the location of the file to load
  21164. */
  21165. url: string);
  21166. /**
  21167. * Execute the current task
  21168. * @param scene defines the scene where you want your assets to be loaded
  21169. * @param onSuccess is a callback called when the task is successfully executed
  21170. * @param onError is a callback called if an error occurs
  21171. */
  21172. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21173. }
  21174. /**
  21175. * Define a task used by {BABYLON.AssetsManager} to load images
  21176. */
  21177. class ImageAssetTask extends AbstractAssetTask {
  21178. /**
  21179. * Defines the name of the task
  21180. */
  21181. name: string;
  21182. /**
  21183. * Defines the location of the image to load
  21184. */
  21185. url: string;
  21186. /**
  21187. * Gets the loaded images
  21188. */
  21189. image: HTMLImageElement;
  21190. /**
  21191. * Callback called when the task is successful
  21192. */
  21193. onSuccess: (task: ImageAssetTask) => void;
  21194. /**
  21195. * Callback called when the task is successful
  21196. */
  21197. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  21198. /**
  21199. * Creates a new ImageAssetTask
  21200. * @param name defines the name of the task
  21201. * @param url defines the location of the image to load
  21202. */
  21203. constructor(
  21204. /**
  21205. * Defines the name of the task
  21206. */
  21207. name: string,
  21208. /**
  21209. * Defines the location of the image to load
  21210. */
  21211. url: string);
  21212. /**
  21213. * Execute the current task
  21214. * @param scene defines the scene where you want your assets to be loaded
  21215. * @param onSuccess is a callback called when the task is successfully executed
  21216. * @param onError is a callback called if an error occurs
  21217. */
  21218. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21219. }
  21220. /**
  21221. * Defines the interface used by texture loading tasks
  21222. */
  21223. interface ITextureAssetTask<TEX extends BaseTexture> {
  21224. /**
  21225. * Gets the loaded texture
  21226. */
  21227. texture: TEX;
  21228. }
  21229. /**
  21230. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  21231. */
  21232. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  21233. /**
  21234. * Defines the name of the task
  21235. */
  21236. name: string;
  21237. /**
  21238. * Defines the location of the file to load
  21239. */
  21240. url: string;
  21241. /**
  21242. * Defines if mipmap should not be generated (default is false)
  21243. */
  21244. noMipmap: boolean | undefined;
  21245. /**
  21246. * Defines if texture must be inverted on Y axis (default is false)
  21247. */
  21248. invertY: boolean | undefined;
  21249. /**
  21250. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  21251. */
  21252. samplingMode: number;
  21253. /**
  21254. * Gets the loaded texture
  21255. */
  21256. texture: Texture;
  21257. /**
  21258. * Callback called when the task is successful
  21259. */
  21260. onSuccess: (task: TextureAssetTask) => void;
  21261. /**
  21262. * Callback called when the task is successful
  21263. */
  21264. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  21265. /**
  21266. * Creates a new TextureAssetTask object
  21267. * @param name defines the name of the task
  21268. * @param url defines the location of the file to load
  21269. * @param noMipmap defines if mipmap should not be generated (default is false)
  21270. * @param invertY defines if texture must be inverted on Y axis (default is false)
  21271. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  21272. */
  21273. constructor(
  21274. /**
  21275. * Defines the name of the task
  21276. */
  21277. name: string,
  21278. /**
  21279. * Defines the location of the file to load
  21280. */
  21281. url: string,
  21282. /**
  21283. * Defines if mipmap should not be generated (default is false)
  21284. */
  21285. noMipmap?: boolean | undefined,
  21286. /**
  21287. * Defines if texture must be inverted on Y axis (default is false)
  21288. */
  21289. invertY?: boolean | undefined,
  21290. /**
  21291. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  21292. */
  21293. samplingMode?: number);
  21294. /**
  21295. * Execute the current task
  21296. * @param scene defines the scene where you want your assets to be loaded
  21297. * @param onSuccess is a callback called when the task is successfully executed
  21298. * @param onError is a callback called if an error occurs
  21299. */
  21300. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21301. }
  21302. /**
  21303. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  21304. */
  21305. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  21306. /**
  21307. * Defines the name of the task
  21308. */
  21309. name: string;
  21310. /**
  21311. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  21312. */
  21313. url: string;
  21314. /**
  21315. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  21316. */
  21317. extensions: string[] | undefined;
  21318. /**
  21319. * Defines if mipmaps should not be generated (default is false)
  21320. */
  21321. noMipmap: boolean | undefined;
  21322. /**
  21323. * Defines the explicit list of files (undefined by default)
  21324. */
  21325. files: string[] | undefined;
  21326. /**
  21327. * Gets the loaded texture
  21328. */
  21329. texture: CubeTexture;
  21330. /**
  21331. * Callback called when the task is successful
  21332. */
  21333. onSuccess: (task: CubeTextureAssetTask) => void;
  21334. /**
  21335. * Callback called when the task is successful
  21336. */
  21337. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  21338. /**
  21339. * Creates a new CubeTextureAssetTask
  21340. * @param name defines the name of the task
  21341. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  21342. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  21343. * @param noMipmap defines if mipmaps should not be generated (default is false)
  21344. * @param files defines the explicit list of files (undefined by default)
  21345. */
  21346. constructor(
  21347. /**
  21348. * Defines the name of the task
  21349. */
  21350. name: string,
  21351. /**
  21352. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  21353. */
  21354. url: string,
  21355. /**
  21356. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  21357. */
  21358. extensions?: string[] | undefined,
  21359. /**
  21360. * Defines if mipmaps should not be generated (default is false)
  21361. */
  21362. noMipmap?: boolean | undefined,
  21363. /**
  21364. * Defines the explicit list of files (undefined by default)
  21365. */
  21366. files?: string[] | undefined);
  21367. /**
  21368. * Execute the current task
  21369. * @param scene defines the scene where you want your assets to be loaded
  21370. * @param onSuccess is a callback called when the task is successfully executed
  21371. * @param onError is a callback called if an error occurs
  21372. */
  21373. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21374. }
  21375. /**
  21376. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  21377. */
  21378. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  21379. /**
  21380. * Defines the name of the task
  21381. */
  21382. name: string;
  21383. /**
  21384. * Defines the location of the file to load
  21385. */
  21386. url: string;
  21387. /**
  21388. * 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.
  21389. */
  21390. size: number | undefined;
  21391. /**
  21392. * Defines if mipmaps should not be generated (default is false)
  21393. */
  21394. noMipmap: boolean;
  21395. /**
  21396. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  21397. */
  21398. generateHarmonics: boolean;
  21399. /**
  21400. * 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)
  21401. */
  21402. useInGammaSpace: boolean;
  21403. /**
  21404. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  21405. */
  21406. usePMREMGenerator: boolean;
  21407. /**
  21408. * Gets the loaded texture
  21409. */
  21410. texture: HDRCubeTexture;
  21411. /**
  21412. * Callback called when the task is successful
  21413. */
  21414. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  21415. /**
  21416. * Callback called when the task is successful
  21417. */
  21418. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  21419. /**
  21420. * Creates a new HDRCubeTextureAssetTask object
  21421. * @param name defines the name of the task
  21422. * @param url defines the location of the file to load
  21423. * @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.
  21424. * @param noMipmap defines if mipmaps should not be generated (default is false)
  21425. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  21426. * @param useInGammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  21427. * @param usePMREMGenerator specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  21428. */
  21429. constructor(
  21430. /**
  21431. * Defines the name of the task
  21432. */
  21433. name: string,
  21434. /**
  21435. * Defines the location of the file to load
  21436. */
  21437. url: string,
  21438. /**
  21439. * 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.
  21440. */
  21441. size?: number | undefined,
  21442. /**
  21443. * Defines if mipmaps should not be generated (default is false)
  21444. */
  21445. noMipmap?: boolean,
  21446. /**
  21447. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  21448. */
  21449. generateHarmonics?: boolean,
  21450. /**
  21451. * 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)
  21452. */
  21453. useInGammaSpace?: boolean,
  21454. /**
  21455. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  21456. */
  21457. usePMREMGenerator?: boolean);
  21458. /**
  21459. * Execute the current task
  21460. * @param scene defines the scene where you want your assets to be loaded
  21461. * @param onSuccess is a callback called when the task is successfully executed
  21462. * @param onError is a callback called if an error occurs
  21463. */
  21464. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21465. }
  21466. /**
  21467. * This class can be used to easily import assets into a scene
  21468. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  21469. */
  21470. class AssetsManager {
  21471. private _scene;
  21472. private _isLoading;
  21473. protected _tasks: AbstractAssetTask[];
  21474. protected _waitingTasksCount: number;
  21475. protected _totalTasksCount: number;
  21476. /**
  21477. * Callback called when all tasks are processed
  21478. */
  21479. onFinish: (tasks: AbstractAssetTask[]) => void;
  21480. /**
  21481. * Callback called when a task is successful
  21482. */
  21483. onTaskSuccess: (task: AbstractAssetTask) => void;
  21484. /**
  21485. * Callback called when a task had an error
  21486. */
  21487. onTaskError: (task: AbstractAssetTask) => void;
  21488. /**
  21489. * Callback called when a task is done (whatever the result is)
  21490. */
  21491. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  21492. /**
  21493. * Observable called when all tasks are processed
  21494. */
  21495. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  21496. /**
  21497. * Observable called when a task had an error
  21498. */
  21499. onTaskErrorObservable: Observable<AbstractAssetTask>;
  21500. /**
  21501. * Observable called when a task is successful
  21502. */
  21503. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  21504. /**
  21505. * Observable called when a task is done (whatever the result is)
  21506. */
  21507. onProgressObservable: Observable<IAssetsProgressEvent>;
  21508. /**
  21509. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  21510. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  21511. */
  21512. useDefaultLoadingScreen: boolean;
  21513. /**
  21514. * Creates a new AssetsManager
  21515. * @param scene defines the scene to work on
  21516. */
  21517. constructor(scene: Scene);
  21518. /**
  21519. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  21520. * @param taskName defines the name of the new task
  21521. * @param meshesNames defines the name of meshes to load
  21522. * @param rootUrl defines the root url to use to locate files
  21523. * @param sceneFilename defines the filename of the scene file
  21524. * @returns a new {BABYLON.MeshAssetTask} object
  21525. */
  21526. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  21527. /**
  21528. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  21529. * @param taskName defines the name of the new task
  21530. * @param url defines the url of the file to load
  21531. * @returns a new {BABYLON.TextFileAssetTask} object
  21532. */
  21533. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  21534. /**
  21535. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  21536. * @param taskName defines the name of the new task
  21537. * @param url defines the url of the file to load
  21538. * @returns a new {BABYLON.BinaryFileAssetTask} object
  21539. */
  21540. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  21541. /**
  21542. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  21543. * @param taskName defines the name of the new task
  21544. * @param url defines the url of the file to load
  21545. * @returns a new {BABYLON.ImageAssetTask} object
  21546. */
  21547. addImageTask(taskName: string, url: string): ImageAssetTask;
  21548. /**
  21549. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  21550. * @param taskName defines the name of the new task
  21551. * @param url defines the url of the file to load
  21552. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  21553. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  21554. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  21555. * @returns a new {BABYLON.TextureAssetTask} object
  21556. */
  21557. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  21558. /**
  21559. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  21560. * @param taskName defines the name of the new task
  21561. * @param url defines the url of the file to load
  21562. * @param extensions defines the extension to use to load the cube map (can be null)
  21563. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  21564. * @param files defines the list of files to load (can be null)
  21565. * @returns a new {BABYLON.CubeTextureAssetTask} object
  21566. */
  21567. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  21568. /**
  21569. *
  21570. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  21571. * @param taskName defines the name of the new task
  21572. * @param url defines the url of the file to load
  21573. * @param size defines the size you want for the cubemap (can be null)
  21574. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  21575. * @param generateHarmonics defines if you want to automatically generate (true by default)
  21576. * @param useInGammaSpace defines if the texture must be considered in gamma space (false by default)
  21577. * @param usePMREMGenerator is a reserved parameter and must be set to false or ignored
  21578. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  21579. */
  21580. addHDRCubeTextureTask(taskName: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean): HDRCubeTextureAssetTask;
  21581. private _decreaseWaitingTasksCount(task);
  21582. private _runTask(task);
  21583. /**
  21584. * Reset the {BABYLON.AssetsManager} and remove all tasks
  21585. * @return the current instance of the {BABYLON.AssetsManager}
  21586. */
  21587. reset(): AssetsManager;
  21588. /**
  21589. * Start the loading process
  21590. * @return the current instance of the {BABYLON.AssetsManager}
  21591. */
  21592. load(): AssetsManager;
  21593. }
  21594. }
  21595. declare module BABYLON {
  21596. class Database {
  21597. private callbackManifestChecked;
  21598. private currentSceneUrl;
  21599. private db;
  21600. private _enableSceneOffline;
  21601. private _enableTexturesOffline;
  21602. private manifestVersionFound;
  21603. private mustUpdateRessources;
  21604. private hasReachedQuota;
  21605. private isSupported;
  21606. private idbFactory;
  21607. static IsUASupportingBlobStorage: boolean;
  21608. static IDBStorageEnabled: boolean;
  21609. readonly enableSceneOffline: boolean;
  21610. readonly enableTexturesOffline: boolean;
  21611. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any);
  21612. static parseURL: (url: string) => string;
  21613. static ReturnFullUrlLocation: (url: string) => string;
  21614. checkManifestFile(): void;
  21615. openAsync(successCallback: () => void, errorCallback: () => void): void;
  21616. loadImageFromDB(url: string, image: HTMLImageElement): void;
  21617. private _loadImageFromDBAsync(url, image, notInDBCallback);
  21618. private _saveImageIntoDBAsync(url, image);
  21619. private _checkVersionFromDB(url, versionLoaded);
  21620. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  21621. private _saveVersionIntoDBAsync(url, callback);
  21622. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  21623. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  21624. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  21625. }
  21626. }
  21627. declare module BABYLON {
  21628. interface DDSInfo {
  21629. width: number;
  21630. height: number;
  21631. mipmapCount: number;
  21632. isFourCC: boolean;
  21633. isRGB: boolean;
  21634. isLuminance: boolean;
  21635. isCube: boolean;
  21636. isCompressed: boolean;
  21637. dxgiFormat: number;
  21638. textureType: number;
  21639. }
  21640. class DDSTools {
  21641. static StoreLODInAlphaChannel: boolean;
  21642. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  21643. private static _FloatView;
  21644. private static _Int32View;
  21645. private static _ToHalfFloat(value);
  21646. private static _FromHalfFloat(value);
  21647. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  21648. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  21649. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  21650. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  21651. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  21652. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  21653. private static _ExtractLongWordOrder(value);
  21654. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  21655. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  21656. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  21657. }
  21658. }
  21659. declare module BABYLON {
  21660. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  21661. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21662. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21663. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21664. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21665. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21666. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21667. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21668. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21669. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21670. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21671. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21672. class SerializationHelper {
  21673. static Serialize<T>(entity: T, serializationObject?: any): any;
  21674. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  21675. static Clone<T>(creationFunction: () => T, source: T): T;
  21676. static Instanciate<T>(creationFunction: () => T, source: T): T;
  21677. }
  21678. }
  21679. declare module BABYLON {
  21680. /**
  21681. * Wrapper class for promise with external resolve and reject.
  21682. */
  21683. class Deferred<T> {
  21684. /**
  21685. * The promise associated with this deferred object.
  21686. */
  21687. readonly promise: Promise<T>;
  21688. private _resolve;
  21689. private _reject;
  21690. /**
  21691. * The resolve method of the promise associated with this deferred object.
  21692. */
  21693. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  21694. /**
  21695. * The reject method of the promise associated with this deferred object.
  21696. */
  21697. readonly reject: (reason?: any) => void;
  21698. /**
  21699. * Constructor for this deferred object.
  21700. */
  21701. constructor();
  21702. }
  21703. }
  21704. declare module Earcut {
  21705. /**
  21706. * The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
  21707. * @param data is a flat array of vertice coordinates like [x0, y0, x1, y1, x2, y2, ...].
  21708. * @param holeIndices is an array of hole indices if any (e.g. [5, 8] for a 12- vertice input would mean one hole with vertices 5–7 and another with 8–11).
  21709. * @param dim is the number of coordinates per vertice in the input array (2 by default).
  21710. */
  21711. function earcut(data: number[], holeIndices: number[], dim: number): Array<number>;
  21712. /**
  21713. * return a percentage difference between the polygon area and its triangulation area;
  21714. * used to verify correctness of triangulation
  21715. */
  21716. function deviation(data: number[], holeIndices: number[], dim: number, triangles: number[]): number;
  21717. /**
  21718. * turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
  21719. */
  21720. function flatten(data: number[][][]): {
  21721. vertices: number[];
  21722. holes: number[];
  21723. dimensions: number;
  21724. };
  21725. }
  21726. declare module BABYLON {
  21727. class FilesInput {
  21728. static FilesToLoad: {
  21729. [key: string]: File;
  21730. };
  21731. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  21732. private _engine;
  21733. private _currentScene;
  21734. private _sceneLoadedCallback;
  21735. private _progressCallback;
  21736. private _additionalRenderLoopLogicCallback;
  21737. private _textureLoadingCallback;
  21738. private _startingProcessingFilesCallback;
  21739. private _onReloadCallback;
  21740. private _errorCallback;
  21741. private _elementToMonitor;
  21742. private _sceneFileToLoad;
  21743. private _filesToLoad;
  21744. 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);
  21745. private _dragEnterHandler;
  21746. private _dragOverHandler;
  21747. private _dropHandler;
  21748. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  21749. dispose(): void;
  21750. private renderFunction();
  21751. private drag(e);
  21752. private drop(eventDrop);
  21753. private _traverseFolder(folder, files, remaining, callback);
  21754. private _processFiles(files);
  21755. loadFiles(event: any): void;
  21756. private _processReload();
  21757. reload(): void;
  21758. }
  21759. }
  21760. declare module BABYLON {
  21761. /**
  21762. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  21763. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  21764. */
  21765. class KhronosTextureContainer {
  21766. arrayBuffer: any;
  21767. static HEADER_LEN: number;
  21768. static COMPRESSED_2D: number;
  21769. static COMPRESSED_3D: number;
  21770. static TEX_2D: number;
  21771. static TEX_3D: number;
  21772. glType: number;
  21773. glTypeSize: number;
  21774. glFormat: number;
  21775. glInternalFormat: number;
  21776. glBaseInternalFormat: number;
  21777. pixelWidth: number;
  21778. pixelHeight: number;
  21779. pixelDepth: number;
  21780. numberOfArrayElements: number;
  21781. numberOfFaces: number;
  21782. numberOfMipmapLevels: number;
  21783. bytesOfKeyValueData: number;
  21784. loadType: number;
  21785. /**
  21786. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  21787. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  21788. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  21789. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  21790. */
  21791. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  21792. switchEndainness(val: number): number;
  21793. /**
  21794. * It is assumed that the texture has already been created & is currently bound
  21795. */
  21796. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  21797. private _upload2DCompressedLevels(gl, loadMipmaps);
  21798. }
  21799. }
  21800. declare module BABYLON {
  21801. /**
  21802. * A class serves as a medium between the observable and its observers
  21803. */
  21804. class EventState {
  21805. /**
  21806. * Create a new EventState
  21807. * @param mask defines the mask associated with this state
  21808. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  21809. * @param target defines the original target of the state
  21810. * @param currentTarget defines the current target of the state
  21811. */
  21812. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  21813. /**
  21814. * Initialize the current event state
  21815. * @param mask defines the mask associated with this state
  21816. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  21817. * @param target defines the original target of the state
  21818. * @param currentTarget defines the current target of the state
  21819. * @returns the current event state
  21820. */
  21821. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  21822. /**
  21823. * An Observer can set this property to true to prevent subsequent observers of being notified
  21824. */
  21825. skipNextObservers: boolean;
  21826. /**
  21827. * Get the mask value that were used to trigger the event corresponding to this EventState object
  21828. */
  21829. mask: number;
  21830. /**
  21831. * The object that originally notified the event
  21832. */
  21833. target?: any;
  21834. /**
  21835. * The current object in the bubbling phase
  21836. */
  21837. currentTarget?: any;
  21838. /**
  21839. * This will be populated with the return value of the last function that was executed.
  21840. * If it is the first function in the callback chain it will be the event data.
  21841. */
  21842. lastReturnValue?: any;
  21843. }
  21844. /**
  21845. * Represent an Observer registered to a given Observable object.
  21846. */
  21847. class Observer<T> {
  21848. /**
  21849. * Defines the callback to call when the observer is notified
  21850. */
  21851. callback: (eventData: T, eventState: EventState) => void;
  21852. /**
  21853. * Defines the mask of the observer (used to filter notifications)
  21854. */
  21855. mask: number;
  21856. /**
  21857. * Defines the current scope used to restore the JS context
  21858. */
  21859. scope: any;
  21860. /** @ignore */
  21861. _willBeUnregistered: boolean;
  21862. /**
  21863. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  21864. */
  21865. unregisterOnNextCall: boolean;
  21866. /**
  21867. * Creates a new observer
  21868. * @param callback defines the callback to call when the observer is notified
  21869. * @param mask defines the mask of the observer (used to filter notifications)
  21870. * @param scope defines the current scope used to restore the JS context
  21871. */
  21872. constructor(
  21873. /**
  21874. * Defines the callback to call when the observer is notified
  21875. */
  21876. callback: (eventData: T, eventState: EventState) => void,
  21877. /**
  21878. * Defines the mask of the observer (used to filter notifications)
  21879. */
  21880. mask: number,
  21881. /**
  21882. * Defines the current scope used to restore the JS context
  21883. */
  21884. scope?: any);
  21885. }
  21886. /**
  21887. * Represent a list of observers registered to multiple Observables object.
  21888. */
  21889. class MultiObserver<T> {
  21890. private _observers;
  21891. private _observables;
  21892. /**
  21893. * Release associated resources
  21894. */
  21895. dispose(): void;
  21896. /**
  21897. * Raise a callback when one of the observable will notify
  21898. * @param observables defines a list of observables to watch
  21899. * @param callback defines the callback to call on notification
  21900. * @param mask defines the mask used to filter notifications
  21901. * @param scope defines the current scope used to restore the JS context
  21902. * @returns the new MultiObserver
  21903. */
  21904. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  21905. }
  21906. /**
  21907. * The Observable class is a simple implementation of the Observable pattern.
  21908. * 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.
  21909. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  21910. * 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).
  21911. * 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.
  21912. */
  21913. class Observable<T> {
  21914. private _observers;
  21915. private _eventState;
  21916. private _onObserverAdded;
  21917. /**
  21918. * Creates a new observable
  21919. * @param onObserverAdded defines a callback to call when a new observer is added
  21920. */
  21921. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  21922. /**
  21923. * Create a new Observer with the specified callback
  21924. * @param callback the callback that will be executed for that Observer
  21925. * @param mask the mask used to filter observers
  21926. * @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.
  21927. * @param scope optional scope for the callback to be called from
  21928. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  21929. * @returns the new observer created for the callback
  21930. */
  21931. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  21932. /**
  21933. * Remove an Observer from the Observable object
  21934. * @param observer the instance of the Observer to remove
  21935. * @returns false if it doesn't belong to this Observable
  21936. */
  21937. remove(observer: Nullable<Observer<T>>): boolean;
  21938. /**
  21939. * Remove a callback from the Observable object
  21940. * @param callback the callback to remove
  21941. * @param scope optional scope. If used only the callbacks with this scope will be removed
  21942. * @returns false if it doesn't belong to this Observable
  21943. */
  21944. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  21945. private _deferUnregister(observer);
  21946. /**
  21947. * Notify all Observers by calling their respective callback with the given data
  21948. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  21949. * @param eventData defines the data to send to all observers
  21950. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  21951. * @param target defines the original target of the state
  21952. * @param currentTarget defines the current target of the state
  21953. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  21954. */
  21955. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  21956. /**
  21957. * Calling this will execute each callback, expecting it to be a promise or return a value.
  21958. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  21959. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  21960. * and it is crucial that all callbacks will be executed.
  21961. * The order of the callbacks is kept, callbacks are not executed parallel.
  21962. *
  21963. * @param eventData The data to be sent to each callback
  21964. * @param mask is used to filter observers defaults to -1
  21965. * @param target defines the callback target (see EventState)
  21966. * @param currentTarget defines he current object in the bubbling phase
  21967. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  21968. */
  21969. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  21970. /**
  21971. * Notify a specific observer
  21972. * @param observer defines the observer to notify
  21973. * @param eventData defines the data to be sent to each callback
  21974. * @param mask is used to filter observers defaults to -1
  21975. */
  21976. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  21977. /**
  21978. * Gets a boolean indicating if the observable has at least one observer
  21979. * @returns true is the Observable has at least one Observer registered
  21980. */
  21981. hasObservers(): boolean;
  21982. /**
  21983. * Clear the list of observers
  21984. */
  21985. clear(): void;
  21986. /**
  21987. * Clone the current observable
  21988. * @returns a new observable
  21989. */
  21990. clone(): Observable<T>;
  21991. /**
  21992. * Does this observable handles observer registered with a given mask
  21993. * @param mask defines the mask to be tested
  21994. * @return whether or not one observer registered with the given mask is handeled
  21995. **/
  21996. hasSpecificMask(mask?: number): boolean;
  21997. }
  21998. }
  21999. declare module BABYLON {
  22000. /**
  22001. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  22002. */
  22003. class PerformanceMonitor {
  22004. private _enabled;
  22005. private _rollingFrameTime;
  22006. private _lastFrameTimeMs;
  22007. /**
  22008. * constructor
  22009. * @param frameSampleSize The number of samples required to saturate the sliding window
  22010. */
  22011. constructor(frameSampleSize?: number);
  22012. /**
  22013. * Samples current frame
  22014. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  22015. */
  22016. sampleFrame(timeMs?: number): void;
  22017. /**
  22018. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  22019. * @return Average frame time in milliseconds
  22020. */
  22021. readonly averageFrameTime: number;
  22022. /**
  22023. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  22024. * @return Frame time variance in milliseconds squared
  22025. */
  22026. readonly averageFrameTimeVariance: number;
  22027. /**
  22028. * Returns the frame time of the most recent frame
  22029. * @return Frame time in milliseconds
  22030. */
  22031. readonly instantaneousFrameTime: number;
  22032. /**
  22033. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  22034. * @return Framerate in frames per second
  22035. */
  22036. readonly averageFPS: number;
  22037. /**
  22038. * Returns the average framerate in frames per second using the most recent frame time
  22039. * @return Framerate in frames per second
  22040. */
  22041. readonly instantaneousFPS: number;
  22042. /**
  22043. * Returns true if enough samples have been taken to completely fill the sliding window
  22044. * @return true if saturated
  22045. */
  22046. readonly isSaturated: boolean;
  22047. /**
  22048. * Enables contributions to the sliding window sample set
  22049. */
  22050. enable(): void;
  22051. /**
  22052. * Disables contributions to the sliding window sample set
  22053. * Samples will not be interpolated over the disabled period
  22054. */
  22055. disable(): void;
  22056. /**
  22057. * Returns true if sampling is enabled
  22058. * @return true if enabled
  22059. */
  22060. readonly isEnabled: boolean;
  22061. /**
  22062. * Resets performance monitor
  22063. */
  22064. reset(): void;
  22065. }
  22066. /**
  22067. * RollingAverage
  22068. *
  22069. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  22070. */
  22071. class RollingAverage {
  22072. /**
  22073. * Current average
  22074. */
  22075. average: number;
  22076. /**
  22077. * Current variance
  22078. */
  22079. variance: number;
  22080. protected _samples: Array<number>;
  22081. protected _sampleCount: number;
  22082. protected _pos: number;
  22083. protected _m2: number;
  22084. /**
  22085. * constructor
  22086. * @param length The number of samples required to saturate the sliding window
  22087. */
  22088. constructor(length: number);
  22089. /**
  22090. * Adds a sample to the sample set
  22091. * @param v The sample value
  22092. */
  22093. add(v: number): void;
  22094. /**
  22095. * Returns previously added values or null if outside of history or outside the sliding window domain
  22096. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  22097. * @return Value previously recorded with add() or null if outside of range
  22098. */
  22099. history(i: number): number;
  22100. /**
  22101. * Returns true if enough samples have been taken to completely fill the sliding window
  22102. * @return true if sample-set saturated
  22103. */
  22104. isSaturated(): boolean;
  22105. /**
  22106. * Resets the rolling average (equivalent to 0 samples taken so far)
  22107. */
  22108. reset(): void;
  22109. /**
  22110. * Wraps a value around the sample range boundaries
  22111. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  22112. * @return Wrapped position in sample range
  22113. */
  22114. protected _wrapPosition(i: number): number;
  22115. }
  22116. }
  22117. declare module BABYLON {
  22118. /**
  22119. * Helper class that provides a small promise polyfill
  22120. */
  22121. class PromisePolyfill {
  22122. /**
  22123. * Static function used to check if the polyfill is required
  22124. * If this is the case then the function will inject the polyfill to window.Promise
  22125. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  22126. */
  22127. static Apply(force?: boolean): void;
  22128. }
  22129. }
  22130. declare module BABYLON {
  22131. /**
  22132. * Defines the root class used to create scene optimization to use with SceneOptimizer
  22133. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22134. */
  22135. class SceneOptimization {
  22136. /**
  22137. * Defines the priority of this optimization (0 by default which means first in the list)
  22138. */
  22139. priority: number;
  22140. /**
  22141. * Gets a string describing the action executed by the current optimization
  22142. * @returns description string
  22143. */
  22144. getDescription(): string;
  22145. /**
  22146. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22147. * @param scene defines the current scene where to apply this optimization
  22148. * @param optimizer defines the current optimizer
  22149. * @returns true if everything that can be done was applied
  22150. */
  22151. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22152. /**
  22153. * Creates the SceneOptimization object
  22154. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  22155. * @param desc defines the description associated with the optimization
  22156. */
  22157. constructor(
  22158. /**
  22159. * Defines the priority of this optimization (0 by default which means first in the list)
  22160. */
  22161. priority?: number);
  22162. }
  22163. /**
  22164. * Defines an optimization used to reduce the size of render target textures
  22165. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22166. */
  22167. class TextureOptimization extends SceneOptimization {
  22168. /**
  22169. * Defines the priority of this optimization (0 by default which means first in the list)
  22170. */
  22171. priority: number;
  22172. /**
  22173. * 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
  22174. */
  22175. maximumSize: number;
  22176. /**
  22177. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  22178. */
  22179. step: number;
  22180. /**
  22181. * Gets a string describing the action executed by the current optimization
  22182. * @returns description string
  22183. */
  22184. getDescription(): string;
  22185. /**
  22186. * Creates the TextureOptimization object
  22187. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  22188. * @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
  22189. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  22190. */
  22191. constructor(
  22192. /**
  22193. * Defines the priority of this optimization (0 by default which means first in the list)
  22194. */
  22195. priority?: number,
  22196. /**
  22197. * 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
  22198. */
  22199. maximumSize?: number,
  22200. /**
  22201. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  22202. */
  22203. step?: number);
  22204. /**
  22205. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22206. * @param scene defines the current scene where to apply this optimization
  22207. * @param optimizer defines the current optimizer
  22208. * @returns true if everything that can be done was applied
  22209. */
  22210. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22211. }
  22212. /**
  22213. * Defines an optimization used to increase or decrease the rendering resolution
  22214. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22215. */
  22216. class HardwareScalingOptimization extends SceneOptimization {
  22217. /**
  22218. * Defines the priority of this optimization (0 by default which means first in the list)
  22219. */
  22220. priority: number;
  22221. /**
  22222. * Defines the maximum scale to use (2 by default)
  22223. */
  22224. maximumScale: number;
  22225. /**
  22226. * Defines the step to use between two passes (0.5 by default)
  22227. */
  22228. step: number;
  22229. private _currentScale;
  22230. private _directionOffset;
  22231. /**
  22232. * Gets a string describing the action executed by the current optimization
  22233. * @return description string
  22234. */
  22235. getDescription(): string;
  22236. /**
  22237. * Creates the HardwareScalingOptimization object
  22238. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  22239. * @param maximumScale defines the maximum scale to use (2 by default)
  22240. * @param step defines the step to use between two passes (0.5 by default)
  22241. */
  22242. constructor(
  22243. /**
  22244. * Defines the priority of this optimization (0 by default which means first in the list)
  22245. */
  22246. priority?: number,
  22247. /**
  22248. * Defines the maximum scale to use (2 by default)
  22249. */
  22250. maximumScale?: number,
  22251. /**
  22252. * Defines the step to use between two passes (0.5 by default)
  22253. */
  22254. step?: number);
  22255. /**
  22256. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22257. * @param scene defines the current scene where to apply this optimization
  22258. * @param optimizer defines the current optimizer
  22259. * @returns true if everything that can be done was applied
  22260. */
  22261. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22262. }
  22263. /**
  22264. * Defines an optimization used to remove shadows
  22265. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22266. */
  22267. class ShadowsOptimization extends SceneOptimization {
  22268. /**
  22269. * Gets a string describing the action executed by the current optimization
  22270. * @return description string
  22271. */
  22272. getDescription(): string;
  22273. /**
  22274. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22275. * @param scene defines the current scene where to apply this optimization
  22276. * @param optimizer defines the current optimizer
  22277. * @returns true if everything that can be done was applied
  22278. */
  22279. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22280. }
  22281. /**
  22282. * Defines an optimization used to turn post-processes off
  22283. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22284. */
  22285. class PostProcessesOptimization extends SceneOptimization {
  22286. /**
  22287. * Gets a string describing the action executed by the current optimization
  22288. * @return description string
  22289. */
  22290. getDescription(): string;
  22291. /**
  22292. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22293. * @param scene defines the current scene where to apply this optimization
  22294. * @param optimizer defines the current optimizer
  22295. * @returns true if everything that can be done was applied
  22296. */
  22297. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22298. }
  22299. /**
  22300. * Defines an optimization used to turn lens flares off
  22301. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22302. */
  22303. class LensFlaresOptimization extends SceneOptimization {
  22304. /**
  22305. * Gets a string describing the action executed by the current optimization
  22306. * @return description string
  22307. */
  22308. getDescription(): string;
  22309. /**
  22310. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22311. * @param scene defines the current scene where to apply this optimization
  22312. * @param optimizer defines the current optimizer
  22313. * @returns true if everything that can be done was applied
  22314. */
  22315. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22316. }
  22317. /**
  22318. * Defines an optimization based on user defined callback.
  22319. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22320. */
  22321. class CustomOptimization extends SceneOptimization {
  22322. /**
  22323. * Callback called to apply the custom optimization.
  22324. */
  22325. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  22326. /**
  22327. * Callback called to get custom description
  22328. */
  22329. onGetDescription: () => string;
  22330. /**
  22331. * Gets a string describing the action executed by the current optimization
  22332. * @returns description string
  22333. */
  22334. getDescription(): string;
  22335. /**
  22336. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22337. * @param scene defines the current scene where to apply this optimization
  22338. * @param optimizer defines the current optimizer
  22339. * @returns true if everything that can be done was applied
  22340. */
  22341. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22342. }
  22343. /**
  22344. * Defines an optimization used to turn particles off
  22345. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22346. */
  22347. class ParticlesOptimization extends SceneOptimization {
  22348. /**
  22349. * Gets a string describing the action executed by the current optimization
  22350. * @return description string
  22351. */
  22352. getDescription(): string;
  22353. /**
  22354. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22355. * @param scene defines the current scene where to apply this optimization
  22356. * @param optimizer defines the current optimizer
  22357. * @returns true if everything that can be done was applied
  22358. */
  22359. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22360. }
  22361. /**
  22362. * Defines an optimization used to turn render targets off
  22363. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22364. */
  22365. class RenderTargetsOptimization extends SceneOptimization {
  22366. /**
  22367. * Gets a string describing the action executed by the current optimization
  22368. * @return description string
  22369. */
  22370. getDescription(): string;
  22371. /**
  22372. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22373. * @param scene defines the current scene where to apply this optimization
  22374. * @param optimizer defines the current optimizer
  22375. * @returns true if everything that can be done was applied
  22376. */
  22377. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22378. }
  22379. /**
  22380. * Defines an optimization used to merge meshes with compatible materials
  22381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22382. */
  22383. class MergeMeshesOptimization extends SceneOptimization {
  22384. private static _UpdateSelectionTree;
  22385. /**
  22386. * Gets or sets a boolean which defines if optimization octree has to be updated
  22387. */
  22388. /**
  22389. * Gets or sets a boolean which defines if optimization octree has to be updated
  22390. */
  22391. static UpdateSelectionTree: boolean;
  22392. /**
  22393. * Gets a string describing the action executed by the current optimization
  22394. * @return description string
  22395. */
  22396. getDescription(): string;
  22397. private _canBeMerged;
  22398. /**
  22399. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22400. * @param scene defines the current scene where to apply this optimization
  22401. * @param optimizer defines the current optimizer
  22402. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  22403. * @returns true if everything that can be done was applied
  22404. */
  22405. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  22406. }
  22407. /**
  22408. * Defines a list of options used by SceneOptimizer
  22409. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22410. */
  22411. class SceneOptimizerOptions {
  22412. /**
  22413. * Defines the target frame rate to reach (60 by default)
  22414. */
  22415. targetFrameRate: number;
  22416. /**
  22417. * Defines the interval between two checkes (2000ms by default)
  22418. */
  22419. trackerDuration: number;
  22420. /**
  22421. * Gets the list of optimizations to apply
  22422. */
  22423. optimizations: SceneOptimization[];
  22424. /**
  22425. * Creates a new list of options used by SceneOptimizer
  22426. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  22427. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  22428. */
  22429. constructor(
  22430. /**
  22431. * Defines the target frame rate to reach (60 by default)
  22432. */
  22433. targetFrameRate?: number,
  22434. /**
  22435. * Defines the interval between two checkes (2000ms by default)
  22436. */
  22437. trackerDuration?: number);
  22438. /**
  22439. * Add a new optimization
  22440. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  22441. * @returns the current SceneOptimizerOptions
  22442. */
  22443. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  22444. /**
  22445. * Add a new custom optimization
  22446. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  22447. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  22448. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  22449. * @returns the current SceneOptimizerOptions
  22450. */
  22451. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  22452. /**
  22453. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  22454. * @param targetFrameRate defines the target frame rate (60 by default)
  22455. * @returns a SceneOptimizerOptions object
  22456. */
  22457. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  22458. /**
  22459. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  22460. * @param targetFrameRate defines the target frame rate (60 by default)
  22461. * @returns a SceneOptimizerOptions object
  22462. */
  22463. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  22464. /**
  22465. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  22466. * @param targetFrameRate defines the target frame rate (60 by default)
  22467. * @returns a SceneOptimizerOptions object
  22468. */
  22469. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  22470. }
  22471. /**
  22472. * Class used to run optimizations in order to reach a target frame rate
  22473. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22474. */
  22475. class SceneOptimizer implements IDisposable {
  22476. private _isRunning;
  22477. private _options;
  22478. private _scene;
  22479. private _currentPriorityLevel;
  22480. private _targetFrameRate;
  22481. private _trackerDuration;
  22482. private _currentFrameRate;
  22483. private _sceneDisposeObserver;
  22484. private _improvementMode;
  22485. /**
  22486. * Defines an observable called when the optimizer reaches the target frame rate
  22487. */
  22488. onSuccessObservable: Observable<SceneOptimizer>;
  22489. /**
  22490. * Defines an observable called when the optimizer enables an optimization
  22491. */
  22492. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  22493. /**
  22494. * Defines an observable called when the optimizer is not able to reach the target frame rate
  22495. */
  22496. onFailureObservable: Observable<SceneOptimizer>;
  22497. /**
  22498. * Gets a boolean indicating if the optimizer is in improvement mode
  22499. */
  22500. readonly isInImprovementMode: boolean;
  22501. /**
  22502. * Gets the current priority level (0 at start)
  22503. */
  22504. readonly currentPriorityLevel: number;
  22505. /**
  22506. * Gets the current frame rate checked by the SceneOptimizer
  22507. */
  22508. readonly currentFrameRate: number;
  22509. /**
  22510. * Gets or sets the current target frame rate (60 by default)
  22511. */
  22512. /**
  22513. * Gets or sets the current target frame rate (60 by default)
  22514. */
  22515. targetFrameRate: number;
  22516. /**
  22517. * Gets or sets the current interval between two checks (every 2000ms by default)
  22518. */
  22519. /**
  22520. * Gets or sets the current interval between two checks (every 2000ms by default)
  22521. */
  22522. trackerDuration: number;
  22523. /**
  22524. * Gets the list of active optimizations
  22525. */
  22526. readonly optimizations: SceneOptimization[];
  22527. /**
  22528. * Creates a new SceneOptimizer
  22529. * @param scene defines the scene to work on
  22530. * @param options defines the options to use with the SceneOptimizer
  22531. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  22532. * @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)
  22533. */
  22534. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  22535. /**
  22536. * Stops the current optimizer
  22537. */
  22538. stop(): void;
  22539. /**
  22540. * Reset the optimizer to initial step (current priority level = 0)
  22541. */
  22542. reset(): void;
  22543. /**
  22544. * Start the optimizer. By default it will try to reach a specific framerate
  22545. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  22546. */
  22547. start(): void;
  22548. private _checkCurrentState();
  22549. /**
  22550. * Release all resources
  22551. */
  22552. dispose(): void;
  22553. /**
  22554. * Helper function to create a SceneOptimizer with one single line of code
  22555. * @param scene defines the scene to work on
  22556. * @param options defines the options to use with the SceneOptimizer
  22557. * @param onSuccess defines a callback to call on success
  22558. * @param onFailure defines a callback to call on failure
  22559. * @returns the new SceneOptimizer object
  22560. */
  22561. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  22562. }
  22563. }
  22564. declare module BABYLON {
  22565. class SceneSerializer {
  22566. static ClearCache(): void;
  22567. static Serialize(scene: Scene): any;
  22568. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  22569. }
  22570. }
  22571. declare module BABYLON {
  22572. class SmartArray<T> {
  22573. data: Array<T>;
  22574. length: number;
  22575. protected _id: number;
  22576. [index: number]: T;
  22577. constructor(capacity: number);
  22578. push(value: T): void;
  22579. forEach(func: (content: T) => void): void;
  22580. sort(compareFn: (a: T, b: T) => number): void;
  22581. reset(): void;
  22582. dispose(): void;
  22583. concat(array: any): void;
  22584. indexOf(value: T): number;
  22585. contains(value: T): boolean;
  22586. private static _GlobalId;
  22587. }
  22588. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  22589. private _duplicateId;
  22590. [index: number]: T;
  22591. push(value: T): void;
  22592. pushNoDuplicate(value: T): boolean;
  22593. reset(): void;
  22594. concatWithNoDuplicate(array: any): void;
  22595. }
  22596. }
  22597. declare module BABYLON {
  22598. /**
  22599. * This class implement a typical dictionary using a string as key and the generic type T as value.
  22600. * The underlying implementation relies on an associative array to ensure the best performances.
  22601. * The value can be anything including 'null' but except 'undefined'
  22602. */
  22603. class StringDictionary<T> {
  22604. /**
  22605. * This will clear this dictionary and copy the content from the 'source' one.
  22606. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  22607. * @param source the dictionary to take the content from and copy to this dictionary
  22608. */
  22609. copyFrom(source: StringDictionary<T>): void;
  22610. /**
  22611. * Get a value based from its key
  22612. * @param key the given key to get the matching value from
  22613. * @return the value if found, otherwise undefined is returned
  22614. */
  22615. get(key: string): T | undefined;
  22616. /**
  22617. * Get a value from its key or add it if it doesn't exist.
  22618. * This method will ensure you that a given key/data will be present in the dictionary.
  22619. * @param key the given key to get the matching value from
  22620. * @param factory the factory that will create the value if the key is not present in the dictionary.
  22621. * The factory will only be invoked if there's no data for the given key.
  22622. * @return the value corresponding to the key.
  22623. */
  22624. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  22625. /**
  22626. * Get a value from its key if present in the dictionary otherwise add it
  22627. * @param key the key to get the value from
  22628. * @param val if there's no such key/value pair in the dictionary add it with this value
  22629. * @return the value corresponding to the key
  22630. */
  22631. getOrAdd(key: string, val: T): T;
  22632. /**
  22633. * Check if there's a given key in the dictionary
  22634. * @param key the key to check for
  22635. * @return true if the key is present, false otherwise
  22636. */
  22637. contains(key: string): boolean;
  22638. /**
  22639. * Add a new key and its corresponding value
  22640. * @param key the key to add
  22641. * @param value the value corresponding to the key
  22642. * @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
  22643. */
  22644. add(key: string, value: T): boolean;
  22645. set(key: string, value: T): boolean;
  22646. /**
  22647. * Get the element of the given key and remove it from the dictionary
  22648. * @param key
  22649. */
  22650. getAndRemove(key: string): Nullable<T>;
  22651. /**
  22652. * Remove a key/value from the dictionary.
  22653. * @param key the key to remove
  22654. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  22655. */
  22656. remove(key: string): boolean;
  22657. /**
  22658. * Clear the whole content of the dictionary
  22659. */
  22660. clear(): void;
  22661. readonly count: number;
  22662. /**
  22663. * Execute a callback on each key/val of the dictionary.
  22664. * Note that you can remove any element in this dictionary in the callback implementation
  22665. * @param callback the callback to execute on a given key/value pair
  22666. */
  22667. forEach(callback: (key: string, val: T) => void): void;
  22668. /**
  22669. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  22670. * If the callback returns null or undefined the method will iterate to the next key/value pair
  22671. * Note that you can remove any element in this dictionary in the callback implementation
  22672. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  22673. */
  22674. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  22675. private _count;
  22676. private _data;
  22677. }
  22678. }
  22679. declare module BABYLON {
  22680. class Tags {
  22681. static EnableFor(obj: any): void;
  22682. static DisableFor(obj: any): void;
  22683. static HasTags(obj: any): boolean;
  22684. static GetTags(obj: any, asString?: boolean): any;
  22685. static AddTagsTo(obj: any, tagsString: string): void;
  22686. static _AddTagTo(obj: any, tag: string): void;
  22687. static RemoveTagsFrom(obj: any, tagsString: string): void;
  22688. static _RemoveTagFrom(obj: any, tag: string): void;
  22689. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  22690. }
  22691. }
  22692. declare module BABYLON {
  22693. class TextureTools {
  22694. /**
  22695. * Uses the GPU to create a copy texture rescaled at a given size
  22696. * @param texture Texture to copy from
  22697. * @param width Desired width
  22698. * @param height Desired height
  22699. * @return Generated texture
  22700. */
  22701. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  22702. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  22703. private static _environmentBRDFBase64Texture;
  22704. }
  22705. }
  22706. declare module BABYLON {
  22707. class TGATools {
  22708. private static _TYPE_INDEXED;
  22709. private static _TYPE_RGB;
  22710. private static _TYPE_GREY;
  22711. private static _TYPE_RLE_INDEXED;
  22712. private static _TYPE_RLE_RGB;
  22713. private static _TYPE_RLE_GREY;
  22714. private static _ORIGIN_MASK;
  22715. private static _ORIGIN_SHIFT;
  22716. private static _ORIGIN_BL;
  22717. private static _ORIGIN_BR;
  22718. private static _ORIGIN_UL;
  22719. private static _ORIGIN_UR;
  22720. static GetTGAHeader(data: Uint8Array): any;
  22721. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  22722. 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;
  22723. 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;
  22724. 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;
  22725. 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;
  22726. 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;
  22727. 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;
  22728. }
  22729. }
  22730. declare module BABYLON {
  22731. interface IAnimatable {
  22732. animations: Array<Animation>;
  22733. }
  22734. class LoadFileError extends Error {
  22735. request: XMLHttpRequest | undefined;
  22736. private static _setPrototypeOf;
  22737. constructor(message: string, request?: XMLHttpRequest | undefined);
  22738. }
  22739. class RetryStrategy {
  22740. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  22741. }
  22742. interface IFileRequest {
  22743. /**
  22744. * Raised when the request is complete (success or error).
  22745. */
  22746. onCompleteObservable: Observable<IFileRequest>;
  22747. /**
  22748. * Aborts the request for a file.
  22749. */
  22750. abort: () => void;
  22751. }
  22752. class Tools {
  22753. static BaseUrl: string;
  22754. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  22755. /**
  22756. * Default behaviour for cors in the application.
  22757. * It can be a string if the expected behavior is identical in the entire app.
  22758. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  22759. */
  22760. static CorsBehavior: string | ((url: string | string[]) => string);
  22761. static UseFallbackTexture: boolean;
  22762. /**
  22763. * Use this object to register external classes like custom textures or material
  22764. * to allow the laoders to instantiate them
  22765. */
  22766. static RegisteredExternalClasses: {
  22767. [key: string]: Object;
  22768. };
  22769. static fallbackTexture: string;
  22770. /**
  22771. * Interpolates between a and b via alpha
  22772. * @param a The lower value (returned when alpha = 0)
  22773. * @param b The upper value (returned when alpha = 1)
  22774. * @param alpha The interpolation-factor
  22775. * @return The mixed value
  22776. */
  22777. static Mix(a: number, b: number, alpha: number): number;
  22778. static Instantiate(className: string): any;
  22779. /**
  22780. * Provides a slice function that will work even on IE
  22781. * @param data defines the array to slice
  22782. * @returns the new sliced array
  22783. */
  22784. static Slice(data: FloatArray): FloatArray;
  22785. static SetImmediate(action: () => void): void;
  22786. static IsExponentOfTwo(value: number): boolean;
  22787. /**
  22788. * Find the next highest power of two.
  22789. * @param x Number to start search from.
  22790. * @return Next highest power of two.
  22791. */
  22792. static CeilingPOT(x: number): number;
  22793. /**
  22794. * Find the next lowest power of two.
  22795. * @param x Number to start search from.
  22796. * @return Next lowest power of two.
  22797. */
  22798. static FloorPOT(x: number): number;
  22799. /**
  22800. * Find the nearest power of two.
  22801. * @param x Number to start search from.
  22802. * @return Next nearest power of two.
  22803. */
  22804. static NearestPOT(x: number): number;
  22805. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  22806. static GetFilename(path: string): string;
  22807. /**
  22808. * Extracts the "folder" part of a path (everything before the filename).
  22809. * @param uri The URI to extract the info from
  22810. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  22811. * @returns The "folder" part of the path
  22812. */
  22813. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  22814. static GetDOMTextContent(element: HTMLElement): string;
  22815. static ToDegrees(angle: number): number;
  22816. static ToRadians(angle: number): number;
  22817. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  22818. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  22819. minimum: Vector3;
  22820. maximum: Vector3;
  22821. };
  22822. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  22823. minimum: Vector3;
  22824. maximum: Vector3;
  22825. };
  22826. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  22827. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  22828. minimum: Vector2;
  22829. maximum: Vector2;
  22830. };
  22831. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  22832. static GetPointerPrefix(): string;
  22833. /**
  22834. * @param func - the function to be called
  22835. * @param requester - the object that will request the next frame. Falls back to window.
  22836. */
  22837. static QueueNewFrame(func: () => void, requester?: any): number;
  22838. static RequestFullscreen(element: HTMLElement): void;
  22839. static ExitFullscreen(): void;
  22840. static SetCorsBehavior(url: string | string[], element: {
  22841. crossOrigin: string | null;
  22842. }): void;
  22843. static CleanUrl(url: string): string;
  22844. static PreprocessUrl: (url: string) => string;
  22845. static LoadImage(url: any, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  22846. 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;
  22847. /**
  22848. * Load a script (identified by an url). When the url returns, the
  22849. * content of this file is added into a new script element, attached to the DOM (body element)
  22850. */
  22851. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  22852. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (this: MSBaseReader, ev: ProgressEvent) => any): IFileRequest;
  22853. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (this: MSBaseReader, ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  22854. static FileAsURL(content: string): string;
  22855. static Format(value: number, decimals?: number): string;
  22856. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  22857. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  22858. static IsEmpty(obj: any): boolean;
  22859. static RegisterTopRootEvents(events: {
  22860. name: string;
  22861. handler: Nullable<(e: FocusEvent) => any>;
  22862. }[]): void;
  22863. static UnregisterTopRootEvents(events: {
  22864. name: string;
  22865. handler: Nullable<(e: FocusEvent) => any>;
  22866. }[]): void;
  22867. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  22868. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  22869. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  22870. /**
  22871. * Generates an image screenshot from the specified camera.
  22872. *
  22873. * @param engine The engine to use for rendering
  22874. * @param camera The camera to use for rendering
  22875. * @param size This parameter can be set to a single number or to an object with the
  22876. * following (optional) properties: precision, width, height. If a single number is passed,
  22877. * it will be used for both width and height. If an object is passed, the screenshot size
  22878. * will be derived from the parameters. The precision property is a multiplier allowing
  22879. * rendering at a higher or lower resolution.
  22880. * @param successCallback The callback receives a single parameter which contains the
  22881. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  22882. * src parameter of an <img> to display it.
  22883. * @param mimeType The MIME type of the screenshot image (default: image/png).
  22884. * Check your browser for supported MIME types.
  22885. * @param samples Texture samples (default: 1)
  22886. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  22887. * @param fileName A name for for the downloaded file.
  22888. * @constructor
  22889. */
  22890. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  22891. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  22892. /**
  22893. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22894. * Be aware Math.random() could cause collisions, but:
  22895. * "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"
  22896. */
  22897. static RandomId(): string;
  22898. /**
  22899. * Test if the given uri is a base64 string.
  22900. * @param uri The uri to test
  22901. * @return True if the uri is a base64 string or false otherwise.
  22902. */
  22903. static IsBase64(uri: string): boolean;
  22904. /**
  22905. * Decode the given base64 uri.
  22906. * @param uri The uri to decode
  22907. * @return The decoded base64 data.
  22908. */
  22909. static DecodeBase64(uri: string): ArrayBuffer;
  22910. private static _NoneLogLevel;
  22911. private static _MessageLogLevel;
  22912. private static _WarningLogLevel;
  22913. private static _ErrorLogLevel;
  22914. private static _LogCache;
  22915. static errorsCount: number;
  22916. static OnNewCacheEntry: (entry: string) => void;
  22917. static readonly NoneLogLevel: number;
  22918. static readonly MessageLogLevel: number;
  22919. static readonly WarningLogLevel: number;
  22920. static readonly ErrorLogLevel: number;
  22921. static readonly AllLogLevel: number;
  22922. private static _AddLogEntry(entry);
  22923. private static _FormatMessage(message);
  22924. private static _LogDisabled(message);
  22925. private static _LogEnabled(message);
  22926. private static _WarnDisabled(message);
  22927. private static _WarnEnabled(message);
  22928. private static _ErrorDisabled(message);
  22929. private static _ErrorEnabled(message);
  22930. static Log: (message: string) => void;
  22931. static Warn: (message: string) => void;
  22932. static Error: (message: string) => void;
  22933. static readonly LogCache: string;
  22934. static ClearLogCache(): void;
  22935. static LogLevels: number;
  22936. static IsWindowObjectExist(): boolean;
  22937. private static _PerformanceNoneLogLevel;
  22938. private static _PerformanceUserMarkLogLevel;
  22939. private static _PerformanceConsoleLogLevel;
  22940. private static _performance;
  22941. static readonly PerformanceNoneLogLevel: number;
  22942. static readonly PerformanceUserMarkLogLevel: number;
  22943. static readonly PerformanceConsoleLogLevel: number;
  22944. static PerformanceLogLevel: number;
  22945. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  22946. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  22947. static _StartUserMark(counterName: string, condition?: boolean): void;
  22948. static _EndUserMark(counterName: string, condition?: boolean): void;
  22949. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  22950. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  22951. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  22952. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  22953. static readonly Now: number;
  22954. /**
  22955. * This method will return the name of the class used to create the instance of the given object.
  22956. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  22957. * @param object the object to get the class name from
  22958. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  22959. */
  22960. static GetClassName(object: any, isType?: boolean): string;
  22961. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  22962. /**
  22963. * This method will return the name of the full name of the class, including its owning module (if any).
  22964. * 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).
  22965. * @param object the object to get the class name from
  22966. * @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.
  22967. */
  22968. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  22969. /**
  22970. * 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.
  22971. * @param array
  22972. */
  22973. static arrayOrStringFeeder(array: any): (i: number) => number;
  22974. /**
  22975. * Compute the hashCode of a stream of number
  22976. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  22977. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  22978. * @return the hash code computed
  22979. */
  22980. static hashCodeFromStream(feeder: (index: number) => number): number;
  22981. /**
  22982. * Returns a promise that resolves after the given amount of time.
  22983. * @param delay Number of milliseconds to delay
  22984. * @returns Promise that resolves after the given amount of time
  22985. */
  22986. static DelayAsync(delay: number): Promise<void>;
  22987. }
  22988. /**
  22989. * This class is used to track a performance counter which is number based.
  22990. * The user has access to many properties which give statistics of different nature
  22991. *
  22992. * The implementer can track two kinds of Performance Counter: time and count
  22993. * 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.
  22994. * 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.
  22995. */
  22996. class PerfCounter {
  22997. static Enabled: boolean;
  22998. /**
  22999. * Returns the smallest value ever
  23000. */
  23001. readonly min: number;
  23002. /**
  23003. * Returns the biggest value ever
  23004. */
  23005. readonly max: number;
  23006. /**
  23007. * Returns the average value since the performance counter is running
  23008. */
  23009. readonly average: number;
  23010. /**
  23011. * Returns the average value of the last second the counter was monitored
  23012. */
  23013. readonly lastSecAverage: number;
  23014. /**
  23015. * Returns the current value
  23016. */
  23017. readonly current: number;
  23018. readonly total: number;
  23019. readonly count: number;
  23020. constructor();
  23021. /**
  23022. * Call this method to start monitoring a new frame.
  23023. * 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.
  23024. */
  23025. fetchNewFrame(): void;
  23026. /**
  23027. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  23028. * @param newCount the count value to add to the monitored count
  23029. * @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.
  23030. */
  23031. addCount(newCount: number, fetchResult: boolean): void;
  23032. /**
  23033. * Start monitoring this performance counter
  23034. */
  23035. beginMonitoring(): void;
  23036. /**
  23037. * Compute the time lapsed since the previous beginMonitoring() call.
  23038. * @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
  23039. */
  23040. endMonitoring(newFrame?: boolean): void;
  23041. private _fetchResult();
  23042. private _startMonitoringTime;
  23043. private _min;
  23044. private _max;
  23045. private _average;
  23046. private _current;
  23047. private _totalValueCount;
  23048. private _totalAccumulated;
  23049. private _lastSecAverage;
  23050. private _lastSecAccumulated;
  23051. private _lastSecTime;
  23052. private _lastSecValueCount;
  23053. }
  23054. /**
  23055. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  23056. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  23057. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  23058. * @param name The name of the class, case should be preserved
  23059. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  23060. */
  23061. function className(name: string, module?: string): (target: Object) => void;
  23062. /**
  23063. * An implementation of a loop for asynchronous functions.
  23064. */
  23065. class AsyncLoop {
  23066. iterations: number;
  23067. private _fn;
  23068. private _successCallback;
  23069. index: number;
  23070. private _done;
  23071. /**
  23072. * Constroctor.
  23073. * @param iterations the number of iterations.
  23074. * @param _fn the function to run each iteration
  23075. * @param _successCallback the callback that will be called upon succesful execution
  23076. * @param offset starting offset.
  23077. */
  23078. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  23079. /**
  23080. * Execute the next iteration. Must be called after the last iteration was finished.
  23081. */
  23082. executeNext(): void;
  23083. /**
  23084. * Break the loop and run the success callback.
  23085. */
  23086. breakLoop(): void;
  23087. /**
  23088. * Helper function
  23089. */
  23090. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  23091. /**
  23092. * A for-loop that will run a given number of iterations synchronous and the rest async.
  23093. * @param iterations total number of iterations
  23094. * @param syncedIterations number of synchronous iterations in each async iteration.
  23095. * @param fn the function to call each iteration.
  23096. * @param callback a success call back that will be called when iterating stops.
  23097. * @param breakFunction a break condition (optional)
  23098. * @param timeout timeout settings for the setTimeout function. default - 0.
  23099. * @constructor
  23100. */
  23101. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  23102. }
  23103. }
  23104. declare module BABYLON {
  23105. enum JoystickAxis {
  23106. X = 0,
  23107. Y = 1,
  23108. Z = 2,
  23109. }
  23110. class VirtualJoystick {
  23111. reverseLeftRight: boolean;
  23112. reverseUpDown: boolean;
  23113. deltaPosition: Vector3;
  23114. pressed: boolean;
  23115. private static _globalJoystickIndex;
  23116. private static vjCanvas;
  23117. private static vjCanvasContext;
  23118. private static vjCanvasWidth;
  23119. private static vjCanvasHeight;
  23120. private static halfWidth;
  23121. private _action;
  23122. private _axisTargetedByLeftAndRight;
  23123. private _axisTargetedByUpAndDown;
  23124. private _joystickSensibility;
  23125. private _inversedSensibility;
  23126. private _joystickPointerID;
  23127. private _joystickColor;
  23128. private _joystickPointerPos;
  23129. private _joystickPreviousPointerPos;
  23130. private _joystickPointerStartPos;
  23131. private _deltaJoystickVector;
  23132. private _leftJoystick;
  23133. private _touches;
  23134. private _onPointerDownHandlerRef;
  23135. private _onPointerMoveHandlerRef;
  23136. private _onPointerUpHandlerRef;
  23137. private _onResize;
  23138. constructor(leftJoystick?: boolean);
  23139. setJoystickSensibility(newJoystickSensibility: number): void;
  23140. private _onPointerDown(e);
  23141. private _onPointerMove(e);
  23142. private _onPointerUp(e);
  23143. /**
  23144. * Change the color of the virtual joystick
  23145. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  23146. */
  23147. setJoystickColor(newColor: string): void;
  23148. setActionOnTouch(action: () => any): void;
  23149. setAxisForLeftRight(axis: JoystickAxis): void;
  23150. setAxisForUpDown(axis: JoystickAxis): void;
  23151. private _drawVirtualJoystick();
  23152. releaseCanvas(): void;
  23153. }
  23154. }
  23155. declare module BABYLON {
  23156. /**
  23157. * Helper class to push actions to a pool of workers.
  23158. */
  23159. class WorkerPool implements IDisposable {
  23160. private _workerInfos;
  23161. private _pendingActions;
  23162. /**
  23163. * Constructor
  23164. * @param workers Array of workers to use for actions
  23165. */
  23166. constructor(workers: Array<Worker>);
  23167. /**
  23168. * Terminates all workers and clears any pending actions.
  23169. */
  23170. dispose(): void;
  23171. /**
  23172. * Pushes an action to the worker pool. If all the workers are active, the action will be
  23173. * pended until a worker has completed its action.
  23174. * @param action The action to perform. Call onComplete when the action is complete.
  23175. */
  23176. push(action: (worker: Worker, onComplete: () => void) => void): void;
  23177. private _execute(workerInfo, action);
  23178. }
  23179. }
  23180. declare module BABYLON {
  23181. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  23182. readonly name: string;
  23183. private _zoomStopsAnimation;
  23184. private _idleRotationSpeed;
  23185. private _idleRotationWaitTime;
  23186. private _idleRotationSpinupTime;
  23187. /**
  23188. * Gets the flag that indicates if user zooming should stop animation.
  23189. */
  23190. /**
  23191. * Sets the flag that indicates if user zooming should stop animation.
  23192. */
  23193. zoomStopsAnimation: boolean;
  23194. /**
  23195. * Gets the default speed at which the camera rotates around the model.
  23196. */
  23197. /**
  23198. * Sets the default speed at which the camera rotates around the model.
  23199. */
  23200. idleRotationSpeed: number;
  23201. /**
  23202. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  23203. */
  23204. /**
  23205. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  23206. */
  23207. idleRotationWaitTime: number;
  23208. /**
  23209. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  23210. */
  23211. /**
  23212. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  23213. */
  23214. idleRotationSpinupTime: number;
  23215. /**
  23216. * Gets a value indicating if the camera is currently rotating because of this behavior
  23217. */
  23218. readonly rotationInProgress: boolean;
  23219. private _onPrePointerObservableObserver;
  23220. private _onAfterCheckInputsObserver;
  23221. private _attachedCamera;
  23222. private _isPointerDown;
  23223. private _lastFrameTime;
  23224. private _lastInteractionTime;
  23225. private _cameraRotationSpeed;
  23226. init(): void;
  23227. attach(camera: ArcRotateCamera): void;
  23228. detach(): void;
  23229. /**
  23230. * Returns true if user is scrolling.
  23231. * @return true if user is scrolling.
  23232. */
  23233. private _userIsZooming();
  23234. private _lastFrameRadius;
  23235. private _shouldAnimationStopForInteraction();
  23236. /**
  23237. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  23238. */
  23239. private _applyUserInteraction();
  23240. private _userIsMoving();
  23241. }
  23242. }
  23243. declare module BABYLON {
  23244. /**
  23245. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  23246. */
  23247. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  23248. readonly name: string;
  23249. /**
  23250. * The easing function used by animations
  23251. */
  23252. static EasingFunction: BackEase;
  23253. /**
  23254. * The easing mode used by animations
  23255. */
  23256. static EasingMode: number;
  23257. /**
  23258. * The duration of the animation, in milliseconds
  23259. */
  23260. transitionDuration: number;
  23261. /**
  23262. * Length of the distance animated by the transition when lower radius is reached
  23263. */
  23264. lowerRadiusTransitionRange: number;
  23265. /**
  23266. * Length of the distance animated by the transition when upper radius is reached
  23267. */
  23268. upperRadiusTransitionRange: number;
  23269. private _autoTransitionRange;
  23270. /**
  23271. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  23272. */
  23273. /**
  23274. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  23275. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  23276. */
  23277. autoTransitionRange: boolean;
  23278. private _attachedCamera;
  23279. private _onAfterCheckInputsObserver;
  23280. private _onMeshTargetChangedObserver;
  23281. init(): void;
  23282. attach(camera: ArcRotateCamera): void;
  23283. detach(): void;
  23284. private _radiusIsAnimating;
  23285. private _radiusBounceTransition;
  23286. private _animatables;
  23287. private _cachedWheelPrecision;
  23288. /**
  23289. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  23290. * @param radiusLimit The limit to check against.
  23291. * @return Bool to indicate if at limit.
  23292. */
  23293. private _isRadiusAtLimit(radiusLimit);
  23294. /**
  23295. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  23296. * @param radiusDelta The delta by which to animate to. Can be negative.
  23297. */
  23298. private _applyBoundRadiusAnimation(radiusDelta);
  23299. /**
  23300. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  23301. */
  23302. protected _clearAnimationLocks(): void;
  23303. /**
  23304. * Stops and removes all animations that have been applied to the camera
  23305. */
  23306. stopAllAnimations(): void;
  23307. }
  23308. }
  23309. declare module BABYLON {
  23310. class FramingBehavior implements Behavior<ArcRotateCamera> {
  23311. readonly name: string;
  23312. private _mode;
  23313. private _radiusScale;
  23314. private _positionScale;
  23315. private _defaultElevation;
  23316. private _elevationReturnTime;
  23317. private _elevationReturnWaitTime;
  23318. private _zoomStopsAnimation;
  23319. private _framingTime;
  23320. /**
  23321. * The easing function used by animations
  23322. */
  23323. static EasingFunction: ExponentialEase;
  23324. /**
  23325. * The easing mode used by animations
  23326. */
  23327. static EasingMode: number;
  23328. /**
  23329. * Gets current mode used by the behavior.
  23330. */
  23331. /**
  23332. * Sets the current mode used by the behavior
  23333. */
  23334. mode: number;
  23335. /**
  23336. * Gets the scale applied to the radius
  23337. */
  23338. /**
  23339. * Sets the scale applied to the radius (1 by default)
  23340. */
  23341. radiusScale: number;
  23342. /**
  23343. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  23344. */
  23345. /**
  23346. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  23347. */
  23348. positionScale: number;
  23349. /**
  23350. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  23351. * behaviour is triggered, in radians.
  23352. */
  23353. /**
  23354. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  23355. * behaviour is triggered, in radians.
  23356. */
  23357. defaultElevation: number;
  23358. /**
  23359. * Gets the time (in milliseconds) taken to return to the default beta position.
  23360. * Negative value indicates camera should not return to default.
  23361. */
  23362. /**
  23363. * Sets the time (in milliseconds) taken to return to the default beta position.
  23364. * Negative value indicates camera should not return to default.
  23365. */
  23366. elevationReturnTime: number;
  23367. /**
  23368. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  23369. */
  23370. /**
  23371. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  23372. */
  23373. elevationReturnWaitTime: number;
  23374. /**
  23375. * Gets the flag that indicates if user zooming should stop animation.
  23376. */
  23377. /**
  23378. * Sets the flag that indicates if user zooming should stop animation.
  23379. */
  23380. zoomStopsAnimation: boolean;
  23381. /**
  23382. * Gets the transition time when framing the mesh, in milliseconds
  23383. */
  23384. /**
  23385. * Sets the transition time when framing the mesh, in milliseconds
  23386. */
  23387. framingTime: number;
  23388. private _onPrePointerObservableObserver;
  23389. private _onAfterCheckInputsObserver;
  23390. private _onMeshTargetChangedObserver;
  23391. private _attachedCamera;
  23392. private _isPointerDown;
  23393. private _lastInteractionTime;
  23394. init(): void;
  23395. attach(camera: ArcRotateCamera): void;
  23396. detach(): void;
  23397. private _animatables;
  23398. private _betaIsAnimating;
  23399. private _betaTransition;
  23400. private _radiusTransition;
  23401. private _vectorTransition;
  23402. /**
  23403. * Targets the given mesh and updates zoom level accordingly.
  23404. * @param mesh The mesh to target.
  23405. * @param radius Optional. If a cached radius position already exists, overrides default.
  23406. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23407. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23408. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23409. */
  23410. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23411. /**
  23412. * Targets the given mesh with its children and updates zoom level accordingly.
  23413. * @param mesh The mesh to target.
  23414. * @param radius Optional. If a cached radius position already exists, overrides default.
  23415. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23416. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23417. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23418. */
  23419. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23420. /**
  23421. * Targets the given meshes with their children and updates zoom level accordingly.
  23422. * @param meshes The mesh to target.
  23423. * @param radius Optional. If a cached radius position already exists, overrides default.
  23424. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23425. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23426. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23427. */
  23428. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23429. /**
  23430. * Targets the given mesh and updates zoom level accordingly.
  23431. * @param mesh The mesh to target.
  23432. * @param radius Optional. If a cached radius position already exists, overrides default.
  23433. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23434. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23435. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23436. */
  23437. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23438. /**
  23439. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  23440. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  23441. * frustum width.
  23442. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  23443. * to fully enclose the mesh in the viewing frustum.
  23444. */
  23445. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  23446. /**
  23447. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  23448. * is automatically returned to its default position (expected to be above ground plane).
  23449. */
  23450. private _maintainCameraAboveGround();
  23451. /**
  23452. * Returns the frustum slope based on the canvas ratio and camera FOV
  23453. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  23454. */
  23455. private _getFrustumSlope();
  23456. /**
  23457. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  23458. */
  23459. private _clearAnimationLocks();
  23460. /**
  23461. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  23462. */
  23463. private _applyUserInteraction();
  23464. /**
  23465. * Stops and removes all animations that have been applied to the camera
  23466. */
  23467. stopAllAnimations(): void;
  23468. /**
  23469. * Gets a value indicating if the user is moving the camera
  23470. */
  23471. readonly isUserIsMoving: boolean;
  23472. /**
  23473. * The camera can move all the way towards the mesh.
  23474. */
  23475. static IgnoreBoundsSizeMode: number;
  23476. /**
  23477. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  23478. */
  23479. static FitFrustumSidesMode: number;
  23480. }
  23481. }
  23482. declare module BABYLON {
  23483. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  23484. camera: ArcRotateCamera;
  23485. gamepad: Nullable<Gamepad>;
  23486. private _onGamepadConnectedObserver;
  23487. private _onGamepadDisconnectedObserver;
  23488. gamepadRotationSensibility: number;
  23489. gamepadMoveSensibility: number;
  23490. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23491. detachControl(element: Nullable<HTMLElement>): void;
  23492. checkInputs(): void;
  23493. getClassName(): string;
  23494. getSimpleName(): string;
  23495. }
  23496. }
  23497. declare module BABYLON {
  23498. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  23499. camera: ArcRotateCamera;
  23500. private _keys;
  23501. keysUp: number[];
  23502. keysDown: number[];
  23503. keysLeft: number[];
  23504. keysRight: number[];
  23505. keysReset: number[];
  23506. panningSensibility: number;
  23507. zoomingSensibility: number;
  23508. useAltToZoom: boolean;
  23509. private _ctrlPressed;
  23510. private _altPressed;
  23511. private _onCanvasBlurObserver;
  23512. private _onKeyboardObserver;
  23513. private _engine;
  23514. private _scene;
  23515. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23516. detachControl(element: Nullable<HTMLElement>): void;
  23517. checkInputs(): void;
  23518. getClassName(): string;
  23519. getSimpleName(): string;
  23520. }
  23521. }
  23522. declare module BABYLON {
  23523. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  23524. camera: ArcRotateCamera;
  23525. private _wheel;
  23526. private _observer;
  23527. wheelPrecision: number;
  23528. /**
  23529. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  23530. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  23531. */
  23532. wheelDeltaPercentage: number;
  23533. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23534. detachControl(element: Nullable<HTMLElement>): void;
  23535. getClassName(): string;
  23536. getSimpleName(): string;
  23537. }
  23538. }
  23539. declare module BABYLON {
  23540. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  23541. camera: ArcRotateCamera;
  23542. buttons: number[];
  23543. angularSensibilityX: number;
  23544. angularSensibilityY: number;
  23545. pinchPrecision: number;
  23546. /**
  23547. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  23548. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  23549. */
  23550. pinchDeltaPercentage: number;
  23551. panningSensibility: number;
  23552. multiTouchPanning: boolean;
  23553. multiTouchPanAndZoom: boolean;
  23554. private _isPanClick;
  23555. pinchInwards: boolean;
  23556. private _pointerInput;
  23557. private _observer;
  23558. private _onMouseMove;
  23559. private _onGestureStart;
  23560. private _onGesture;
  23561. private _MSGestureHandler;
  23562. private _onLostFocus;
  23563. private _onContextMenu;
  23564. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23565. detachControl(element: Nullable<HTMLElement>): void;
  23566. getClassName(): string;
  23567. getSimpleName(): string;
  23568. }
  23569. }
  23570. declare module BABYLON {
  23571. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  23572. camera: ArcRotateCamera;
  23573. alphaCorrection: number;
  23574. betaCorrection: number;
  23575. gammaCorrection: number;
  23576. private _alpha;
  23577. private _gamma;
  23578. private _dirty;
  23579. private _deviceOrientationHandler;
  23580. constructor();
  23581. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23582. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  23583. checkInputs(): void;
  23584. detachControl(element: Nullable<HTMLElement>): void;
  23585. getClassName(): string;
  23586. getSimpleName(): string;
  23587. }
  23588. }
  23589. declare module BABYLON {
  23590. /**
  23591. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  23592. * Screen rotation is taken into account.
  23593. */
  23594. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  23595. private _camera;
  23596. private _screenOrientationAngle;
  23597. private _constantTranform;
  23598. private _screenQuaternion;
  23599. private _alpha;
  23600. private _beta;
  23601. private _gamma;
  23602. constructor();
  23603. camera: FreeCamera;
  23604. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23605. private _orientationChanged;
  23606. private _deviceOrientation;
  23607. detachControl(element: Nullable<HTMLElement>): void;
  23608. checkInputs(): void;
  23609. getClassName(): string;
  23610. getSimpleName(): string;
  23611. }
  23612. }
  23613. declare module BABYLON {
  23614. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  23615. camera: FreeCamera;
  23616. gamepad: Nullable<Gamepad>;
  23617. private _onGamepadConnectedObserver;
  23618. private _onGamepadDisconnectedObserver;
  23619. gamepadAngularSensibility: number;
  23620. gamepadMoveSensibility: number;
  23621. private _cameraTransform;
  23622. private _deltaTransform;
  23623. private _vector3;
  23624. private _vector2;
  23625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23626. detachControl(element: Nullable<HTMLElement>): void;
  23627. checkInputs(): void;
  23628. getClassName(): string;
  23629. getSimpleName(): string;
  23630. }
  23631. }
  23632. declare module BABYLON {
  23633. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  23634. camera: FreeCamera;
  23635. private _keys;
  23636. private _onCanvasBlurObserver;
  23637. private _onKeyboardObserver;
  23638. private _engine;
  23639. private _scene;
  23640. keysUp: number[];
  23641. keysDown: number[];
  23642. keysLeft: number[];
  23643. keysRight: number[];
  23644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23645. detachControl(element: Nullable<HTMLElement>): void;
  23646. checkInputs(): void;
  23647. getClassName(): string;
  23648. _onLostFocus(e: FocusEvent): void;
  23649. getSimpleName(): string;
  23650. }
  23651. }
  23652. declare module BABYLON {
  23653. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  23654. touchEnabled: boolean;
  23655. camera: FreeCamera;
  23656. buttons: number[];
  23657. angularSensibility: number;
  23658. private _pointerInput;
  23659. private _onMouseMove;
  23660. private _observer;
  23661. private previousPosition;
  23662. constructor(touchEnabled?: boolean);
  23663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23664. detachControl(element: Nullable<HTMLElement>): void;
  23665. getClassName(): string;
  23666. getSimpleName(): string;
  23667. }
  23668. }
  23669. declare module BABYLON {
  23670. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  23671. camera: FreeCamera;
  23672. private _offsetX;
  23673. private _offsetY;
  23674. private _pointerPressed;
  23675. private _pointerInput;
  23676. private _observer;
  23677. private _onLostFocus;
  23678. touchAngularSensibility: number;
  23679. touchMoveSensibility: number;
  23680. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23681. detachControl(element: Nullable<HTMLElement>): void;
  23682. checkInputs(): void;
  23683. getClassName(): string;
  23684. getSimpleName(): string;
  23685. }
  23686. }
  23687. declare module BABYLON {
  23688. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  23689. camera: FreeCamera;
  23690. private _leftjoystick;
  23691. private _rightjoystick;
  23692. getLeftJoystick(): VirtualJoystick;
  23693. getRightJoystick(): VirtualJoystick;
  23694. checkInputs(): void;
  23695. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23696. detachControl(element: Nullable<HTMLElement>): void;
  23697. getClassName(): string;
  23698. getSimpleName(): string;
  23699. }
  23700. }
  23701. declare module BABYLON {
  23702. class VRCameraMetrics {
  23703. hResolution: number;
  23704. vResolution: number;
  23705. hScreenSize: number;
  23706. vScreenSize: number;
  23707. vScreenCenter: number;
  23708. eyeToScreenDistance: number;
  23709. lensSeparationDistance: number;
  23710. interpupillaryDistance: number;
  23711. distortionK: number[];
  23712. chromaAbCorrection: number[];
  23713. postProcessScaleFactor: number;
  23714. lensCenterOffset: number;
  23715. compensateDistortion: boolean;
  23716. readonly aspectRatio: number;
  23717. readonly aspectRatioFov: number;
  23718. readonly leftHMatrix: Matrix;
  23719. readonly rightHMatrix: Matrix;
  23720. readonly leftPreViewMatrix: Matrix;
  23721. readonly rightPreViewMatrix: Matrix;
  23722. static GetDefault(): VRCameraMetrics;
  23723. }
  23724. }
  23725. declare module BABYLON {
  23726. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  23727. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  23728. getClassName(): string;
  23729. }
  23730. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  23731. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  23732. getClassName(): string;
  23733. }
  23734. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  23735. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  23736. getClassName(): string;
  23737. }
  23738. }
  23739. declare module BABYLON {
  23740. /**
  23741. * Options to modify the vr teleportation behavior.
  23742. */
  23743. interface VRTeleportationOptions {
  23744. /**
  23745. * The name of the mesh which should be used as the teleportation floor. (default: null)
  23746. */
  23747. floorMeshName?: string;
  23748. /**
  23749. * A list of meshes to be used as the teleportation floor. (default: empty)
  23750. */
  23751. floorMeshes?: Mesh[];
  23752. }
  23753. /**
  23754. * Options to modify the vr experience helper's behavior.
  23755. */
  23756. interface VRExperienceHelperOptions extends WebVROptions {
  23757. /**
  23758. * Create a DeviceOrientationCamera to be used as your out of vr camera.
  23759. */
  23760. createDeviceOrientationCamera?: boolean;
  23761. /**
  23762. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found.
  23763. */
  23764. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  23765. }
  23766. /**
  23767. * Helps to quickly add VR support to an existing scene.
  23768. * See http://doc.babylonjs.com/how_to/webvr_helper
  23769. */
  23770. class VRExperienceHelper {
  23771. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  23772. private _scene;
  23773. private _position;
  23774. private _btnVR;
  23775. private _btnVRDisplayed;
  23776. private _webVRsupported;
  23777. private _webVRready;
  23778. private _webVRrequesting;
  23779. private _webVRpresenting;
  23780. private _fullscreenVRpresenting;
  23781. private _canvas;
  23782. private _webVRCamera;
  23783. private _vrDeviceOrientationCamera;
  23784. private _deviceOrientationCamera;
  23785. private _existingCamera;
  23786. private _onKeyDown;
  23787. private _onVrDisplayPresentChange;
  23788. private _onVRDisplayChanged;
  23789. private _onVRRequestPresentStart;
  23790. private _onVRRequestPresentComplete;
  23791. /**
  23792. * Observable raised when entering VR.
  23793. */
  23794. onEnteringVRObservable: Observable<VRExperienceHelper>;
  23795. /**
  23796. * Observable raised when exiting VR.
  23797. */
  23798. onExitingVRObservable: Observable<VRExperienceHelper>;
  23799. /**
  23800. * Observable raised when controller mesh is loaded.
  23801. */
  23802. onControllerMeshLoadedObservable: Observable<WebVRController>;
  23803. /** Return this.onEnteringVRObservable
  23804. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  23805. */
  23806. readonly onEnteringVR: Observable<VRExperienceHelper>;
  23807. /** Return this.onExitingVRObservable
  23808. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  23809. */
  23810. readonly onExitingVR: Observable<VRExperienceHelper>;
  23811. /** Return this.onControllerMeshLoadedObservable
  23812. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  23813. */
  23814. readonly onControllerMeshLoaded: Observable<WebVRController>;
  23815. private _rayLength;
  23816. private _useCustomVRButton;
  23817. private _teleportationRequested;
  23818. private _teleportActive;
  23819. private _floorMeshName;
  23820. private _floorMeshesCollection;
  23821. private _rotationAllowed;
  23822. private _teleportBackwardsVector;
  23823. private _rotationRightAsked;
  23824. private _rotationLeftAsked;
  23825. private _teleportationTarget;
  23826. private _isDefaultTeleportationTarget;
  23827. private _postProcessMove;
  23828. private _teleportationFillColor;
  23829. private _teleportationBorderColor;
  23830. private _rotationAngle;
  23831. private _haloCenter;
  23832. private _cameraGazer;
  23833. private _padSensibilityUp;
  23834. private _padSensibilityDown;
  23835. private leftController;
  23836. private rightController;
  23837. /**
  23838. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  23839. */
  23840. onNewMeshSelected: Observable<AbstractMesh>;
  23841. /**
  23842. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  23843. */
  23844. onNewMeshPicked: Observable<PickingInfo>;
  23845. private _circleEase;
  23846. /**
  23847. * Observable raised before camera teleportation
  23848. */
  23849. onBeforeCameraTeleport: Observable<Vector3>;
  23850. /**
  23851. * Observable raised after camera teleportation
  23852. */
  23853. onAfterCameraTeleport: Observable<Vector3>;
  23854. /**
  23855. * Observable raised when current selected mesh gets unselected
  23856. */
  23857. onSelectedMeshUnselected: Observable<AbstractMesh>;
  23858. private _raySelectionPredicate;
  23859. /**
  23860. * To be optionaly changed by user to define custom ray selection
  23861. */
  23862. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  23863. /**
  23864. * To be optionaly changed by user to define custom selection logic (after ray selection)
  23865. */
  23866. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  23867. /**
  23868. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  23869. */
  23870. teleportationEnabled: boolean;
  23871. private _defaultHeight;
  23872. private _teleportationInitialized;
  23873. private _interactionsEnabled;
  23874. private _interactionsRequested;
  23875. private _displayGaze;
  23876. private _displayLaserPointer;
  23877. /**
  23878. * The mesh used to display where the user is going to teleport.
  23879. */
  23880. /**
  23881. * Sets the mesh to be used to display where the user is going to teleport.
  23882. */
  23883. teleportationTarget: Mesh;
  23884. /**
  23885. * The mesh used to display where the user is selecting,
  23886. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  23887. * See http://doc.babylonjs.com/resources/baking_transformations
  23888. */
  23889. gazeTrackerMesh: Mesh;
  23890. /**
  23891. * If the ray of the gaze should be displayed.
  23892. */
  23893. /**
  23894. * Sets if the ray of the gaze should be displayed.
  23895. */
  23896. displayGaze: boolean;
  23897. /**
  23898. * If the ray of the LaserPointer should be displayed.
  23899. */
  23900. /**
  23901. * Sets if the ray of the LaserPointer should be displayed.
  23902. */
  23903. displayLaserPointer: boolean;
  23904. /**
  23905. * The deviceOrientationCamera used as the camera when not in VR.
  23906. */
  23907. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  23908. /**
  23909. * Based on the current WebVR support, returns the current VR camera used.
  23910. */
  23911. readonly currentVRCamera: Nullable<Camera>;
  23912. /**
  23913. * The webVRCamera which is used when in VR.
  23914. */
  23915. readonly webVRCamera: WebVRFreeCamera;
  23916. /**
  23917. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  23918. */
  23919. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  23920. private readonly _teleportationRequestInitiated;
  23921. /**
  23922. * Instantiates a VRExperienceHelper.
  23923. * Helps to quickly add VR support to an existing scene.
  23924. * @param scene The scene the VRExperienceHelper belongs to.
  23925. * @param webVROptions Options to modify the vr experience helper's behavior.
  23926. */
  23927. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  23928. private _onDefaultMeshLoaded(webVRController);
  23929. private _onResize;
  23930. private _onFullscreenChange;
  23931. /**
  23932. * Gets a value indicating if we are currently in VR mode.
  23933. */
  23934. readonly isInVRMode: boolean;
  23935. private onVrDisplayPresentChange();
  23936. private onVRDisplayChanged(eventArgs);
  23937. private moveButtonToBottomRight();
  23938. private displayVRButton();
  23939. private updateButtonVisibility();
  23940. /**
  23941. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  23942. * Otherwise, will use the fullscreen API.
  23943. */
  23944. enterVR(): void;
  23945. /**
  23946. * Attempt to exit VR, or fullscreen.
  23947. */
  23948. exitVR(): void;
  23949. /**
  23950. * The position of the vr experience helper.
  23951. */
  23952. /**
  23953. * Sets the position of the vr experience helper.
  23954. */
  23955. position: Vector3;
  23956. /**
  23957. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  23958. */
  23959. enableInteractions(): void;
  23960. private beforeRender;
  23961. private _isTeleportationFloor(mesh);
  23962. /**
  23963. * Adds a floor mesh to be used for teleportation.
  23964. * @param floorMesh the mesh to be used for teleportation.
  23965. */
  23966. addFloorMesh(floorMesh: Mesh): void;
  23967. /**
  23968. * Removes a floor mesh from being used for teleportation.
  23969. * @param floorMesh the mesh to be removed.
  23970. */
  23971. removeFloorMesh(floorMesh: Mesh): void;
  23972. /**
  23973. * Enables interactions and teleportation using the VR controllers and gaze.
  23974. * @param vrTeleportationOptions options to modify teleportation behavior.
  23975. */
  23976. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  23977. private _onNewGamepadConnected;
  23978. private _tryEnableInteractionOnController;
  23979. private _onNewGamepadDisconnected;
  23980. private _enableInteractionOnController(controller);
  23981. private _checkTeleportWithRay(stateObject, gazer);
  23982. private _checkRotate(stateObject, gazer);
  23983. private _checkTeleportBackwards(stateObject, gazer);
  23984. private _enableTeleportationOnController(controller);
  23985. private _createTeleportationCircles();
  23986. private _displayTeleportationTarget();
  23987. private _hideTeleportationTarget();
  23988. private _rotateCamera(right);
  23989. private _moveTeleportationSelectorTo(hit, gazer);
  23990. private _workingVector;
  23991. private _workingQuaternion;
  23992. private _workingMatrix;
  23993. private _teleportCamera(location);
  23994. private _castRayAndSelectObject(gazer);
  23995. private _notifySelectedMeshUnselected(mesh);
  23996. /**
  23997. * Sets the color of the laser ray from the vr controllers.
  23998. * @param color new color for the ray.
  23999. */
  24000. changeLaserColor(color: Color3): void;
  24001. /**
  24002. * Sets the color of the ray from the vr headsets gaze.
  24003. * @param color new color for the ray.
  24004. */
  24005. changeGazeColor(color: Color3): void;
  24006. /**
  24007. * Exits VR and disposes of the vr experience helper
  24008. */
  24009. dispose(): void;
  24010. /**
  24011. * Gets the name of the VRExperienceHelper class
  24012. * @returns "VRExperienceHelper"
  24013. */
  24014. getClassName(): string;
  24015. }
  24016. }
  24017. declare var HMDVRDevice: any;
  24018. declare var VRDisplay: any;
  24019. declare var VRFrameData: any;
  24020. declare module BABYLON {
  24021. /**
  24022. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  24023. * IMPORTANT!! The data is right-hand data.
  24024. * @export
  24025. * @interface DevicePose
  24026. */
  24027. interface DevicePose {
  24028. /**
  24029. * The position of the device, values in array are [x,y,z].
  24030. */
  24031. readonly position?: Float32Array;
  24032. /**
  24033. * The linearVelocity of the device, values in array are [x,y,z].
  24034. */
  24035. readonly linearVelocity?: Float32Array;
  24036. /**
  24037. * The linearAcceleration of the device, values in array are [x,y,z].
  24038. */
  24039. readonly linearAcceleration?: Float32Array;
  24040. /**
  24041. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  24042. */
  24043. readonly orientation?: Float32Array;
  24044. /**
  24045. * The angularVelocity of the device, values in array are [x,y,z].
  24046. */
  24047. readonly angularVelocity?: Float32Array;
  24048. /**
  24049. * The angularAcceleration of the device, values in array are [x,y,z].
  24050. */
  24051. readonly angularAcceleration?: Float32Array;
  24052. }
  24053. /**
  24054. * Interface representing a pose controlled object in Babylon.
  24055. * A pose controlled object has both regular pose values as well as pose values
  24056. * from an external device such as a VR head mounted display
  24057. */
  24058. interface PoseControlled {
  24059. /**
  24060. * The position of the object in babylon space.
  24061. */
  24062. position: Vector3;
  24063. /**
  24064. * The rotation quaternion of the object in babylon space.
  24065. */
  24066. rotationQuaternion: Quaternion;
  24067. /**
  24068. * The position of the device in babylon space.
  24069. */
  24070. devicePosition?: Vector3;
  24071. /**
  24072. * The rotation quaternion of the device in babylon space.
  24073. */
  24074. deviceRotationQuaternion: Quaternion;
  24075. /**
  24076. * The raw pose coming from the device.
  24077. */
  24078. rawPose: Nullable<DevicePose>;
  24079. /**
  24080. * The scale of the device to be used when translating from device space to babylon space.
  24081. */
  24082. deviceScaleFactor: number;
  24083. /**
  24084. * Updates the poseControlled values based on the input device pose.
  24085. * @param poseData the pose data to update the object with
  24086. */
  24087. updateFromDevice(poseData: DevicePose): void;
  24088. }
  24089. /**
  24090. * Set of options to customize the webVRCamera
  24091. */
  24092. interface WebVROptions {
  24093. /**
  24094. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  24095. */
  24096. trackPosition?: boolean;
  24097. /**
  24098. * Sets the scale of the vrDevice in babylon space. (default: 1)
  24099. */
  24100. positionScale?: number;
  24101. /**
  24102. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  24103. */
  24104. displayName?: string;
  24105. /**
  24106. * Should the native controller meshes be initialized. (default: true)
  24107. */
  24108. controllerMeshes?: boolean;
  24109. /**
  24110. * Creating a default HemiLight only on controllers. (default: true)
  24111. */
  24112. defaultLightingOnControllers?: boolean;
  24113. /**
  24114. * If you don't want to use the default VR button of the helper. (default: false)
  24115. */
  24116. useCustomVRButton?: boolean;
  24117. /**
  24118. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  24119. */
  24120. customVRButton?: HTMLButtonElement;
  24121. /**
  24122. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  24123. */
  24124. rayLength?: number;
  24125. /**
  24126. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  24127. */
  24128. defaultHeight?: number;
  24129. }
  24130. /**
  24131. * This represents a WebVR camera.
  24132. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  24133. * @example http://doc.babylonjs.com/how_to/webvr_camera
  24134. */
  24135. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  24136. private webVROptions;
  24137. /**
  24138. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  24139. */
  24140. _vrDevice: any;
  24141. /**
  24142. * The rawPose of the vrDevice.
  24143. */
  24144. rawPose: Nullable<DevicePose>;
  24145. private _onVREnabled;
  24146. private _specsVersion;
  24147. private _attached;
  24148. private _frameData;
  24149. protected _descendants: Array<Node>;
  24150. private _deviceRoomPosition;
  24151. private _deviceRoomRotationQuaternion;
  24152. private _standingMatrix;
  24153. /**
  24154. * Represents device position in babylon space.
  24155. */
  24156. devicePosition: Vector3;
  24157. /**
  24158. * Represents device rotation in babylon space.
  24159. */
  24160. deviceRotationQuaternion: Quaternion;
  24161. /**
  24162. * The scale of the device to be used when translating from device space to babylon space.
  24163. */
  24164. deviceScaleFactor: number;
  24165. private _deviceToWorld;
  24166. private _worldToDevice;
  24167. /**
  24168. * References to the webVR controllers for the vrDevice.
  24169. */
  24170. controllers: Array<WebVRController>;
  24171. /**
  24172. * Emits an event when a controller is attached.
  24173. */
  24174. onControllersAttachedObservable: Observable<WebVRController[]>;
  24175. /**
  24176. * Emits an event when a controller's mesh has been loaded;
  24177. */
  24178. onControllerMeshLoadedObservable: Observable<WebVRController>;
  24179. /**
  24180. * If the rig cameras be used as parent instead of this camera.
  24181. */
  24182. rigParenting: boolean;
  24183. private _lightOnControllers;
  24184. private _defaultHeight?;
  24185. /**
  24186. * Instantiates a WebVRFreeCamera.
  24187. * @param name The name of the WebVRFreeCamera
  24188. * @param position The starting anchor position for the camera
  24189. * @param scene The scene the camera belongs to
  24190. * @param webVROptions a set of customizable options for the webVRCamera
  24191. */
  24192. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  24193. /**
  24194. * Gets the device distance from the ground in meters.
  24195. * @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.
  24196. */
  24197. deviceDistanceToRoomGround(): number;
  24198. /**
  24199. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  24200. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  24201. */
  24202. useStandingMatrix(callback?: (bool: boolean) => void): void;
  24203. /**
  24204. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  24205. * @returns A promise with a boolean set to if the standing matrix is supported.
  24206. */
  24207. useStandingMatrixAsync(): Promise<boolean>;
  24208. /**
  24209. * Disposes the camera
  24210. */
  24211. dispose(): void;
  24212. /**
  24213. * Gets a vrController by name.
  24214. * @param name The name of the controller to retreive
  24215. * @returns the controller matching the name specified or null if not found
  24216. */
  24217. getControllerByName(name: string): Nullable<WebVRController>;
  24218. private _leftController;
  24219. /**
  24220. * The controller corrisponding to the users left hand.
  24221. */
  24222. readonly leftController: Nullable<WebVRController>;
  24223. private _rightController;
  24224. /**
  24225. * The controller corrisponding to the users right hand.
  24226. */
  24227. readonly rightController: Nullable<WebVRController>;
  24228. /**
  24229. * Casts a ray forward from the vrCamera's gaze.
  24230. * @param length Length of the ray (default: 100)
  24231. * @returns the ray corrisponding to the gaze
  24232. */
  24233. getForwardRay(length?: number): Ray;
  24234. /**
  24235. * Updates the camera based on device's frame data
  24236. */
  24237. _checkInputs(): void;
  24238. /**
  24239. * Updates the poseControlled values based on the input device pose.
  24240. * @param poseData Pose coming from the device
  24241. */
  24242. updateFromDevice(poseData: DevicePose): void;
  24243. /**
  24244. * WebVR's attach control will start broadcasting frames to the device.
  24245. * Note that in certain browsers (chrome for example) this function must be called
  24246. * within a user-interaction callback. Example:
  24247. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  24248. *
  24249. * @param element html element to attach the vrDevice to
  24250. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  24251. */
  24252. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24253. /**
  24254. * Detaches the camera from the html element and disables VR
  24255. *
  24256. * @param element html element to detach from
  24257. */
  24258. detachControl(element: HTMLElement): void;
  24259. /**
  24260. * @returns the name of this class
  24261. */
  24262. getClassName(): string;
  24263. /**
  24264. * Calls resetPose on the vrDisplay
  24265. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  24266. */
  24267. resetToCurrentRotation(): void;
  24268. /**
  24269. * Updates the rig cameras (left and right eye)
  24270. */
  24271. _updateRigCameras(): void;
  24272. private _workingVector;
  24273. private _oneVector;
  24274. private _workingMatrix;
  24275. private updateCacheCalled;
  24276. /**
  24277. * Updates the cached values of the camera
  24278. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  24279. */
  24280. _updateCache(ignoreParentClass?: boolean): void;
  24281. /**
  24282. * Updates the current device position and rotation in the babylon world
  24283. */
  24284. update(): void;
  24285. /**
  24286. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  24287. * @returns an identity matrix
  24288. */
  24289. _getViewMatrix(): Matrix;
  24290. /**
  24291. * This function is called by the two RIG cameras.
  24292. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  24293. */
  24294. protected _getWebVRViewMatrix(): Matrix;
  24295. protected _getWebVRProjectionMatrix(): Matrix;
  24296. private _onGamepadConnectedObserver;
  24297. private _onGamepadDisconnectedObserver;
  24298. /**
  24299. * Initializes the controllers and their meshes
  24300. */
  24301. initControllers(): void;
  24302. }
  24303. }
  24304. declare module BABYLON {
  24305. interface IOctreeContainer<T> {
  24306. blocks: Array<OctreeBlock<T>>;
  24307. }
  24308. class Octree<T> {
  24309. maxDepth: number;
  24310. blocks: Array<OctreeBlock<T>>;
  24311. dynamicContent: T[];
  24312. private _maxBlockCapacity;
  24313. private _selectionContent;
  24314. private _creationFunc;
  24315. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  24316. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  24317. addMesh(entry: T): void;
  24318. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  24319. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  24320. intersectsRay(ray: Ray): SmartArray<T>;
  24321. 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;
  24322. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  24323. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  24324. }
  24325. }
  24326. declare module BABYLON {
  24327. class OctreeBlock<T> {
  24328. entries: T[];
  24329. blocks: Array<OctreeBlock<T>>;
  24330. private _depth;
  24331. private _maxDepth;
  24332. private _capacity;
  24333. private _minPoint;
  24334. private _maxPoint;
  24335. private _boundingVectors;
  24336. private _creationFunc;
  24337. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  24338. readonly capacity: number;
  24339. readonly minPoint: Vector3;
  24340. readonly maxPoint: Vector3;
  24341. addEntry(entry: T): void;
  24342. addEntries(entries: T[]): void;
  24343. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  24344. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  24345. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  24346. createInnerBlocks(): void;
  24347. }
  24348. }
  24349. declare module BABYLON {
  24350. /**
  24351. * Google Daydream controller
  24352. */
  24353. class DaydreamController extends WebVRController {
  24354. /**
  24355. * Base Url for the controller model.
  24356. */
  24357. static MODEL_BASE_URL: string;
  24358. /**
  24359. * File name for the controller model.
  24360. */
  24361. static MODEL_FILENAME: string;
  24362. /**
  24363. * Gamepad Id prefix used to identify Daydream Controller.
  24364. */
  24365. static readonly GAMEPAD_ID_PREFIX: string;
  24366. constructor(vrGamepad: any);
  24367. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24368. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24369. }
  24370. }
  24371. declare module BABYLON {
  24372. class GearVRController extends WebVRController {
  24373. static MODEL_BASE_URL: string;
  24374. static MODEL_FILENAME: string;
  24375. static readonly GAMEPAD_ID_PREFIX: string;
  24376. private readonly _buttonIndexToObservableNameMap;
  24377. constructor(vrGamepad: any);
  24378. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24379. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24380. }
  24381. }
  24382. declare module BABYLON {
  24383. class GenericController extends WebVRController {
  24384. static readonly MODEL_BASE_URL: string;
  24385. static readonly MODEL_FILENAME: string;
  24386. constructor(vrGamepad: any);
  24387. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24388. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24389. }
  24390. }
  24391. declare module BABYLON {
  24392. class OculusTouchController extends WebVRController {
  24393. static MODEL_BASE_URL: string;
  24394. static MODEL_LEFT_FILENAME: string;
  24395. static MODEL_RIGHT_FILENAME: string;
  24396. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  24397. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  24398. constructor(vrGamepad: any);
  24399. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24400. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24401. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24402. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24403. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24404. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24405. }
  24406. }
  24407. declare module BABYLON {
  24408. enum PoseEnabledControllerType {
  24409. VIVE = 0,
  24410. OCULUS = 1,
  24411. WINDOWS = 2,
  24412. GEAR_VR = 3,
  24413. /**
  24414. * Google Daydream
  24415. */
  24416. DAYDREAM = 4,
  24417. GENERIC = 5,
  24418. }
  24419. interface MutableGamepadButton {
  24420. value: number;
  24421. touched: boolean;
  24422. pressed: boolean;
  24423. }
  24424. interface ExtendedGamepadButton extends GamepadButton {
  24425. readonly pressed: boolean;
  24426. readonly touched: boolean;
  24427. readonly value: number;
  24428. }
  24429. class PoseEnabledControllerHelper {
  24430. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  24431. }
  24432. class PoseEnabledController extends Gamepad implements PoseControlled {
  24433. private _deviceRoomPosition;
  24434. private _deviceRoomRotationQuaternion;
  24435. devicePosition: Vector3;
  24436. deviceRotationQuaternion: Quaternion;
  24437. deviceScaleFactor: number;
  24438. position: Vector3;
  24439. rotationQuaternion: Quaternion;
  24440. controllerType: PoseEnabledControllerType;
  24441. private _calculatedPosition;
  24442. private _calculatedRotation;
  24443. rawPose: DevicePose;
  24444. _mesh: Nullable<AbstractMesh>;
  24445. private _poseControlledCamera;
  24446. private _leftHandSystemQuaternion;
  24447. _deviceToWorld: Matrix;
  24448. /**
  24449. * Node to be used when casting a ray from the controller
  24450. */
  24451. _pointingPoseNode: Nullable<AbstractMesh>;
  24452. /**
  24453. * Name of the child mesh that can be used to cast a ray from the controller
  24454. */
  24455. static readonly POINTING_POSE: string;
  24456. constructor(browserGamepad: any);
  24457. private _workingMatrix;
  24458. update(): void;
  24459. updateFromDevice(poseData: DevicePose): void;
  24460. attachToMesh(mesh: AbstractMesh): void;
  24461. attachToPoseControlledCamera(camera: TargetCamera): void;
  24462. dispose(): void;
  24463. readonly mesh: Nullable<AbstractMesh>;
  24464. getForwardRay(length?: number): Ray;
  24465. }
  24466. }
  24467. declare module BABYLON {
  24468. class ViveController extends WebVRController {
  24469. static MODEL_BASE_URL: string;
  24470. static MODEL_FILENAME: string;
  24471. constructor(vrGamepad: any);
  24472. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24473. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24474. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24475. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24476. /**
  24477. * Vive mapping:
  24478. * 0: touchpad
  24479. * 1: trigger
  24480. * 2: left AND right buttons
  24481. * 3: menu button
  24482. */
  24483. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24484. }
  24485. }
  24486. declare module BABYLON {
  24487. abstract class WebVRController extends PoseEnabledController {
  24488. protected _defaultModel: AbstractMesh;
  24489. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  24490. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24491. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24492. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  24493. onPadValuesChangedObservable: Observable<StickValues>;
  24494. protected _buttons: Array<MutableGamepadButton>;
  24495. private _onButtonStateChange;
  24496. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  24497. pad: StickValues;
  24498. hand: string;
  24499. readonly defaultModel: AbstractMesh;
  24500. constructor(vrGamepad: any);
  24501. update(): void;
  24502. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24503. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24504. private _setButtonValue(newState, currentState, buttonIndex);
  24505. private _changes;
  24506. private _checkChanges(newState, currentState);
  24507. dispose(): void;
  24508. }
  24509. }
  24510. declare module BABYLON {
  24511. class WindowsMotionController extends WebVRController {
  24512. static MODEL_BASE_URL: string;
  24513. static MODEL_LEFT_FILENAME: string;
  24514. static MODEL_RIGHT_FILENAME: string;
  24515. static readonly GAMEPAD_ID_PREFIX: string;
  24516. private static readonly GAMEPAD_ID_PATTERN;
  24517. private _loadedMeshInfo;
  24518. private readonly _mapping;
  24519. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  24520. onTrackpadValuesChangedObservable: Observable<StickValues>;
  24521. trackpad: StickValues;
  24522. constructor(vrGamepad: any);
  24523. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24524. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24525. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24526. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24527. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24528. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  24529. /**
  24530. * Called once per frame by the engine.
  24531. */
  24532. update(): void;
  24533. /**
  24534. * Called once for each button that changed state since the last frame
  24535. * @param buttonIdx Which button index changed
  24536. * @param state New state of the button
  24537. * @param changes Which properties on the state changed since last frame
  24538. */
  24539. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24540. protected lerpButtonTransform(buttonName: string, buttonValue: number): void;
  24541. protected lerpAxisTransform(axis: number, axisValue: number): void;
  24542. /**
  24543. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  24544. * @param scene scene in which to add meshes
  24545. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  24546. */
  24547. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  24548. /**
  24549. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  24550. * can be transformed by button presses and axes values, based on this._mapping.
  24551. *
  24552. * @param scene scene in which the meshes exist
  24553. * @param meshes list of meshes that make up the controller model to process
  24554. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  24555. */
  24556. private processModel(scene, meshes);
  24557. private createMeshInfo(rootNode);
  24558. getForwardRay(length?: number): Ray;
  24559. dispose(): void;
  24560. }
  24561. }
  24562. declare module BABYLON {
  24563. /**
  24564. * Interface to implement to create a shadow generator compatible with BJS.
  24565. */
  24566. interface IShadowGenerator {
  24567. /**
  24568. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  24569. * @returns The render target texture if present otherwise, null
  24570. */
  24571. getShadowMap(): Nullable<RenderTargetTexture>;
  24572. /**
  24573. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  24574. * @returns The render target texture if the shadow map is present otherwise, null
  24575. */
  24576. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  24577. /**
  24578. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  24579. * @param subMesh The submesh we want to render in the shadow map
  24580. * @param useInstances Defines wether will draw in the map using instances
  24581. * @returns true if ready otherwise, false
  24582. */
  24583. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24584. /**
  24585. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  24586. * @param defines Defines of the material we want to update
  24587. * @param lightIndex Index of the light in the enabled light list of the material
  24588. */
  24589. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  24590. /**
  24591. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  24592. * defined in the generator but impacting the effect).
  24593. * It implies the unifroms available on the materials are the standard BJS ones.
  24594. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  24595. * @param effect The effect we are binfing the information for
  24596. */
  24597. bindShadowLight(lightIndex: string, effect: Effect): void;
  24598. /**
  24599. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  24600. * (eq to shadow prjection matrix * light transform matrix)
  24601. * @returns The transform matrix used to create the shadow map
  24602. */
  24603. getTransformMatrix(): Matrix;
  24604. /**
  24605. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  24606. * Cube and 2D textures for instance.
  24607. */
  24608. recreateShadowMap(): void;
  24609. /**
  24610. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  24611. * @param onCompiled Callback triggered at the and of the effects compilation
  24612. * @param options Sets of optional options forcing the compilation with different modes
  24613. */
  24614. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  24615. useInstances: boolean;
  24616. }>): void;
  24617. /**
  24618. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  24619. * @param options Sets of optional options forcing the compilation with different modes
  24620. * @returns A promise that resolves when the compilation completes
  24621. */
  24622. forceCompilationAsync(options?: Partial<{
  24623. useInstances: boolean;
  24624. }>): Promise<void>;
  24625. /**
  24626. * Serializes the shadow generator setup to a json object.
  24627. * @returns The serialized JSON object
  24628. */
  24629. serialize(): any;
  24630. /**
  24631. * Disposes the Shadow map and related Textures and effects.
  24632. */
  24633. dispose(): void;
  24634. }
  24635. /**
  24636. * Default implementation of @see IShadowGenerator.
  24637. * This is the main object responsible of generating shadows in the framework.
  24638. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  24639. */
  24640. class ShadowGenerator implements IShadowGenerator {
  24641. private static _FILTER_NONE;
  24642. private static _FILTER_EXPONENTIALSHADOWMAP;
  24643. private static _FILTER_POISSONSAMPLING;
  24644. private static _FILTER_BLUREXPONENTIALSHADOWMAP;
  24645. private static _FILTER_CLOSEEXPONENTIALSHADOWMAP;
  24646. private static _FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  24647. /**
  24648. * Shadow generator mode None: no filtering applied.
  24649. */
  24650. static readonly FILTER_NONE: number;
  24651. /**
  24652. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  24653. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  24654. */
  24655. static readonly FILTER_POISSONSAMPLING: number;
  24656. /**
  24657. * Shadow generator mode ESM: Exponential Shadow Mapping.
  24658. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  24659. */
  24660. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  24661. /**
  24662. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  24663. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  24664. */
  24665. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  24666. /**
  24667. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  24668. * edge artifacts on steep falloff.
  24669. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  24670. */
  24671. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  24672. /**
  24673. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  24674. * edge artifacts on steep falloff.
  24675. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  24676. */
  24677. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  24678. private _bias;
  24679. /**
  24680. * Gets the bias: offset applied on the depth preventing acnea.
  24681. */
  24682. /**
  24683. * Sets the bias: offset applied on the depth preventing acnea.
  24684. */
  24685. bias: number;
  24686. private _blurBoxOffset;
  24687. /**
  24688. * Gets the blur box offset: offset applied during the blur pass.
  24689. * Only usefull if useKernelBlur = false
  24690. */
  24691. /**
  24692. * Sets the blur box offset: offset applied during the blur pass.
  24693. * Only usefull if useKernelBlur = false
  24694. */
  24695. blurBoxOffset: number;
  24696. private _blurScale;
  24697. /**
  24698. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  24699. * 2 means half of the size.
  24700. */
  24701. /**
  24702. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  24703. * 2 means half of the size.
  24704. */
  24705. blurScale: number;
  24706. private _blurKernel;
  24707. /**
  24708. * Gets the blur kernel: kernel size of the blur pass.
  24709. * Only usefull if useKernelBlur = true
  24710. */
  24711. /**
  24712. * Sets the blur kernel: kernel size of the blur pass.
  24713. * Only usefull if useKernelBlur = true
  24714. */
  24715. blurKernel: number;
  24716. private _useKernelBlur;
  24717. /**
  24718. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  24719. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  24720. */
  24721. /**
  24722. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  24723. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  24724. */
  24725. useKernelBlur: boolean;
  24726. private _depthScale;
  24727. /**
  24728. * Gets the depth scale used in ESM mode.
  24729. */
  24730. /**
  24731. * Sets the depth scale used in ESM mode.
  24732. * This can override the scale stored on the light.
  24733. */
  24734. depthScale: number;
  24735. private _filter;
  24736. /**
  24737. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  24738. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  24739. */
  24740. /**
  24741. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  24742. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  24743. */
  24744. filter: number;
  24745. /**
  24746. * Gets if the current filter is set to Poisson Sampling aka PCF.
  24747. */
  24748. /**
  24749. * Sets the current filter to Poisson Sampling aka PCF.
  24750. */
  24751. usePoissonSampling: boolean;
  24752. /**
  24753. * Gets if the current filter is set to VSM.
  24754. * DEPRECATED. Should use useExponentialShadowMap instead.
  24755. */
  24756. /**
  24757. * Sets the current filter is to VSM.
  24758. * DEPRECATED. Should use useExponentialShadowMap instead.
  24759. */
  24760. useVarianceShadowMap: boolean;
  24761. /**
  24762. * Gets if the current filter is set to blurred VSM.
  24763. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  24764. */
  24765. /**
  24766. * Sets the current filter is to blurred VSM.
  24767. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  24768. */
  24769. useBlurVarianceShadowMap: boolean;
  24770. /**
  24771. * Gets if the current filter is set to ESM.
  24772. */
  24773. /**
  24774. * Sets the current filter is to ESM.
  24775. */
  24776. useExponentialShadowMap: boolean;
  24777. /**
  24778. * Gets if the current filter is set to filtered ESM.
  24779. */
  24780. /**
  24781. * Gets if the current filter is set to filtered ESM.
  24782. */
  24783. useBlurExponentialShadowMap: boolean;
  24784. /**
  24785. * Gets if the current filter is set to "close ESM" (using the inverse of the
  24786. * exponential to prevent steep falloff artifacts).
  24787. */
  24788. /**
  24789. * Sets the current filter to "close ESM" (using the inverse of the
  24790. * exponential to prevent steep falloff artifacts).
  24791. */
  24792. useCloseExponentialShadowMap: boolean;
  24793. /**
  24794. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  24795. * exponential to prevent steep falloff artifacts).
  24796. */
  24797. /**
  24798. * Sets the current filter to fileterd "close ESM" (using the inverse of the
  24799. * exponential to prevent steep falloff artifacts).
  24800. */
  24801. useBlurCloseExponentialShadowMap: boolean;
  24802. private _darkness;
  24803. /**
  24804. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  24805. * 0 means strongest and 1 would means no shadow.
  24806. * @returns the darkness.
  24807. */
  24808. getDarkness(): number;
  24809. /**
  24810. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  24811. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  24812. * @returns the shadow generator allowing fluent coding.
  24813. */
  24814. setDarkness(darkness: number): ShadowGenerator;
  24815. private _transparencyShadow;
  24816. /**
  24817. * Sets the ability to have transparent shadow (boolean).
  24818. * @param transparent True if transparent else False
  24819. * @returns the shadow generator allowing fluent coding
  24820. */
  24821. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  24822. private _shadowMap;
  24823. private _shadowMap2;
  24824. /**
  24825. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  24826. * @returns The render target texture if present otherwise, null
  24827. */
  24828. getShadowMap(): Nullable<RenderTargetTexture>;
  24829. /**
  24830. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  24831. * @returns The render target texture if the shadow map is present otherwise, null
  24832. */
  24833. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  24834. /**
  24835. * Helper function to add a mesh and its descendants to the list of shadow casters.
  24836. * @param mesh Mesh to add
  24837. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  24838. * @returns the Shadow Generator itself
  24839. */
  24840. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  24841. /**
  24842. * Helper function to remove a mesh and its descendants from the list of shadow casters
  24843. * @param mesh Mesh to remove
  24844. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  24845. * @returns the Shadow Generator itself
  24846. */
  24847. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  24848. /**
  24849. * Controls the extent to which the shadows fade out at the edge of the frustum
  24850. * Used only by directionals and spots
  24851. */
  24852. frustumEdgeFalloff: number;
  24853. private _light;
  24854. /**
  24855. * Returns the associated light object.
  24856. * @returns the light generating the shadow
  24857. */
  24858. getLight(): IShadowLight;
  24859. /**
  24860. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  24861. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  24862. * It might on the other hand introduce peter panning.
  24863. */
  24864. forceBackFacesOnly: boolean;
  24865. private _scene;
  24866. private _lightDirection;
  24867. private _effect;
  24868. private _viewMatrix;
  24869. private _projectionMatrix;
  24870. private _transformMatrix;
  24871. private _cachedPosition;
  24872. private _cachedDirection;
  24873. private _cachedDefines;
  24874. private _currentRenderID;
  24875. private _boxBlurPostprocess;
  24876. private _kernelBlurXPostprocess;
  24877. private _kernelBlurYPostprocess;
  24878. private _blurPostProcesses;
  24879. private _mapSize;
  24880. private _currentFaceIndex;
  24881. private _currentFaceIndexCache;
  24882. private _textureType;
  24883. private _defaultTextureMatrix;
  24884. /**
  24885. * Creates a ShadowGenerator object.
  24886. * A ShadowGenerator is the required tool to use the shadows.
  24887. * Each light casting shadows needs to use its own ShadowGenerator.
  24888. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  24889. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  24890. * @param light The light object generating the shadows.
  24891. * @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.
  24892. */
  24893. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  24894. private _initializeGenerator();
  24895. private _initializeShadowMap();
  24896. private _initializeBlurRTTAndPostProcesses();
  24897. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  24898. private _renderSubMeshForShadowMap(subMesh);
  24899. private _applyFilterValues();
  24900. /**
  24901. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  24902. * @param onCompiled Callback triggered at the and of the effects compilation
  24903. * @param options Sets of optional options forcing the compilation with different modes
  24904. */
  24905. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  24906. useInstances: boolean;
  24907. }>): void;
  24908. /**
  24909. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  24910. * @param options Sets of optional options forcing the compilation with different modes
  24911. * @returns A promise that resolves when the compilation completes
  24912. */
  24913. forceCompilationAsync(options?: Partial<{
  24914. useInstances: boolean;
  24915. }>): Promise<void>;
  24916. /**
  24917. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  24918. * @param subMesh The submesh we want to render in the shadow map
  24919. * @param useInstances Defines wether will draw in the map using instances
  24920. * @returns true if ready otherwise, false
  24921. */
  24922. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24923. /**
  24924. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  24925. * @param defines Defines of the material we want to update
  24926. * @param lightIndex Index of the light in the enabled light list of the material
  24927. */
  24928. prepareDefines(defines: any, lightIndex: number): void;
  24929. /**
  24930. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  24931. * defined in the generator but impacting the effect).
  24932. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  24933. * @param effect The effect we are binfing the information for
  24934. */
  24935. bindShadowLight(lightIndex: string, effect: Effect): void;
  24936. /**
  24937. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  24938. * (eq to shadow prjection matrix * light transform matrix)
  24939. * @returns The transform matrix used to create the shadow map
  24940. */
  24941. getTransformMatrix(): Matrix;
  24942. /**
  24943. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  24944. * Cube and 2D textures for instance.
  24945. */
  24946. recreateShadowMap(): void;
  24947. private _disposeBlurPostProcesses();
  24948. private _disposeRTTandPostProcesses();
  24949. /**
  24950. * Disposes the ShadowGenerator.
  24951. * Returns nothing.
  24952. */
  24953. dispose(): void;
  24954. /**
  24955. * Serializes the shadow generator setup to a json object.
  24956. * @returns The serialized JSON object
  24957. */
  24958. serialize(): any;
  24959. /**
  24960. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  24961. * @param parsedShadowGenerator The JSON object to parse
  24962. * @param scene The scene to create the shadow map for
  24963. * @returns The parsed shadow generator
  24964. */
  24965. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  24966. }
  24967. }
  24968. declare module BABYLON {
  24969. }
  24970. declare module BABYLON {
  24971. /**
  24972. * Background material used to create an efficient environement around your scene.
  24973. */
  24974. class BackgroundMaterial extends PushMaterial {
  24975. /**
  24976. * Standard reflectance value at parallel view angle.
  24977. */
  24978. static StandardReflectance0: number;
  24979. /**
  24980. * Standard reflectance value at grazing angle.
  24981. */
  24982. static StandardReflectance90: number;
  24983. protected _primaryColor: Color3;
  24984. /**
  24985. * Key light Color (multiply against the R channel of the environement texture)
  24986. */
  24987. primaryColor: Color3;
  24988. protected _primaryLevel: float;
  24989. /**
  24990. * Key light Level (allowing HDR output of the background)
  24991. */
  24992. primaryLevel: float;
  24993. protected _secondaryColor: Color3;
  24994. /**
  24995. * Secondary light Color (multiply against the G channel of the environement texture)
  24996. */
  24997. secondaryColor: Color3;
  24998. protected _secondaryLevel: float;
  24999. /**
  25000. * Secondary light Level (allowing HDR output of the background)
  25001. */
  25002. secondaryLevel: float;
  25003. protected _tertiaryColor: Color3;
  25004. /**
  25005. * Tertiary light Color (multiply against the B channel of the environement texture)
  25006. */
  25007. tertiaryColor: Color3;
  25008. protected _tertiaryLevel: float;
  25009. /**
  25010. * Tertiary light Level (allowing HDR output of the background)
  25011. */
  25012. tertiaryLevel: float;
  25013. protected _reflectionTexture: Nullable<BaseTexture>;
  25014. /**
  25015. * Reflection Texture used in the material.
  25016. * Should be author in a specific way for the best result (refer to the documentation).
  25017. */
  25018. reflectionTexture: Nullable<BaseTexture>;
  25019. protected _reflectionBlur: float;
  25020. /**
  25021. * Reflection Texture level of blur.
  25022. *
  25023. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  25024. * texture twice.
  25025. */
  25026. reflectionBlur: float;
  25027. protected _diffuseTexture: Nullable<BaseTexture>;
  25028. /**
  25029. * Diffuse Texture used in the material.
  25030. * Should be author in a specific way for the best result (refer to the documentation).
  25031. */
  25032. diffuseTexture: Nullable<BaseTexture>;
  25033. protected _shadowLights: Nullable<IShadowLight[]>;
  25034. /**
  25035. * Specify the list of lights casting shadow on the material.
  25036. * All scene shadow lights will be included if null.
  25037. */
  25038. shadowLights: Nullable<IShadowLight[]>;
  25039. protected _shadowBlurScale: int;
  25040. /**
  25041. * For the lights having a blurred shadow generator, this can add a second blur pass in order to reach
  25042. * soft lighting on the background.
  25043. */
  25044. shadowBlurScale: int;
  25045. protected _shadowLevel: float;
  25046. /**
  25047. * Helps adjusting the shadow to a softer level if required.
  25048. * 0 means black shadows and 1 means no shadows.
  25049. */
  25050. shadowLevel: float;
  25051. protected _sceneCenter: Vector3;
  25052. /**
  25053. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  25054. * It is usually zero but might be interesting to modify according to your setup.
  25055. */
  25056. sceneCenter: Vector3;
  25057. protected _opacityFresnel: boolean;
  25058. /**
  25059. * This helps specifying that the material is falling off to the sky box at grazing angle.
  25060. * This helps ensuring a nice transition when the camera goes under the ground.
  25061. */
  25062. opacityFresnel: boolean;
  25063. protected _reflectionFresnel: boolean;
  25064. /**
  25065. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  25066. * This helps adding a mirror texture on the ground.
  25067. */
  25068. reflectionFresnel: boolean;
  25069. protected _reflectionFalloffDistance: number;
  25070. /**
  25071. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  25072. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  25073. */
  25074. reflectionFalloffDistance: number;
  25075. protected _reflectionAmount: number;
  25076. /**
  25077. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  25078. */
  25079. reflectionAmount: number;
  25080. protected _reflectionReflectance0: number;
  25081. /**
  25082. * This specifies the weight of the reflection at grazing angle.
  25083. */
  25084. reflectionReflectance0: number;
  25085. protected _reflectionReflectance90: number;
  25086. /**
  25087. * This specifies the weight of the reflection at a perpendicular point of view.
  25088. */
  25089. reflectionReflectance90: number;
  25090. /**
  25091. * Sets the reflection reflectance fresnel values according to the default standard
  25092. * empirically know to work well :-)
  25093. */
  25094. reflectionStandardFresnelWeight: number;
  25095. protected _useRGBColor: boolean;
  25096. /**
  25097. * Helps to directly use the maps channels instead of their level.
  25098. */
  25099. useRGBColor: boolean;
  25100. protected _enableNoise: boolean;
  25101. /**
  25102. * This helps reducing the banding effect that could occur on the background.
  25103. */
  25104. enableNoise: boolean;
  25105. /**
  25106. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  25107. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  25108. * Recommended to be keep at 1.0 except for special cases.
  25109. */
  25110. fovMultiplier: number;
  25111. private _fovMultiplier;
  25112. /**
  25113. * Enable the FOV adjustment feature controlled by fovMultiplier.
  25114. * @type {boolean}
  25115. */
  25116. useEquirectangularFOV: boolean;
  25117. private _maxSimultaneousLights;
  25118. /**
  25119. * Number of Simultaneous lights allowed on the material.
  25120. */
  25121. maxSimultaneousLights: int;
  25122. /**
  25123. * Default configuration related to image processing available in the Background Material.
  25124. */
  25125. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25126. /**
  25127. * Keep track of the image processing observer to allow dispose and replace.
  25128. */
  25129. private _imageProcessingObserver;
  25130. /**
  25131. * Attaches a new image processing configuration to the PBR Material.
  25132. * @param configuration (if null the scene configuration will be use)
  25133. */
  25134. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25135. /**
  25136. * Gets the image processing configuration used either in this material.
  25137. */
  25138. /**
  25139. * Sets the Default image processing configuration used either in the this material.
  25140. *
  25141. * If sets to null, the scene one is in use.
  25142. */
  25143. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  25144. /**
  25145. * Gets wether the color curves effect is enabled.
  25146. */
  25147. /**
  25148. * Sets wether the color curves effect is enabled.
  25149. */
  25150. cameraColorCurvesEnabled: boolean;
  25151. /**
  25152. * Gets wether the color grading effect is enabled.
  25153. */
  25154. /**
  25155. * Gets wether the color grading effect is enabled.
  25156. */
  25157. cameraColorGradingEnabled: boolean;
  25158. /**
  25159. * Gets wether tonemapping is enabled or not.
  25160. */
  25161. /**
  25162. * Sets wether tonemapping is enabled or not
  25163. */
  25164. cameraToneMappingEnabled: boolean;
  25165. /**
  25166. * The camera exposure used on this material.
  25167. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25168. * This corresponds to a photographic exposure.
  25169. */
  25170. /**
  25171. * The camera exposure used on this material.
  25172. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25173. * This corresponds to a photographic exposure.
  25174. */
  25175. cameraExposure: float;
  25176. /**
  25177. * Gets The camera contrast used on this material.
  25178. */
  25179. /**
  25180. * Sets The camera contrast used on this material.
  25181. */
  25182. cameraContrast: float;
  25183. /**
  25184. * Gets the Color Grading 2D Lookup Texture.
  25185. */
  25186. /**
  25187. * Sets the Color Grading 2D Lookup Texture.
  25188. */
  25189. cameraColorGradingTexture: Nullable<BaseTexture>;
  25190. /**
  25191. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25192. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25193. * 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;
  25194. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25195. */
  25196. /**
  25197. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25198. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25199. * 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;
  25200. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25201. */
  25202. cameraColorCurves: Nullable<ColorCurves>;
  25203. /**
  25204. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  25205. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  25206. */
  25207. switchToBGR: boolean;
  25208. private _renderTargets;
  25209. private _reflectionControls;
  25210. /**
  25211. * Instantiates a Background Material in the given scene
  25212. * @param name The friendly name of the material
  25213. * @param scene The scene to add the material to
  25214. */
  25215. constructor(name: string, scene: Scene);
  25216. /**
  25217. * The entire material has been created in order to prevent overdraw.
  25218. * @returns false
  25219. */
  25220. needAlphaTesting(): boolean;
  25221. /**
  25222. * The entire material has been created in order to prevent overdraw.
  25223. * @returns true if blending is enable
  25224. */
  25225. needAlphaBlending(): boolean;
  25226. /**
  25227. * Checks wether the material is ready to be rendered for a given mesh.
  25228. * @param mesh The mesh to render
  25229. * @param subMesh The submesh to check against
  25230. * @param useInstances Specify wether or not the material is used with instances
  25231. * @returns true if all the dependencies are ready (Textures, Effects...)
  25232. */
  25233. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25234. /**
  25235. * Build the uniform buffer used in the material.
  25236. */
  25237. buildUniformLayout(): void;
  25238. /**
  25239. * Unbind the material.
  25240. */
  25241. unbind(): void;
  25242. /**
  25243. * Bind only the world matrix to the material.
  25244. * @param world The world matrix to bind.
  25245. */
  25246. bindOnlyWorldMatrix(world: Matrix): void;
  25247. /**
  25248. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  25249. * @param world The world matrix to bind.
  25250. * @param subMesh The submesh to bind for.
  25251. */
  25252. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25253. /**
  25254. * Dispose the material.
  25255. * @param forceDisposeEffect Force disposal of the associated effect.
  25256. * @param forceDisposeTextures Force disposal of the associated textures.
  25257. */
  25258. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25259. /**
  25260. * Clones the material.
  25261. * @param name The cloned name.
  25262. * @returns The cloned material.
  25263. */
  25264. clone(name: string): BackgroundMaterial;
  25265. /**
  25266. * Serializes the current material to its JSON representation.
  25267. * @returns The JSON representation.
  25268. */
  25269. serialize(): any;
  25270. /**
  25271. * Gets the class name of the material
  25272. * @returns "BackgroundMaterial"
  25273. */
  25274. getClassName(): string;
  25275. /**
  25276. * Parse a JSON input to create back a background material.
  25277. * @param source The JSON data to parse
  25278. * @param scene The scene to create the parsed material in
  25279. * @param rootUrl The root url of the assets the material depends upon
  25280. * @returns the instantiated BackgroundMaterial.
  25281. */
  25282. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  25283. }
  25284. }
  25285. declare module BABYLON {
  25286. /**
  25287. * The Physically based material base class of BJS.
  25288. *
  25289. * This offers the main features of a standard PBR material.
  25290. * For more information, please refer to the documentation :
  25291. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  25292. */
  25293. abstract class PBRBaseMaterial extends PushMaterial {
  25294. /**
  25295. * Intensity of the direct lights e.g. the four lights available in your scene.
  25296. * This impacts both the direct diffuse and specular highlights.
  25297. */
  25298. protected _directIntensity: number;
  25299. /**
  25300. * Intensity of the emissive part of the material.
  25301. * This helps controlling the emissive effect without modifying the emissive color.
  25302. */
  25303. protected _emissiveIntensity: number;
  25304. /**
  25305. * Intensity of the environment e.g. how much the environment will light the object
  25306. * either through harmonics for rough material or through the refelction for shiny ones.
  25307. */
  25308. protected _environmentIntensity: number;
  25309. /**
  25310. * This is a special control allowing the reduction of the specular highlights coming from the
  25311. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  25312. */
  25313. protected _specularIntensity: number;
  25314. /**
  25315. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  25316. */
  25317. private _lightingInfos;
  25318. /**
  25319. * Debug Control allowing disabling the bump map on this material.
  25320. */
  25321. protected _disableBumpMap: boolean;
  25322. /**
  25323. * AKA Diffuse Texture in standard nomenclature.
  25324. */
  25325. protected _albedoTexture: BaseTexture;
  25326. /**
  25327. * AKA Occlusion Texture in other nomenclature.
  25328. */
  25329. protected _ambientTexture: BaseTexture;
  25330. /**
  25331. * AKA Occlusion Texture Intensity in other nomenclature.
  25332. */
  25333. protected _ambientTextureStrength: number;
  25334. /**
  25335. * Stores the alpha values in a texture.
  25336. */
  25337. protected _opacityTexture: BaseTexture;
  25338. /**
  25339. * Stores the reflection values in a texture.
  25340. */
  25341. protected _reflectionTexture: BaseTexture;
  25342. /**
  25343. * Stores the refraction values in a texture.
  25344. */
  25345. protected _refractionTexture: BaseTexture;
  25346. /**
  25347. * Stores the emissive values in a texture.
  25348. */
  25349. protected _emissiveTexture: BaseTexture;
  25350. /**
  25351. * AKA Specular texture in other nomenclature.
  25352. */
  25353. protected _reflectivityTexture: BaseTexture;
  25354. /**
  25355. * Used to switch from specular/glossiness to metallic/roughness workflow.
  25356. */
  25357. protected _metallicTexture: BaseTexture;
  25358. /**
  25359. * Specifies the metallic scalar of the metallic/roughness workflow.
  25360. * Can also be used to scale the metalness values of the metallic texture.
  25361. */
  25362. protected _metallic: number;
  25363. /**
  25364. * Specifies the roughness scalar of the metallic/roughness workflow.
  25365. * Can also be used to scale the roughness values of the metallic texture.
  25366. */
  25367. protected _roughness: number;
  25368. /**
  25369. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  25370. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  25371. */
  25372. protected _microSurfaceTexture: BaseTexture;
  25373. /**
  25374. * Stores surface normal data used to displace a mesh in a texture.
  25375. */
  25376. protected _bumpTexture: BaseTexture;
  25377. /**
  25378. * Stores the pre-calculated light information of a mesh in a texture.
  25379. */
  25380. protected _lightmapTexture: BaseTexture;
  25381. /**
  25382. * The color of a material in ambient lighting.
  25383. */
  25384. protected _ambientColor: Color3;
  25385. /**
  25386. * AKA Diffuse Color in other nomenclature.
  25387. */
  25388. protected _albedoColor: Color3;
  25389. /**
  25390. * AKA Specular Color in other nomenclature.
  25391. */
  25392. protected _reflectivityColor: Color3;
  25393. /**
  25394. * The color applied when light is reflected from a material.
  25395. */
  25396. protected _reflectionColor: Color3;
  25397. /**
  25398. * The color applied when light is emitted from a material.
  25399. */
  25400. protected _emissiveColor: Color3;
  25401. /**
  25402. * AKA Glossiness in other nomenclature.
  25403. */
  25404. protected _microSurface: number;
  25405. /**
  25406. * source material index of refraction (IOR)' / 'destination material IOR.
  25407. */
  25408. protected _indexOfRefraction: number;
  25409. /**
  25410. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  25411. */
  25412. protected _invertRefractionY: boolean;
  25413. /**
  25414. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25415. * Materials half opaque for instance using refraction could benefit from this control.
  25416. */
  25417. protected _linkRefractionWithTransparency: boolean;
  25418. /**
  25419. * Specifies that the material will use the light map as a show map.
  25420. */
  25421. protected _useLightmapAsShadowmap: boolean;
  25422. /**
  25423. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  25424. * makes the reflect vector face the model (under horizon).
  25425. */
  25426. protected _useHorizonOcclusion: boolean;
  25427. /**
  25428. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  25429. * too much the area relying on ambient texture to define their ambient occlusion.
  25430. */
  25431. protected _useRadianceOcclusion: boolean;
  25432. /**
  25433. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  25434. */
  25435. protected _useAlphaFromAlbedoTexture: boolean;
  25436. /**
  25437. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  25438. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  25439. */
  25440. protected _useSpecularOverAlpha: boolean;
  25441. /**
  25442. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  25443. */
  25444. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  25445. /**
  25446. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  25447. */
  25448. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  25449. /**
  25450. * Specifies if the metallic texture contains the roughness information in its green channel.
  25451. */
  25452. protected _useRoughnessFromMetallicTextureGreen: boolean;
  25453. /**
  25454. * Specifies if the metallic texture contains the metallness information in its blue channel.
  25455. */
  25456. protected _useMetallnessFromMetallicTextureBlue: boolean;
  25457. /**
  25458. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  25459. */
  25460. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  25461. /**
  25462. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  25463. */
  25464. protected _useAmbientInGrayScale: boolean;
  25465. /**
  25466. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  25467. * The material will try to infer what glossiness each pixel should be.
  25468. */
  25469. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  25470. /**
  25471. * BJS is using an harcoded light falloff based on a manually sets up range.
  25472. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  25473. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  25474. */
  25475. protected _usePhysicalLightFalloff: boolean;
  25476. /**
  25477. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  25478. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  25479. */
  25480. protected _useRadianceOverAlpha: boolean;
  25481. /**
  25482. * Allows using an object space normal map (instead of tangent space).
  25483. */
  25484. protected _useObjectSpaceNormalMap: boolean;
  25485. /**
  25486. * Allows using the bump map in parallax mode.
  25487. */
  25488. protected _useParallax: boolean;
  25489. /**
  25490. * Allows using the bump map in parallax occlusion mode.
  25491. */
  25492. protected _useParallaxOcclusion: boolean;
  25493. /**
  25494. * Controls the scale bias of the parallax mode.
  25495. */
  25496. protected _parallaxScaleBias: number;
  25497. /**
  25498. * If sets to true, disables all the lights affecting the material.
  25499. */
  25500. protected _disableLighting: boolean;
  25501. /**
  25502. * Number of Simultaneous lights allowed on the material.
  25503. */
  25504. protected _maxSimultaneousLights: number;
  25505. /**
  25506. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  25507. */
  25508. protected _invertNormalMapX: boolean;
  25509. /**
  25510. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  25511. */
  25512. protected _invertNormalMapY: boolean;
  25513. /**
  25514. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25515. */
  25516. protected _twoSidedLighting: boolean;
  25517. /**
  25518. * Defines the alpha limits in alpha test mode.
  25519. */
  25520. protected _alphaCutOff: number;
  25521. /**
  25522. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25523. */
  25524. protected _forceAlphaTest: boolean;
  25525. /**
  25526. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  25527. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  25528. */
  25529. protected _useAlphaFresnel: boolean;
  25530. /**
  25531. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  25532. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  25533. */
  25534. protected _useLinearAlphaFresnel: boolean;
  25535. /**
  25536. * The transparency mode of the material.
  25537. */
  25538. protected _transparencyMode: Nullable<number>;
  25539. /**
  25540. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  25541. * from cos thetav and roughness:
  25542. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  25543. */
  25544. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  25545. /**
  25546. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  25547. */
  25548. protected _forceIrradianceInFragment: boolean;
  25549. /**
  25550. * Force normal to face away from face.
  25551. */
  25552. protected _forceNormalForward: boolean;
  25553. /**
  25554. * Default configuration related to image processing available in the PBR Material.
  25555. */
  25556. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25557. /**
  25558. * Keep track of the image processing observer to allow dispose and replace.
  25559. */
  25560. private _imageProcessingObserver;
  25561. /**
  25562. * Attaches a new image processing configuration to the PBR Material.
  25563. * @param configuration
  25564. */
  25565. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25566. /**
  25567. * Stores the available render targets.
  25568. */
  25569. private _renderTargets;
  25570. /**
  25571. * Sets the global ambient color for the material used in lighting calculations.
  25572. */
  25573. private _globalAmbientColor;
  25574. /**
  25575. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  25576. */
  25577. private _useLogarithmicDepth;
  25578. /**
  25579. * Instantiates a new PBRMaterial instance.
  25580. *
  25581. * @param name The material name
  25582. * @param scene The scene the material will be use in.
  25583. */
  25584. constructor(name: string, scene: Scene);
  25585. /**
  25586. * Gets the name of the material class.
  25587. */
  25588. getClassName(): string;
  25589. /**
  25590. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  25591. */
  25592. /**
  25593. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  25594. */
  25595. useLogarithmicDepth: boolean;
  25596. /**
  25597. * Gets the current transparency mode.
  25598. */
  25599. /**
  25600. * Sets the transparency mode of the material.
  25601. */
  25602. transparencyMode: Nullable<number>;
  25603. /**
  25604. * Returns true if alpha blending should be disabled.
  25605. */
  25606. private readonly _disableAlphaBlending;
  25607. /**
  25608. * Specifies whether or not this material should be rendered in alpha blend mode.
  25609. */
  25610. needAlphaBlending(): boolean;
  25611. /**
  25612. * Specifies if the mesh will require alpha blending.
  25613. * @param mesh - BJS mesh.
  25614. */
  25615. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25616. /**
  25617. * Specifies whether or not this material should be rendered in alpha test mode.
  25618. */
  25619. needAlphaTesting(): boolean;
  25620. /**
  25621. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  25622. */
  25623. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  25624. /**
  25625. * Gets the texture used for the alpha test.
  25626. */
  25627. getAlphaTestTexture(): BaseTexture;
  25628. /**
  25629. * Stores the reflectivity values based on metallic roughness workflow.
  25630. */
  25631. private static _scaledReflectivity;
  25632. /**
  25633. * Specifies that the submesh is ready to be used.
  25634. * @param mesh - BJS mesh.
  25635. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  25636. * @param useInstances - Specifies that instances should be used.
  25637. * @returns - boolean indicating that the submesh is ready or not.
  25638. */
  25639. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25640. /**
  25641. * Specifies if the material uses metallic roughness workflow.
  25642. * @returns boolean specifiying if the material uses metallic roughness workflow.
  25643. */
  25644. isMetallicWorkflow(): boolean;
  25645. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  25646. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  25647. /**
  25648. * Force shader compilation
  25649. */
  25650. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  25651. clipPlane: boolean;
  25652. }>): void;
  25653. /**
  25654. * Initializes the uniform buffer layout for the shader.
  25655. */
  25656. buildUniformLayout(): void;
  25657. /**
  25658. * Unbinds the textures.
  25659. */
  25660. unbind(): void;
  25661. /**
  25662. * Binds the submesh data.
  25663. * @param world - The world matrix.
  25664. * @param mesh - The BJS mesh.
  25665. * @param subMesh - A submesh of the BJS mesh.
  25666. */
  25667. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25668. /**
  25669. * Returns the animatable textures.
  25670. * @returns - Array of animatable textures.
  25671. */
  25672. getAnimatables(): IAnimatable[];
  25673. /**
  25674. * Returns the texture used for reflections.
  25675. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  25676. */
  25677. private _getReflectionTexture();
  25678. /**
  25679. * Returns the texture used for refraction or null if none is used.
  25680. * @returns - Refection texture if present. If no refraction texture and refraction
  25681. * is linked with transparency, returns environment texture. Otherwise, returns null.
  25682. */
  25683. private _getRefractionTexture();
  25684. /**
  25685. * Disposes the resources of the material.
  25686. * @param forceDisposeEffect - Forces the disposal of effects.
  25687. * @param forceDisposeTextures - Forces the disposal of all textures.
  25688. */
  25689. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25690. }
  25691. }
  25692. declare module BABYLON {
  25693. /**
  25694. * The Physically based simple base material of BJS.
  25695. *
  25696. * This enables better naming and convention enforcements on top of the pbrMaterial.
  25697. * It is used as the base class for both the specGloss and metalRough conventions.
  25698. */
  25699. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  25700. /**
  25701. * Number of Simultaneous lights allowed on the material.
  25702. */
  25703. maxSimultaneousLights: number;
  25704. /**
  25705. * If sets to true, disables all the lights affecting the material.
  25706. */
  25707. disableLighting: boolean;
  25708. /**
  25709. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  25710. */
  25711. environmentTexture: BaseTexture;
  25712. /**
  25713. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25714. */
  25715. invertNormalMapX: boolean;
  25716. /**
  25717. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25718. */
  25719. invertNormalMapY: boolean;
  25720. /**
  25721. * Normal map used in the model.
  25722. */
  25723. normalTexture: BaseTexture;
  25724. /**
  25725. * Emissivie color used to self-illuminate the model.
  25726. */
  25727. emissiveColor: Color3;
  25728. /**
  25729. * Emissivie texture used to self-illuminate the model.
  25730. */
  25731. emissiveTexture: BaseTexture;
  25732. /**
  25733. * Occlusion Channel Strenght.
  25734. */
  25735. occlusionStrength: number;
  25736. /**
  25737. * Occlusion Texture of the material (adding extra occlusion effects).
  25738. */
  25739. occlusionTexture: BaseTexture;
  25740. /**
  25741. * Defines the alpha limits in alpha test mode.
  25742. */
  25743. alphaCutOff: number;
  25744. /**
  25745. * Gets the current double sided mode.
  25746. */
  25747. /**
  25748. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25749. */
  25750. doubleSided: boolean;
  25751. lightmapTexture: BaseTexture;
  25752. useLightmapAsShadowmap: boolean;
  25753. /**
  25754. * Return the active textures of the material.
  25755. */
  25756. getActiveTextures(): BaseTexture[];
  25757. hasTexture(texture: BaseTexture): boolean;
  25758. /**
  25759. * Instantiates a new PBRMaterial instance.
  25760. *
  25761. * @param name The material name
  25762. * @param scene The scene the material will be use in.
  25763. */
  25764. constructor(name: string, scene: Scene);
  25765. getClassName(): string;
  25766. }
  25767. }
  25768. declare module BABYLON {
  25769. /**
  25770. * The Physically based material of BJS.
  25771. *
  25772. * This offers the main features of a standard PBR material.
  25773. * For more information, please refer to the documentation :
  25774. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  25775. */
  25776. class PBRMaterial extends PBRBaseMaterial {
  25777. private static _PBRMATERIAL_OPAQUE;
  25778. /**
  25779. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25780. */
  25781. static readonly PBRMATERIAL_OPAQUE: number;
  25782. /**
  25783. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25784. */
  25785. private static _PBRMATERIAL_ALPHATEST;
  25786. /**
  25787. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25788. */
  25789. static readonly PBRMATERIAL_ALPHATEST: number;
  25790. /**
  25791. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25792. */
  25793. private static _PBRMATERIAL_ALPHABLEND;
  25794. /**
  25795. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25796. */
  25797. static readonly PBRMATERIAL_ALPHABLEND: number;
  25798. /**
  25799. * 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.
  25800. * They are also discarded below the alpha cutoff threshold to improve performances.
  25801. */
  25802. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  25803. /**
  25804. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25805. * They are also discarded below the alpha cutoff threshold to improve performances.
  25806. */
  25807. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  25808. /**
  25809. * Intensity of the direct lights e.g. the four lights available in your scene.
  25810. * This impacts both the direct diffuse and specular highlights.
  25811. */
  25812. directIntensity: number;
  25813. /**
  25814. * Intensity of the emissive part of the material.
  25815. * This helps controlling the emissive effect without modifying the emissive color.
  25816. */
  25817. emissiveIntensity: number;
  25818. /**
  25819. * Intensity of the environment e.g. how much the environment will light the object
  25820. * either through harmonics for rough material or through the refelction for shiny ones.
  25821. */
  25822. environmentIntensity: number;
  25823. /**
  25824. * This is a special control allowing the reduction of the specular highlights coming from the
  25825. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  25826. */
  25827. specularIntensity: number;
  25828. /**
  25829. * Debug Control allowing disabling the bump map on this material.
  25830. */
  25831. disableBumpMap: boolean;
  25832. /**
  25833. * AKA Diffuse Texture in standard nomenclature.
  25834. */
  25835. albedoTexture: BaseTexture;
  25836. /**
  25837. * AKA Occlusion Texture in other nomenclature.
  25838. */
  25839. ambientTexture: BaseTexture;
  25840. /**
  25841. * AKA Occlusion Texture Intensity in other nomenclature.
  25842. */
  25843. ambientTextureStrength: number;
  25844. /**
  25845. * Stores the alpha values in a texture.
  25846. */
  25847. opacityTexture: BaseTexture;
  25848. /**
  25849. * Stores the reflection values in a texture.
  25850. */
  25851. reflectionTexture: Nullable<BaseTexture>;
  25852. /**
  25853. * Stores the emissive values in a texture.
  25854. */
  25855. emissiveTexture: BaseTexture;
  25856. /**
  25857. * AKA Specular texture in other nomenclature.
  25858. */
  25859. reflectivityTexture: BaseTexture;
  25860. /**
  25861. * Used to switch from specular/glossiness to metallic/roughness workflow.
  25862. */
  25863. metallicTexture: BaseTexture;
  25864. /**
  25865. * Specifies the metallic scalar of the metallic/roughness workflow.
  25866. * Can also be used to scale the metalness values of the metallic texture.
  25867. */
  25868. metallic: number;
  25869. /**
  25870. * Specifies the roughness scalar of the metallic/roughness workflow.
  25871. * Can also be used to scale the roughness values of the metallic texture.
  25872. */
  25873. roughness: number;
  25874. /**
  25875. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  25876. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  25877. */
  25878. microSurfaceTexture: BaseTexture;
  25879. /**
  25880. * Stores surface normal data used to displace a mesh in a texture.
  25881. */
  25882. bumpTexture: BaseTexture;
  25883. /**
  25884. * Stores the pre-calculated light information of a mesh in a texture.
  25885. */
  25886. lightmapTexture: BaseTexture;
  25887. /**
  25888. * Stores the refracted light information in a texture.
  25889. */
  25890. refractionTexture: BaseTexture;
  25891. /**
  25892. * The color of a material in ambient lighting.
  25893. */
  25894. ambientColor: Color3;
  25895. /**
  25896. * AKA Diffuse Color in other nomenclature.
  25897. */
  25898. albedoColor: Color3;
  25899. /**
  25900. * AKA Specular Color in other nomenclature.
  25901. */
  25902. reflectivityColor: Color3;
  25903. /**
  25904. * The color reflected from the material.
  25905. */
  25906. reflectionColor: Color3;
  25907. /**
  25908. * The color emitted from the material.
  25909. */
  25910. emissiveColor: Color3;
  25911. /**
  25912. * AKA Glossiness in other nomenclature.
  25913. */
  25914. microSurface: number;
  25915. /**
  25916. * source material index of refraction (IOR)' / 'destination material IOR.
  25917. */
  25918. indexOfRefraction: number;
  25919. /**
  25920. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  25921. */
  25922. invertRefractionY: boolean;
  25923. /**
  25924. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25925. * Materials half opaque for instance using refraction could benefit from this control.
  25926. */
  25927. linkRefractionWithTransparency: boolean;
  25928. useLightmapAsShadowmap: boolean;
  25929. /**
  25930. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  25931. */
  25932. useAlphaFromAlbedoTexture: boolean;
  25933. /**
  25934. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25935. */
  25936. forceAlphaTest: boolean;
  25937. /**
  25938. * Defines the alpha limits in alpha test mode.
  25939. */
  25940. alphaCutOff: number;
  25941. /**
  25942. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  25943. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  25944. */
  25945. useSpecularOverAlpha: boolean;
  25946. /**
  25947. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  25948. */
  25949. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  25950. /**
  25951. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  25952. */
  25953. useRoughnessFromMetallicTextureAlpha: boolean;
  25954. /**
  25955. * Specifies if the metallic texture contains the roughness information in its green channel.
  25956. */
  25957. useRoughnessFromMetallicTextureGreen: boolean;
  25958. /**
  25959. * Specifies if the metallic texture contains the metallness information in its blue channel.
  25960. */
  25961. useMetallnessFromMetallicTextureBlue: boolean;
  25962. /**
  25963. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  25964. */
  25965. useAmbientOcclusionFromMetallicTextureRed: boolean;
  25966. /**
  25967. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  25968. */
  25969. useAmbientInGrayScale: boolean;
  25970. /**
  25971. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  25972. * The material will try to infer what glossiness each pixel should be.
  25973. */
  25974. useAutoMicroSurfaceFromReflectivityMap: boolean;
  25975. /**
  25976. * BJS is using an harcoded light falloff based on a manually sets up range.
  25977. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  25978. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  25979. */
  25980. usePhysicalLightFalloff: boolean;
  25981. /**
  25982. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  25983. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  25984. */
  25985. useRadianceOverAlpha: boolean;
  25986. /**
  25987. * Allows using an object space normal map (instead of tangent space).
  25988. */
  25989. useObjectSpaceNormalMap: boolean;
  25990. /**
  25991. * Allows using the bump map in parallax mode.
  25992. */
  25993. useParallax: boolean;
  25994. /**
  25995. * Allows using the bump map in parallax occlusion mode.
  25996. */
  25997. useParallaxOcclusion: boolean;
  25998. /**
  25999. * Controls the scale bias of the parallax mode.
  26000. */
  26001. parallaxScaleBias: number;
  26002. /**
  26003. * If sets to true, disables all the lights affecting the material.
  26004. */
  26005. disableLighting: boolean;
  26006. /**
  26007. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26008. */
  26009. forceIrradianceInFragment: boolean;
  26010. /**
  26011. * Number of Simultaneous lights allowed on the material.
  26012. */
  26013. maxSimultaneousLights: number;
  26014. /**
  26015. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26016. */
  26017. invertNormalMapX: boolean;
  26018. /**
  26019. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26020. */
  26021. invertNormalMapY: boolean;
  26022. /**
  26023. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26024. */
  26025. twoSidedLighting: boolean;
  26026. /**
  26027. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26028. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26029. */
  26030. useAlphaFresnel: boolean;
  26031. /**
  26032. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26033. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26034. */
  26035. useLinearAlphaFresnel: boolean;
  26036. /**
  26037. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26038. * And/Or occlude the blended part.
  26039. */
  26040. environmentBRDFTexture: Nullable<BaseTexture>;
  26041. /**
  26042. * Force normal to face away from face.
  26043. */
  26044. forceNormalForward: boolean;
  26045. /**
  26046. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26047. * makes the reflect vector face the model (under horizon).
  26048. */
  26049. useHorizonOcclusion: boolean;
  26050. /**
  26051. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26052. * too much the area relying on ambient texture to define their ambient occlusion.
  26053. */
  26054. useRadianceOcclusion: boolean;
  26055. /**
  26056. * Gets the image processing configuration used either in this material.
  26057. */
  26058. /**
  26059. * Sets the Default image processing configuration used either in the this material.
  26060. *
  26061. * If sets to null, the scene one is in use.
  26062. */
  26063. imageProcessingConfiguration: ImageProcessingConfiguration;
  26064. /**
  26065. * Gets wether the color curves effect is enabled.
  26066. */
  26067. /**
  26068. * Sets wether the color curves effect is enabled.
  26069. */
  26070. cameraColorCurvesEnabled: boolean;
  26071. /**
  26072. * Gets wether the color grading effect is enabled.
  26073. */
  26074. /**
  26075. * Gets wether the color grading effect is enabled.
  26076. */
  26077. cameraColorGradingEnabled: boolean;
  26078. /**
  26079. * Gets wether tonemapping is enabled or not.
  26080. */
  26081. /**
  26082. * Sets wether tonemapping is enabled or not
  26083. */
  26084. cameraToneMappingEnabled: boolean;
  26085. /**
  26086. * The camera exposure used on this material.
  26087. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26088. * This corresponds to a photographic exposure.
  26089. */
  26090. /**
  26091. * The camera exposure used on this material.
  26092. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26093. * This corresponds to a photographic exposure.
  26094. */
  26095. cameraExposure: number;
  26096. /**
  26097. * Gets The camera contrast used on this material.
  26098. */
  26099. /**
  26100. * Sets The camera contrast used on this material.
  26101. */
  26102. cameraContrast: number;
  26103. /**
  26104. * Gets the Color Grading 2D Lookup Texture.
  26105. */
  26106. /**
  26107. * Sets the Color Grading 2D Lookup Texture.
  26108. */
  26109. cameraColorGradingTexture: Nullable<BaseTexture>;
  26110. /**
  26111. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26112. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26113. * 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;
  26114. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26115. */
  26116. /**
  26117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26119. * 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;
  26120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26121. */
  26122. cameraColorCurves: Nullable<ColorCurves>;
  26123. /**
  26124. * Instantiates a new PBRMaterial instance.
  26125. *
  26126. * @param name The material name
  26127. * @param scene The scene the material will be use in.
  26128. */
  26129. constructor(name: string, scene: Scene);
  26130. /**
  26131. * Returns the name of this material class.
  26132. */
  26133. getClassName(): string;
  26134. /**
  26135. * Returns an array of the actively used textures.
  26136. * @returns - Array of BaseTextures
  26137. */
  26138. getActiveTextures(): BaseTexture[];
  26139. /**
  26140. * Checks to see if a texture is used in the material.
  26141. * @param texture - Base texture to use.
  26142. * @returns - Boolean specifying if a texture is used in the material.
  26143. */
  26144. hasTexture(texture: BaseTexture): boolean;
  26145. /**
  26146. * Makes a duplicate of the current material.
  26147. * @param name - name to use for the new material.
  26148. */
  26149. clone(name: string): PBRMaterial;
  26150. /**
  26151. * Serializes this PBR Material.
  26152. * @returns - An object with the serialized material.
  26153. */
  26154. serialize(): any;
  26155. /**
  26156. * Parses a PBR Material from a serialized object.
  26157. * @param source - Serialized object.
  26158. * @param scene - BJS scene instance.
  26159. * @param rootUrl - url for the scene object
  26160. * @returns - PBRMaterial
  26161. */
  26162. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  26163. }
  26164. }
  26165. declare module BABYLON {
  26166. /**
  26167. * The PBR material of BJS following the metal roughness convention.
  26168. *
  26169. * This fits to the PBR convention in the GLTF definition:
  26170. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  26171. */
  26172. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  26173. /**
  26174. * The base color has two different interpretations depending on the value of metalness.
  26175. * When the material is a metal, the base color is the specific measured reflectance value
  26176. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  26177. * of the material.
  26178. */
  26179. baseColor: Color3;
  26180. /**
  26181. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  26182. * well as opacity information in the alpha channel.
  26183. */
  26184. baseTexture: BaseTexture;
  26185. /**
  26186. * Specifies the metallic scalar value of the material.
  26187. * Can also be used to scale the metalness values of the metallic texture.
  26188. */
  26189. metallic: number;
  26190. /**
  26191. * Specifies the roughness scalar value of the material.
  26192. * Can also be used to scale the roughness values of the metallic texture.
  26193. */
  26194. roughness: number;
  26195. /**
  26196. * Texture containing both the metallic value in the B channel and the
  26197. * roughness value in the G channel to keep better precision.
  26198. */
  26199. metallicRoughnessTexture: BaseTexture;
  26200. /**
  26201. * Instantiates a new PBRMetalRoughnessMaterial instance.
  26202. *
  26203. * @param name The material name
  26204. * @param scene The scene the material will be use in.
  26205. */
  26206. constructor(name: string, scene: Scene);
  26207. /**
  26208. * Return the currrent class name of the material.
  26209. */
  26210. getClassName(): string;
  26211. /**
  26212. * Return the active textures of the material.
  26213. */
  26214. getActiveTextures(): BaseTexture[];
  26215. /**
  26216. * Checks to see if a texture is used in the material.
  26217. * @param texture - Base texture to use.
  26218. * @returns - Boolean specifying if a texture is used in the material.
  26219. */
  26220. hasTexture(texture: BaseTexture): boolean;
  26221. /**
  26222. * Makes a duplicate of the current material.
  26223. * @param name - name to use for the new material.
  26224. */
  26225. clone(name: string): PBRMetallicRoughnessMaterial;
  26226. /**
  26227. * Serialize the material to a parsable JSON object.
  26228. */
  26229. serialize(): any;
  26230. /**
  26231. * Parses a JSON object correponding to the serialize function.
  26232. */
  26233. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  26234. }
  26235. }
  26236. declare module BABYLON {
  26237. /**
  26238. * The PBR material of BJS following the specular glossiness convention.
  26239. *
  26240. * This fits to the PBR convention in the GLTF definition:
  26241. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  26242. */
  26243. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  26244. /**
  26245. * Specifies the diffuse color of the material.
  26246. */
  26247. diffuseColor: Color3;
  26248. /**
  26249. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  26250. * channel.
  26251. */
  26252. diffuseTexture: BaseTexture;
  26253. /**
  26254. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  26255. */
  26256. specularColor: Color3;
  26257. /**
  26258. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  26259. */
  26260. glossiness: number;
  26261. /**
  26262. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  26263. */
  26264. specularGlossinessTexture: BaseTexture;
  26265. /**
  26266. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  26267. *
  26268. * @param name The material name
  26269. * @param scene The scene the material will be use in.
  26270. */
  26271. constructor(name: string, scene: Scene);
  26272. /**
  26273. * Return the currrent class name of the material.
  26274. */
  26275. getClassName(): string;
  26276. /**
  26277. * Return the active textures of the material.
  26278. */
  26279. getActiveTextures(): BaseTexture[];
  26280. /**
  26281. * Checks to see if a texture is used in the material.
  26282. * @param texture - Base texture to use.
  26283. * @returns - Boolean specifying if a texture is used in the material.
  26284. */
  26285. hasTexture(texture: BaseTexture): boolean;
  26286. /**
  26287. * Makes a duplicate of the current material.
  26288. * @param name - name to use for the new material.
  26289. */
  26290. clone(name: string): PBRSpecularGlossinessMaterial;
  26291. /**
  26292. * Serialize the material to a parsable JSON object.
  26293. */
  26294. serialize(): any;
  26295. /**
  26296. * Parses a JSON object correponding to the serialize function.
  26297. */
  26298. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  26299. }
  26300. }
  26301. declare module BABYLON {
  26302. class BaseTexture {
  26303. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26304. name: string;
  26305. private _hasAlpha;
  26306. hasAlpha: boolean;
  26307. getAlphaFromRGB: boolean;
  26308. level: number;
  26309. coordinatesIndex: number;
  26310. private _coordinatesMode;
  26311. /**
  26312. * How a texture is mapped.
  26313. *
  26314. * | Value | Type | Description |
  26315. * | ----- | ----------------------------------- | ----------- |
  26316. * | 0 | EXPLICIT_MODE | |
  26317. * | 1 | SPHERICAL_MODE | |
  26318. * | 2 | PLANAR_MODE | |
  26319. * | 3 | CUBIC_MODE | |
  26320. * | 4 | PROJECTION_MODE | |
  26321. * | 5 | SKYBOX_MODE | |
  26322. * | 6 | INVCUBIC_MODE | |
  26323. * | 7 | EQUIRECTANGULAR_MODE | |
  26324. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26325. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26326. */
  26327. coordinatesMode: number;
  26328. /**
  26329. * | Value | Type | Description |
  26330. * | ----- | ------------------ | ----------- |
  26331. * | 0 | CLAMP_ADDRESSMODE | |
  26332. * | 1 | WRAP_ADDRESSMODE | |
  26333. * | 2 | MIRROR_ADDRESSMODE | |
  26334. */
  26335. wrapU: number;
  26336. /**
  26337. * | Value | Type | Description |
  26338. * | ----- | ------------------ | ----------- |
  26339. * | 0 | CLAMP_ADDRESSMODE | |
  26340. * | 1 | WRAP_ADDRESSMODE | |
  26341. * | 2 | MIRROR_ADDRESSMODE | |
  26342. */
  26343. wrapV: number;
  26344. /**
  26345. * | Value | Type | Description |
  26346. * | ----- | ------------------ | ----------- |
  26347. * | 0 | CLAMP_ADDRESSMODE | |
  26348. * | 1 | WRAP_ADDRESSMODE | |
  26349. * | 2 | MIRROR_ADDRESSMODE | |
  26350. */
  26351. wrapR: number;
  26352. anisotropicFilteringLevel: number;
  26353. isCube: boolean;
  26354. is3D: boolean;
  26355. gammaSpace: boolean;
  26356. invertZ: boolean;
  26357. lodLevelInAlpha: boolean;
  26358. lodGenerationOffset: number;
  26359. lodGenerationScale: number;
  26360. isRenderTarget: boolean;
  26361. readonly uid: string;
  26362. toString(): string;
  26363. getClassName(): string;
  26364. animations: Animation[];
  26365. /**
  26366. * An event triggered when the texture is disposed.
  26367. * @type {BABYLON.Observable}
  26368. */
  26369. onDisposeObservable: Observable<BaseTexture>;
  26370. private _onDisposeObserver;
  26371. onDispose: () => void;
  26372. delayLoadState: number;
  26373. private _scene;
  26374. _texture: Nullable<InternalTexture>;
  26375. private _uid;
  26376. readonly isBlocking: boolean;
  26377. constructor(scene: Nullable<Scene>);
  26378. getScene(): Nullable<Scene>;
  26379. getTextureMatrix(): Matrix;
  26380. getReflectionTextureMatrix(): Matrix;
  26381. getInternalTexture(): Nullable<InternalTexture>;
  26382. isReadyOrNotBlocking(): boolean;
  26383. isReady(): boolean;
  26384. getSize(): ISize;
  26385. getBaseSize(): ISize;
  26386. scale(ratio: number): void;
  26387. readonly canRescale: boolean;
  26388. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  26389. _rebuild(): void;
  26390. delayLoad(): void;
  26391. clone(): Nullable<BaseTexture>;
  26392. readonly textureType: number;
  26393. readonly textureFormat: number;
  26394. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  26395. releaseInternalTexture(): void;
  26396. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26397. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26398. readonly _lodTextureMid: Nullable<BaseTexture>;
  26399. readonly _lodTextureLow: Nullable<BaseTexture>;
  26400. dispose(): void;
  26401. serialize(): any;
  26402. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26403. }
  26404. }
  26405. declare module BABYLON {
  26406. /**
  26407. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  26408. * It can help converting any input color in a desired output one. This can then be used to create effects
  26409. * from sepia, black and white to sixties or futuristic rendering...
  26410. *
  26411. * The only supported format is currently 3dl.
  26412. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  26413. */
  26414. class ColorGradingTexture extends BaseTexture {
  26415. /**
  26416. * The current texture matrix. (will always be identity in color grading texture)
  26417. */
  26418. private _textureMatrix;
  26419. /**
  26420. * The texture URL.
  26421. */
  26422. url: string;
  26423. /**
  26424. * Empty line regex stored for GC.
  26425. */
  26426. private static _noneEmptyLineRegex;
  26427. private _engine;
  26428. /**
  26429. * Instantiates a ColorGradingTexture from the following parameters.
  26430. *
  26431. * @param url The location of the color gradind data (currently only supporting 3dl)
  26432. * @param scene The scene the texture will be used in
  26433. */
  26434. constructor(url: string, scene: Scene);
  26435. /**
  26436. * Returns the texture matrix used in most of the material.
  26437. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  26438. */
  26439. getTextureMatrix(): Matrix;
  26440. /**
  26441. * Occurs when the file being loaded is a .3dl LUT file.
  26442. */
  26443. private load3dlTexture();
  26444. /**
  26445. * Starts the loading process of the texture.
  26446. */
  26447. private loadTexture();
  26448. /**
  26449. * Clones the color gradind texture.
  26450. */
  26451. clone(): ColorGradingTexture;
  26452. /**
  26453. * Called during delayed load for textures.
  26454. */
  26455. delayLoad(): void;
  26456. /**
  26457. * Parses a color grading texture serialized by Babylon.
  26458. * @param parsedTexture The texture information being parsedTexture
  26459. * @param scene The scene to load the texture in
  26460. * @param rootUrl The root url of the data assets to load
  26461. * @return A color gradind texture
  26462. */
  26463. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  26464. /**
  26465. * Serializes the LUT texture to json format.
  26466. */
  26467. serialize(): any;
  26468. }
  26469. }
  26470. declare module BABYLON {
  26471. class CubeTexture extends BaseTexture {
  26472. url: string;
  26473. coordinatesMode: number;
  26474. /**
  26475. * Gets or sets the center of the bounding box associated with the cube texture
  26476. * It must define where the camera used to render the texture was set
  26477. */
  26478. boundingBoxPosition: Vector3;
  26479. private _boundingBoxSize;
  26480. /**
  26481. * Gets or sets the size of the bounding box associated with the cube texture
  26482. * When defined, the cubemap will switch to local mode
  26483. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  26484. * @example https://www.babylonjs-playground.com/#RNASML
  26485. */
  26486. boundingBoxSize: Vector3;
  26487. private _noMipmap;
  26488. private _files;
  26489. private _extensions;
  26490. private _textureMatrix;
  26491. private _format;
  26492. private _prefiltered;
  26493. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  26494. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture;
  26495. 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);
  26496. delayLoad(): void;
  26497. getReflectionTextureMatrix(): Matrix;
  26498. setReflectionTextureMatrix(value: Matrix): void;
  26499. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  26500. clone(): CubeTexture;
  26501. }
  26502. }
  26503. declare module BABYLON {
  26504. class DynamicTexture extends Texture {
  26505. private _generateMipMaps;
  26506. private _canvas;
  26507. private _context;
  26508. private _engine;
  26509. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  26510. readonly canRescale: boolean;
  26511. private _recreate(textureSize);
  26512. scale(ratio: number): void;
  26513. scaleTo(width: number, height: number): void;
  26514. getContext(): CanvasRenderingContext2D;
  26515. clear(): void;
  26516. update(invertY?: boolean): void;
  26517. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  26518. clone(): DynamicTexture;
  26519. _rebuild(): void;
  26520. }
  26521. }
  26522. declare module BABYLON {
  26523. /**
  26524. * This represents a texture coming from an HDR input.
  26525. *
  26526. * The only supported format is currently panorama picture stored in RGBE format.
  26527. * Example of such files can be found on HDRLib: http://hdrlib.com/
  26528. */
  26529. class HDRCubeTexture extends BaseTexture {
  26530. private static _facesMapping;
  26531. private _useInGammaSpace;
  26532. private _generateHarmonics;
  26533. private _noMipmap;
  26534. private _textureMatrix;
  26535. private _size;
  26536. private _usePMREMGenerator;
  26537. private _isBABYLONPreprocessed;
  26538. private _onLoad;
  26539. private _onError;
  26540. /**
  26541. * The texture URL.
  26542. */
  26543. url: string;
  26544. /**
  26545. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  26546. */
  26547. coordinatesMode: number;
  26548. /**
  26549. * Specifies wether the texture has been generated through the PMREMGenerator tool.
  26550. * This is usefull at run time to apply the good shader.
  26551. */
  26552. isPMREM: boolean;
  26553. protected _isBlocking: boolean;
  26554. /**
  26555. * Gets wether or not the texture is blocking during loading.
  26556. */
  26557. /**
  26558. * Sets wether or not the texture is blocking during loading.
  26559. */
  26560. isBlocking: boolean;
  26561. /**
  26562. * Gets or sets the center of the bounding box associated with the cube texture
  26563. * It must define where the camera used to render the texture was set
  26564. */
  26565. boundingBoxPosition: Vector3;
  26566. private _boundingBoxSize;
  26567. /**
  26568. * Gets or sets the size of the bounding box associated with the cube texture
  26569. * When defined, the cubemap will switch to local mode
  26570. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  26571. * @example https://www.babylonjs-playground.com/#RNASML
  26572. */
  26573. boundingBoxSize: Vector3;
  26574. /**
  26575. * Instantiates an HDRTexture from the following parameters.
  26576. *
  26577. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  26578. * @param scene The scene the texture will be used in
  26579. * @param size The cubemap desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
  26580. * @param noMipmap Forces to not generate the mipmap if true
  26581. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  26582. * @param useInGammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  26583. * @param usePMREMGenerator Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
  26584. */
  26585. constructor(url: string, scene: Scene, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  26586. /**
  26587. * Occurs when the file is a preprocessed .babylon.hdr file.
  26588. */
  26589. private loadBabylonTexture();
  26590. /**
  26591. * Occurs when the file is raw .hdr file.
  26592. */
  26593. private loadHDRTexture();
  26594. /**
  26595. * Starts the loading process of the texture.
  26596. */
  26597. private loadTexture();
  26598. clone(): HDRCubeTexture;
  26599. delayLoad(): void;
  26600. getReflectionTextureMatrix(): Matrix;
  26601. setReflectionTextureMatrix(value: Matrix): void;
  26602. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  26603. serialize(): any;
  26604. /**
  26605. * Saves as a file the data contained in the texture in a binary format.
  26606. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  26607. * as the spherical used in the lighting.
  26608. * @param url The HDR file url.
  26609. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  26610. * @param onError Method called if any error happens during download.
  26611. * @return The packed binary data.
  26612. */
  26613. static generateBabylonHDROnDisk(url: string, size: number, onError?: Nullable<(() => void)>): void;
  26614. /**
  26615. * Serializes the data contained in the texture in a binary format.
  26616. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  26617. * as the spherical used in the lighting.
  26618. * @param url The HDR file url.
  26619. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  26620. * @param onError Method called if any error happens during download.
  26621. * @return The packed binary data.
  26622. */
  26623. static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer: ArrayBuffer) => void), onError?: Nullable<(() => void)>): void;
  26624. }
  26625. }
  26626. declare module BABYLON {
  26627. /**
  26628. * Class used to store data associated with WebGL texture data for the engine
  26629. * This class should not be used directly
  26630. */
  26631. class InternalTexture implements IInternalTextureTracker {
  26632. /**
  26633. * The source of the texture data is unknown
  26634. */
  26635. static DATASOURCE_UNKNOWN: number;
  26636. /**
  26637. * Texture data comes from an URL
  26638. */
  26639. static DATASOURCE_URL: number;
  26640. /**
  26641. * Texture data is only used for temporary storage
  26642. */
  26643. static DATASOURCE_TEMP: number;
  26644. /**
  26645. * Texture data comes from raw data (ArrayBuffer)
  26646. */
  26647. static DATASOURCE_RAW: number;
  26648. /**
  26649. * Texture content is dynamic (video or dynamic texture)
  26650. */
  26651. static DATASOURCE_DYNAMIC: number;
  26652. /**
  26653. * Texture content is generated by rendering to it
  26654. */
  26655. static DATASOURCE_RENDERTARGET: number;
  26656. /**
  26657. * Texture content is part of a multi render target process
  26658. */
  26659. static DATASOURCE_MULTIRENDERTARGET: number;
  26660. /**
  26661. * Texture data comes from a cube data file
  26662. */
  26663. static DATASOURCE_CUBE: number;
  26664. /**
  26665. * Texture data comes from a raw cube data
  26666. */
  26667. static DATASOURCE_CUBERAW: number;
  26668. /**
  26669. * Texture data come from a prefiltered cube data file
  26670. */
  26671. static DATASOURCE_CUBEPREFILTERED: number;
  26672. /**
  26673. * Texture content is raw 3D data
  26674. */
  26675. static DATASOURCE_RAW3D: number;
  26676. /**
  26677. * Texture content is a depth texture
  26678. */
  26679. static DATASOURCE_DEPTHTEXTURE: number;
  26680. /**
  26681. * Defines if the texture is ready
  26682. */
  26683. isReady: boolean;
  26684. /**
  26685. * Defines if the texture is a cube texture
  26686. */
  26687. isCube: boolean;
  26688. /**
  26689. * Defines if the texture contains 3D data
  26690. */
  26691. is3D: boolean;
  26692. /**
  26693. * Gets the URL used to load this texture
  26694. */
  26695. url: string;
  26696. /**
  26697. * Gets the sampling mode of the texture
  26698. */
  26699. samplingMode: number;
  26700. /**
  26701. * Gets a boolean indicating if the texture needs mipmaps generation
  26702. */
  26703. generateMipMaps: boolean;
  26704. /**
  26705. * Gets the number of samples used by the texture (WebGL2+ only)
  26706. */
  26707. samples: number;
  26708. /**
  26709. * Gets the type of the texture
  26710. */
  26711. type: number;
  26712. /**
  26713. * Gets the format of the texture
  26714. */
  26715. format: number;
  26716. /**
  26717. * Observable called when the texture is loaded
  26718. */
  26719. onLoadedObservable: Observable<InternalTexture>;
  26720. /**
  26721. * Gets the width of the texture
  26722. */
  26723. width: number;
  26724. /**
  26725. * Gets the height of the texture
  26726. */
  26727. height: number;
  26728. /**
  26729. * Gets the depth of the texture
  26730. */
  26731. depth: number;
  26732. /**
  26733. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  26734. */
  26735. baseWidth: number;
  26736. /**
  26737. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  26738. */
  26739. baseHeight: number;
  26740. /**
  26741. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  26742. */
  26743. baseDepth: number;
  26744. /**
  26745. * Gets a boolean indicating if the texture is inverted on Y axis
  26746. */
  26747. invertY: boolean;
  26748. /**
  26749. * Gets or set the previous tracker in the list
  26750. */
  26751. previous: Nullable<IInternalTextureTracker>;
  26752. /**
  26753. * Gets or set the next tracker in the list
  26754. */
  26755. next: Nullable<IInternalTextureTracker>;
  26756. /** @ignore */
  26757. _initialSlot: number;
  26758. /** @ignore */
  26759. _designatedSlot: number;
  26760. /** @ignore */
  26761. _dataSource: number;
  26762. /** @ignore */
  26763. _buffer: Nullable<ArrayBuffer | HTMLImageElement>;
  26764. /** @ignore */
  26765. _bufferView: Nullable<ArrayBufferView>;
  26766. /** @ignore */
  26767. _bufferViewArray: Nullable<ArrayBufferView[]>;
  26768. /** @ignore */
  26769. _size: number;
  26770. /** @ignore */
  26771. _extension: string;
  26772. /** @ignore */
  26773. _files: Nullable<string[]>;
  26774. /** @ignore */
  26775. _workingCanvas: HTMLCanvasElement;
  26776. /** @ignore */
  26777. _workingContext: CanvasRenderingContext2D;
  26778. /** @ignore */
  26779. _framebuffer: Nullable<WebGLFramebuffer>;
  26780. /** @ignore */
  26781. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  26782. /** @ignore */
  26783. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  26784. /** @ignore */
  26785. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  26786. /** @ignore */
  26787. _attachments: Nullable<number[]>;
  26788. /** @ignore */
  26789. _cachedCoordinatesMode: Nullable<number>;
  26790. /** @ignore */
  26791. _cachedWrapU: Nullable<number>;
  26792. /** @ignore */
  26793. _cachedWrapV: Nullable<number>;
  26794. /** @ignore */
  26795. _cachedWrapR: Nullable<number>;
  26796. /** @ignore */
  26797. _cachedAnisotropicFilteringLevel: Nullable<number>;
  26798. /** @ignore */
  26799. _isDisabled: boolean;
  26800. /** @ignore */
  26801. _compression: Nullable<string>;
  26802. /** @ignore */
  26803. _generateStencilBuffer: boolean;
  26804. /** @ignore */
  26805. _generateDepthBuffer: boolean;
  26806. /** @ignore */
  26807. _comparisonFunction: number;
  26808. /** @ignore */
  26809. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  26810. /** @ignore */
  26811. _lodGenerationScale: number;
  26812. /** @ignore */
  26813. _lodGenerationOffset: number;
  26814. /** @ignore */
  26815. _lodTextureHigh: BaseTexture;
  26816. /** @ignore */
  26817. _lodTextureMid: BaseTexture;
  26818. /** @ignore */
  26819. _lodTextureLow: BaseTexture;
  26820. /** @ignore */
  26821. _webGLTexture: Nullable<WebGLTexture>;
  26822. /** @ignore */
  26823. _references: number;
  26824. private _engine;
  26825. /**
  26826. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  26827. */
  26828. readonly dataSource: number;
  26829. /**
  26830. * Creates a new InternalTexture
  26831. * @param engine defines the engine to use
  26832. * @param dataSource defines the type of data that will be used
  26833. */
  26834. constructor(engine: Engine, dataSource: number);
  26835. /**
  26836. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  26837. */
  26838. incrementReferences(): void;
  26839. /**
  26840. * Change the size of the texture (not the size of the content)
  26841. * @param width defines the new width
  26842. * @param height defines the new height
  26843. * @param depth defines the new depth (1 by default)
  26844. */
  26845. updateSize(width: int, height: int, depth?: int): void;
  26846. /** @ignore */
  26847. _rebuild(): void;
  26848. private _swapAndDie(target);
  26849. /**
  26850. * Dispose the current allocated resources
  26851. */
  26852. dispose(): void;
  26853. }
  26854. }
  26855. declare module BABYLON {
  26856. /**
  26857. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  26858. */
  26859. interface IInternalTextureTracker {
  26860. /**
  26861. * Gets or set the previous tracker in the list
  26862. */
  26863. previous: Nullable<IInternalTextureTracker>;
  26864. /**
  26865. * Gets or set the next tracker in the list
  26866. */
  26867. next: Nullable<IInternalTextureTracker>;
  26868. }
  26869. /**
  26870. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  26871. */
  26872. class DummyInternalTextureTracker {
  26873. /**
  26874. * Gets or set the previous tracker in the list
  26875. */
  26876. previous: Nullable<IInternalTextureTracker>;
  26877. /**
  26878. * Gets or set the next tracker in the list
  26879. */
  26880. next: Nullable<IInternalTextureTracker>;
  26881. }
  26882. }
  26883. declare module BABYLON {
  26884. class MirrorTexture extends RenderTargetTexture {
  26885. mirrorPlane: Plane;
  26886. private _transformMatrix;
  26887. private _mirrorMatrix;
  26888. private _savedViewMatrix;
  26889. private _blurX;
  26890. private _blurY;
  26891. private _adaptiveBlurKernel;
  26892. private _blurKernelX;
  26893. private _blurKernelY;
  26894. private _blurRatio;
  26895. blurRatio: number;
  26896. adaptiveBlurKernel: number;
  26897. blurKernel: number;
  26898. blurKernelX: number;
  26899. blurKernelY: number;
  26900. private _autoComputeBlurKernel();
  26901. protected _onRatioRescale(): void;
  26902. constructor(name: string, size: number | {
  26903. width: number;
  26904. height: number;
  26905. } | {
  26906. ratio: number;
  26907. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  26908. private _preparePostProcesses();
  26909. clone(): MirrorTexture;
  26910. serialize(): any;
  26911. }
  26912. }
  26913. declare module BABYLON {
  26914. interface IMultiRenderTargetOptions {
  26915. generateMipMaps?: boolean;
  26916. types?: number[];
  26917. samplingModes?: number[];
  26918. generateDepthBuffer?: boolean;
  26919. generateStencilBuffer?: boolean;
  26920. generateDepthTexture?: boolean;
  26921. textureCount?: number;
  26922. doNotChangeAspectRatio?: boolean;
  26923. defaultType?: number;
  26924. }
  26925. class MultiRenderTarget extends RenderTargetTexture {
  26926. private _internalTextures;
  26927. private _textures;
  26928. readonly isSupported: boolean;
  26929. private _multiRenderTargetOptions;
  26930. readonly textures: Texture[];
  26931. readonly depthTexture: Texture;
  26932. wrapU: number;
  26933. wrapV: number;
  26934. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26935. _rebuild(): void;
  26936. private _createInternalTextures();
  26937. private _createTextures();
  26938. samples: number;
  26939. resize(size: any): void;
  26940. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26941. dispose(): void;
  26942. releaseInternalTextures(): void;
  26943. }
  26944. }
  26945. declare module BABYLON {
  26946. class RawTexture extends Texture {
  26947. format: number;
  26948. private _engine;
  26949. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  26950. update(data: ArrayBufferView): void;
  26951. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  26952. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  26953. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  26954. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  26955. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  26956. }
  26957. }
  26958. declare module BABYLON {
  26959. /**
  26960. * Creates a refraction texture used by refraction channel of the standard material.
  26961. * @param name the texture name
  26962. * @param size size of the underlying texture
  26963. * @param scene root scene
  26964. */
  26965. class RefractionTexture extends RenderTargetTexture {
  26966. refractionPlane: Plane;
  26967. depth: number;
  26968. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  26969. clone(): RefractionTexture;
  26970. serialize(): any;
  26971. }
  26972. }
  26973. declare module BABYLON {
  26974. class RenderTargetTexture extends Texture {
  26975. isCube: boolean;
  26976. static _REFRESHRATE_RENDER_ONCE: number;
  26977. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  26978. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  26979. static readonly REFRESHRATE_RENDER_ONCE: number;
  26980. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  26981. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  26982. /**
  26983. * Use this predicate to dynamically define the list of mesh you want to render.
  26984. * If set, the renderList property will be overwritten.
  26985. */
  26986. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  26987. /**
  26988. * Use this list to define the list of mesh you want to render.
  26989. */
  26990. renderList: Nullable<Array<AbstractMesh>>;
  26991. renderParticles: boolean;
  26992. renderSprites: boolean;
  26993. coordinatesMode: number;
  26994. activeCamera: Nullable<Camera>;
  26995. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  26996. useCameraPostProcesses: boolean;
  26997. ignoreCameraViewport: boolean;
  26998. private _postProcessManager;
  26999. private _postProcesses;
  27000. private _resizeObserver;
  27001. /**
  27002. * An event triggered when the texture is unbind.
  27003. * @type {BABYLON.Observable}
  27004. */
  27005. onBeforeBindObservable: Observable<RenderTargetTexture>;
  27006. /**
  27007. * An event triggered when the texture is unbind.
  27008. * @type {BABYLON.Observable}
  27009. */
  27010. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  27011. private _onAfterUnbindObserver;
  27012. onAfterUnbind: () => void;
  27013. /**
  27014. * An event triggered before rendering the texture
  27015. * @type {BABYLON.Observable}
  27016. */
  27017. onBeforeRenderObservable: Observable<number>;
  27018. private _onBeforeRenderObserver;
  27019. onBeforeRender: (faceIndex: number) => void;
  27020. /**
  27021. * An event triggered after rendering the texture
  27022. * @type {BABYLON.Observable}
  27023. */
  27024. onAfterRenderObservable: Observable<number>;
  27025. private _onAfterRenderObserver;
  27026. onAfterRender: (faceIndex: number) => void;
  27027. /**
  27028. * An event triggered after the texture clear
  27029. * @type {BABYLON.Observable}
  27030. */
  27031. onClearObservable: Observable<Engine>;
  27032. private _onClearObserver;
  27033. onClear: (Engine: Engine) => void;
  27034. clearColor: Color4;
  27035. protected _size: number | {
  27036. width: number;
  27037. height: number;
  27038. };
  27039. protected _initialSizeParameter: number | {
  27040. width: number;
  27041. height: number;
  27042. } | {
  27043. ratio: number;
  27044. };
  27045. protected _sizeRatio: Nullable<number>;
  27046. _generateMipMaps: boolean;
  27047. protected _renderingManager: RenderingManager;
  27048. _waitingRenderList: string[];
  27049. protected _doNotChangeAspectRatio: boolean;
  27050. protected _currentRefreshId: number;
  27051. protected _refreshRate: number;
  27052. protected _textureMatrix: Matrix;
  27053. protected _samples: number;
  27054. protected _renderTargetOptions: RenderTargetCreationOptions;
  27055. readonly renderTargetOptions: RenderTargetCreationOptions;
  27056. protected _engine: Engine;
  27057. protected _onRatioRescale(): void;
  27058. /**
  27059. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  27060. * It must define where the camera used to render the texture is set
  27061. */
  27062. boundingBoxPosition: Vector3;
  27063. private _boundingBoxSize;
  27064. /**
  27065. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  27066. * When defined, the cubemap will switch to local mode
  27067. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  27068. * @example https://www.babylonjs-playground.com/#RNASML
  27069. */
  27070. boundingBoxSize: Vector3;
  27071. /**
  27072. * In case the RTT has been created with a depth texture, get the associated
  27073. * depth texture.
  27074. * Otherwise, return null.
  27075. */
  27076. depthStencilTexture: Nullable<InternalTexture>;
  27077. /**
  27078. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  27079. * or used a shadow, depth texture...
  27080. * @param name The friendly name of the texture
  27081. * @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)
  27082. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  27083. * @param generateMipMaps True if mip maps need to be generated after render.
  27084. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  27085. * @param type The type of the buffer in the RTT (int, half float, float...)
  27086. * @param isCube True if a cube texture needs to be created
  27087. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  27088. * @param generateDepthBuffer True to generate a depth buffer
  27089. * @param generateStencilBuffer True to generate a stencil buffer
  27090. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  27091. */
  27092. constructor(name: string, size: number | {
  27093. width: number;
  27094. height: number;
  27095. } | {
  27096. ratio: number;
  27097. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  27098. private _processSizeParameter(size);
  27099. samples: number;
  27100. resetRefreshCounter(): void;
  27101. refreshRate: number;
  27102. addPostProcess(postProcess: PostProcess): void;
  27103. clearPostProcesses(dispose?: boolean): void;
  27104. removePostProcess(postProcess: PostProcess): void;
  27105. _shouldRender(): boolean;
  27106. getRenderSize(): number;
  27107. getRenderWidth(): number;
  27108. getRenderHeight(): number;
  27109. readonly canRescale: boolean;
  27110. scale(ratio: number): void;
  27111. getReflectionTextureMatrix(): Matrix;
  27112. resize(size: number | {
  27113. width: number;
  27114. height: number;
  27115. } | {
  27116. ratio: number;
  27117. }): void;
  27118. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  27119. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  27120. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  27121. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  27122. /**
  27123. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  27124. * This allowed control for front to back rendering or reversly depending of the special needs.
  27125. *
  27126. * @param renderingGroupId The rendering group id corresponding to its index
  27127. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  27128. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  27129. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  27130. */
  27131. 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;
  27132. /**
  27133. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  27134. *
  27135. * @param renderingGroupId The rendering group id corresponding to its index
  27136. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  27137. */
  27138. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  27139. clone(): RenderTargetTexture;
  27140. serialize(): any;
  27141. disposeFramebufferObjects(): void;
  27142. dispose(): void;
  27143. _rebuild(): void;
  27144. }
  27145. }
  27146. declare module BABYLON {
  27147. class Texture extends BaseTexture {
  27148. static NEAREST_SAMPLINGMODE: number;
  27149. static NEAREST_NEAREST_MIPLINEAR: number;
  27150. static BILINEAR_SAMPLINGMODE: number;
  27151. static LINEAR_LINEAR_MIPNEAREST: number;
  27152. static TRILINEAR_SAMPLINGMODE: number;
  27153. static LINEAR_LINEAR_MIPLINEAR: number;
  27154. static NEAREST_NEAREST_MIPNEAREST: number;
  27155. static NEAREST_LINEAR_MIPNEAREST: number;
  27156. static NEAREST_LINEAR_MIPLINEAR: number;
  27157. static NEAREST_LINEAR: number;
  27158. static NEAREST_NEAREST: number;
  27159. static LINEAR_NEAREST_MIPNEAREST: number;
  27160. static LINEAR_NEAREST_MIPLINEAR: number;
  27161. static LINEAR_LINEAR: number;
  27162. static LINEAR_NEAREST: number;
  27163. static EXPLICIT_MODE: number;
  27164. static SPHERICAL_MODE: number;
  27165. static PLANAR_MODE: number;
  27166. static CUBIC_MODE: number;
  27167. static PROJECTION_MODE: number;
  27168. static SKYBOX_MODE: number;
  27169. static INVCUBIC_MODE: number;
  27170. static EQUIRECTANGULAR_MODE: number;
  27171. static FIXED_EQUIRECTANGULAR_MODE: number;
  27172. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27173. static CLAMP_ADDRESSMODE: number;
  27174. static WRAP_ADDRESSMODE: number;
  27175. static MIRROR_ADDRESSMODE: number;
  27176. /**
  27177. * 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
  27178. */
  27179. static UseSerializedUrlIfAny: boolean;
  27180. url: Nullable<string>;
  27181. uOffset: number;
  27182. vOffset: number;
  27183. uScale: number;
  27184. vScale: number;
  27185. uAng: number;
  27186. vAng: number;
  27187. wAng: number;
  27188. readonly noMipmap: boolean;
  27189. private _noMipmap;
  27190. _invertY: boolean;
  27191. private _rowGenerationMatrix;
  27192. private _cachedTextureMatrix;
  27193. private _projectionModeMatrix;
  27194. private _t0;
  27195. private _t1;
  27196. private _t2;
  27197. private _cachedUOffset;
  27198. private _cachedVOffset;
  27199. private _cachedUScale;
  27200. private _cachedVScale;
  27201. private _cachedUAng;
  27202. private _cachedVAng;
  27203. private _cachedWAng;
  27204. private _cachedProjectionMatrixId;
  27205. private _cachedCoordinatesMode;
  27206. _samplingMode: number;
  27207. private _buffer;
  27208. private _deleteBuffer;
  27209. protected _format: Nullable<number>;
  27210. private _delayedOnLoad;
  27211. private _delayedOnError;
  27212. protected _onLoadObservable: Nullable<Observable<Texture>>;
  27213. protected _isBlocking: boolean;
  27214. isBlocking: boolean;
  27215. readonly samplingMode: number;
  27216. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: any, deleteBuffer?: boolean, format?: number);
  27217. updateURL(url: string): void;
  27218. delayLoad(): void;
  27219. updateSamplingMode(samplingMode: number): void;
  27220. private _prepareRowForTextureGeneration(x, y, z, t);
  27221. getTextureMatrix(): Matrix;
  27222. getReflectionTextureMatrix(): Matrix;
  27223. clone(): Texture;
  27224. readonly onLoadObservable: Observable<Texture>;
  27225. serialize(): any;
  27226. getClassName(): string;
  27227. dispose(): void;
  27228. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  27229. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  27230. 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;
  27231. }
  27232. }
  27233. declare module BABYLON {
  27234. /**
  27235. * Settings for finer control over video usage
  27236. */
  27237. interface VideoTextureSettings {
  27238. /**
  27239. * Applies `autoplay` to video, if specified
  27240. */
  27241. autoPlay?: boolean;
  27242. /**
  27243. * Applies `loop` to video, if specified
  27244. */
  27245. loop?: boolean;
  27246. /**
  27247. * Automatically updates internal texture from video at every frame in the render loop
  27248. */
  27249. autoUpdateTexture: boolean;
  27250. }
  27251. class VideoTexture extends Texture {
  27252. /**
  27253. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27254. */
  27255. readonly autoUpdateTexture: boolean;
  27256. /**
  27257. * The video instance used by the texture internally
  27258. */
  27259. readonly video: HTMLVideoElement;
  27260. private _generateMipMaps;
  27261. private _engine;
  27262. /**
  27263. * Creates a video texture.
  27264. * Sample : https://doc.babylonjs.com/how_to/video_texture
  27265. * @param {string | null} name optional name, will detect from video source, if not defined
  27266. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  27267. * @param {BABYLON.Scene} scene is obviously the current scene.
  27268. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27269. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  27270. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27271. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  27272. */
  27273. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27274. private _getName(src);
  27275. private _getVideo(src);
  27276. private _createInternalTexture;
  27277. private reset;
  27278. /**
  27279. * Internal method to initiate `update`.
  27280. */
  27281. _rebuild(): void;
  27282. /**
  27283. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27284. */
  27285. update(): void;
  27286. /**
  27287. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27288. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27289. */
  27290. updateTexture(isVisible: boolean): void;
  27291. protected _updateInternalTexture: (e?: Event | undefined) => void;
  27292. /**
  27293. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27294. * @param url New url.
  27295. */
  27296. updateURL(url: string): void;
  27297. dispose(): void;
  27298. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27299. minWidth: number;
  27300. maxWidth: number;
  27301. minHeight: number;
  27302. maxHeight: number;
  27303. deviceId: string;
  27304. }): void;
  27305. }
  27306. }
  27307. declare module BABYLON {
  27308. /**
  27309. * Particle emitter emitting particles from the inside of a box.
  27310. * It emits the particles randomly between 2 given directions.
  27311. */
  27312. class BoxParticleEmitter implements IParticleEmitterType {
  27313. /**
  27314. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  27315. */
  27316. direction1: Vector3;
  27317. /**
  27318. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  27319. */
  27320. direction2: Vector3;
  27321. /**
  27322. * 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.
  27323. */
  27324. minEmitBox: Vector3;
  27325. /**
  27326. * 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.
  27327. */
  27328. maxEmitBox: Vector3;
  27329. /**
  27330. * Creates a new instance of @see BoxParticleEmitter
  27331. */
  27332. constructor();
  27333. /**
  27334. * Called by the particle System when the direction is computed for the created particle.
  27335. * @param emitPower is the power of the particle (speed)
  27336. * @param worldMatrix is the world matrix of the particle system
  27337. * @param directionToUpdate is the direction vector to update with the result
  27338. * @param particle is the particle we are computed the direction for
  27339. */
  27340. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  27341. /**
  27342. * Called by the particle System when the position is computed for the created particle.
  27343. * @param worldMatrix is the world matrix of the particle system
  27344. * @param positionToUpdate is the position vector to update with the result
  27345. * @param particle is the particle we are computed the position for
  27346. */
  27347. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  27348. /**
  27349. * Clones the current emitter and returns a copy of it
  27350. * @returns the new emitter
  27351. */
  27352. clone(): BoxParticleEmitter;
  27353. /**
  27354. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  27355. * @param effect defines the update shader
  27356. */
  27357. applyToShader(effect: Effect): void;
  27358. /**
  27359. * Returns a string to use to update the GPU particles update shader
  27360. * @returns a string containng the defines string
  27361. */
  27362. getEffectDefines(): string;
  27363. /**
  27364. * Returns the string "BoxEmitter"
  27365. * @returns a string containing the class name
  27366. */
  27367. getClassName(): string;
  27368. /**
  27369. * Serializes the particle system to a JSON object.
  27370. * @returns the JSON object
  27371. */
  27372. serialize(): any;
  27373. /**
  27374. * Parse properties from a JSON object
  27375. * @param serializationObject defines the JSON object
  27376. */
  27377. parse(serializationObject: any): void;
  27378. }
  27379. }
  27380. declare module BABYLON {
  27381. /**
  27382. * Particle emitter emitting particles from the inside of a cone.
  27383. * It emits the particles alongside the cone volume from the base to the particle.
  27384. * The emission direction might be randomized.
  27385. */
  27386. class ConeParticleEmitter implements IParticleEmitterType {
  27387. /**
  27388. * The radius of the emission cone.
  27389. */
  27390. angle: number;
  27391. /**
  27392. * The cone base angle.
  27393. */
  27394. directionRandomizer: number;
  27395. private _radius;
  27396. private _height;
  27397. /**
  27398. * Gets the radius of the emission cone.
  27399. */
  27400. /**
  27401. * Sets the radius of the emission cone.
  27402. */
  27403. radius: number;
  27404. /**
  27405. * Creates a new instance of @see ConeParticleEmitter
  27406. * @param radius the radius of the emission cone (1 by default)
  27407. * @param angles the cone base angle (PI by default)
  27408. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  27409. */
  27410. constructor(radius?: number,
  27411. /**
  27412. * The radius of the emission cone.
  27413. */
  27414. angle?: number,
  27415. /**
  27416. * The cone base angle.
  27417. */
  27418. directionRandomizer?: number);
  27419. /**
  27420. * Called by the particle System when the direction is computed for the created particle.
  27421. * @param emitPower is the power of the particle (speed)
  27422. * @param worldMatrix is the world matrix of the particle system
  27423. * @param directionToUpdate is the direction vector to update with the result
  27424. * @param particle is the particle we are computed the direction for
  27425. */
  27426. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  27427. /**
  27428. * Called by the particle System when the position is computed for the created particle.
  27429. * @param worldMatrix is the world matrix of the particle system
  27430. * @param positionToUpdate is the position vector to update with the result
  27431. * @param particle is the particle we are computed the position for
  27432. */
  27433. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  27434. /**
  27435. * Clones the current emitter and returns a copy of it
  27436. * @returns the new emitter
  27437. */
  27438. clone(): ConeParticleEmitter;
  27439. /**
  27440. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  27441. * @param effect defines the update shader
  27442. */
  27443. applyToShader(effect: Effect): void;
  27444. /**
  27445. * Returns a string to use to update the GPU particles update shader
  27446. * @returns a string containng the defines string
  27447. */
  27448. getEffectDefines(): string;
  27449. /**
  27450. * Returns the string "BoxEmitter"
  27451. * @returns a string containing the class name
  27452. */
  27453. getClassName(): string;
  27454. /**
  27455. * Serializes the particle system to a JSON object.
  27456. * @returns the JSON object
  27457. */
  27458. serialize(): any;
  27459. /**
  27460. * Parse properties from a JSON object
  27461. * @param serializationObject defines the JSON object
  27462. */
  27463. parse(serializationObject: any): void;
  27464. }
  27465. }
  27466. declare module BABYLON {
  27467. /**
  27468. * Particle emitter represents a volume emitting particles.
  27469. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  27470. */
  27471. interface IParticleEmitterType {
  27472. /**
  27473. * Called by the particle System when the direction is computed for the created particle.
  27474. * @param emitPower is the power of the particle (speed)
  27475. * @param worldMatrix is the world matrix of the particle system
  27476. * @param directionToUpdate is the direction vector to update with the result
  27477. * @param particle is the particle we are computed the direction for
  27478. */
  27479. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  27480. /**
  27481. * Called by the particle System when the position is computed for the created particle.
  27482. * @param worldMatrix is the world matrix of the particle system
  27483. * @param positionToUpdate is the position vector to update with the result
  27484. * @param particle is the particle we are computed the position for
  27485. */
  27486. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  27487. /**
  27488. * Clones the current emitter and returns a copy of it
  27489. * @returns the new emitter
  27490. */
  27491. clone(): IParticleEmitterType;
  27492. /**
  27493. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  27494. * @param effect defines the update shader
  27495. */
  27496. applyToShader(effect: Effect): void;
  27497. /**
  27498. * Returns a string to use to update the GPU particles update shader
  27499. * @returns the effect defines string
  27500. */
  27501. getEffectDefines(): string;
  27502. /**
  27503. * Returns a string representing the class name
  27504. * @returns a string containing the class name
  27505. */
  27506. getClassName(): string;
  27507. /**
  27508. * Serializes the particle system to a JSON object.
  27509. * @returns the JSON object
  27510. */
  27511. serialize(): any;
  27512. /**
  27513. * Parse properties from a JSON object
  27514. * @param serializationObject defines the JSON object
  27515. */
  27516. parse(serializationObject: any): void;
  27517. }
  27518. }
  27519. declare module BABYLON {
  27520. /**
  27521. * Particle emitter emitting particles from the inside of a sphere.
  27522. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  27523. */
  27524. class SphereParticleEmitter implements IParticleEmitterType {
  27525. /**
  27526. * The radius of the emission sphere.
  27527. */
  27528. radius: number;
  27529. /**
  27530. * How much to randomize the particle direction [0-1].
  27531. */
  27532. directionRandomizer: number;
  27533. /**
  27534. * Creates a new instance of @see SphereParticleEmitter
  27535. * @param radius the radius of the emission sphere (1 by default)
  27536. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  27537. */
  27538. constructor(
  27539. /**
  27540. * The radius of the emission sphere.
  27541. */
  27542. radius?: number,
  27543. /**
  27544. * How much to randomize the particle direction [0-1].
  27545. */
  27546. directionRandomizer?: number);
  27547. /**
  27548. * Called by the particle System when the direction is computed for the created particle.
  27549. * @param emitPower is the power of the particle (speed)
  27550. * @param worldMatrix is the world matrix of the particle system
  27551. * @param directionToUpdate is the direction vector to update with the result
  27552. * @param particle is the particle we are computed the direction for
  27553. */
  27554. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  27555. /**
  27556. * Called by the particle System when the position is computed for the created particle.
  27557. * @param worldMatrix is the world matrix of the particle system
  27558. * @param positionToUpdate is the position vector to update with the result
  27559. * @param particle is the particle we are computed the position for
  27560. */
  27561. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  27562. /**
  27563. * Clones the current emitter and returns a copy of it
  27564. * @returns the new emitter
  27565. */
  27566. clone(): SphereParticleEmitter;
  27567. /**
  27568. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  27569. * @param effect defines the update shader
  27570. */
  27571. applyToShader(effect: Effect): void;
  27572. /**
  27573. * Returns a string to use to update the GPU particles update shader
  27574. * @returns a string containng the defines string
  27575. */
  27576. getEffectDefines(): string;
  27577. /**
  27578. * Returns the string "SphereParticleEmitter"
  27579. * @returns a string containing the class name
  27580. */
  27581. getClassName(): string;
  27582. /**
  27583. * Serializes the particle system to a JSON object.
  27584. * @returns the JSON object
  27585. */
  27586. serialize(): any;
  27587. /**
  27588. * Parse properties from a JSON object
  27589. * @param serializationObject defines the JSON object
  27590. */
  27591. parse(serializationObject: any): void;
  27592. }
  27593. /**
  27594. * Particle emitter emitting particles from the inside of a sphere.
  27595. * It emits the particles randomly between two vectors.
  27596. */
  27597. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  27598. /**
  27599. * The min limit of the emission direction.
  27600. */
  27601. direction1: Vector3;
  27602. /**
  27603. * The max limit of the emission direction.
  27604. */
  27605. direction2: Vector3;
  27606. /**
  27607. * Creates a new instance of @see SphereDirectedParticleEmitter
  27608. * @param radius the radius of the emission sphere (1 by default)
  27609. * @param direction1 the min limit of the emission direction (up vector by default)
  27610. * @param direction2 the max limit of the emission direction (up vector by default)
  27611. */
  27612. constructor(radius?: number,
  27613. /**
  27614. * The min limit of the emission direction.
  27615. */
  27616. direction1?: Vector3,
  27617. /**
  27618. * The max limit of the emission direction.
  27619. */
  27620. direction2?: Vector3);
  27621. /**
  27622. * Called by the particle System when the direction is computed for the created particle.
  27623. * @param emitPower is the power of the particle (speed)
  27624. * @param worldMatrix is the world matrix of the particle system
  27625. * @param directionToUpdate is the direction vector to update with the result
  27626. * @param particle is the particle we are computed the direction for
  27627. */
  27628. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  27629. /**
  27630. * Clones the current emitter and returns a copy of it
  27631. * @returns the new emitter
  27632. */
  27633. clone(): SphereDirectedParticleEmitter;
  27634. /**
  27635. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  27636. * @param effect defines the update shader
  27637. */
  27638. applyToShader(effect: Effect): void;
  27639. /**
  27640. * Returns a string to use to update the GPU particles update shader
  27641. * @returns a string containng the defines string
  27642. */
  27643. getEffectDefines(): string;
  27644. /**
  27645. * Returns the string "SphereDirectedParticleEmitter"
  27646. * @returns a string containing the class name
  27647. */
  27648. getClassName(): string;
  27649. /**
  27650. * Serializes the particle system to a JSON object.
  27651. * @returns the JSON object
  27652. */
  27653. serialize(): any;
  27654. /**
  27655. * Parse properties from a JSON object
  27656. * @param serializationObject defines the JSON object
  27657. */
  27658. parse(serializationObject: any): void;
  27659. }
  27660. }
  27661. declare var DracoDecoderModule: any;
  27662. declare module BABYLON {
  27663. /**
  27664. * Draco compression (https://google.github.io/draco/)
  27665. */
  27666. class DracoCompression implements IDisposable {
  27667. private _workerPool;
  27668. /**
  27669. * Gets the url to the draco decoder if available.
  27670. */
  27671. static DecoderUrl: Nullable<string>;
  27672. /**
  27673. * Constructor
  27674. * @param numWorkers The number of workers for async operations
  27675. */
  27676. constructor(numWorkers?: number);
  27677. /**
  27678. * Stop all async operations and release resources.
  27679. */
  27680. dispose(): void;
  27681. /**
  27682. * Decode Draco compressed mesh data to vertex data.
  27683. * @param data The array buffer view for the Draco compression data
  27684. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  27685. * @returns A promise that resolves with the decoded vertex data
  27686. */
  27687. decodeMeshAsync(data: ArrayBufferView, attributes: {
  27688. [kind: string]: number;
  27689. }): Promise<VertexData>;
  27690. /**
  27691. * The worker function that gets converted to a blob url to pass into a worker.
  27692. */
  27693. private static _Worker();
  27694. private static _GetDefaultDecoderUrl();
  27695. }
  27696. }
  27697. declare module BABYLON {
  27698. class CannonJSPlugin implements IPhysicsEnginePlugin {
  27699. private _useDeltaForWorldStep;
  27700. world: any;
  27701. name: string;
  27702. private _physicsMaterials;
  27703. private _fixedTimeStep;
  27704. BJSCANNON: any;
  27705. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  27706. setGravity(gravity: Vector3): void;
  27707. setTimeStep(timeStep: number): void;
  27708. getTimeStep(): number;
  27709. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27710. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27711. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27712. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27713. private _processChildMeshes(mainImpostor);
  27714. removePhysicsBody(impostor: PhysicsImpostor): void;
  27715. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  27716. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  27717. private _addMaterial(name, friction, restitution);
  27718. private _checkWithEpsilon(value);
  27719. private _createShape(impostor);
  27720. private _createHeightmap(object, pointDepth?);
  27721. private _minus90X;
  27722. private _plus90X;
  27723. private _tmpPosition;
  27724. private _tmpDeltaPosition;
  27725. private _tmpUnityRotation;
  27726. private _updatePhysicsBodyTransformation(impostor);
  27727. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27728. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27729. isSupported(): boolean;
  27730. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  27731. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  27732. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27733. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27734. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27735. getBodyMass(impostor: PhysicsImpostor): number;
  27736. getBodyFriction(impostor: PhysicsImpostor): number;
  27737. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27738. getBodyRestitution(impostor: PhysicsImpostor): number;
  27739. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27740. sleepBody(impostor: PhysicsImpostor): void;
  27741. wakeUpBody(impostor: PhysicsImpostor): void;
  27742. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27743. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  27744. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  27745. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27746. getRadius(impostor: PhysicsImpostor): number;
  27747. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27748. dispose(): void;
  27749. private _extendNamespace();
  27750. }
  27751. }
  27752. declare module BABYLON {
  27753. class OimoJSPlugin implements IPhysicsEnginePlugin {
  27754. world: any;
  27755. name: string;
  27756. BJSOIMO: any;
  27757. constructor(iterations?: number);
  27758. setGravity(gravity: Vector3): void;
  27759. setTimeStep(timeStep: number): void;
  27760. getTimeStep(): number;
  27761. private _tmpImpostorsArray;
  27762. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27763. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27764. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27765. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27766. private _tmpPositionVector;
  27767. removePhysicsBody(impostor: PhysicsImpostor): void;
  27768. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  27769. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  27770. isSupported(): boolean;
  27771. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27772. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27773. private _getLastShape(body);
  27774. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  27775. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  27776. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27777. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27778. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27779. getBodyMass(impostor: PhysicsImpostor): number;
  27780. getBodyFriction(impostor: PhysicsImpostor): number;
  27781. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27782. getBodyRestitution(impostor: PhysicsImpostor): number;
  27783. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27784. sleepBody(impostor: PhysicsImpostor): void;
  27785. wakeUpBody(impostor: PhysicsImpostor): void;
  27786. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27787. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27788. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27789. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27790. getRadius(impostor: PhysicsImpostor): number;
  27791. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27792. dispose(): void;
  27793. }
  27794. }
  27795. declare module BABYLON {
  27796. /**
  27797. * This represents a set of one or more post processes in Babylon.
  27798. * A post process can be used to apply a shader to a texture after it is rendered.
  27799. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  27800. */
  27801. class PostProcessRenderEffect {
  27802. private _postProcesses;
  27803. private _getPostProcesses;
  27804. private _singleInstance;
  27805. private _cameras;
  27806. private _indicesForCamera;
  27807. /**
  27808. * Name of the effect
  27809. */
  27810. _name: string;
  27811. /**
  27812. * Instantiates a post process render effect.
  27813. * A post process can be used to apply a shader to a texture after it is rendered.
  27814. * @param engine The engine the effect is tied to
  27815. * @param name The name of the effect
  27816. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  27817. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  27818. */
  27819. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  27820. /**
  27821. * Checks if all the post processes in the effect are supported.
  27822. */
  27823. readonly isSupported: boolean;
  27824. /**
  27825. * Updates the current state of the effect
  27826. */
  27827. _update(): void;
  27828. /**
  27829. * Attaches the effect on cameras
  27830. * @param cameras The camera to attach to.
  27831. */
  27832. _attachCameras(cameras: Camera): void;
  27833. /**
  27834. * Attaches the effect on cameras
  27835. * @param cameras The camera to attach to.
  27836. */
  27837. _attachCameras(cameras: Camera[]): void;
  27838. /**
  27839. * Detatches the effect on cameras
  27840. * @param cameras The camera to detatch from.
  27841. */
  27842. _detachCameras(cameras: Camera): void;
  27843. /**
  27844. * Detatches the effect on cameras
  27845. * @param cameras The camera to detatch from.
  27846. */
  27847. _detachCameras(cameras: Camera[]): void;
  27848. /**
  27849. * Enables the effect on given cameras
  27850. * @param cameras The camera to enable.
  27851. */
  27852. _enable(cameras: Camera): void;
  27853. /**
  27854. * Enables the effect on given cameras
  27855. * @param cameras The camera to enable.
  27856. */
  27857. _enable(cameras: Nullable<Camera[]>): void;
  27858. /**
  27859. * Disables the effect on the given cameras
  27860. * @param cameras The camera to disable.
  27861. */
  27862. _disable(cameras: Camera): void;
  27863. /**
  27864. * Disables the effect on the given cameras
  27865. * @param cameras The camera to disable.
  27866. */
  27867. _disable(cameras: Nullable<Camera[]>): void;
  27868. /**
  27869. * Gets a list of the post processes contained in the effect.
  27870. * @param camera The camera to get the post processes on.
  27871. * @returns The list of the post processes in the effect.
  27872. */
  27873. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  27874. }
  27875. }
  27876. declare module BABYLON {
  27877. class PostProcessRenderPipeline {
  27878. private engine;
  27879. private _renderEffects;
  27880. private _renderEffectsForIsolatedPass;
  27881. protected _cameras: Camera[];
  27882. _name: string;
  27883. constructor(engine: Engine, name: string);
  27884. getClassName(): string;
  27885. readonly isSupported: boolean;
  27886. addEffect(renderEffect: PostProcessRenderEffect): void;
  27887. _rebuild(): void;
  27888. _enableEffect(renderEffectName: string, cameras: Camera): void;
  27889. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  27890. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  27891. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  27892. _attachCameras(cameras: Camera, unique: boolean): void;
  27893. _attachCameras(cameras: Camera[], unique: boolean): void;
  27894. _detachCameras(cameras: Camera): void;
  27895. _detachCameras(cameras: Nullable<Camera[]>): void;
  27896. _update(): void;
  27897. _reset(): void;
  27898. protected _enableMSAAOnFirstPostProcess(): boolean;
  27899. dispose(): void;
  27900. }
  27901. }
  27902. declare module BABYLON {
  27903. class PostProcessRenderPipelineManager {
  27904. private _renderPipelines;
  27905. constructor();
  27906. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  27907. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  27908. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  27909. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  27910. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  27911. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  27912. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  27913. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  27914. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  27915. update(): void;
  27916. _rebuild(): void;
  27917. dispose(): void;
  27918. }
  27919. }
  27920. declare module BABYLON {
  27921. /**
  27922. * Helper class dealing with the extraction of spherical polynomial dataArray
  27923. * from a cube map.
  27924. */
  27925. class CubeMapToSphericalPolynomialTools {
  27926. private static FileFaces;
  27927. /**
  27928. * Converts a texture to the according Spherical Polynomial data.
  27929. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27930. *
  27931. * @param texture The texture to extract the information from.
  27932. * @return The Spherical Polynomial data.
  27933. */
  27934. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27935. /**
  27936. * Converts a cubemap to the according Spherical Polynomial data.
  27937. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27938. *
  27939. * @param cubeInfo The Cube map to extract the information from.
  27940. * @return The Spherical Polynomial data.
  27941. */
  27942. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27943. }
  27944. }
  27945. declare module BABYLON {
  27946. /**
  27947. * Header information of HDR texture files.
  27948. */
  27949. interface HDRInfo {
  27950. /**
  27951. * The height of the texture in pixels.
  27952. */
  27953. height: number;
  27954. /**
  27955. * The width of the texture in pixels.
  27956. */
  27957. width: number;
  27958. /**
  27959. * The index of the beginning of the data in the binary file.
  27960. */
  27961. dataPosition: number;
  27962. }
  27963. /**
  27964. * This groups tools to convert HDR texture to native colors array.
  27965. */
  27966. class HDRTools {
  27967. private static Ldexp(mantissa, exponent);
  27968. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  27969. private static readStringLine(uint8array, startIndex);
  27970. /**
  27971. * Reads header information from an RGBE texture stored in a native array.
  27972. * More information on this format are available here:
  27973. * https://en.wikipedia.org/wiki/RGBE_image_format
  27974. *
  27975. * @param uint8array The binary file stored in native array.
  27976. * @return The header information.
  27977. */
  27978. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  27979. /**
  27980. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  27981. * This RGBE texture needs to store the information as a panorama.
  27982. *
  27983. * More information on this format are available here:
  27984. * https://en.wikipedia.org/wiki/RGBE_image_format
  27985. *
  27986. * @param buffer The binary file stored in an array buffer.
  27987. * @param size The expected size of the extracted cubemap.
  27988. * @return The Cube Map information.
  27989. */
  27990. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  27991. /**
  27992. * Returns the pixels data extracted from an RGBE texture.
  27993. * This pixels will be stored left to right up to down in the R G B order in one array.
  27994. *
  27995. * More information on this format are available here:
  27996. * https://en.wikipedia.org/wiki/RGBE_image_format
  27997. *
  27998. * @param uint8array The binary file stored in an array buffer.
  27999. * @param hdrInfo The header information of the file.
  28000. * @return The pixels data in RGB right to left up to down order.
  28001. */
  28002. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  28003. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  28004. }
  28005. }
  28006. declare module BABYLON {
  28007. /**
  28008. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28009. */
  28010. interface CubeMapInfo {
  28011. /**
  28012. * The pixel array for the front face.
  28013. * This is stored in format, left to right, up to down format.
  28014. */
  28015. front: Nullable<ArrayBufferView>;
  28016. /**
  28017. * The pixel array for the back face.
  28018. * This is stored in format, left to right, up to down format.
  28019. */
  28020. back: Nullable<ArrayBufferView>;
  28021. /**
  28022. * The pixel array for the left face.
  28023. * This is stored in format, left to right, up to down format.
  28024. */
  28025. left: Nullable<ArrayBufferView>;
  28026. /**
  28027. * The pixel array for the right face.
  28028. * This is stored in format, left to right, up to down format.
  28029. */
  28030. right: Nullable<ArrayBufferView>;
  28031. /**
  28032. * The pixel array for the up face.
  28033. * This is stored in format, left to right, up to down format.
  28034. */
  28035. up: Nullable<ArrayBufferView>;
  28036. /**
  28037. * The pixel array for the down face.
  28038. * This is stored in format, left to right, up to down format.
  28039. */
  28040. down: Nullable<ArrayBufferView>;
  28041. /**
  28042. * The size of the cubemap stored.
  28043. *
  28044. * Each faces will be size * size pixels.
  28045. */
  28046. size: number;
  28047. /**
  28048. * The format of the texture.
  28049. *
  28050. * RGBA, RGB.
  28051. */
  28052. format: number;
  28053. /**
  28054. * The type of the texture data.
  28055. *
  28056. * UNSIGNED_INT, FLOAT.
  28057. */
  28058. type: number;
  28059. /**
  28060. * Specifies whether the texture is in gamma space.
  28061. */
  28062. gammaSpace: boolean;
  28063. }
  28064. /**
  28065. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  28066. */
  28067. class PanoramaToCubeMapTools {
  28068. private static FACE_FRONT;
  28069. private static FACE_BACK;
  28070. private static FACE_RIGHT;
  28071. private static FACE_LEFT;
  28072. private static FACE_DOWN;
  28073. private static FACE_UP;
  28074. /**
  28075. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28076. *
  28077. * @param float32Array The source data.
  28078. * @param inputWidth The width of the input panorama.
  28079. * @param inputhHeight The height of the input panorama.
  28080. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28081. * @return The cubemap data
  28082. */
  28083. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28084. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  28085. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  28086. }
  28087. }
  28088. declare module BABYLON {
  28089. class CustomProceduralTexture extends ProceduralTexture {
  28090. private _animate;
  28091. private _time;
  28092. private _config;
  28093. private _texturePath;
  28094. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  28095. private loadJson(jsonUrl);
  28096. isReady(): boolean;
  28097. render(useCameraPostProcess?: boolean): void;
  28098. updateTextures(): void;
  28099. updateShaderUniforms(): void;
  28100. animate: boolean;
  28101. }
  28102. }
  28103. declare module BABYLON {
  28104. class ProceduralTexture extends Texture {
  28105. isCube: boolean;
  28106. private _size;
  28107. _generateMipMaps: boolean;
  28108. isEnabled: boolean;
  28109. private _currentRefreshId;
  28110. private _refreshRate;
  28111. onGenerated: () => void;
  28112. private _vertexBuffers;
  28113. private _indexBuffer;
  28114. private _effect;
  28115. private _uniforms;
  28116. private _samplers;
  28117. private _fragment;
  28118. _textures: {
  28119. [key: string]: Texture;
  28120. };
  28121. private _floats;
  28122. private _floatsArrays;
  28123. private _colors3;
  28124. private _colors4;
  28125. private _vectors2;
  28126. private _vectors3;
  28127. private _matrices;
  28128. private _fallbackTexture;
  28129. private _fallbackTextureUsed;
  28130. private _engine;
  28131. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  28132. private _createIndexBuffer();
  28133. _rebuild(): void;
  28134. reset(): void;
  28135. isReady(): boolean;
  28136. resetRefreshCounter(): void;
  28137. setFragment(fragment: any): void;
  28138. refreshRate: number;
  28139. _shouldRender(): boolean;
  28140. getRenderSize(): number;
  28141. resize(size: number, generateMipMaps: boolean): void;
  28142. private _checkUniform(uniformName);
  28143. setTexture(name: string, texture: Texture): ProceduralTexture;
  28144. setFloat(name: string, value: number): ProceduralTexture;
  28145. setFloats(name: string, value: number[]): ProceduralTexture;
  28146. setColor3(name: string, value: Color3): ProceduralTexture;
  28147. setColor4(name: string, value: Color4): ProceduralTexture;
  28148. setVector2(name: string, value: Vector2): ProceduralTexture;
  28149. setVector3(name: string, value: Vector3): ProceduralTexture;
  28150. setMatrix(name: string, value: Matrix): ProceduralTexture;
  28151. render(useCameraPostProcess?: boolean): void;
  28152. clone(): ProceduralTexture;
  28153. dispose(): void;
  28154. }
  28155. }
  28156. declare module BABYLON {
  28157. /**
  28158. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  28159. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  28160. */
  28161. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  28162. private _scene;
  28163. /**
  28164. * ID of the sharpen post process,
  28165. */
  28166. readonly SharpenPostProcessId: string;
  28167. /**
  28168. * ID of the pass post process used for bloom,
  28169. */
  28170. readonly PassPostProcessId: string;
  28171. /**
  28172. * ID of the highlight post process used for bloom,
  28173. */
  28174. readonly HighLightsPostProcessId: string;
  28175. /**
  28176. * ID of the blurX post process used for bloom,
  28177. */
  28178. readonly BlurXPostProcessId: string;
  28179. /**
  28180. * ID of the blurY post process used for bloom,
  28181. */
  28182. readonly BlurYPostProcessId: string;
  28183. /**
  28184. * ID of the copy back post process used for bloom,
  28185. */
  28186. readonly CopyBackPostProcessId: string;
  28187. /**
  28188. * ID of the image processing post process;
  28189. */
  28190. readonly ImageProcessingPostProcessId: string;
  28191. /**
  28192. * ID of the Fast Approximate Anti-Aliasing post process;
  28193. */
  28194. readonly FxaaPostProcessId: string;
  28195. /**
  28196. * ID of the final merge post process;
  28197. */
  28198. readonly FinalMergePostProcessId: string;
  28199. /**
  28200. * ID of the chromatic aberration post process,
  28201. */
  28202. readonly ChromaticAberrationPostProcessId: string;
  28203. /**
  28204. * Sharpen post process which will apply a sharpen convolution to enhance edges
  28205. */
  28206. sharpen: SharpenPostProcess;
  28207. /**
  28208. * First pass of bloom to capture the original image texture for later use.
  28209. */
  28210. pass: PassPostProcess;
  28211. /**
  28212. * Second pass of bloom used to brighten bright portions of the image.
  28213. */
  28214. highlights: HighlightsPostProcess;
  28215. /**
  28216. * BlurX post process used in coordination with blurY to guassian blur the highlighted image.
  28217. */
  28218. blurX: BlurPostProcess;
  28219. /**
  28220. * BlurY post process used in coordination with blurX to guassian blur the highlighted image.
  28221. */
  28222. blurY: BlurPostProcess;
  28223. /**
  28224. * Final pass run for bloom to copy the resulting bloom texture back to screen.
  28225. */
  28226. copyBack: PassPostProcess;
  28227. /**
  28228. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  28229. */
  28230. depthOfField: DepthOfFieldEffect;
  28231. /**
  28232. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  28233. */
  28234. fxaa: FxaaPostProcess;
  28235. /**
  28236. * Image post processing pass used to perform operations such as tone mapping or color grading.
  28237. */
  28238. imageProcessing: ImageProcessingPostProcess;
  28239. /**
  28240. * Final post process to merge results of all previous passes
  28241. */
  28242. finalMerge: PassPostProcess;
  28243. /**
  28244. * Chromatic aberration post process which will shift rgb colors in the image
  28245. */
  28246. chromaticAberration: ChromaticAberrationPostProcess;
  28247. /**
  28248. * Animations which can be used to tweak settings over a period of time
  28249. */
  28250. animations: Animation[];
  28251. private _sharpenEnabled;
  28252. private _bloomEnabled;
  28253. private _depthOfFieldEnabled;
  28254. private _depthOfFieldBlurLevel;
  28255. private _fxaaEnabled;
  28256. private _msaaEnabled;
  28257. private _imageProcessingEnabled;
  28258. private _defaultPipelineTextureType;
  28259. private _bloomScale;
  28260. private _chromaticAberrationEnabled;
  28261. private _buildAllowed;
  28262. /**
  28263. * Enable or disable the sharpen process from the pipeline
  28264. */
  28265. sharpenEnabled: boolean;
  28266. /**
  28267. * Specifies the size of the bloom blur kernel, relative to the final output size
  28268. */
  28269. bloomKernel: number;
  28270. /**
  28271. * Specifies the weight of the bloom in the final rendering
  28272. */
  28273. private _bloomWeight;
  28274. private _hdr;
  28275. /**
  28276. * The strength of the bloom.
  28277. */
  28278. bloomWeight: number;
  28279. /**
  28280. * The scale of the bloom, lower value will provide better performance.
  28281. */
  28282. bloomScale: number;
  28283. /**
  28284. * Enable or disable the bloom from the pipeline
  28285. */
  28286. bloomEnabled: boolean;
  28287. /**
  28288. * If the depth of field is enabled.
  28289. */
  28290. depthOfFieldEnabled: boolean;
  28291. /**
  28292. * Blur level of the depth of field effect. (Higher blur will effect performance)
  28293. */
  28294. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  28295. /**
  28296. * If the anti aliasing is enabled.
  28297. */
  28298. fxaaEnabled: boolean;
  28299. /**
  28300. * If the multisample anti-aliasing is enabled.
  28301. */
  28302. msaaEnabled: boolean;
  28303. /**
  28304. * If image processing is enabled.
  28305. */
  28306. imageProcessingEnabled: boolean;
  28307. /**
  28308. * Enable or disable the chromaticAberration process from the pipeline
  28309. */
  28310. chromaticAberrationEnabled: boolean;
  28311. /**
  28312. * @constructor
  28313. * @param {string} name - The rendering pipeline name
  28314. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  28315. * @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)
  28316. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  28317. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
  28318. */
  28319. constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild?: boolean);
  28320. /**
  28321. * Force the compilation of the entire pipeline.
  28322. */
  28323. prepare(): void;
  28324. private _buildPipeline();
  28325. private _disposePostProcesses();
  28326. /**
  28327. * Dispose of the pipeline and stop all post processes
  28328. */
  28329. dispose(): void;
  28330. /**
  28331. * Serialize the rendering pipeline (Used when exporting)
  28332. * @returns the serialized object
  28333. */
  28334. serialize(): any;
  28335. /**
  28336. * Parse the serialized pipeline
  28337. * @param source Source pipeline.
  28338. * @param scene The scene to load the pipeline to.
  28339. * @param rootUrl The URL of the serialized pipeline.
  28340. * @returns An instantiated pipeline from the serialized object.
  28341. */
  28342. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  28343. }
  28344. }
  28345. declare module BABYLON {
  28346. class LensRenderingPipeline extends PostProcessRenderPipeline {
  28347. /**
  28348. * The chromatic aberration PostProcess id in the pipeline
  28349. * @type {string}
  28350. */
  28351. LensChromaticAberrationEffect: string;
  28352. /**
  28353. * The highlights enhancing PostProcess id in the pipeline
  28354. * @type {string}
  28355. */
  28356. HighlightsEnhancingEffect: string;
  28357. /**
  28358. * The depth-of-field PostProcess id in the pipeline
  28359. * @type {string}
  28360. */
  28361. LensDepthOfFieldEffect: string;
  28362. private _scene;
  28363. private _depthTexture;
  28364. private _grainTexture;
  28365. private _chromaticAberrationPostProcess;
  28366. private _highlightsPostProcess;
  28367. private _depthOfFieldPostProcess;
  28368. private _edgeBlur;
  28369. private _grainAmount;
  28370. private _chromaticAberration;
  28371. private _distortion;
  28372. private _highlightsGain;
  28373. private _highlightsThreshold;
  28374. private _dofDistance;
  28375. private _dofAperture;
  28376. private _dofDarken;
  28377. private _dofPentagon;
  28378. private _blurNoise;
  28379. /**
  28380. * @constructor
  28381. *
  28382. * Effect parameters are as follow:
  28383. * {
  28384. * chromatic_aberration: number; // from 0 to x (1 for realism)
  28385. * edge_blur: number; // from 0 to x (1 for realism)
  28386. * distortion: number; // from 0 to x (1 for realism)
  28387. * grain_amount: number; // from 0 to 1
  28388. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  28389. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  28390. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  28391. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  28392. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  28393. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  28394. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  28395. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  28396. * }
  28397. * Note: if an effect parameter is unset, effect is disabled
  28398. *
  28399. * @param {string} name - The rendering pipeline name
  28400. * @param {object} parameters - An object containing all parameters (see above)
  28401. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  28402. * @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)
  28403. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  28404. */
  28405. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  28406. setEdgeBlur(amount: number): void;
  28407. disableEdgeBlur(): void;
  28408. setGrainAmount(amount: number): void;
  28409. disableGrain(): void;
  28410. setChromaticAberration(amount: number): void;
  28411. disableChromaticAberration(): void;
  28412. setEdgeDistortion(amount: number): void;
  28413. disableEdgeDistortion(): void;
  28414. setFocusDistance(amount: number): void;
  28415. disableDepthOfField(): void;
  28416. setAperture(amount: number): void;
  28417. setDarkenOutOfFocus(amount: number): void;
  28418. enablePentagonBokeh(): void;
  28419. disablePentagonBokeh(): void;
  28420. enableNoiseBlur(): void;
  28421. disableNoiseBlur(): void;
  28422. setHighlightsGain(amount: number): void;
  28423. setHighlightsThreshold(amount: number): void;
  28424. disableHighlights(): void;
  28425. /**
  28426. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  28427. */
  28428. dispose(disableDepthRender?: boolean): void;
  28429. private _createChromaticAberrationPostProcess(ratio);
  28430. private _createHighlightsPostProcess(ratio);
  28431. private _createDepthOfFieldPostProcess(ratio);
  28432. private _createGrainTexture();
  28433. }
  28434. }
  28435. declare module BABYLON {
  28436. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  28437. /**
  28438. * The PassPostProcess id in the pipeline that contains the original scene color
  28439. * @type {string}
  28440. */
  28441. SSAOOriginalSceneColorEffect: string;
  28442. /**
  28443. * The SSAO PostProcess id in the pipeline
  28444. * @type {string}
  28445. */
  28446. SSAORenderEffect: string;
  28447. /**
  28448. * The horizontal blur PostProcess id in the pipeline
  28449. * @type {string}
  28450. */
  28451. SSAOBlurHRenderEffect: string;
  28452. /**
  28453. * The vertical blur PostProcess id in the pipeline
  28454. * @type {string}
  28455. */
  28456. SSAOBlurVRenderEffect: string;
  28457. /**
  28458. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  28459. * @type {string}
  28460. */
  28461. SSAOCombineRenderEffect: string;
  28462. /**
  28463. * The output strength of the SSAO post-process. Default value is 1.0.
  28464. * @type {number}
  28465. */
  28466. totalStrength: number;
  28467. /**
  28468. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  28469. * @type {number}
  28470. */
  28471. maxZ: number;
  28472. /**
  28473. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  28474. * @type {number}
  28475. */
  28476. minZAspect: number;
  28477. /**
  28478. * Number of samples used for the SSAO calculations. Default value is 8
  28479. * @type {number}
  28480. */
  28481. private _samples;
  28482. /**
  28483. * Dynamically generated sphere sampler.
  28484. * @type {number[]}
  28485. */
  28486. private _sampleSphere;
  28487. /**
  28488. * Blur filter offsets
  28489. * @type {number[]}
  28490. */
  28491. private _samplerOffsets;
  28492. samples: number;
  28493. /**
  28494. * Are we using bilateral blur ?
  28495. * @type {boolean}
  28496. */
  28497. private _expensiveBlur;
  28498. expensiveBlur: boolean;
  28499. /**
  28500. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  28501. * @type {number}
  28502. */
  28503. radius: number;
  28504. /**
  28505. * The base color of the SSAO post-process
  28506. * The final result is "base + ssao" between [0, 1]
  28507. * @type {number}
  28508. */
  28509. base: number;
  28510. /**
  28511. * Support test.
  28512. * @type {boolean}
  28513. */
  28514. static readonly IsSupported: boolean;
  28515. private _scene;
  28516. private _depthTexture;
  28517. private _normalTexture;
  28518. private _randomTexture;
  28519. private _originalColorPostProcess;
  28520. private _ssaoPostProcess;
  28521. private _blurHPostProcess;
  28522. private _blurVPostProcess;
  28523. private _ssaoCombinePostProcess;
  28524. private _firstUpdate;
  28525. /**
  28526. * @constructor
  28527. * @param {string} name - The rendering pipeline name
  28528. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  28529. * @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 }
  28530. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  28531. */
  28532. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  28533. /**
  28534. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  28535. */
  28536. dispose(disableGeometryBufferRenderer?: boolean): void;
  28537. private _createBlurPostProcess(ssaoRatio, blurRatio);
  28538. _rebuild(): void;
  28539. private _generateHemisphere();
  28540. private _createSSAOPostProcess(ratio);
  28541. private _createSSAOCombinePostProcess(ratio);
  28542. private _createRandomTexture();
  28543. }
  28544. }
  28545. declare module BABYLON {
  28546. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  28547. /**
  28548. * The PassPostProcess id in the pipeline that contains the original scene color
  28549. * @type {string}
  28550. */
  28551. SSAOOriginalSceneColorEffect: string;
  28552. /**
  28553. * The SSAO PostProcess id in the pipeline
  28554. * @type {string}
  28555. */
  28556. SSAORenderEffect: string;
  28557. /**
  28558. * The horizontal blur PostProcess id in the pipeline
  28559. * @type {string}
  28560. */
  28561. SSAOBlurHRenderEffect: string;
  28562. /**
  28563. * The vertical blur PostProcess id in the pipeline
  28564. * @type {string}
  28565. */
  28566. SSAOBlurVRenderEffect: string;
  28567. /**
  28568. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  28569. * @type {string}
  28570. */
  28571. SSAOCombineRenderEffect: string;
  28572. /**
  28573. * The output strength of the SSAO post-process. Default value is 1.0.
  28574. * @type {number}
  28575. */
  28576. totalStrength: number;
  28577. /**
  28578. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  28579. * @type {number}
  28580. */
  28581. radius: number;
  28582. /**
  28583. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  28584. * Must not be equal to fallOff and superior to fallOff.
  28585. * Default value is 0.975
  28586. * @type {number}
  28587. */
  28588. area: number;
  28589. /**
  28590. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  28591. * Must not be equal to area and inferior to area.
  28592. * Default value is 0.0
  28593. * @type {number}
  28594. */
  28595. fallOff: number;
  28596. /**
  28597. * The base color of the SSAO post-process
  28598. * The final result is "base + ssao" between [0, 1]
  28599. * @type {number}
  28600. */
  28601. base: number;
  28602. private _scene;
  28603. private _depthTexture;
  28604. private _randomTexture;
  28605. private _originalColorPostProcess;
  28606. private _ssaoPostProcess;
  28607. private _blurHPostProcess;
  28608. private _blurVPostProcess;
  28609. private _ssaoCombinePostProcess;
  28610. private _firstUpdate;
  28611. /**
  28612. * @constructor
  28613. * @param {string} name - The rendering pipeline name
  28614. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  28615. * @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 }
  28616. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  28617. */
  28618. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  28619. /**
  28620. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  28621. */
  28622. dispose(disableDepthRender?: boolean): void;
  28623. private _createBlurPostProcess(ratio);
  28624. _rebuild(): void;
  28625. private _createSSAOPostProcess(ratio);
  28626. private _createSSAOCombinePostProcess(ratio);
  28627. private _createRandomTexture();
  28628. }
  28629. }
  28630. declare module BABYLON {
  28631. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  28632. /**
  28633. * Public members
  28634. */
  28635. originalPostProcess: Nullable<PostProcess>;
  28636. downSampleX4PostProcess: Nullable<PostProcess>;
  28637. brightPassPostProcess: Nullable<PostProcess>;
  28638. blurHPostProcesses: PostProcess[];
  28639. blurVPostProcesses: PostProcess[];
  28640. textureAdderPostProcess: Nullable<PostProcess>;
  28641. volumetricLightPostProcess: Nullable<PostProcess>;
  28642. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  28643. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  28644. volumetricLightMergePostProces: Nullable<PostProcess>;
  28645. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  28646. luminancePostProcess: Nullable<PostProcess>;
  28647. luminanceDownSamplePostProcesses: PostProcess[];
  28648. hdrPostProcess: Nullable<PostProcess>;
  28649. textureAdderFinalPostProcess: Nullable<PostProcess>;
  28650. lensFlareFinalPostProcess: Nullable<PostProcess>;
  28651. hdrFinalPostProcess: Nullable<PostProcess>;
  28652. lensFlarePostProcess: Nullable<PostProcess>;
  28653. lensFlareComposePostProcess: Nullable<PostProcess>;
  28654. motionBlurPostProcess: Nullable<PostProcess>;
  28655. depthOfFieldPostProcess: Nullable<PostProcess>;
  28656. brightThreshold: number;
  28657. blurWidth: number;
  28658. horizontalBlur: boolean;
  28659. exposure: number;
  28660. lensTexture: Nullable<Texture>;
  28661. volumetricLightCoefficient: number;
  28662. volumetricLightPower: number;
  28663. volumetricLightBlurScale: number;
  28664. sourceLight: Nullable<SpotLight | DirectionalLight>;
  28665. hdrMinimumLuminance: number;
  28666. hdrDecreaseRate: number;
  28667. hdrIncreaseRate: number;
  28668. lensColorTexture: Nullable<Texture>;
  28669. lensFlareStrength: number;
  28670. lensFlareGhostDispersal: number;
  28671. lensFlareHaloWidth: number;
  28672. lensFlareDistortionStrength: number;
  28673. lensStarTexture: Nullable<Texture>;
  28674. lensFlareDirtTexture: Nullable<Texture>;
  28675. depthOfFieldDistance: number;
  28676. depthOfFieldBlurWidth: number;
  28677. motionStrength: number;
  28678. animations: Animation[];
  28679. /**
  28680. * Private members
  28681. */
  28682. private _scene;
  28683. private _currentDepthOfFieldSource;
  28684. private _basePostProcess;
  28685. private _hdrCurrentLuminance;
  28686. private _floatTextureType;
  28687. private _ratio;
  28688. private _bloomEnabled;
  28689. private _depthOfFieldEnabled;
  28690. private _vlsEnabled;
  28691. private _lensFlareEnabled;
  28692. private _hdrEnabled;
  28693. private _motionBlurEnabled;
  28694. private _motionBlurSamples;
  28695. private _volumetricLightStepsCount;
  28696. BloomEnabled: boolean;
  28697. DepthOfFieldEnabled: boolean;
  28698. LensFlareEnabled: boolean;
  28699. HDREnabled: boolean;
  28700. VLSEnabled: boolean;
  28701. MotionBlurEnabled: boolean;
  28702. volumetricLightStepsCount: number;
  28703. motionBlurSamples: number;
  28704. /**
  28705. * @constructor
  28706. * @param {string} name - The rendering pipeline name
  28707. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  28708. * @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)
  28709. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  28710. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  28711. */
  28712. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  28713. private _buildPipeline();
  28714. private _createDownSampleX4PostProcess(scene, ratio);
  28715. private _createBrightPassPostProcess(scene, ratio);
  28716. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  28717. private _createTextureAdderPostProcess(scene, ratio);
  28718. private _createVolumetricLightPostProcess(scene, ratio);
  28719. private _createLuminancePostProcesses(scene, textureType);
  28720. private _createHdrPostProcess(scene, ratio);
  28721. private _createLensFlarePostProcess(scene, ratio);
  28722. private _createDepthOfFieldPostProcess(scene, ratio);
  28723. private _createMotionBlurPostProcess(scene, ratio);
  28724. private _getDepthTexture();
  28725. private _disposePostProcesses();
  28726. dispose(): void;
  28727. serialize(): any;
  28728. /**
  28729. * Static members
  28730. */
  28731. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  28732. static LuminanceSteps: number;
  28733. }
  28734. }