babylon.d.ts 1.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074
  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: ParticleSystem[];
  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. }
  179. interface WebGLRenderingContext {
  180. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  181. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  182. vertexAttribDivisor(index: number, divisor: number): void;
  183. createVertexArray(): any;
  184. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  185. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  186. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  187. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  188. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  189. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  190. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  191. createQuery(): WebGLQuery;
  192. deleteQuery(query: WebGLQuery): void;
  193. beginQuery(target: number, query: WebGLQuery): void;
  194. endQuery(target: number): void;
  195. getQueryParameter(query: WebGLQuery, pname: number): any;
  196. getQuery(target: number, pname: number): any;
  197. MAX_SAMPLES: number;
  198. RGBA8: number;
  199. READ_FRAMEBUFFER: number;
  200. DRAW_FRAMEBUFFER: number;
  201. UNIFORM_BUFFER: number;
  202. HALF_FLOAT_OES: number;
  203. RGBA16F: number;
  204. RGBA32F: number;
  205. DEPTH24_STENCIL8: number;
  206. drawBuffers(buffers: number[]): void;
  207. readBuffer(src: number): void;
  208. readonly COLOR_ATTACHMENT0: number;
  209. readonly COLOR_ATTACHMENT1: number;
  210. readonly COLOR_ATTACHMENT2: number;
  211. readonly COLOR_ATTACHMENT3: number;
  212. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  213. ANY_SAMPLES_PASSED: number;
  214. QUERY_RESULT_AVAILABLE: number;
  215. QUERY_RESULT: number;
  216. }
  217. interface Document {
  218. mozCancelFullScreen(): void;
  219. msCancelFullScreen(): void;
  220. mozFullScreen: boolean;
  221. msIsFullScreen: boolean;
  222. fullscreen: boolean;
  223. mozPointerLockElement: HTMLElement;
  224. msPointerLockElement: HTMLElement;
  225. webkitPointerLockElement: HTMLElement;
  226. }
  227. interface HTMLCanvasElement {
  228. msRequestPointerLock?(): void;
  229. mozRequestPointerLock?(): void;
  230. webkitRequestPointerLock?(): void;
  231. }
  232. interface CanvasRenderingContext2D {
  233. msImageSmoothingEnabled: boolean;
  234. }
  235. interface WebGLBuffer {
  236. references: number;
  237. capacity: number;
  238. is32Bits: boolean;
  239. }
  240. interface WebGLProgram {
  241. transformFeedback?: WebGLTransformFeedback | null;
  242. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  243. }
  244. interface MouseEvent {
  245. mozMovementX: number;
  246. mozMovementY: number;
  247. webkitMovementX: number;
  248. webkitMovementY: number;
  249. msMovementX: number;
  250. msMovementY: number;
  251. }
  252. interface Navigator {
  253. getVRDisplays: () => any;
  254. mozGetVRDevices: (any: any) => any;
  255. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  256. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  257. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  258. webkitGetGamepads(): Gamepad[];
  259. msGetGamepads(): Gamepad[];
  260. webkitGamepads(): Gamepad[];
  261. }
  262. interface HTMLVideoElement {
  263. mozSrcObject: any;
  264. }
  265. interface Screen {
  266. orientation: string;
  267. mozOrientation: string;
  268. }
  269. interface Math {
  270. fround(x: number): number;
  271. imul(a: number, b: number): number;
  272. }
  273. interface GamepadPose {
  274. hasOrientation: boolean;
  275. hasPosition: boolean;
  276. position?: Float32Array;
  277. linearVelocity?: Float32Array;
  278. linearAcceleration?: Float32Array;
  279. orientation?: Float32Array;
  280. angularVelocity?: Float32Array;
  281. angularAcceleration?: Float32Array;
  282. }
  283. interface EXT_disjoint_timer_query {
  284. QUERY_COUNTER_BITS_EXT: number;
  285. TIME_ELAPSED_EXT: number;
  286. TIMESTAMP_EXT: number;
  287. GPU_DISJOINT_EXT: number;
  288. QUERY_RESULT_EXT: number;
  289. QUERY_RESULT_AVAILABLE_EXT: number;
  290. queryCounterEXT(query: WebGLQuery, target: number): void;
  291. createQueryEXT(): WebGLQuery;
  292. beginQueryEXT(target: number, query: WebGLQuery): void;
  293. endQueryEXT(target: number): void;
  294. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  295. deleteQueryEXT(query: WebGLQuery): void;
  296. }
  297. interface WebGLUniformLocation {
  298. _currentState: any;
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Node is the basic class for all scene objects (Mesh, Light Camera).
  303. */
  304. class Node {
  305. /**
  306. * Gets or sets the name of the node
  307. */
  308. name: string;
  309. /**
  310. * Gets or sets the id of the node
  311. */
  312. id: string;
  313. /**
  314. * Gets or sets the unique id of the node
  315. */
  316. uniqueId: number;
  317. /**
  318. * Gets or sets a string used to store user defined state for the node
  319. */
  320. state: string;
  321. /**
  322. * Gets or sets an object used to store user defined information for the node
  323. */
  324. metadata: any;
  325. /**
  326. * Gets or sets a boolean used to define if the node must be serialized
  327. */
  328. doNotSerialize: boolean;
  329. /** @ignore */
  330. _isDisposed: boolean;
  331. /**
  332. * Gets a list of {BABYLON.Animation} associated with the node
  333. */
  334. animations: Animation[];
  335. private _ranges;
  336. /**
  337. * Callback raised when the node is ready to be used
  338. */
  339. onReady: (node: Node) => void;
  340. private _isEnabled;
  341. private _isReady;
  342. /** @ignore */
  343. _currentRenderId: number;
  344. private _parentRenderId;
  345. /** @ignore */
  346. _waitingParentId: Nullable<string>;
  347. private _scene;
  348. /** @ignore */
  349. _cache: any;
  350. private _parentNode;
  351. private _children;
  352. /**
  353. * Gets a boolean indicating if the node has been disposed
  354. * @returns true if the node was disposed
  355. */
  356. isDisposed(): boolean;
  357. /**
  358. * Gets or sets the parent of the node
  359. */
  360. parent: Nullable<Node>;
  361. /**
  362. * Gets a string idenfifying the name of the class
  363. * @returns "Node" string
  364. */
  365. getClassName(): string;
  366. /**
  367. * An event triggered when the mesh is disposed
  368. * @type {BABYLON.Observable}
  369. */
  370. onDisposeObservable: Observable<Node>;
  371. private _onDisposeObserver;
  372. /**
  373. * Sets a callback that will be raised when the node will be disposed
  374. */
  375. onDispose: () => void;
  376. /**
  377. * Creates a new Node
  378. * @param {string} name - the name and id to be given to this node
  379. * @param {BABYLON.Scene} the scene this node will be added to
  380. */
  381. constructor(name: string, scene?: Nullable<Scene>);
  382. /**
  383. * Gets the scene of the node
  384. * @returns a {BABYLON.Scene}
  385. */
  386. getScene(): Scene;
  387. /**
  388. * Gets the engine of the node
  389. * @returns a {BABYLON.Engine}
  390. */
  391. getEngine(): Engine;
  392. private _behaviors;
  393. /**
  394. * Attach a behavior to the node
  395. * @see http://doc.babylonjs.com/features/behaviour
  396. * @param behavior defines the behavior to attach
  397. * @returns the current Node
  398. */
  399. addBehavior(behavior: Behavior<Node>): Node;
  400. /**
  401. * Remove an attached behavior
  402. * @see http://doc.babylonjs.com/features/behaviour
  403. * @param behavior defines the behavior to attach
  404. * @returns the current Node
  405. */
  406. removeBehavior(behavior: Behavior<Node>): Node;
  407. /**
  408. * Gets the list of attached behaviors
  409. * @see http://doc.babylonjs.com/features/behaviour
  410. */
  411. readonly behaviors: Behavior<Node>[];
  412. /**
  413. * Gets an attached behavior by name
  414. * @param name defines the name of the behavior to look for
  415. * @see http://doc.babylonjs.com/features/behaviour
  416. * @returns null if behavior was not found else the requested behavior
  417. */
  418. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  419. /**
  420. * Returns the world matrix of the node
  421. * @returns a matrix containing the node's world matrix
  422. */
  423. getWorldMatrix(): Matrix;
  424. /** @ignore */
  425. _initCache(): void;
  426. /** @ignore */
  427. updateCache(force?: boolean): void;
  428. /** @ignore */
  429. _updateCache(ignoreParentClass?: boolean): void;
  430. /** @ignore */
  431. _isSynchronized(): boolean;
  432. /** @ignore */
  433. _markSyncedWithParent(): void;
  434. /** @ignore */
  435. isSynchronizedWithParent(): boolean;
  436. /** @ignore */
  437. isSynchronized(updateCache?: boolean): boolean;
  438. /** @ignore */
  439. hasNewParent(update?: boolean): boolean;
  440. /**
  441. * Is this node ready to be used/rendered
  442. * @return true if the node is ready
  443. */
  444. isReady(): boolean;
  445. /**
  446. * Is this node enabled?
  447. * 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
  448. * @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
  449. * @return whether this node (and its parent) is enabled
  450. * @see setEnabled
  451. */
  452. isEnabled(checkAncestors?: boolean): boolean;
  453. /**
  454. * Set the enabled state of this node
  455. * @param value defines the new enabled state
  456. * @see isEnabled
  457. */
  458. setEnabled(value: boolean): void;
  459. /**
  460. * Is this node a descendant of the given node?
  461. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  462. * @param ancestor defines the parent node to inspect
  463. * @see parent
  464. * @returns a boolean indicating if this node is a descendant of the given node
  465. */
  466. isDescendantOf(ancestor: Node): boolean;
  467. /** @ignore */
  468. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  469. /**
  470. * Will return all nodes that have this node as ascendant
  471. * @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
  472. * @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
  473. * @return all children nodes of all types
  474. */
  475. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  476. /**
  477. * Get all child-meshes of this node
  478. * @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
  479. * @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
  480. * @returns an array of {BABYLON.AbstractMesh}
  481. */
  482. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  483. /**
  484. * Get all child-transformNodes of this node
  485. * @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
  486. * @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
  487. * @returns an array of {BABYLON.TransformNode}
  488. */
  489. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  490. /**
  491. * Get all direct children of this node
  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.Node}
  494. */
  495. getChildren(predicate?: (node: Node) => boolean): Node[];
  496. /** @ignore */
  497. _setReady(state: boolean): void;
  498. /**
  499. * Get an animation by name
  500. * @param name defines the name of the animation to look for
  501. * @returns null if not found else the requested animation
  502. */
  503. getAnimationByName(name: string): Nullable<Animation>;
  504. /**
  505. * Creates an animation range for this node
  506. * @param name defines the name of the range
  507. * @param from defines the starting key
  508. * @param to defines the end key
  509. */
  510. createAnimationRange(name: string, from: number, to: number): void;
  511. /**
  512. * Delete a specific animation range
  513. * @param name defines the name of the range to delete
  514. * @param deleteFrames defines if animation frames from the range must be deleted as well
  515. */
  516. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  517. /**
  518. * Get an animation range by name
  519. * @param name defines the name of the animation range to look for
  520. * @returns null if not found else the requested animation range
  521. */
  522. getAnimationRange(name: string): Nullable<AnimationRange>;
  523. /**
  524. * Will start the animation sequence
  525. * @param name defines the range frames for animation sequence
  526. * @param loop defines if the animation should loop (false by default)
  527. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  528. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  529. * @returns the object created for this animation. If range does not exist, it will return null
  530. */
  531. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  532. /**
  533. * Serialize animation ranges into a JSON compatible object
  534. * @returns serialization object
  535. */
  536. serializeAnimationRanges(): any;
  537. /**
  538. * Computes the world matrix of the node
  539. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  540. * @returns the world matrix
  541. */
  542. computeWorldMatrix(force?: boolean): Matrix;
  543. /**
  544. * Releases all associated resources
  545. */
  546. dispose(): void;
  547. /**
  548. * Parse animation range data from a serialization object and store them into a given node
  549. * @param node defines where to store the animation ranges
  550. * @param parsedNode defines the serialization object to read data from
  551. * @param scene defines the hosting scene
  552. */
  553. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  554. }
  555. }
  556. declare module BABYLON {
  557. interface IDisposable {
  558. dispose(): void;
  559. }
  560. interface IActiveMeshCandidateProvider {
  561. getMeshes(scene: Scene): AbstractMesh[];
  562. readonly checksIsEnabled: boolean;
  563. }
  564. /**
  565. * This class is used by the onRenderingGroupObservable
  566. */
  567. class RenderingGroupInfo {
  568. /**
  569. * The Scene that being rendered
  570. */
  571. scene: Scene;
  572. /**
  573. * The camera currently used for the rendering pass
  574. */
  575. camera: Nullable<Camera>;
  576. /**
  577. * The ID of the renderingGroup being processed
  578. */
  579. renderingGroupId: number;
  580. /**
  581. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  582. */
  583. renderStage: number;
  584. /**
  585. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  586. * This stage will be fired no matter what
  587. */
  588. static STAGE_PRECLEAR: number;
  589. /**
  590. * Called before opaque object are rendered.
  591. * This stage will be fired only if there's 3D Opaque content to render
  592. */
  593. static STAGE_PREOPAQUE: number;
  594. /**
  595. * Called after the opaque objects are rendered and before the transparent ones
  596. * This stage will be fired only if there's 3D transparent content to render
  597. */
  598. static STAGE_PRETRANSPARENT: number;
  599. /**
  600. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  601. * This stage will be fired no matter what
  602. */
  603. static STAGE_POSTTRANSPARENT: number;
  604. }
  605. /**
  606. * Represents a scene to be rendered by the engine.
  607. * @see http://doc.babylonjs.com/page.php?p=21911
  608. */
  609. class Scene implements IAnimatable {
  610. private static _FOGMODE_NONE;
  611. private static _FOGMODE_EXP;
  612. private static _FOGMODE_EXP2;
  613. private static _FOGMODE_LINEAR;
  614. private static _uniqueIdCounter;
  615. static MinDeltaTime: number;
  616. static MaxDeltaTime: number;
  617. /** The fog is deactivated */
  618. static readonly FOGMODE_NONE: number;
  619. /** The fog density is following an exponential function */
  620. static readonly FOGMODE_EXP: number;
  621. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  622. static readonly FOGMODE_EXP2: number;
  623. /** The fog density is following a linear function. */
  624. static readonly FOGMODE_LINEAR: number;
  625. autoClear: boolean;
  626. autoClearDepthAndStencil: boolean;
  627. clearColor: Color4;
  628. ambientColor: Color3;
  629. _environmentBRDFTexture: BaseTexture;
  630. protected _environmentTexture: BaseTexture;
  631. /**
  632. * Texture used in all pbr material as the reflection texture.
  633. * As in the majority of the scene they are the same (exception for multi room and so on),
  634. * this is easier to reference from here than from all the materials.
  635. */
  636. /**
  637. * Texture used in all pbr material as the reflection texture.
  638. * As in the majority of the scene they are the same (exception for multi room and so on),
  639. * this is easier to set here than in all the materials.
  640. */
  641. environmentTexture: BaseTexture;
  642. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  643. /**
  644. * Default image processing configuration used either in the rendering
  645. * Forward main pass or through the imageProcessingPostProcess if present.
  646. * As in the majority of the scene they are the same (exception for multi camera),
  647. * this is easier to reference from here than from all the materials and post process.
  648. *
  649. * No setter as we it is a shared configuration, you can set the values instead.
  650. */
  651. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  652. forceWireframe: boolean;
  653. private _forcePointsCloud;
  654. forcePointsCloud: boolean;
  655. forceShowBoundingBoxes: boolean;
  656. clipPlane: Nullable<Plane>;
  657. animationsEnabled: boolean;
  658. useConstantAnimationDeltaTime: boolean;
  659. constantlyUpdateMeshUnderPointer: boolean;
  660. hoverCursor: string;
  661. defaultCursor: string;
  662. /**
  663. * This is used to call preventDefault() on pointer down
  664. * in order to block unwanted artifacts like system double clicks
  665. */
  666. preventDefaultOnPointerDown: boolean;
  667. metadata: any;
  668. loadingPluginName: string;
  669. private _spritePredicate;
  670. /**
  671. * An event triggered when the scene is disposed.
  672. * @type {BABYLON.Observable}
  673. */
  674. onDisposeObservable: Observable<Scene>;
  675. private _onDisposeObserver;
  676. /** A function to be executed when this scene is disposed. */
  677. onDispose: () => void;
  678. /**
  679. * An event triggered before rendering the scene (right after animations and physics)
  680. * @type {BABYLON.Observable}
  681. */
  682. onBeforeRenderObservable: Observable<Scene>;
  683. private _onBeforeRenderObserver;
  684. /** A function to be executed before rendering this scene */
  685. beforeRender: Nullable<() => void>;
  686. /**
  687. * An event triggered after rendering the scene
  688. * @type {BABYLON.Observable}
  689. */
  690. onAfterRenderObservable: Observable<Scene>;
  691. private _onAfterRenderObserver;
  692. /** A function to be executed after rendering this scene */
  693. afterRender: Nullable<() => void>;
  694. /**
  695. * An event triggered before animating the scene
  696. * @type {BABYLON.Observable}
  697. */
  698. onBeforeAnimationsObservable: Observable<Scene>;
  699. /**
  700. * An event triggered after animations processing
  701. * @type {BABYLON.Observable}
  702. */
  703. onAfterAnimationsObservable: Observable<Scene>;
  704. /**
  705. * An event triggered before draw calls are ready to be sent
  706. * @type {BABYLON.Observable}
  707. */
  708. onBeforeDrawPhaseObservable: Observable<Scene>;
  709. /**
  710. * An event triggered after draw calls have been sent
  711. * @type {BABYLON.Observable}
  712. */
  713. onAfterDrawPhaseObservable: Observable<Scene>;
  714. /**
  715. * An event triggered when physic simulation is about to be run
  716. * @type {BABYLON.Observable}
  717. */
  718. onBeforePhysicsObservable: Observable<Scene>;
  719. /**
  720. * An event triggered when physic simulation has been done
  721. * @type {BABYLON.Observable}
  722. */
  723. onAfterPhysicsObservable: Observable<Scene>;
  724. /**
  725. * An event triggered when the scene is ready
  726. * @type {BABYLON.Observable}
  727. */
  728. onReadyObservable: Observable<Scene>;
  729. /**
  730. * An event triggered before rendering a camera
  731. * @type {BABYLON.Observable}
  732. */
  733. onBeforeCameraRenderObservable: Observable<Camera>;
  734. private _onBeforeCameraRenderObserver;
  735. beforeCameraRender: () => void;
  736. /**
  737. * An event triggered after rendering a camera
  738. * @type {BABYLON.Observable}
  739. */
  740. onAfterCameraRenderObservable: Observable<Camera>;
  741. private _onAfterCameraRenderObserver;
  742. afterCameraRender: () => void;
  743. /**
  744. * An event triggered when active meshes evaluation is about to start
  745. * @type {BABYLON.Observable}
  746. */
  747. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  748. /**
  749. * An event triggered when active meshes evaluation is done
  750. * @type {BABYLON.Observable}
  751. */
  752. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  753. /**
  754. * An event triggered when particles rendering is about to start
  755. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  756. * @type {BABYLON.Observable}
  757. */
  758. onBeforeParticlesRenderingObservable: Observable<Scene>;
  759. /**
  760. * An event triggered when particles rendering is done
  761. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  762. * @type {BABYLON.Observable}
  763. */
  764. onAfterParticlesRenderingObservable: Observable<Scene>;
  765. /**
  766. * An event triggered when sprites rendering is about to start
  767. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  768. * @type {BABYLON.Observable}
  769. */
  770. onBeforeSpritesRenderingObservable: Observable<Scene>;
  771. /**
  772. * An event triggered when sprites rendering is done
  773. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  774. * @type {BABYLON.Observable}
  775. */
  776. onAfterSpritesRenderingObservable: Observable<Scene>;
  777. /**
  778. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  779. * @type {BABYLON.Observable}
  780. */
  781. onDataLoadedObservable: Observable<Scene>;
  782. /**
  783. * An event triggered when a camera is created
  784. * @type {BABYLON.Observable}
  785. */
  786. onNewCameraAddedObservable: Observable<Camera>;
  787. /**
  788. * An event triggered when a camera is removed
  789. * @type {BABYLON.Observable}
  790. */
  791. onCameraRemovedObservable: Observable<Camera>;
  792. /**
  793. * An event triggered when a light is created
  794. * @type {BABYLON.Observable}
  795. */
  796. onNewLightAddedObservable: Observable<Light>;
  797. /**
  798. * An event triggered when a light is removed
  799. * @type {BABYLON.Observable}
  800. */
  801. onLightRemovedObservable: Observable<Light>;
  802. /**
  803. * An event triggered when a geometry is created
  804. * @type {BABYLON.Observable}
  805. */
  806. onNewGeometryAddedObservable: Observable<Geometry>;
  807. /**
  808. * An event triggered when a geometry is removed
  809. * @type {BABYLON.Observable}
  810. */
  811. onGeometryRemovedObservable: Observable<Geometry>;
  812. /**
  813. * An event triggered when a transform node is created
  814. * @type {BABYLON.Observable}
  815. */
  816. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  817. /**
  818. * An event triggered when a transform node is removed
  819. * @type {BABYLON.Observable}
  820. */
  821. onTransformNodeRemovedObservable: Observable<TransformNode>;
  822. /**
  823. * An event triggered when a mesh is created
  824. * @type {BABYLON.Observable}
  825. */
  826. onNewMeshAddedObservable: Observable<AbstractMesh>;
  827. /**
  828. * An event triggered when a mesh is removed
  829. * @type {BABYLON.Observable}
  830. */
  831. onMeshRemovedObservable: Observable<AbstractMesh>;
  832. /**
  833. * An event triggered when render targets are about to be rendered
  834. * Can happen multiple times per frame.
  835. * @type {BABYLON.Observable}
  836. */
  837. OnBeforeRenderTargetsRenderObservable: Observable<Scene>;
  838. /**
  839. * An event triggered when render targets were rendered.
  840. * Can happen multiple times per frame.
  841. * @type {BABYLON.Observable}
  842. */
  843. OnAfterRenderTargetsRenderObservable: Observable<Scene>;
  844. /**
  845. * An event triggered before calculating deterministic simulation step
  846. * @type {BABYLON.Observable}
  847. */
  848. onBeforeStepObservable: Observable<Scene>;
  849. /**
  850. * An event triggered after calculating deterministic simulation step
  851. * @type {BABYLON.Observable}
  852. */
  853. onAfterStepObservable: Observable<Scene>;
  854. /**
  855. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  856. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  857. * 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)
  858. */
  859. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  860. animations: Animation[];
  861. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  862. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  863. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  864. private _onPointerMove;
  865. private _onPointerDown;
  866. private _onPointerUp;
  867. /** Deprecated. Use onPointerObservable instead */
  868. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  869. /** Deprecated. Use onPointerObservable instead */
  870. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  871. /** Deprecated. Use onPointerObservable instead */
  872. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>) => void;
  873. /** Deprecated. Use onPointerObservable instead */
  874. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  875. private _gamepadManager;
  876. readonly gamepadManager: GamepadManager;
  877. /**
  878. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  879. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  880. */
  881. onPrePointerObservable: Observable<PointerInfoPre>;
  882. /**
  883. * Observable event triggered each time an input event is received from the rendering canvas
  884. */
  885. onPointerObservable: Observable<PointerInfo>;
  886. readonly unTranslatedPointer: Vector2;
  887. /** The distance in pixel that you have to move to prevent some events */
  888. static DragMovementThreshold: number;
  889. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  890. static LongPressDelay: number;
  891. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  892. static DoubleClickDelay: number;
  893. /** If you need to check double click without raising a single click at first click, enable this flag */
  894. static ExclusiveDoubleClickMode: boolean;
  895. private _initClickEvent;
  896. private _initActionManager;
  897. private _delayedSimpleClick;
  898. private _delayedSimpleClickTimeout;
  899. private _previousDelayedSimpleClickTimeout;
  900. private _meshPickProceed;
  901. private _previousButtonPressed;
  902. private _currentPickResult;
  903. private _previousPickResult;
  904. private _totalPointersPressed;
  905. private _doubleClickOccured;
  906. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  907. cameraToUseForPointers: Nullable<Camera>;
  908. private _pointerX;
  909. private _pointerY;
  910. private _unTranslatedPointerX;
  911. private _unTranslatedPointerY;
  912. private _startingPointerPosition;
  913. private _previousStartingPointerPosition;
  914. private _startingPointerTime;
  915. private _previousStartingPointerTime;
  916. private _timeAccumulator;
  917. private _currentStepId;
  918. private _currentInternalStep;
  919. _mirroredCameraPosition: Nullable<Vector3>;
  920. /**
  921. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  922. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  923. */
  924. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  925. /**
  926. * Observable event triggered each time an keyboard event is received from the hosting window
  927. */
  928. onKeyboardObservable: Observable<KeyboardInfo>;
  929. private _onKeyDown;
  930. private _onKeyUp;
  931. private _onCanvasFocusObserver;
  932. private _onCanvasBlurObserver;
  933. /**
  934. * use right-handed coordinate system on this scene.
  935. * @type {boolean}
  936. */
  937. private _useRightHandedSystem;
  938. useRightHandedSystem: boolean;
  939. setStepId(newStepId: number): void;
  940. getStepId(): number;
  941. getInternalStep(): number;
  942. private _fogEnabled;
  943. /**
  944. * is fog enabled on this scene.
  945. */
  946. fogEnabled: boolean;
  947. private _fogMode;
  948. fogMode: number;
  949. fogColor: Color3;
  950. fogDensity: number;
  951. fogStart: number;
  952. fogEnd: number;
  953. /**
  954. * is shadow enabled on this scene.
  955. * @type {boolean}
  956. */
  957. private _shadowsEnabled;
  958. shadowsEnabled: boolean;
  959. /**
  960. * is light enabled on this scene.
  961. * @type {boolean}
  962. */
  963. private _lightsEnabled;
  964. lightsEnabled: boolean;
  965. /**
  966. * All of the lights added to this scene.
  967. * @see BABYLON.Light
  968. * @type {BABYLON.Light[]}
  969. */
  970. lights: Light[];
  971. /** All of the cameras added to this scene. */
  972. cameras: Camera[];
  973. /** All of the active cameras added to this scene. */
  974. activeCameras: Camera[];
  975. /** The current active camera */
  976. activeCamera: Nullable<Camera>;
  977. /**
  978. * All of the tranform nodes added to this scene.
  979. * @see BABYLON.TransformNode
  980. * @type {BABYLON.TransformNode[]}
  981. */
  982. transformNodes: TransformNode[];
  983. /**
  984. * All of the (abstract) meshes added to this scene.
  985. * @see BABYLON.AbstractMesh
  986. * @type {BABYLON.AbstractMesh[]}
  987. */
  988. meshes: AbstractMesh[];
  989. /**
  990. * All of the animation groups added to this scene.
  991. * @see BABYLON.AnimationGroup
  992. * @type {BABYLON.AnimationGroup[]}
  993. */
  994. animationGroups: AnimationGroup[];
  995. private _geometries;
  996. materials: Material[];
  997. multiMaterials: MultiMaterial[];
  998. private _defaultMaterial;
  999. /** The default material used on meshes when no material is affected */
  1000. /** The default material used on meshes when no material is affected */
  1001. defaultMaterial: Material;
  1002. private _texturesEnabled;
  1003. texturesEnabled: boolean;
  1004. textures: BaseTexture[];
  1005. particlesEnabled: boolean;
  1006. particleSystems: IParticleSystem[];
  1007. spritesEnabled: boolean;
  1008. spriteManagers: SpriteManager[];
  1009. /**
  1010. * The list of layers (background and foreground) of the scene.
  1011. */
  1012. layers: Layer[];
  1013. /**
  1014. * The list of effect layers (highlights/glow) contained in the scene.
  1015. */
  1016. effectLayers: EffectLayer[];
  1017. private _skeletonsEnabled;
  1018. skeletonsEnabled: boolean;
  1019. skeletons: Skeleton[];
  1020. morphTargetManagers: MorphTargetManager[];
  1021. lensFlaresEnabled: boolean;
  1022. lensFlareSystems: LensFlareSystem[];
  1023. collisionsEnabled: boolean;
  1024. private _workerCollisions;
  1025. collisionCoordinator: ICollisionCoordinator;
  1026. /** Defines the gravity applied to this scene */
  1027. gravity: Vector3;
  1028. postProcesses: PostProcess[];
  1029. postProcessesEnabled: boolean;
  1030. postProcessManager: PostProcessManager;
  1031. private _postProcessRenderPipelineManager;
  1032. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1033. renderTargetsEnabled: boolean;
  1034. dumpNextRenderTargets: boolean;
  1035. customRenderTargets: RenderTargetTexture[];
  1036. useDelayedTextureLoading: boolean;
  1037. importedMeshesFiles: String[];
  1038. probesEnabled: boolean;
  1039. reflectionProbes: ReflectionProbe[];
  1040. database: Database;
  1041. /**
  1042. * This scene's action manager
  1043. * @type {BABYLON.ActionManager}
  1044. */
  1045. actionManager: ActionManager;
  1046. _actionManagers: ActionManager[];
  1047. private _meshesForIntersections;
  1048. proceduralTexturesEnabled: boolean;
  1049. _proceduralTextures: ProceduralTexture[];
  1050. private _mainSoundTrack;
  1051. soundTracks: SoundTrack[];
  1052. private _audioEnabled;
  1053. private _headphone;
  1054. readonly mainSoundTrack: SoundTrack;
  1055. VRHelper: VRExperienceHelper;
  1056. simplificationQueue: SimplificationQueue;
  1057. private _engine;
  1058. private _totalVertices;
  1059. _activeIndices: PerfCounter;
  1060. _activeParticles: PerfCounter;
  1061. _activeBones: PerfCounter;
  1062. private _animationRatio;
  1063. private _animationTimeLast;
  1064. private _animationTime;
  1065. animationTimeScale: number;
  1066. _cachedMaterial: Nullable<Material>;
  1067. _cachedEffect: Nullable<Effect>;
  1068. _cachedVisibility: Nullable<number>;
  1069. private _renderId;
  1070. private _executeWhenReadyTimeoutId;
  1071. private _intermediateRendering;
  1072. private _viewUpdateFlag;
  1073. private _projectionUpdateFlag;
  1074. private _alternateViewUpdateFlag;
  1075. private _alternateProjectionUpdateFlag;
  1076. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1077. private _activeRequests;
  1078. private _pendingData;
  1079. private _isDisposed;
  1080. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1081. private _activeMeshes;
  1082. private _processedMaterials;
  1083. private _renderTargets;
  1084. _activeParticleSystems: SmartArray<IParticleSystem>;
  1085. private _activeSkeletons;
  1086. private _softwareSkinnedMeshes;
  1087. private _renderingManager;
  1088. private _physicsEngine;
  1089. _activeAnimatables: Animatable[];
  1090. private _transformMatrix;
  1091. private _sceneUbo;
  1092. private _alternateSceneUbo;
  1093. private _pickWithRayInverseMatrix;
  1094. private _boundingBoxRenderer;
  1095. private _outlineRenderer;
  1096. private _viewMatrix;
  1097. private _projectionMatrix;
  1098. private _alternateViewMatrix;
  1099. private _alternateProjectionMatrix;
  1100. private _alternateTransformMatrix;
  1101. private _useAlternateCameraConfiguration;
  1102. private _alternateRendering;
  1103. _forcedViewPosition: Nullable<Vector3>;
  1104. readonly _isAlternateRenderingEnabled: boolean;
  1105. private _frustumPlanes;
  1106. readonly frustumPlanes: Plane[];
  1107. requireLightSorting: boolean;
  1108. private _selectionOctree;
  1109. private _pointerOverMesh;
  1110. private _pointerOverSprite;
  1111. private _debugLayer;
  1112. private _depthRenderer;
  1113. private _geometryBufferRenderer;
  1114. /**
  1115. * Gets the current geometry buffer associated to the scene.
  1116. */
  1117. /**
  1118. * Sets the current geometry buffer for the scene.
  1119. */
  1120. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1121. private _pickedDownMesh;
  1122. private _pickedUpMesh;
  1123. private _pickedDownSprite;
  1124. private _externalData;
  1125. private _uid;
  1126. /**
  1127. * @constructor
  1128. * @param {BABYLON.Engine} engine - the engine to be used to render this scene.
  1129. */
  1130. constructor(engine: Engine);
  1131. readonly debugLayer: DebugLayer;
  1132. workerCollisions: boolean;
  1133. readonly selectionOctree: Octree<AbstractMesh>;
  1134. /**
  1135. * The mesh that is currently under the pointer.
  1136. * @return {BABYLON.AbstractMesh} mesh under the pointer/mouse cursor or null if none.
  1137. */
  1138. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1139. /**
  1140. * Current on-screen X position of the pointer
  1141. * @return {number} X position of the pointer
  1142. */
  1143. readonly pointerX: number;
  1144. /**
  1145. * Current on-screen Y position of the pointer
  1146. * @return {number} Y position of the pointer
  1147. */
  1148. readonly pointerY: number;
  1149. getCachedMaterial(): Nullable<Material>;
  1150. getCachedEffect(): Nullable<Effect>;
  1151. getCachedVisibility(): Nullable<number>;
  1152. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1153. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1154. getOutlineRenderer(): OutlineRenderer;
  1155. getEngine(): Engine;
  1156. getTotalVertices(): number;
  1157. readonly totalVerticesPerfCounter: PerfCounter;
  1158. getActiveIndices(): number;
  1159. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1160. getActiveParticles(): number;
  1161. readonly activeParticlesPerfCounter: PerfCounter;
  1162. getActiveBones(): number;
  1163. readonly activeBonesPerfCounter: PerfCounter;
  1164. getInterFramePerfCounter(): number;
  1165. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1166. getLastFrameDuration(): number;
  1167. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1168. getEvaluateActiveMeshesDuration(): number;
  1169. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1170. getActiveMeshes(): SmartArray<AbstractMesh>;
  1171. getRenderTargetsDuration(): number;
  1172. getRenderDuration(): number;
  1173. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1174. getParticlesDuration(): number;
  1175. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1176. getSpritesDuration(): number;
  1177. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1178. getAnimationRatio(): number;
  1179. getRenderId(): number;
  1180. incrementRenderId(): void;
  1181. private _updatePointerPosition(evt);
  1182. private _createUbo();
  1183. private _createAlternateUbo();
  1184. /**
  1185. * Use this method to simulate a pointer move on a mesh
  1186. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1187. */
  1188. simulatePointerMove(pickResult: PickingInfo): Scene;
  1189. private _processPointerMove(pickResult, evt);
  1190. /**
  1191. * Use this method to simulate a pointer down on a mesh
  1192. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1193. */
  1194. simulatePointerDown(pickResult: PickingInfo): Scene;
  1195. private _processPointerDown(pickResult, evt);
  1196. /**
  1197. * Use this method to simulate a pointer up on a mesh
  1198. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1199. */
  1200. simulatePointerUp(pickResult: PickingInfo): Scene;
  1201. private _processPointerUp(pickResult, evt, clickInfo);
  1202. /**
  1203. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1204. * @param attachUp defines if you want to attach events to pointerup
  1205. * @param attachDown defines if you want to attach events to pointerdown
  1206. * @param attachMove defines if you want to attach events to pointermove
  1207. */
  1208. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1209. detachControl(): void;
  1210. /**
  1211. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1212. * Delay loaded resources are not taking in account
  1213. * @return true if all required resources are ready
  1214. */
  1215. isReady(): boolean;
  1216. resetCachedMaterial(): void;
  1217. registerBeforeRender(func: () => void): void;
  1218. unregisterBeforeRender(func: () => void): void;
  1219. registerAfterRender(func: () => void): void;
  1220. unregisterAfterRender(func: () => void): void;
  1221. private _executeOnceBeforeRender(func);
  1222. /**
  1223. * The provided function will run before render once and will be disposed afterwards.
  1224. * A timeout delay can be provided so that the function will be executed in N ms.
  1225. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1226. * @param func The function to be executed.
  1227. * @param timeout optional delay in ms
  1228. */
  1229. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1230. _addPendingData(data: any): void;
  1231. _removePendingData(data: any): void;
  1232. getWaitingItemsCount(): number;
  1233. readonly isLoading: boolean;
  1234. /**
  1235. * Registers a function to be executed when the scene is ready.
  1236. * @param {Function} func - the function to be executed.
  1237. */
  1238. executeWhenReady(func: () => void): void;
  1239. /**
  1240. * Returns a promise that resolves when the scene is ready.
  1241. * @returns A promise that resolves when the scene is ready.
  1242. */
  1243. whenReadyAsync(): Promise<void>;
  1244. _checkIsReady(): void;
  1245. /**
  1246. * Will start the animation sequence of a given target
  1247. * @param target - the target
  1248. * @param {number} from - from which frame should animation start
  1249. * @param {number} to - till which frame should animation run.
  1250. * @param {boolean} [loop] - should the animation loop
  1251. * @param {number} [speedRatio] - the speed in which to run the animation
  1252. * @param {Function} [onAnimationEnd] function to be executed when the animation ended.
  1253. * @param {BABYLON.Animatable} [animatable] an animatable object. If not provided a new one will be created from the given params.
  1254. * Returns {BABYLON.Animatable} the animatable object created for this animation
  1255. * See BABYLON.Animatable
  1256. */
  1257. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1258. /**
  1259. * Begin a new animation on a given node
  1260. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1261. * @param {BABYLON.Animation[]} defines the list of animations to start
  1262. * @param {number} from defines the initial value
  1263. * @param {number} to defines the final value
  1264. * @param {boolean} loop defines if you want animation to loop (off by default)
  1265. * @param {number} speedRatio defines the speed ratio to apply to all animations
  1266. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1267. * @returns the list of created animatables
  1268. */
  1269. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1270. /**
  1271. * Begin a new animation on a given node and its hierarchy
  1272. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1273. * @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.
  1274. * @param {BABYLON.Animation[]} defines the list of animations to start
  1275. * @param {number} from defines the initial value
  1276. * @param {number} to defines the final value
  1277. * @param {boolean} loop defines if you want animation to loop (off by default)
  1278. * @param {number} speedRatio defines the speed ratio to apply to all animations
  1279. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1280. * @returns the list of animatables created for all nodes
  1281. */
  1282. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1283. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1284. readonly animatables: Animatable[];
  1285. /**
  1286. * Will stop the animation of the given target
  1287. * @param target - the target
  1288. * @param animationName - the name of the animation to stop (all animations will be stopped is empty)
  1289. * @see beginAnimation
  1290. */
  1291. stopAnimation(target: any, animationName?: string): void;
  1292. /**
  1293. * Stops and removes all animations that have been applied to the scene
  1294. */
  1295. stopAllAnimations(): void;
  1296. private _animate();
  1297. _switchToAlternateCameraConfiguration(active: boolean): void;
  1298. getViewMatrix(): Matrix;
  1299. getProjectionMatrix(): Matrix;
  1300. getTransformMatrix(): Matrix;
  1301. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1302. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1303. getSceneUniformBuffer(): UniformBuffer;
  1304. getUniqueId(): number;
  1305. addMesh(newMesh: AbstractMesh): void;
  1306. removeMesh(toRemove: AbstractMesh): number;
  1307. addTransformNode(newTransformNode: TransformNode): void;
  1308. removeTransformNode(toRemove: TransformNode): number;
  1309. removeSkeleton(toRemove: Skeleton): number;
  1310. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1311. removeLight(toRemove: Light): number;
  1312. removeCamera(toRemove: Camera): number;
  1313. removeParticleSystem(toRemove: ParticleSystem): number;
  1314. removeAnimation(toRemove: Animation): number;
  1315. removeMultiMaterial(toRemove: MultiMaterial): number;
  1316. removeMaterial(toRemove: Material): number;
  1317. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1318. removeActionManager(toRemove: ActionManager): number;
  1319. addLight(newLight: Light): void;
  1320. sortLightsByPriority(): void;
  1321. addCamera(newCamera: Camera): void;
  1322. addSkeleton(newSkeleton: Skeleton): void;
  1323. addParticleSystem(newParticleSystem: ParticleSystem): void;
  1324. addAnimation(newAnimation: Animation): void;
  1325. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1326. addMaterial(newMaterial: Material): void;
  1327. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1328. addGeometry(newGeometrie: Geometry): void;
  1329. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1330. addActionManager(newActionManager: ActionManager): void;
  1331. /**
  1332. * Switch active camera
  1333. * @param {Camera} newCamera - new active camera
  1334. * @param {boolean} attachControl - call attachControl for the new active camera (default: true)
  1335. */
  1336. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1337. /**
  1338. * sets the active camera of the scene using its ID
  1339. * @param {string} id - the camera's ID
  1340. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1341. * @see activeCamera
  1342. */
  1343. setActiveCameraByID(id: string): Nullable<Camera>;
  1344. /**
  1345. * sets the active camera of the scene using its name
  1346. * @param {string} name - the camera's name
  1347. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1348. * @see activeCamera
  1349. */
  1350. setActiveCameraByName(name: string): Nullable<Camera>;
  1351. /**
  1352. * get an animation group using its name
  1353. * @param {string} the material's name
  1354. * @return {BABYLON.AnimationGroup|null} the animation group or null if none found.
  1355. */
  1356. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1357. /**
  1358. * get a material using its id
  1359. * @param {string} the material's ID
  1360. * @return {BABYLON.Material|null} the material or null if none found.
  1361. */
  1362. getMaterialByID(id: string): Nullable<Material>;
  1363. /**
  1364. * get a material using its name
  1365. * @param {string} the material's name
  1366. * @return {BABYLON.Material|null} the material or null if none found.
  1367. */
  1368. getMaterialByName(name: string): Nullable<Material>;
  1369. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  1370. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  1371. getCameraByID(id: string): Nullable<Camera>;
  1372. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1373. /**
  1374. * get a camera using its name
  1375. * @param {string} the camera's name
  1376. * @return {BABYLON.Camera|null} the camera or null if none found.
  1377. */
  1378. getCameraByName(name: string): Nullable<Camera>;
  1379. /**
  1380. * get a bone using its id
  1381. * @param {string} the bone's id
  1382. * @return {BABYLON.Bone|null} the bone or null if not found
  1383. */
  1384. getBoneByID(id: string): Nullable<Bone>;
  1385. /**
  1386. * get a bone using its id
  1387. * @param {string} the bone's name
  1388. * @return {BABYLON.Bone|null} the bone or null if not found
  1389. */
  1390. getBoneByName(name: string): Nullable<Bone>;
  1391. /**
  1392. * get a light node using its name
  1393. * @param {string} the light's name
  1394. * @return {BABYLON.Light|null} the light or null if none found.
  1395. */
  1396. getLightByName(name: string): Nullable<Light>;
  1397. /**
  1398. * get a light node using its ID
  1399. * @param {string} the light's id
  1400. * @return {BABYLON.Light|null} the light or null if none found.
  1401. */
  1402. getLightByID(id: string): Nullable<Light>;
  1403. /**
  1404. * get a light node using its scene-generated unique ID
  1405. * @param {number} the light's unique id
  1406. * @return {BABYLON.Light|null} the light or null if none found.
  1407. */
  1408. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  1409. /**
  1410. * get a particle system by id
  1411. * @param id {number} the particle system id
  1412. * @return {BABYLON.IParticleSystem|null} the corresponding system or null if none found.
  1413. */
  1414. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  1415. /**
  1416. * get a geometry using its ID
  1417. * @param {string} the geometry's id
  1418. * @return {BABYLON.Geometry|null} the geometry or null if none found.
  1419. */
  1420. getGeometryByID(id: string): Nullable<Geometry>;
  1421. /**
  1422. * add a new geometry to this scene.
  1423. * @param {BABYLON.Geometry} geometry - the geometry to be added to the scene.
  1424. * @param {boolean} [force] - force addition, even if a geometry with this ID already exists
  1425. * @return {boolean} was the geometry added or not
  1426. */
  1427. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  1428. /**
  1429. * Removes an existing geometry
  1430. * @param {BABYLON.Geometry} geometry - the geometry to be removed from the scene.
  1431. * @return {boolean} was the geometry removed or not
  1432. */
  1433. removeGeometry(geometry: Geometry): boolean;
  1434. getGeometries(): Geometry[];
  1435. /**
  1436. * Get the first added mesh found of a given ID
  1437. * @param {string} id - the id to search for
  1438. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1439. */
  1440. getMeshByID(id: string): Nullable<AbstractMesh>;
  1441. getMeshesByID(id: string): Array<AbstractMesh>;
  1442. /**
  1443. * Get the first added transform node found of a given ID
  1444. * @param {string} id - the id to search for
  1445. * @return {BABYLON.TransformNode|null} the transform node found or null if not found at all.
  1446. */
  1447. getTransformNodeByID(id: string): Nullable<TransformNode>;
  1448. getTransformNodesByID(id: string): Array<TransformNode>;
  1449. /**
  1450. * Get a mesh with its auto-generated unique id
  1451. * @param {number} uniqueId - the unique id to search for
  1452. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1453. */
  1454. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  1455. /**
  1456. * Get a the last added mesh found of a given ID
  1457. * @param {string} id - the id to search for
  1458. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1459. */
  1460. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  1461. /**
  1462. * Get a the last added node (Mesh, Camera, Light) found of a given ID
  1463. * @param {string} id - the id to search for
  1464. * @return {BABYLON.Node|null} the node found or null if not found at all.
  1465. */
  1466. getLastEntryByID(id: string): Nullable<Node>;
  1467. getNodeByID(id: string): Nullable<Node>;
  1468. getNodeByName(name: string): Nullable<Node>;
  1469. getMeshByName(name: string): Nullable<AbstractMesh>;
  1470. getTransformNodeByName(name: string): Nullable<TransformNode>;
  1471. getSoundByName(name: string): Nullable<Sound>;
  1472. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  1473. getSkeletonById(id: string): Nullable<Skeleton>;
  1474. getSkeletonByName(name: string): Nullable<Skeleton>;
  1475. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  1476. isActiveMesh(mesh: AbstractMesh): boolean;
  1477. /**
  1478. * Return a the first highlight layer of the scene with a given name.
  1479. * @param name The name of the highlight layer to look for.
  1480. * @return The highlight layer if found otherwise null.
  1481. */
  1482. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  1483. /**
  1484. * Return a the first highlight layer of the scene with a given name.
  1485. * @param name The name of the highlight layer to look for.
  1486. * @return The highlight layer if found otherwise null.
  1487. */
  1488. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  1489. /**
  1490. * Return a unique id as a string which can serve as an identifier for the scene
  1491. */
  1492. readonly uid: string;
  1493. /**
  1494. * Add an externaly attached data from its key.
  1495. * This method call will fail and return false, if such key already exists.
  1496. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  1497. * @param key the unique key that identifies the data
  1498. * @param data the data object to associate to the key for this Engine instance
  1499. * @return true if no such key were already present and the data was added successfully, false otherwise
  1500. */
  1501. addExternalData<T>(key: string, data: T): boolean;
  1502. /**
  1503. * Get an externaly attached data from its key
  1504. * @param key the unique key that identifies the data
  1505. * @return the associated data, if present (can be null), or undefined if not present
  1506. */
  1507. getExternalData<T>(key: string): Nullable<T>;
  1508. /**
  1509. * Get an externaly attached data from its key, create it using a factory if it's not already present
  1510. * @param key the unique key that identifies the data
  1511. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  1512. * @return the associated data, can be null if the factory returned null.
  1513. */
  1514. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  1515. /**
  1516. * Remove an externaly attached data from the Engine instance
  1517. * @param key the unique key that identifies the data
  1518. * @return true if the data was successfully removed, false if it doesn't exist
  1519. */
  1520. removeExternalData(key: string): boolean;
  1521. private _evaluateSubMesh(subMesh, mesh);
  1522. _isInIntermediateRendering(): boolean;
  1523. private _activeMeshCandidateProvider;
  1524. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  1525. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  1526. private _activeMeshesFrozen;
  1527. /**
  1528. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  1529. */
  1530. freezeActiveMeshes(): Scene;
  1531. /**
  1532. * Use this function to restart evaluating active meshes on every frame
  1533. */
  1534. unfreezeActiveMeshes(): this;
  1535. private _evaluateActiveMeshes();
  1536. private _activeMesh(sourceMesh, mesh);
  1537. updateTransformMatrix(force?: boolean): void;
  1538. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  1539. private _renderForCamera(camera);
  1540. private _processSubCameras(camera);
  1541. private _checkIntersections();
  1542. render(): void;
  1543. private _updateAudioParameters();
  1544. audioEnabled: boolean;
  1545. private _disableAudio();
  1546. private _enableAudio();
  1547. headphone: boolean;
  1548. private _switchAudioModeForHeadphones();
  1549. private _switchAudioModeForNormalSpeakers();
  1550. enableDepthRenderer(): DepthRenderer;
  1551. disableDepthRenderer(): void;
  1552. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  1553. disableGeometryBufferRenderer(): void;
  1554. freezeMaterials(): void;
  1555. unfreezeMaterials(): void;
  1556. dispose(): void;
  1557. readonly isDisposed: boolean;
  1558. disposeSounds(): void;
  1559. getWorldExtends(): {
  1560. min: Vector3;
  1561. max: Vector3;
  1562. };
  1563. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  1564. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  1565. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  1566. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  1567. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  1568. private _internalPick(rayFunction, predicate?, fastCheck?);
  1569. private _internalMultiPick(rayFunction, predicate?);
  1570. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  1571. private _tempPickingRay;
  1572. /** Launch a ray to try to pick a mesh in the scene
  1573. * @param x position on screen
  1574. * @param y position on screen
  1575. * @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
  1576. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1577. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1578. */
  1579. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  1580. /** Launch a ray to try to pick a sprite in the scene
  1581. * @param x position on screen
  1582. * @param y position on screen
  1583. * @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
  1584. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1585. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1586. */
  1587. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  1588. private _cachedRayForTransform;
  1589. /** Use the given ray to pick a mesh in the scene
  1590. * @param ray The ray to use to pick meshes
  1591. * @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
  1592. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1593. */
  1594. pickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  1595. /**
  1596. * Launch a ray to try to pick a mesh in the scene
  1597. * @param x X position on screen
  1598. * @param y Y position on screen
  1599. * @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
  1600. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1601. */
  1602. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  1603. /**
  1604. * Launch a ray to try to pick a mesh in the scene
  1605. * @param ray Ray to use
  1606. * @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
  1607. */
  1608. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  1609. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  1610. getPointerOverMesh(): Nullable<AbstractMesh>;
  1611. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  1612. getPointerOverSprite(): Nullable<Sprite>;
  1613. getPhysicsEngine(): Nullable<PhysicsEngine>;
  1614. /**
  1615. * Enables physics to the current scene
  1616. * @param {BABYLON.Vector3} [gravity] - the scene's gravity for the physics engine
  1617. * @param {BABYLON.IPhysicsEnginePlugin} [plugin] - The physics engine to be used. defaults to OimoJS.
  1618. * @return {boolean} was the physics engine initialized
  1619. */
  1620. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  1621. disablePhysicsEngine(): void;
  1622. isPhysicsEnabled(): boolean;
  1623. deleteCompoundImpostor(compound: any): void;
  1624. _rebuildGeometries(): void;
  1625. _rebuildTextures(): void;
  1626. /**
  1627. * Creates a default light for the scene.
  1628. * @param replace Whether to replace the existing lights in the scene.
  1629. */
  1630. createDefaultLight(replace?: boolean): void;
  1631. /**
  1632. * Creates a default camera for the scene.
  1633. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  1634. * @param replace Whether to replace the existing active camera in the scene.
  1635. * @param attachCameraControls Whether to attach camera controls to the canvas.
  1636. */
  1637. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  1638. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  1639. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number): Nullable<Mesh>;
  1640. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  1641. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  1642. private _getByTags(list, tagsQuery, forEach?);
  1643. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  1644. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  1645. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  1646. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  1647. /**
  1648. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  1649. * This allowed control for front to back rendering or reversly depending of the special needs.
  1650. *
  1651. * @param renderingGroupId The rendering group id corresponding to its index
  1652. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  1653. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  1654. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  1655. */
  1656. 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;
  1657. /**
  1658. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  1659. *
  1660. * @param renderingGroupId The rendering group id corresponding to its index
  1661. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  1662. * @param depth Automatically clears depth between groups if true and autoClear is true.
  1663. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  1664. */
  1665. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  1666. /**
  1667. * Will flag all materials as dirty to trigger new shader compilation
  1668. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  1669. */
  1670. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  1671. _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;
  1672. /** @ignore */
  1673. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  1674. }
  1675. }
  1676. declare module BABYLON {
  1677. type Nullable<T> = T | null;
  1678. type float = number;
  1679. type double = number;
  1680. type int = number;
  1681. type FloatArray = number[] | Float32Array;
  1682. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  1683. }
  1684. declare module BABYLON {
  1685. class Action {
  1686. triggerOptions: any;
  1687. trigger: number;
  1688. _actionManager: ActionManager;
  1689. private _nextActiveAction;
  1690. private _child;
  1691. private _condition?;
  1692. private _triggerParameter;
  1693. onBeforeExecuteObservable: Observable<Action>;
  1694. constructor(triggerOptions: any, condition?: Condition);
  1695. _prepare(): void;
  1696. getTriggerParameter(): any;
  1697. _executeCurrent(evt?: ActionEvent): void;
  1698. execute(evt?: ActionEvent): void;
  1699. skipToNextActiveAction(): void;
  1700. then(action: Action): Action;
  1701. _getProperty(propertyPath: string): string;
  1702. _getEffectiveTarget(target: any, propertyPath: string): any;
  1703. serialize(parent: any): any;
  1704. protected _serialize(serializedAction: any, parent?: any): any;
  1705. static _SerializeValueAsString: (value: any) => string;
  1706. static _GetTargetProperty: (target: Scene | Node) => {
  1707. name: string;
  1708. targetType: string;
  1709. value: string;
  1710. };
  1711. }
  1712. }
  1713. declare module BABYLON {
  1714. /**
  1715. * ActionEvent is the event beint sent when an action is triggered.
  1716. */
  1717. class ActionEvent {
  1718. source: any;
  1719. pointerX: number;
  1720. pointerY: number;
  1721. meshUnderPointer: Nullable<AbstractMesh>;
  1722. sourceEvent: any;
  1723. additionalData: any;
  1724. /**
  1725. * @param source The mesh or sprite that triggered the action.
  1726. * @param pointerX The X mouse cursor position at the time of the event
  1727. * @param pointerY The Y mouse cursor position at the time of the event
  1728. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  1729. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  1730. */
  1731. constructor(source: any, pointerX: number, pointerY: number, meshUnderPointer: Nullable<AbstractMesh>, sourceEvent?: any, additionalData?: any);
  1732. /**
  1733. * Helper function to auto-create an ActionEvent from a source mesh.
  1734. * @param source The source mesh that triggered the event
  1735. * @param evt {Event} The original (browser) event
  1736. */
  1737. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  1738. /**
  1739. * Helper function to auto-create an ActionEvent from a source mesh.
  1740. * @param source The source sprite that triggered the event
  1741. * @param scene Scene associated with the sprite
  1742. * @param evt {Event} The original (browser) event
  1743. */
  1744. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  1745. /**
  1746. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  1747. * @param scene the scene where the event occurred
  1748. * @param evt {Event} The original (browser) event
  1749. */
  1750. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  1751. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  1752. }
  1753. /**
  1754. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  1755. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  1756. */
  1757. class ActionManager {
  1758. private static _NothingTrigger;
  1759. private static _OnPickTrigger;
  1760. private static _OnLeftPickTrigger;
  1761. private static _OnRightPickTrigger;
  1762. private static _OnCenterPickTrigger;
  1763. private static _OnPickDownTrigger;
  1764. private static _OnDoublePickTrigger;
  1765. private static _OnPickUpTrigger;
  1766. private static _OnLongPressTrigger;
  1767. private static _OnPointerOverTrigger;
  1768. private static _OnPointerOutTrigger;
  1769. private static _OnEveryFrameTrigger;
  1770. private static _OnIntersectionEnterTrigger;
  1771. private static _OnIntersectionExitTrigger;
  1772. private static _OnKeyDownTrigger;
  1773. private static _OnKeyUpTrigger;
  1774. private static _OnPickOutTrigger;
  1775. static readonly NothingTrigger: number;
  1776. static readonly OnPickTrigger: number;
  1777. static readonly OnLeftPickTrigger: number;
  1778. static readonly OnRightPickTrigger: number;
  1779. static readonly OnCenterPickTrigger: number;
  1780. static readonly OnPickDownTrigger: number;
  1781. static readonly OnDoublePickTrigger: number;
  1782. static readonly OnPickUpTrigger: number;
  1783. static readonly OnPickOutTrigger: number;
  1784. static readonly OnLongPressTrigger: number;
  1785. static readonly OnPointerOverTrigger: number;
  1786. static readonly OnPointerOutTrigger: number;
  1787. static readonly OnEveryFrameTrigger: number;
  1788. static readonly OnIntersectionEnterTrigger: number;
  1789. static readonly OnIntersectionExitTrigger: number;
  1790. static readonly OnKeyDownTrigger: number;
  1791. static readonly OnKeyUpTrigger: number;
  1792. static Triggers: {
  1793. [key: string]: number;
  1794. };
  1795. actions: Action[];
  1796. hoverCursor: string;
  1797. private _scene;
  1798. constructor(scene: Scene);
  1799. dispose(): void;
  1800. getScene(): Scene;
  1801. /**
  1802. * Does this action manager handles actions of any of the given triggers
  1803. * @param {number[]} triggers - the triggers to be tested
  1804. * @return {boolean} whether one (or more) of the triggers is handeled
  1805. */
  1806. hasSpecificTriggers(triggers: number[]): boolean;
  1807. /**
  1808. * Does this action manager handles actions of a given trigger
  1809. * @param {number} trigger - the trigger to be tested
  1810. * @return {boolean} whether the trigger is handeled
  1811. */
  1812. hasSpecificTrigger(trigger: number): boolean;
  1813. /**
  1814. * Does this action manager has pointer triggers
  1815. * @return {boolean} whether or not it has pointer triggers
  1816. */
  1817. readonly hasPointerTriggers: boolean;
  1818. /**
  1819. * Does this action manager has pick triggers
  1820. * @return {boolean} whether or not it has pick triggers
  1821. */
  1822. readonly hasPickTriggers: boolean;
  1823. /**
  1824. * Does exist one action manager with at least one trigger
  1825. * @return {boolean} whether or not it exists one action manager with one trigger
  1826. **/
  1827. static readonly HasTriggers: boolean;
  1828. /**
  1829. * Does exist one action manager with at least one pick trigger
  1830. * @return {boolean} whether or not it exists one action manager with one pick trigger
  1831. **/
  1832. static readonly HasPickTriggers: boolean;
  1833. /**
  1834. * Does exist one action manager that handles actions of a given trigger
  1835. * @param {number} trigger - the trigger to be tested
  1836. * @return {boolean} whether the trigger is handeled by at least one action manager
  1837. **/
  1838. static HasSpecificTrigger(trigger: number): boolean;
  1839. /**
  1840. * Registers an action to this action manager
  1841. * @param {BABYLON.Action} action - the action to be registered
  1842. * @return {BABYLON.Action} the action amended (prepared) after registration
  1843. */
  1844. registerAction(action: Action): Nullable<Action>;
  1845. /**
  1846. * Unregisters an action to this action manager
  1847. * @param action The action to be unregistered
  1848. * @return whether the action has been unregistered
  1849. */
  1850. unregisterAction(action: Action): Boolean;
  1851. /**
  1852. * Process a specific trigger
  1853. * @param {number} trigger - the trigger to process
  1854. * @param evt {BABYLON.ActionEvent} the event details to be processed
  1855. */
  1856. processTrigger(trigger: number, evt?: ActionEvent): void;
  1857. _getEffectiveTarget(target: any, propertyPath: string): any;
  1858. _getProperty(propertyPath: string): string;
  1859. serialize(name: string): any;
  1860. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  1861. static GetTriggerName(trigger: number): string;
  1862. }
  1863. }
  1864. declare module BABYLON {
  1865. class Condition {
  1866. _actionManager: ActionManager;
  1867. _evaluationId: number;
  1868. _currentResult: boolean;
  1869. constructor(actionManager: ActionManager);
  1870. isValid(): boolean;
  1871. _getProperty(propertyPath: string): string;
  1872. _getEffectiveTarget(target: any, propertyPath: string): any;
  1873. serialize(): any;
  1874. protected _serialize(serializedCondition: any): any;
  1875. }
  1876. class ValueCondition extends Condition {
  1877. propertyPath: string;
  1878. value: any;
  1879. operator: number;
  1880. private static _IsEqual;
  1881. private static _IsDifferent;
  1882. private static _IsGreater;
  1883. private static _IsLesser;
  1884. static readonly IsEqual: number;
  1885. static readonly IsDifferent: number;
  1886. static readonly IsGreater: number;
  1887. static readonly IsLesser: number;
  1888. _actionManager: ActionManager;
  1889. private _target;
  1890. private _effectiveTarget;
  1891. private _property;
  1892. constructor(actionManager: ActionManager, target: any, propertyPath: string, value: any, operator?: number);
  1893. isValid(): boolean;
  1894. serialize(): any;
  1895. static GetOperatorName(operator: number): string;
  1896. }
  1897. class PredicateCondition extends Condition {
  1898. predicate: () => boolean;
  1899. _actionManager: ActionManager;
  1900. constructor(actionManager: ActionManager, predicate: () => boolean);
  1901. isValid(): boolean;
  1902. }
  1903. class StateCondition extends Condition {
  1904. value: string;
  1905. _actionManager: ActionManager;
  1906. private _target;
  1907. constructor(actionManager: ActionManager, target: any, value: string);
  1908. isValid(): boolean;
  1909. serialize(): any;
  1910. }
  1911. }
  1912. declare module BABYLON {
  1913. class SwitchBooleanAction extends Action {
  1914. propertyPath: string;
  1915. private _target;
  1916. private _effectiveTarget;
  1917. private _property;
  1918. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  1919. _prepare(): void;
  1920. execute(): void;
  1921. serialize(parent: any): any;
  1922. }
  1923. class SetStateAction extends Action {
  1924. value: string;
  1925. private _target;
  1926. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  1927. execute(): void;
  1928. serialize(parent: any): any;
  1929. }
  1930. class SetValueAction extends Action {
  1931. propertyPath: string;
  1932. value: any;
  1933. private _target;
  1934. private _effectiveTarget;
  1935. private _property;
  1936. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1937. _prepare(): void;
  1938. execute(): void;
  1939. serialize(parent: any): any;
  1940. }
  1941. class IncrementValueAction extends Action {
  1942. propertyPath: string;
  1943. value: any;
  1944. private _target;
  1945. private _effectiveTarget;
  1946. private _property;
  1947. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1948. _prepare(): void;
  1949. execute(): void;
  1950. serialize(parent: any): any;
  1951. }
  1952. class PlayAnimationAction extends Action {
  1953. from: number;
  1954. to: number;
  1955. loop: boolean | undefined;
  1956. private _target;
  1957. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  1958. _prepare(): void;
  1959. execute(): void;
  1960. serialize(parent: any): any;
  1961. }
  1962. class StopAnimationAction extends Action {
  1963. private _target;
  1964. constructor(triggerOptions: any, target: any, condition?: Condition);
  1965. _prepare(): void;
  1966. execute(): void;
  1967. serialize(parent: any): any;
  1968. }
  1969. class DoNothingAction extends Action {
  1970. constructor(triggerOptions?: any, condition?: Condition);
  1971. execute(): void;
  1972. serialize(parent: any): any;
  1973. }
  1974. class CombineAction extends Action {
  1975. children: Action[];
  1976. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  1977. _prepare(): void;
  1978. execute(evt: ActionEvent): void;
  1979. serialize(parent: any): any;
  1980. }
  1981. class ExecuteCodeAction extends Action {
  1982. func: (evt: ActionEvent) => void;
  1983. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  1984. execute(evt: ActionEvent): void;
  1985. }
  1986. class SetParentAction extends Action {
  1987. private _parent;
  1988. private _target;
  1989. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  1990. _prepare(): void;
  1991. execute(): void;
  1992. serialize(parent: any): any;
  1993. }
  1994. class PlaySoundAction extends Action {
  1995. private _sound;
  1996. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  1997. _prepare(): void;
  1998. execute(): void;
  1999. serialize(parent: any): any;
  2000. }
  2001. class StopSoundAction extends Action {
  2002. private _sound;
  2003. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  2004. _prepare(): void;
  2005. execute(): void;
  2006. serialize(parent: any): any;
  2007. }
  2008. }
  2009. declare module BABYLON {
  2010. class InterpolateValueAction extends Action {
  2011. propertyPath: string;
  2012. value: any;
  2013. duration: number;
  2014. stopOtherAnimations: boolean | undefined;
  2015. onInterpolationDone: (() => void) | undefined;
  2016. private _target;
  2017. private _effectiveTarget;
  2018. private _property;
  2019. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  2020. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  2021. _prepare(): void;
  2022. execute(): void;
  2023. serialize(parent: any): any;
  2024. }
  2025. }
  2026. declare module BABYLON {
  2027. class Animatable {
  2028. target: any;
  2029. fromFrame: number;
  2030. toFrame: number;
  2031. loopAnimation: boolean;
  2032. onAnimationEnd: (() => void) | null | undefined;
  2033. private _localDelayOffset;
  2034. private _pausedDelay;
  2035. private _runtimeAnimations;
  2036. private _paused;
  2037. private _scene;
  2038. private _speedRatio;
  2039. animationStarted: boolean;
  2040. speedRatio: number;
  2041. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  2042. getAnimations(): RuntimeAnimation[];
  2043. appendAnimations(target: any, animations: Animation[]): void;
  2044. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  2045. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  2046. reset(): void;
  2047. enableBlending(blendingSpeed: number): void;
  2048. disableBlending(): void;
  2049. goToFrame(frame: number): void;
  2050. pause(): void;
  2051. restart(): void;
  2052. stop(animationName?: string): void;
  2053. _animate(delay: number): boolean;
  2054. }
  2055. }
  2056. declare module BABYLON {
  2057. class AnimationRange {
  2058. name: string;
  2059. from: number;
  2060. to: number;
  2061. constructor(name: string, from: number, to: number);
  2062. clone(): AnimationRange;
  2063. }
  2064. /**
  2065. * Composed of a frame, and an action function
  2066. */
  2067. class AnimationEvent {
  2068. frame: number;
  2069. action: () => void;
  2070. onlyOnce: boolean | undefined;
  2071. isDone: boolean;
  2072. constructor(frame: number, action: () => void, onlyOnce?: boolean | undefined);
  2073. }
  2074. class PathCursor {
  2075. private path;
  2076. private _onchange;
  2077. value: number;
  2078. animations: Animation[];
  2079. constructor(path: Path2);
  2080. getPoint(): Vector3;
  2081. moveAhead(step?: number): PathCursor;
  2082. moveBack(step?: number): PathCursor;
  2083. move(step: number): PathCursor;
  2084. private ensureLimits();
  2085. private raiseOnChange();
  2086. onchange(f: (cursor: PathCursor) => void): PathCursor;
  2087. }
  2088. interface IAnimationKey {
  2089. frame: number;
  2090. value: any;
  2091. inTangent?: any;
  2092. outTangent?: any;
  2093. interpolation?: AnimationKeyInterpolation;
  2094. }
  2095. enum AnimationKeyInterpolation {
  2096. /**
  2097. * Do not interpolate between keys and use the start key value only. Tangents are ignored.
  2098. */
  2099. STEP = 1,
  2100. }
  2101. class Animation {
  2102. name: string;
  2103. targetProperty: string;
  2104. framePerSecond: number;
  2105. dataType: number;
  2106. loopMode: number | undefined;
  2107. enableBlending: boolean | undefined;
  2108. static AllowMatricesInterpolation: boolean;
  2109. private _keys;
  2110. private _easingFunction;
  2111. _runtimeAnimations: RuntimeAnimation[];
  2112. private _events;
  2113. targetPropertyPath: string[];
  2114. blendingSpeed: number;
  2115. private _ranges;
  2116. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  2117. /**
  2118. * Sets up an animation.
  2119. * @param property the property to animate
  2120. * @param animationType the animation type to apply
  2121. * @param easingFunction the easing function used in the animation
  2122. * @returns The created animation
  2123. */
  2124. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  2125. /**
  2126. * Create and start an animation on a node
  2127. * @param {string} name defines the name of the global animation that will be run on all nodes
  2128. * @param {BABYLON.Node} node defines the root node where the animation will take place
  2129. * @param {string} targetProperty defines property to animate
  2130. * @param {number} framePerSecond defines the number of frame per second yo use
  2131. * @param {number} totalFrame defines the number of frames in total
  2132. * @param {any} from defines the initial value
  2133. * @param {any} to defines the final value
  2134. * @param {number} loopMode defines which loop mode you want to use (off by default)
  2135. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  2136. * @param onAnimationEnd defines the callback to call when animation end
  2137. * @returns the animatable created for this animation
  2138. */
  2139. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  2140. /**
  2141. * Create and start an animation on a node and its descendants
  2142. * @param {string} name defines the name of the global animation that will be run on all nodes
  2143. * @param {BABYLON.Node} node defines the root node where the animation will take place
  2144. * @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.
  2145. * @param {string} targetProperty defines property to animate
  2146. * @param {number} framePerSecond defines the number of frame per second yo use
  2147. * @param {number} totalFrame defines the number of frames in total
  2148. * @param {any} from defines the initial value
  2149. * @param {any} to defines the final value
  2150. * @param {number} loopMode defines which loop mode you want to use (off by default)
  2151. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  2152. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  2153. * @returns the list of animatables created for all nodes
  2154. * @example https://www.babylonjs-playground.com/#MH0VLI
  2155. */
  2156. 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[]>;
  2157. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  2158. /**
  2159. * Transition property of the Camera to the target Value.
  2160. * @param property The property to transition
  2161. * @param targetValue The target Value of the property
  2162. * @param host The object where the property to animate belongs
  2163. * @param scene Scene used to run the animation
  2164. * @param frameRate Framerate (in frame/s) to use
  2165. * @param transition The transition type we want to use
  2166. * @param duration The duration of the animation, in milliseconds
  2167. * @param onAnimationEnd Call back trigger at the end of the animation.
  2168. */
  2169. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  2170. /**
  2171. * Return the array of runtime animations currently using this animation
  2172. */
  2173. readonly runtimeAnimations: RuntimeAnimation[];
  2174. readonly hasRunningRuntimeAnimations: boolean;
  2175. constructor(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number | undefined, enableBlending?: boolean | undefined);
  2176. /**
  2177. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  2178. */
  2179. toString(fullDetails?: boolean): string;
  2180. /**
  2181. * Add an event to this animation.
  2182. */
  2183. addEvent(event: AnimationEvent): void;
  2184. /**
  2185. * Remove all events found at the given frame
  2186. * @param frame
  2187. */
  2188. removeEvents(frame: number): void;
  2189. getEvents(): AnimationEvent[];
  2190. createRange(name: string, from: number, to: number): void;
  2191. deleteRange(name: string, deleteFrames?: boolean): void;
  2192. getRange(name: string): Nullable<AnimationRange>;
  2193. getKeys(): Array<IAnimationKey>;
  2194. getHighestFrame(): number;
  2195. getEasingFunction(): IEasingFunction;
  2196. setEasingFunction(easingFunction: EasingFunction): void;
  2197. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  2198. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  2199. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  2200. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  2201. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  2202. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  2203. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  2204. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  2205. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  2206. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  2207. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  2208. clone(): Animation;
  2209. setKeys(values: Array<IAnimationKey>): void;
  2210. serialize(): any;
  2211. private static _ANIMATIONTYPE_FLOAT;
  2212. private static _ANIMATIONTYPE_VECTOR3;
  2213. private static _ANIMATIONTYPE_QUATERNION;
  2214. private static _ANIMATIONTYPE_MATRIX;
  2215. private static _ANIMATIONTYPE_COLOR3;
  2216. private static _ANIMATIONTYPE_VECTOR2;
  2217. private static _ANIMATIONTYPE_SIZE;
  2218. private static _ANIMATIONLOOPMODE_RELATIVE;
  2219. private static _ANIMATIONLOOPMODE_CYCLE;
  2220. private static _ANIMATIONLOOPMODE_CONSTANT;
  2221. static readonly ANIMATIONTYPE_FLOAT: number;
  2222. static readonly ANIMATIONTYPE_VECTOR3: number;
  2223. static readonly ANIMATIONTYPE_VECTOR2: number;
  2224. static readonly ANIMATIONTYPE_SIZE: number;
  2225. static readonly ANIMATIONTYPE_QUATERNION: number;
  2226. static readonly ANIMATIONTYPE_MATRIX: number;
  2227. static readonly ANIMATIONTYPE_COLOR3: number;
  2228. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  2229. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  2230. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  2231. static Parse(parsedAnimation: any): Animation;
  2232. static AppendSerializedAnimations(source: IAnimatable, destination: any): any;
  2233. }
  2234. }
  2235. declare module BABYLON {
  2236. /**
  2237. * This class defines the direct association between an animation and a target
  2238. */
  2239. class TargetedAnimation {
  2240. animation: Animation;
  2241. target: any;
  2242. }
  2243. /**
  2244. * Use this class to create coordinated animations on multiple targets
  2245. */
  2246. class AnimationGroup implements IDisposable {
  2247. name: string;
  2248. private _scene;
  2249. private _targetedAnimations;
  2250. private _animatables;
  2251. private _from;
  2252. private _to;
  2253. private _isStarted;
  2254. private _speedRatio;
  2255. onAnimationEndObservable: Observable<TargetedAnimation>;
  2256. /**
  2257. * Define if the animations are started
  2258. */
  2259. readonly isStarted: boolean;
  2260. /**
  2261. * Gets or sets the speed ratio to use for all animations
  2262. */
  2263. /**
  2264. * Gets or sets the speed ratio to use for all animations
  2265. */
  2266. speedRatio: number;
  2267. /**
  2268. * Gets the targeted animations for this animation group
  2269. */
  2270. readonly targetedAnimations: Array<TargetedAnimation>;
  2271. constructor(name: string, scene?: Nullable<Scene>);
  2272. /**
  2273. * Add an animation (with its target) in the group
  2274. * @param animation defines the animation we want to add
  2275. * @param target defines the target of the animation
  2276. * @returns the {BABYLON.TargetedAnimation} object
  2277. */
  2278. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  2279. /**
  2280. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  2281. * It can add constant keys at begin or end
  2282. * @param beginFrame defines the new begin frame for all animations. It can't be bigger than the smallest begin frame of all animations
  2283. * @param endFrame defines the new end frame for all animations. It can't be smaller than the largest end frame of all animations
  2284. */
  2285. normalize(beginFrame?: number, endFrame?: number): AnimationGroup;
  2286. /**
  2287. * Start all animations on given targets
  2288. * @param loop defines if animations must loop
  2289. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  2290. */
  2291. start(loop?: boolean, speedRatio?: number): AnimationGroup;
  2292. /**
  2293. * Pause all animations
  2294. */
  2295. pause(): AnimationGroup;
  2296. /**
  2297. * Play all animations to initial state
  2298. * This function will start() the animations if they were not started or will restart() them if they were paused
  2299. * @param loop defines if animations must loop
  2300. */
  2301. play(loop?: boolean): AnimationGroup;
  2302. /**
  2303. * Reset all animations to initial state
  2304. */
  2305. reset(): AnimationGroup;
  2306. /**
  2307. * Restart animations from key 0
  2308. */
  2309. restart(): AnimationGroup;
  2310. /**
  2311. * Stop all animations
  2312. */
  2313. stop(): AnimationGroup;
  2314. /**
  2315. * Dispose all associated resources
  2316. */
  2317. dispose(): void;
  2318. }
  2319. }
  2320. declare module BABYLON {
  2321. interface IEasingFunction {
  2322. ease(gradient: number): number;
  2323. }
  2324. class EasingFunction implements IEasingFunction {
  2325. private static _EASINGMODE_EASEIN;
  2326. private static _EASINGMODE_EASEOUT;
  2327. private static _EASINGMODE_EASEINOUT;
  2328. static readonly EASINGMODE_EASEIN: number;
  2329. static readonly EASINGMODE_EASEOUT: number;
  2330. static readonly EASINGMODE_EASEINOUT: number;
  2331. private _easingMode;
  2332. setEasingMode(easingMode: number): void;
  2333. getEasingMode(): number;
  2334. easeInCore(gradient: number): number;
  2335. ease(gradient: number): number;
  2336. }
  2337. class CircleEase extends EasingFunction implements IEasingFunction {
  2338. easeInCore(gradient: number): number;
  2339. }
  2340. class BackEase extends EasingFunction implements IEasingFunction {
  2341. amplitude: number;
  2342. constructor(amplitude?: number);
  2343. easeInCore(gradient: number): number;
  2344. }
  2345. class BounceEase extends EasingFunction implements IEasingFunction {
  2346. bounces: number;
  2347. bounciness: number;
  2348. constructor(bounces?: number, bounciness?: number);
  2349. easeInCore(gradient: number): number;
  2350. }
  2351. class CubicEase extends EasingFunction implements IEasingFunction {
  2352. easeInCore(gradient: number): number;
  2353. }
  2354. class ElasticEase extends EasingFunction implements IEasingFunction {
  2355. oscillations: number;
  2356. springiness: number;
  2357. constructor(oscillations?: number, springiness?: number);
  2358. easeInCore(gradient: number): number;
  2359. }
  2360. class ExponentialEase extends EasingFunction implements IEasingFunction {
  2361. exponent: number;
  2362. constructor(exponent?: number);
  2363. easeInCore(gradient: number): number;
  2364. }
  2365. class PowerEase extends EasingFunction implements IEasingFunction {
  2366. power: number;
  2367. constructor(power?: number);
  2368. easeInCore(gradient: number): number;
  2369. }
  2370. class QuadraticEase extends EasingFunction implements IEasingFunction {
  2371. easeInCore(gradient: number): number;
  2372. }
  2373. class QuarticEase extends EasingFunction implements IEasingFunction {
  2374. easeInCore(gradient: number): number;
  2375. }
  2376. class QuinticEase extends EasingFunction implements IEasingFunction {
  2377. easeInCore(gradient: number): number;
  2378. }
  2379. class SineEase extends EasingFunction implements IEasingFunction {
  2380. easeInCore(gradient: number): number;
  2381. }
  2382. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  2383. x1: number;
  2384. y1: number;
  2385. x2: number;
  2386. y2: number;
  2387. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  2388. easeInCore(gradient: number): number;
  2389. }
  2390. }
  2391. declare module BABYLON {
  2392. class RuntimeAnimation {
  2393. currentFrame: number;
  2394. private _animation;
  2395. private _target;
  2396. private _originalBlendValue;
  2397. private _offsetsCache;
  2398. private _highLimitsCache;
  2399. private _stopped;
  2400. private _blendingFactor;
  2401. constructor(target: any, animation: Animation);
  2402. readonly animation: Animation;
  2403. reset(): void;
  2404. isStopped(): boolean;
  2405. dispose(): void;
  2406. private _getKeyValue(value);
  2407. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  2408. setValue(currentValue: any, blend?: boolean): void;
  2409. goToFrame(frame: number): void;
  2410. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  2411. private _ratioOffset;
  2412. private _previousDelay;
  2413. private _previousRatio;
  2414. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, blend?: boolean): boolean;
  2415. }
  2416. }
  2417. declare module BABYLON {
  2418. class Analyser {
  2419. SMOOTHING: number;
  2420. FFT_SIZE: number;
  2421. BARGRAPHAMPLITUDE: number;
  2422. DEBUGCANVASPOS: {
  2423. x: number;
  2424. y: number;
  2425. };
  2426. DEBUGCANVASSIZE: {
  2427. width: number;
  2428. height: number;
  2429. };
  2430. private _byteFreqs;
  2431. private _byteTime;
  2432. private _floatFreqs;
  2433. private _webAudioAnalyser;
  2434. private _debugCanvas;
  2435. private _debugCanvasContext;
  2436. private _scene;
  2437. private _registerFunc;
  2438. private _audioEngine;
  2439. constructor(scene: Scene);
  2440. getFrequencyBinCount(): number;
  2441. getByteFrequencyData(): Uint8Array;
  2442. getByteTimeDomainData(): Uint8Array;
  2443. getFloatFrequencyData(): Uint8Array;
  2444. drawDebugCanvas(): void;
  2445. stopDebugCanvas(): void;
  2446. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  2447. dispose(): void;
  2448. }
  2449. }
  2450. declare module BABYLON {
  2451. class AudioEngine {
  2452. private _audioContext;
  2453. private _audioContextInitialized;
  2454. canUseWebAudio: boolean;
  2455. masterGain: GainNode;
  2456. private _connectedAnalyser;
  2457. WarnedWebAudioUnsupported: boolean;
  2458. unlocked: boolean;
  2459. onAudioUnlocked: () => any;
  2460. isMP3supported: boolean;
  2461. isOGGsupported: boolean;
  2462. readonly audioContext: Nullable<AudioContext>;
  2463. constructor();
  2464. private _unlockiOSaudio();
  2465. private _initializeAudioContext();
  2466. dispose(): void;
  2467. getGlobalVolume(): number;
  2468. setGlobalVolume(newVolume: number): void;
  2469. connectToAnalyser(analyser: Analyser): void;
  2470. }
  2471. }
  2472. declare module BABYLON {
  2473. class Sound {
  2474. name: string;
  2475. autoplay: boolean;
  2476. loop: boolean;
  2477. useCustomAttenuation: boolean;
  2478. soundTrackId: number;
  2479. spatialSound: boolean;
  2480. refDistance: number;
  2481. rolloffFactor: number;
  2482. maxDistance: number;
  2483. distanceModel: string;
  2484. private _panningModel;
  2485. onended: () => any;
  2486. private _playbackRate;
  2487. private _streaming;
  2488. private _startTime;
  2489. private _startOffset;
  2490. private _position;
  2491. private _localDirection;
  2492. private _volume;
  2493. private _isReadyToPlay;
  2494. isPlaying: boolean;
  2495. isPaused: boolean;
  2496. private _isDirectional;
  2497. private _readyToPlayCallback;
  2498. private _audioBuffer;
  2499. private _soundSource;
  2500. private _streamingSource;
  2501. private _soundPanner;
  2502. private _soundGain;
  2503. private _inputAudioNode;
  2504. private _ouputAudioNode;
  2505. private _coneInnerAngle;
  2506. private _coneOuterAngle;
  2507. private _coneOuterGain;
  2508. private _scene;
  2509. private _connectedMesh;
  2510. private _customAttenuationFunction;
  2511. private _registerFunc;
  2512. private _isOutputConnected;
  2513. private _htmlAudioElement;
  2514. private _urlType;
  2515. /**
  2516. * Create a sound and attach it to a scene
  2517. * @param name Name of your sound
  2518. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  2519. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  2520. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  2521. */
  2522. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  2523. dispose(): void;
  2524. isReady(): boolean;
  2525. private _soundLoaded(audioData);
  2526. setAudioBuffer(audioBuffer: AudioBuffer): void;
  2527. updateOptions(options: any): void;
  2528. private _createSpatialParameters();
  2529. private _updateSpatialParameters();
  2530. switchPanningModelToHRTF(): void;
  2531. switchPanningModelToEqualPower(): void;
  2532. private _switchPanningModel();
  2533. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  2534. /**
  2535. * Transform this sound into a directional source
  2536. * @param coneInnerAngle Size of the inner cone in degree
  2537. * @param coneOuterAngle Size of the outer cone in degree
  2538. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  2539. */
  2540. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  2541. setPosition(newPosition: Vector3): void;
  2542. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  2543. private _updateDirection();
  2544. updateDistanceFromListener(): void;
  2545. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  2546. /**
  2547. * Play the sound
  2548. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  2549. * @param offset (optional) Start the sound setting it at a specific time
  2550. */
  2551. play(time?: number, offset?: number): void;
  2552. private _onended();
  2553. /**
  2554. * Stop the sound
  2555. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  2556. */
  2557. stop(time?: number): void;
  2558. pause(): void;
  2559. setVolume(newVolume: number, time?: number): void;
  2560. setPlaybackRate(newPlaybackRate: number): void;
  2561. getVolume(): number;
  2562. attachToMesh(meshToConnectTo: AbstractMesh): void;
  2563. detachFromMesh(): void;
  2564. private _onRegisterAfterWorldMatrixUpdate(node);
  2565. clone(): Nullable<Sound>;
  2566. getAudioBuffer(): AudioBuffer | null;
  2567. serialize(): any;
  2568. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  2569. }
  2570. }
  2571. declare module BABYLON {
  2572. class SoundTrack {
  2573. private _outputAudioNode;
  2574. private _scene;
  2575. id: number;
  2576. soundCollection: Array<Sound>;
  2577. private _isMainTrack;
  2578. private _connectedAnalyser;
  2579. private _options;
  2580. private _isInitialized;
  2581. constructor(scene: Scene, options?: any);
  2582. private _initializeSoundTrackAudioGraph();
  2583. dispose(): void;
  2584. AddSound(sound: Sound): void;
  2585. RemoveSound(sound: Sound): void;
  2586. setVolume(newVolume: number): void;
  2587. switchPanningModelToHRTF(): void;
  2588. switchPanningModelToEqualPower(): void;
  2589. connectToAnalyser(analyser: Analyser): void;
  2590. }
  2591. }
  2592. declare module BABYLON {
  2593. interface Behavior<T extends Node> {
  2594. name: string;
  2595. init(): void;
  2596. attach(node: T): void;
  2597. detach(): void;
  2598. }
  2599. }
  2600. declare module BABYLON {
  2601. class Bone extends Node {
  2602. name: string;
  2603. private static _tmpVecs;
  2604. private static _tmpQuat;
  2605. private static _tmpMats;
  2606. children: Bone[];
  2607. animations: Animation[];
  2608. length: number;
  2609. _index: Nullable<number>;
  2610. private _skeleton;
  2611. private _localMatrix;
  2612. private _restPose;
  2613. private _baseMatrix;
  2614. private _worldTransform;
  2615. private _absoluteTransform;
  2616. private _invertedAbsoluteTransform;
  2617. private _parent;
  2618. private _scaleMatrix;
  2619. private _scaleVector;
  2620. private _negateScaleChildren;
  2621. private _scalingDeterminant;
  2622. _matrix: Matrix;
  2623. constructor(name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  2624. getSkeleton(): Skeleton;
  2625. getParent(): Nullable<Bone>;
  2626. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  2627. getLocalMatrix(): Matrix;
  2628. getBaseMatrix(): Matrix;
  2629. getRestPose(): Matrix;
  2630. returnToRest(): void;
  2631. getWorldMatrix(): Matrix;
  2632. getInvertedAbsoluteTransform(): Matrix;
  2633. getAbsoluteTransform(): Matrix;
  2634. position: Vector3;
  2635. rotation: Vector3;
  2636. rotationQuaternion: Quaternion;
  2637. scaling: Vector3;
  2638. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean): void;
  2639. _updateDifferenceMatrix(rootMatrix?: Matrix): void;
  2640. markAsDirty(): void;
  2641. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  2642. /**
  2643. * Translate the bone in local or world space.
  2644. * @param vec The amount to translate the bone.
  2645. * @param space The space that the translation is in.
  2646. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2647. */
  2648. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2649. /**
  2650. * Set the postion of the bone in local or world space.
  2651. * @param position The position to set the bone.
  2652. * @param space The space that the position is in.
  2653. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2654. */
  2655. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2656. /**
  2657. * Set the absolute postion of the bone (world space).
  2658. * @param position The position to set the bone.
  2659. * @param mesh The mesh that this bone is attached to.
  2660. */
  2661. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  2662. /**
  2663. * Set the scale of the bone on the x, y and z axes.
  2664. * @param x The scale of the bone on the x axis.
  2665. * @param x The scale of the bone on the y axis.
  2666. * @param z The scale of the bone on the z axis.
  2667. * @param scaleChildren Set this to true if children of the bone should be scaled.
  2668. */
  2669. setScale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  2670. /**
  2671. * Scale the bone on the x, y and z axes.
  2672. * @param x The amount to scale the bone on the x axis.
  2673. * @param x The amount to scale the bone on the y axis.
  2674. * @param z The amount to scale the bone on the z axis.
  2675. * @param scaleChildren Set this to true if children of the bone should be scaled.
  2676. */
  2677. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  2678. /**
  2679. * Set the yaw, pitch, and roll of the bone in local or world space.
  2680. * @param yaw The rotation of the bone on the y axis.
  2681. * @param pitch The rotation of the bone on the x axis.
  2682. * @param roll The rotation of the bone on the z axis.
  2683. * @param space The space that the axes of rotation are in.
  2684. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2685. */
  2686. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  2687. /**
  2688. * Rotate the bone on an axis in local or world space.
  2689. * @param axis The axis to rotate the bone on.
  2690. * @param amount The amount to rotate the bone.
  2691. * @param space The space that the axis is in.
  2692. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2693. */
  2694. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  2695. /**
  2696. * Set the rotation of the bone to a particular axis angle in local or world space.
  2697. * @param axis The axis to rotate the bone on.
  2698. * @param angle The angle that the bone should be rotated to.
  2699. * @param space The space that the axis is in.
  2700. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2701. */
  2702. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  2703. /**
  2704. * Set the euler rotation of the bone in local of world space.
  2705. * @param rotation The euler rotation that the bone should be set to.
  2706. * @param space The space that the rotation is in.
  2707. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2708. */
  2709. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2710. /**
  2711. * Set the quaternion rotation of the bone in local of world space.
  2712. * @param quat The quaternion rotation that the bone should be set to.
  2713. * @param space The space that the rotation is in.
  2714. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2715. */
  2716. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  2717. /**
  2718. * Set the rotation matrix of the bone in local of world space.
  2719. * @param rotMat The rotation matrix that the bone should be set to.
  2720. * @param space The space that the rotation is in.
  2721. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2722. */
  2723. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  2724. private _rotateWithMatrix(rmat, space?, mesh?);
  2725. private _getNegativeRotationToRef(rotMatInv, space?, mesh?);
  2726. /**
  2727. * Get the scale of the bone
  2728. * @returns the scale of the bone
  2729. */
  2730. getScale(): Vector3;
  2731. /**
  2732. * Copy the scale of the bone to a vector3.
  2733. * @param result The vector3 to copy the scale to
  2734. */
  2735. getScaleToRef(result: Vector3): void;
  2736. /**
  2737. * Get the position of the bone in local or world space.
  2738. * @param space The space that the returned position is in.
  2739. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2740. * @returns The position of the bone
  2741. */
  2742. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  2743. /**
  2744. * Copy the position of the bone to a vector3 in local or world space.
  2745. * @param space The space that the returned position is in.
  2746. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2747. * @param result The vector3 to copy the position to.
  2748. */
  2749. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  2750. /**
  2751. * Get the absolute position of the bone (world space).
  2752. * @param mesh The mesh that this bone is attached to.
  2753. * @returns The absolute position of the bone
  2754. */
  2755. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  2756. /**
  2757. * Copy the absolute position of the bone (world space) to the result param.
  2758. * @param mesh The mesh that this bone is attached to.
  2759. * @param result The vector3 to copy the absolute position to.
  2760. */
  2761. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  2762. /**
  2763. * Compute the absolute transforms of this bone and its children.
  2764. */
  2765. computeAbsoluteTransforms(): void;
  2766. private _syncScaleVector();
  2767. /**
  2768. * Get the world direction from an axis that is in the local space of the bone.
  2769. * @param localAxis The local direction that is used to compute the world direction.
  2770. * @param mesh The mesh that this bone is attached to.
  2771. * @returns The world direction
  2772. */
  2773. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2774. /**
  2775. * Copy the world direction to a vector3 from an axis that is in the local space of the bone.
  2776. * @param localAxis The local direction that is used to compute the world direction.
  2777. * @param mesh The mesh that this bone is attached to.
  2778. * @param result The vector3 that the world direction will be copied to.
  2779. */
  2780. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2781. /**
  2782. * Get the euler rotation of the bone in local or world space.
  2783. * @param space The space that the rotation should be in.
  2784. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2785. * @returns The euler rotation
  2786. */
  2787. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  2788. /**
  2789. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space.
  2790. * @param space The space that the rotation should be in.
  2791. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2792. * @param result The vector3 that the rotation should be copied to.
  2793. */
  2794. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2795. /**
  2796. * Get the quaternion rotation of the bone in either local or world space.
  2797. * @param space The space that the rotation should be in.
  2798. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2799. * @returns The quaternion rotation
  2800. */
  2801. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  2802. /**
  2803. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space.
  2804. * @param space The space that the rotation should be in.
  2805. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2806. * @param result The quaternion that the rotation should be copied to.
  2807. */
  2808. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  2809. /**
  2810. * Get the rotation matrix of the bone in local or world space.
  2811. * @param space The space that the rotation should be in.
  2812. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2813. * @returns The rotation matrix
  2814. */
  2815. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  2816. /**
  2817. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space.
  2818. * @param space The space that the rotation should be in.
  2819. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2820. * @param result The quaternion that the rotation should be copied to.
  2821. */
  2822. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  2823. /**
  2824. * Get the world position of a point that is in the local space of the bone.
  2825. * @param position The local position
  2826. * @param mesh The mesh that this bone is attached to.
  2827. * @returns The world position
  2828. */
  2829. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2830. /**
  2831. * Get the world position of a point that is in the local space of the bone and copy it to the result param.
  2832. * @param position The local position
  2833. * @param mesh The mesh that this bone is attached to.
  2834. * @param result The vector3 that the world position should be copied to.
  2835. */
  2836. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2837. /**
  2838. * Get the local position of a point that is in world space.
  2839. * @param position The world position
  2840. * @param mesh The mesh that this bone is attached to.
  2841. * @returns The local position
  2842. */
  2843. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2844. /**
  2845. * Get the local position of a point that is in world space and copy it to the result param.
  2846. * @param position The world position
  2847. * @param mesh The mesh that this bone is attached to.
  2848. * @param result The vector3 that the local position should be copied to.
  2849. */
  2850. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2851. }
  2852. }
  2853. declare module BABYLON {
  2854. class BoneIKController {
  2855. private static _tmpVecs;
  2856. private static _tmpQuat;
  2857. private static _tmpMats;
  2858. targetMesh: AbstractMesh;
  2859. poleTargetMesh: AbstractMesh;
  2860. poleTargetBone: Nullable<Bone>;
  2861. targetPosition: Vector3;
  2862. poleTargetPosition: Vector3;
  2863. poleTargetLocalOffset: Vector3;
  2864. poleAngle: number;
  2865. mesh: AbstractMesh;
  2866. slerpAmount: number;
  2867. private _bone1Quat;
  2868. private _bone1Mat;
  2869. private _bone2Ang;
  2870. private _bone1;
  2871. private _bone2;
  2872. private _bone1Length;
  2873. private _bone2Length;
  2874. private _maxAngle;
  2875. private _maxReach;
  2876. private _rightHandedSystem;
  2877. private _bendAxis;
  2878. private _slerping;
  2879. private _adjustRoll;
  2880. maxAngle: number;
  2881. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  2882. targetMesh?: AbstractMesh;
  2883. poleTargetMesh?: AbstractMesh;
  2884. poleTargetBone?: Bone;
  2885. poleTargetLocalOffset?: Vector3;
  2886. poleAngle?: number;
  2887. bendAxis?: Vector3;
  2888. maxAngle?: number;
  2889. slerpAmount?: number;
  2890. });
  2891. private _setMaxAngle(ang);
  2892. update(): void;
  2893. }
  2894. }
  2895. declare module BABYLON {
  2896. class BoneLookController {
  2897. private static _tmpVecs;
  2898. private static _tmpQuat;
  2899. private static _tmpMats;
  2900. /**
  2901. * The target Vector3 that the bone will look at.
  2902. */
  2903. target: Vector3;
  2904. /**
  2905. * The mesh that the bone is attached to.
  2906. */
  2907. mesh: AbstractMesh;
  2908. /**
  2909. * The bone that will be looking to the target.
  2910. */
  2911. bone: Bone;
  2912. /**
  2913. * The up axis of the coordinate system that is used when the bone is rotated.
  2914. */
  2915. upAxis: Vector3;
  2916. /**
  2917. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  2918. */
  2919. upAxisSpace: Space;
  2920. /**
  2921. * Used to make an adjustment to the yaw of the bone.
  2922. */
  2923. adjustYaw: number;
  2924. /**
  2925. * Used to make an adjustment to the pitch of the bone.
  2926. */
  2927. adjustPitch: number;
  2928. /**
  2929. * Used to make an adjustment to the roll of the bone.
  2930. */
  2931. adjustRoll: number;
  2932. /**
  2933. * 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).
  2934. */
  2935. slerpAmount: number;
  2936. private _minYaw;
  2937. private _maxYaw;
  2938. private _minPitch;
  2939. private _maxPitch;
  2940. private _minYawSin;
  2941. private _minYawCos;
  2942. private _maxYawSin;
  2943. private _maxYawCos;
  2944. private _midYawConstraint;
  2945. private _minPitchTan;
  2946. private _maxPitchTan;
  2947. private _boneQuat;
  2948. private _slerping;
  2949. private _transformYawPitch;
  2950. private _transformYawPitchInv;
  2951. private _firstFrameSkipped;
  2952. private _yawRange;
  2953. private _fowardAxis;
  2954. /**
  2955. * Get/set the minimum yaw angle that the bone can look to.
  2956. */
  2957. minYaw: number;
  2958. /**
  2959. * Get/set the maximum yaw angle that the bone can look to.
  2960. */
  2961. maxYaw: number;
  2962. /**
  2963. * Get/set the minimum pitch angle that the bone can look to.
  2964. */
  2965. minPitch: number;
  2966. /**
  2967. * Get/set the maximum pitch angle that the bone can look to.
  2968. */
  2969. maxPitch: number;
  2970. /**
  2971. * Create a BoneLookController
  2972. * @param mesh the mesh that the bone belongs to
  2973. * @param bone the bone that will be looking to the target
  2974. * @param target the target Vector3 to look at
  2975. * @param settings optional settings:
  2976. * - maxYaw: the maximum angle the bone will yaw to
  2977. * - minYaw: the minimum angle the bone will yaw to
  2978. * - maxPitch: the maximum angle the bone will pitch to
  2979. * - minPitch: the minimum angle the bone will yaw to
  2980. * - slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  2981. * - upAxis: the up axis of the coordinate system
  2982. * - upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  2983. * - yawAxis: set yawAxis if the bone does not yaw on the y axis
  2984. * - pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  2985. * - adjustYaw: used to make an adjustment to the yaw of the bone
  2986. * - adjustPitch: used to make an adjustment to the pitch of the bone
  2987. * - adjustRoll: used to make an adjustment to the roll of the bone
  2988. **/
  2989. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  2990. maxYaw?: number;
  2991. minYaw?: number;
  2992. maxPitch?: number;
  2993. minPitch?: number;
  2994. slerpAmount?: number;
  2995. upAxis?: Vector3;
  2996. upAxisSpace?: Space;
  2997. yawAxis?: Vector3;
  2998. pitchAxis?: Vector3;
  2999. adjustYaw?: number;
  3000. adjustPitch?: number;
  3001. adjustRoll?: number;
  3002. });
  3003. /**
  3004. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender()).
  3005. */
  3006. update(): void;
  3007. private _getAngleDiff(ang1, ang2);
  3008. private _getAngleBetween(ang1, ang2);
  3009. private _isAngleBetween(ang, ang1, ang2);
  3010. }
  3011. }
  3012. declare module BABYLON {
  3013. class Skeleton implements IAnimatable {
  3014. name: string;
  3015. id: string;
  3016. bones: Bone[];
  3017. dimensionsAtRest: Vector3;
  3018. needInitialSkinMatrix: boolean;
  3019. animations: Array<Animation>;
  3020. private _scene;
  3021. private _isDirty;
  3022. private _transformMatrices;
  3023. private _meshesWithPoseMatrix;
  3024. private _animatables;
  3025. private _identity;
  3026. private _synchronizedWithMesh;
  3027. private _ranges;
  3028. private _lastAbsoluteTransformsUpdateId;
  3029. /**
  3030. * An event triggered before computing the skeleton's matrices
  3031. * @type {BABYLON.Observable}
  3032. */
  3033. onBeforeComputeObservable: Observable<Skeleton>;
  3034. constructor(name: string, id: string, scene: Scene);
  3035. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  3036. getScene(): Scene;
  3037. /**
  3038. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  3039. */
  3040. toString(fullDetails?: boolean): string;
  3041. /**
  3042. * Get bone's index searching by name
  3043. * @param {string} name is bone's name to search for
  3044. * @return {number} Indice of the bone. Returns -1 if not found
  3045. */
  3046. getBoneIndexByName(name: string): number;
  3047. createAnimationRange(name: string, from: number, to: number): void;
  3048. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  3049. getAnimationRange(name: string): Nullable<AnimationRange>;
  3050. /**
  3051. * Returns as an Array, all AnimationRanges defined on this skeleton
  3052. */
  3053. getAnimationRanges(): Nullable<AnimationRange>[];
  3054. /**
  3055. * note: This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  3056. */
  3057. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  3058. returnToRest(): void;
  3059. private _getHighestAnimationFrame();
  3060. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  3061. _markAsDirty(): void;
  3062. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  3063. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  3064. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  3065. prepare(): void;
  3066. getAnimatables(): IAnimatable[];
  3067. clone(name: string, id: string): Skeleton;
  3068. enableBlending(blendingSpeed?: number): void;
  3069. dispose(): void;
  3070. serialize(): any;
  3071. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  3072. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  3073. getPoseMatrix(): Nullable<Matrix>;
  3074. sortBones(): void;
  3075. private _sortBones(index, bones, visited);
  3076. }
  3077. }
  3078. declare module BABYLON {
  3079. class ArcRotateCamera extends TargetCamera {
  3080. alpha: number;
  3081. beta: number;
  3082. radius: number;
  3083. protected _target: Vector3;
  3084. protected _targetHost: Nullable<AbstractMesh>;
  3085. target: Vector3;
  3086. inertialAlphaOffset: number;
  3087. inertialBetaOffset: number;
  3088. inertialRadiusOffset: number;
  3089. lowerAlphaLimit: Nullable<number>;
  3090. upperAlphaLimit: Nullable<number>;
  3091. lowerBetaLimit: number;
  3092. upperBetaLimit: number;
  3093. lowerRadiusLimit: Nullable<number>;
  3094. upperRadiusLimit: Nullable<number>;
  3095. inertialPanningX: number;
  3096. inertialPanningY: number;
  3097. pinchToPanMaxDistance: number;
  3098. panningDistanceLimit: Nullable<number>;
  3099. panningOriginTarget: Vector3;
  3100. panningInertia: number;
  3101. angularSensibilityX: number;
  3102. angularSensibilityY: number;
  3103. pinchPrecision: number;
  3104. pinchDeltaPercentage: number;
  3105. panningSensibility: number;
  3106. keysUp: number[];
  3107. keysDown: number[];
  3108. keysLeft: number[];
  3109. keysRight: number[];
  3110. wheelPrecision: number;
  3111. wheelDeltaPercentage: number;
  3112. zoomOnFactor: number;
  3113. targetScreenOffset: Vector2;
  3114. allowUpsideDown: boolean;
  3115. _viewMatrix: Matrix;
  3116. _useCtrlForPanning: boolean;
  3117. _panningMouseButton: number;
  3118. inputs: ArcRotateCameraInputsManager;
  3119. _reset: () => void;
  3120. panningAxis: Vector3;
  3121. protected _localDirection: Vector3;
  3122. protected _transformedDirection: Vector3;
  3123. private _bouncingBehavior;
  3124. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  3125. useBouncingBehavior: boolean;
  3126. private _framingBehavior;
  3127. readonly framingBehavior: Nullable<FramingBehavior>;
  3128. useFramingBehavior: boolean;
  3129. private _autoRotationBehavior;
  3130. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  3131. useAutoRotationBehavior: boolean;
  3132. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  3133. onCollide: (collidedMesh: AbstractMesh) => void;
  3134. checkCollisions: boolean;
  3135. collisionRadius: Vector3;
  3136. protected _collider: Collider;
  3137. protected _previousPosition: Vector3;
  3138. protected _collisionVelocity: Vector3;
  3139. protected _newPosition: Vector3;
  3140. protected _previousAlpha: number;
  3141. protected _previousBeta: number;
  3142. protected _previousRadius: number;
  3143. protected _collisionTriggered: boolean;
  3144. protected _targetBoundingCenter: Nullable<Vector3>;
  3145. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene);
  3146. _initCache(): void;
  3147. _updateCache(ignoreParentClass?: boolean): void;
  3148. protected _getTargetPosition(): Vector3;
  3149. /**
  3150. * Store current camera state (fov, position, etc..)
  3151. */
  3152. private _storedAlpha;
  3153. private _storedBeta;
  3154. private _storedRadius;
  3155. private _storedTarget;
  3156. storeState(): Camera;
  3157. /**
  3158. * Restored camera state. You must call storeState() first
  3159. */
  3160. _restoreStateValues(): boolean;
  3161. _isSynchronizedViewMatrix(): boolean;
  3162. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  3163. detachControl(element: HTMLElement): void;
  3164. _checkInputs(): void;
  3165. protected _checkLimits(): void;
  3166. rebuildAnglesAndRadius(): void;
  3167. setPosition(position: Vector3): void;
  3168. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  3169. _getViewMatrix(): Matrix;
  3170. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  3171. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  3172. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  3173. min: Vector3;
  3174. max: Vector3;
  3175. distance: number;
  3176. }, doNotUpdateMaxZ?: boolean): void;
  3177. /**
  3178. * @override
  3179. * Override Camera.createRigCamera
  3180. */
  3181. createRigCamera(name: string, cameraIndex: number): Camera;
  3182. /**
  3183. * @override
  3184. * Override Camera._updateRigCameras
  3185. */
  3186. _updateRigCameras(): void;
  3187. dispose(): void;
  3188. getClassName(): string;
  3189. }
  3190. }
  3191. declare module BABYLON {
  3192. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  3193. constructor(camera: ArcRotateCamera);
  3194. addMouseWheel(): ArcRotateCameraInputsManager;
  3195. addPointers(): ArcRotateCameraInputsManager;
  3196. addKeyboard(): ArcRotateCameraInputsManager;
  3197. addGamepad(): ArcRotateCameraInputsManager;
  3198. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  3199. }
  3200. }
  3201. declare module BABYLON {
  3202. class Camera extends Node {
  3203. inputs: CameraInputsManager<Camera>;
  3204. private static _PERSPECTIVE_CAMERA;
  3205. private static _ORTHOGRAPHIC_CAMERA;
  3206. private static _FOVMODE_VERTICAL_FIXED;
  3207. private static _FOVMODE_HORIZONTAL_FIXED;
  3208. private static _RIG_MODE_NONE;
  3209. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  3210. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  3211. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  3212. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  3213. private static _RIG_MODE_VR;
  3214. private static _RIG_MODE_WEBVR;
  3215. static readonly PERSPECTIVE_CAMERA: number;
  3216. static readonly ORTHOGRAPHIC_CAMERA: number;
  3217. /**
  3218. * This is the default FOV mode for perspective cameras.
  3219. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  3220. *
  3221. */
  3222. static readonly FOVMODE_VERTICAL_FIXED: number;
  3223. /**
  3224. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  3225. *
  3226. */
  3227. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  3228. static readonly RIG_MODE_NONE: number;
  3229. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  3230. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  3231. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  3232. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  3233. static readonly RIG_MODE_VR: number;
  3234. static readonly RIG_MODE_WEBVR: number;
  3235. static ForceAttachControlToAlwaysPreventDefault: boolean;
  3236. static UseAlternateWebVRRendering: boolean;
  3237. position: Vector3;
  3238. /**
  3239. * The vector the camera should consider as up.
  3240. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  3241. */
  3242. upVector: Vector3;
  3243. orthoLeft: Nullable<number>;
  3244. orthoRight: Nullable<number>;
  3245. orthoBottom: Nullable<number>;
  3246. orthoTop: Nullable<number>;
  3247. /**
  3248. * FOV is set in Radians. (default is 0.8)
  3249. */
  3250. fov: number;
  3251. minZ: number;
  3252. maxZ: number;
  3253. inertia: number;
  3254. mode: number;
  3255. isIntermediate: boolean;
  3256. viewport: Viewport;
  3257. /**
  3258. * Restricts the camera to viewing objects with the same layerMask.
  3259. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  3260. */
  3261. layerMask: number;
  3262. /**
  3263. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  3264. */
  3265. fovMode: number;
  3266. cameraRigMode: number;
  3267. interaxialDistance: number;
  3268. isStereoscopicSideBySide: boolean;
  3269. _cameraRigParams: any;
  3270. _rigCameras: Camera[];
  3271. _rigPostProcess: Nullable<PostProcess>;
  3272. protected _webvrViewMatrix: Matrix;
  3273. _skipRendering: boolean;
  3274. _alternateCamera: Camera;
  3275. customRenderTargets: RenderTargetTexture[];
  3276. onViewMatrixChangedObservable: Observable<Camera>;
  3277. onProjectionMatrixChangedObservable: Observable<Camera>;
  3278. onAfterCheckInputsObservable: Observable<Camera>;
  3279. onRestoreStateObservable: Observable<Camera>;
  3280. private _computedViewMatrix;
  3281. _projectionMatrix: Matrix;
  3282. private _doNotComputeProjectionMatrix;
  3283. private _worldMatrix;
  3284. _postProcesses: PostProcess[];
  3285. private _transformMatrix;
  3286. _activeMeshes: SmartArray<AbstractMesh>;
  3287. private _globalPosition;
  3288. private _frustumPlanes;
  3289. private _refreshFrustumPlanes;
  3290. constructor(name: string, position: Vector3, scene: Scene);
  3291. private _storedFov;
  3292. private _stateStored;
  3293. /**
  3294. * Store current camera state (fov, position, etc..)
  3295. */
  3296. storeState(): Camera;
  3297. /**
  3298. * Restores the camera state values if it has been stored. You must call storeState() first
  3299. */
  3300. protected _restoreStateValues(): boolean;
  3301. /**
  3302. * Restored camera state. You must call storeState() first
  3303. */
  3304. restoreState(): boolean;
  3305. getClassName(): string;
  3306. /**
  3307. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  3308. */
  3309. toString(fullDetails?: boolean): string;
  3310. readonly globalPosition: Vector3;
  3311. getActiveMeshes(): SmartArray<AbstractMesh>;
  3312. isActiveMesh(mesh: Mesh): boolean;
  3313. _initCache(): void;
  3314. _updateCache(ignoreParentClass?: boolean): void;
  3315. _isSynchronized(): boolean;
  3316. _isSynchronizedViewMatrix(): boolean;
  3317. _isSynchronizedProjectionMatrix(): boolean;
  3318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  3319. detachControl(element: HTMLElement): void;
  3320. update(): void;
  3321. _checkInputs(): void;
  3322. readonly rigCameras: Camera[];
  3323. readonly rigPostProcess: Nullable<PostProcess>;
  3324. private _cascadePostProcessesToRigCams();
  3325. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  3326. detachPostProcess(postProcess: PostProcess): void;
  3327. getWorldMatrix(): Matrix;
  3328. _getViewMatrix(): Matrix;
  3329. getViewMatrix(force?: boolean): Matrix;
  3330. freezeProjectionMatrix(projection?: Matrix): void;
  3331. unfreezeProjectionMatrix(): void;
  3332. getProjectionMatrix(force?: boolean): Matrix;
  3333. getTranformationMatrix(): Matrix;
  3334. private updateFrustumPlanes();
  3335. isInFrustum(target: ICullable): boolean;
  3336. isCompletelyInFrustum(target: ICullable): boolean;
  3337. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  3338. dispose(): void;
  3339. readonly leftCamera: Nullable<FreeCamera>;
  3340. readonly rightCamera: Nullable<FreeCamera>;
  3341. getLeftTarget(): Nullable<Vector3>;
  3342. getRightTarget(): Nullable<Vector3>;
  3343. setCameraRigMode(mode: number, rigParams: any): void;
  3344. private _getVRProjectionMatrix();
  3345. protected _updateCameraRotationMatrix(): void;
  3346. protected _updateWebVRCameraRotationMatrix(): void;
  3347. /**
  3348. * This function MUST be overwritten by the different WebVR cameras available.
  3349. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  3350. */
  3351. protected _getWebVRProjectionMatrix(): Matrix;
  3352. /**
  3353. * This function MUST be overwritten by the different WebVR cameras available.
  3354. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  3355. */
  3356. protected _getWebVRViewMatrix(): Matrix;
  3357. setCameraRigParameter(name: string, value: any): void;
  3358. /**
  3359. * needs to be overridden by children so sub has required properties to be copied
  3360. */
  3361. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  3362. /**
  3363. * May need to be overridden by children
  3364. */
  3365. _updateRigCameras(): void;
  3366. _setupInputs(): void;
  3367. serialize(): any;
  3368. clone(name: string): Camera;
  3369. getDirection(localAxis: Vector3): Vector3;
  3370. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  3371. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  3372. computeWorldMatrix(): Matrix;
  3373. static Parse(parsedCamera: any, scene: Scene): Camera;
  3374. }
  3375. }
  3376. declare module BABYLON {
  3377. var CameraInputTypes: {};
  3378. interface ICameraInput<TCamera extends Camera> {
  3379. camera: Nullable<TCamera>;
  3380. getClassName(): string;
  3381. getSimpleName(): string;
  3382. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  3383. detachControl: (element: Nullable<HTMLElement>) => void;
  3384. checkInputs?: () => void;
  3385. }
  3386. interface CameraInputsMap<TCamera extends Camera> {
  3387. [name: string]: ICameraInput<TCamera>;
  3388. [idx: number]: ICameraInput<TCamera>;
  3389. }
  3390. class CameraInputsManager<TCamera extends Camera> {
  3391. attached: CameraInputsMap<TCamera>;
  3392. attachedElement: Nullable<HTMLElement>;
  3393. noPreventDefault: boolean;
  3394. camera: TCamera;
  3395. checkInputs: () => void;
  3396. constructor(camera: TCamera);
  3397. /**
  3398. * Add an input method to a camera.
  3399. * builtin inputs example: camera.inputs.addGamepad();
  3400. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  3401. * @param input camera input method
  3402. */
  3403. add(input: ICameraInput<TCamera>): void;
  3404. /**
  3405. * Remove a specific input method from a camera
  3406. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  3407. * @param inputToRemove camera input method
  3408. */
  3409. remove(inputToRemove: ICameraInput<TCamera>): void;
  3410. removeByType(inputType: string): void;
  3411. private _addCheckInputs(fn);
  3412. attachInput(input: ICameraInput<TCamera>): void;
  3413. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  3414. detachElement(element: HTMLElement, disconnect?: boolean): void;
  3415. rebuildInputCheck(): void;
  3416. /**
  3417. * Remove all attached input methods from a camera
  3418. */
  3419. clear(): void;
  3420. serialize(serializedCamera: any): void;
  3421. parse(parsedCamera: any): void;
  3422. }
  3423. }
  3424. declare module BABYLON {
  3425. /**
  3426. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  3427. * being tilted forward or back and left or right.
  3428. */
  3429. class DeviceOrientationCamera extends FreeCamera {
  3430. private _initialQuaternion;
  3431. private _quaternionCache;
  3432. /**
  3433. * Creates a new device orientation camera. @see DeviceOrientationCamera
  3434. * @param name The name of the camera
  3435. * @param position The start position camera
  3436. * @param scene The scene the camera belongs to
  3437. */
  3438. constructor(name: string, position: Vector3, scene: Scene);
  3439. /**
  3440. * Gets the current instance class name ("DeviceOrientationCamera").
  3441. * This helps avoiding instanceof at run time.
  3442. * @returns the class name
  3443. */
  3444. getClassName(): string;
  3445. /**
  3446. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  3447. */
  3448. _checkInputs(): void;
  3449. /**
  3450. * Reset the camera to its default orientation on the specified axis only.
  3451. * @param axis The axis to reset
  3452. */
  3453. resetToCurrentRotation(axis?: Axis): void;
  3454. }
  3455. }
  3456. declare module BABYLON {
  3457. class FollowCamera extends TargetCamera {
  3458. radius: number;
  3459. rotationOffset: number;
  3460. heightOffset: number;
  3461. cameraAcceleration: number;
  3462. maxCameraSpeed: number;
  3463. lockedTarget: Nullable<AbstractMesh>;
  3464. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  3465. private getRadians(degrees);
  3466. private follow(cameraTarget);
  3467. _checkInputs(): void;
  3468. getClassName(): string;
  3469. }
  3470. class ArcFollowCamera extends TargetCamera {
  3471. alpha: number;
  3472. beta: number;
  3473. radius: number;
  3474. target: Nullable<AbstractMesh>;
  3475. private _cartesianCoordinates;
  3476. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  3477. private follow();
  3478. _checkInputs(): void;
  3479. getClassName(): string;
  3480. }
  3481. }
  3482. declare module BABYLON {
  3483. class FreeCamera extends TargetCamera {
  3484. ellipsoid: Vector3;
  3485. ellipsoidOffset: Vector3;
  3486. checkCollisions: boolean;
  3487. applyGravity: boolean;
  3488. inputs: FreeCameraInputsManager;
  3489. /**
  3490. * Gets the input sensibility for a mouse input. (default is 2000.0)
  3491. * Higher values reduce sensitivity.
  3492. */
  3493. /**
  3494. * Sets the input sensibility for a mouse input. (default is 2000.0)
  3495. * Higher values reduce sensitivity.
  3496. */
  3497. angularSensibility: number;
  3498. keysUp: number[];
  3499. keysDown: number[];
  3500. keysLeft: number[];
  3501. keysRight: number[];
  3502. onCollide: (collidedMesh: AbstractMesh) => void;
  3503. private _collider;
  3504. private _needMoveForGravity;
  3505. private _oldPosition;
  3506. private _diffPosition;
  3507. private _newPosition;
  3508. _localDirection: Vector3;
  3509. _transformedDirection: Vector3;
  3510. constructor(name: string, position: Vector3, scene: Scene);
  3511. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  3512. detachControl(element: HTMLElement): void;
  3513. private _collisionMask;
  3514. collisionMask: number;
  3515. _collideWithWorld(displacement: Vector3): void;
  3516. private _onCollisionPositionChange;
  3517. _checkInputs(): void;
  3518. _decideIfNeedsToMove(): boolean;
  3519. _updatePosition(): void;
  3520. dispose(): void;
  3521. getClassName(): string;
  3522. }
  3523. }
  3524. declare module BABYLON {
  3525. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  3526. constructor(camera: FreeCamera);
  3527. addKeyboard(): FreeCameraInputsManager;
  3528. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  3529. addGamepad(): FreeCameraInputsManager;
  3530. addDeviceOrientation(): FreeCameraInputsManager;
  3531. addTouch(): FreeCameraInputsManager;
  3532. addVirtualJoystick(): FreeCameraInputsManager;
  3533. }
  3534. }
  3535. declare module BABYLON {
  3536. class GamepadCamera extends UniversalCamera {
  3537. gamepadAngularSensibility: number;
  3538. gamepadMoveSensibility: number;
  3539. constructor(name: string, position: Vector3, scene: Scene);
  3540. getClassName(): string;
  3541. }
  3542. }
  3543. declare module BABYLON {
  3544. class AnaglyphFreeCamera extends FreeCamera {
  3545. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3546. getClassName(): string;
  3547. }
  3548. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  3549. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  3550. getClassName(): string;
  3551. }
  3552. class AnaglyphGamepadCamera extends GamepadCamera {
  3553. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3554. getClassName(): string;
  3555. }
  3556. class AnaglyphUniversalCamera extends UniversalCamera {
  3557. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3558. getClassName(): string;
  3559. }
  3560. class StereoscopicFreeCamera extends FreeCamera {
  3561. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3562. getClassName(): string;
  3563. }
  3564. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  3565. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3566. getClassName(): string;
  3567. }
  3568. class StereoscopicGamepadCamera extends GamepadCamera {
  3569. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3570. getClassName(): string;
  3571. }
  3572. class StereoscopicUniversalCamera extends UniversalCamera {
  3573. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3574. getClassName(): string;
  3575. }
  3576. }
  3577. declare module BABYLON {
  3578. class TargetCamera extends Camera {
  3579. cameraDirection: Vector3;
  3580. cameraRotation: Vector2;
  3581. rotation: Vector3;
  3582. rotationQuaternion: Quaternion;
  3583. speed: number;
  3584. noRotationConstraint: boolean;
  3585. lockedTarget: any;
  3586. _currentTarget: Vector3;
  3587. _viewMatrix: Matrix;
  3588. _camMatrix: Matrix;
  3589. _cameraTransformMatrix: Matrix;
  3590. _cameraRotationMatrix: Matrix;
  3591. private _rigCamTransformMatrix;
  3592. _referencePoint: Vector3;
  3593. private _currentUpVector;
  3594. _transformedReferencePoint: Vector3;
  3595. _lookAtTemp: Matrix;
  3596. _tempMatrix: Matrix;
  3597. _reset: () => void;
  3598. constructor(name: string, position: Vector3, scene: Scene);
  3599. getFrontPosition(distance: number): Vector3;
  3600. _getLockedTargetPosition(): Nullable<Vector3>;
  3601. /**
  3602. * Store current camera state (fov, position, etc..)
  3603. */
  3604. private _storedPosition;
  3605. private _storedRotation;
  3606. private _storedRotationQuaternion;
  3607. storeState(): Camera;
  3608. /**
  3609. * Restored camera state. You must call storeState() first
  3610. */
  3611. _restoreStateValues(): boolean;
  3612. _initCache(): void;
  3613. _updateCache(ignoreParentClass?: boolean): void;
  3614. _isSynchronizedViewMatrix(): boolean;
  3615. _computeLocalCameraSpeed(): number;
  3616. setTarget(target: Vector3): void;
  3617. /**
  3618. * Return the current target position of the camera. This value is expressed in local space.
  3619. */
  3620. getTarget(): Vector3;
  3621. _decideIfNeedsToMove(): boolean;
  3622. _updatePosition(): void;
  3623. _checkInputs(): void;
  3624. protected _updateCameraRotationMatrix(): void;
  3625. _getViewMatrix(): Matrix;
  3626. /**
  3627. * @override
  3628. * Override Camera.createRigCamera
  3629. */
  3630. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  3631. /**
  3632. * @override
  3633. * Override Camera._updateRigCameras
  3634. */
  3635. _updateRigCameras(): void;
  3636. private _getRigCamPosition(halfSpace, result);
  3637. getClassName(): string;
  3638. }
  3639. }
  3640. declare module BABYLON {
  3641. class TouchCamera extends FreeCamera {
  3642. touchAngularSensibility: number;
  3643. touchMoveSensibility: number;
  3644. constructor(name: string, position: Vector3, scene: Scene);
  3645. getClassName(): string;
  3646. _setupInputs(): void;
  3647. }
  3648. }
  3649. declare module BABYLON {
  3650. class UniversalCamera extends TouchCamera {
  3651. gamepadAngularSensibility: number;
  3652. gamepadMoveSensibility: number;
  3653. constructor(name: string, position: Vector3, scene: Scene);
  3654. getClassName(): string;
  3655. }
  3656. }
  3657. declare module BABYLON {
  3658. class VirtualJoysticksCamera extends FreeCamera {
  3659. constructor(name: string, position: Vector3, scene: Scene);
  3660. getClassName(): string;
  3661. }
  3662. }
  3663. declare module BABYLON {
  3664. class BoundingBox implements ICullable {
  3665. minimum: Vector3;
  3666. maximum: Vector3;
  3667. vectors: Vector3[];
  3668. center: Vector3;
  3669. centerWorld: Vector3;
  3670. extendSize: Vector3;
  3671. extendSizeWorld: Vector3;
  3672. directions: Vector3[];
  3673. vectorsWorld: Vector3[];
  3674. minimumWorld: Vector3;
  3675. maximumWorld: Vector3;
  3676. private _worldMatrix;
  3677. constructor(minimum: Vector3, maximum: Vector3);
  3678. getWorldMatrix(): Matrix;
  3679. setWorldMatrix(matrix: Matrix): BoundingBox;
  3680. _update(world: Matrix): void;
  3681. isInFrustum(frustumPlanes: Plane[]): boolean;
  3682. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  3683. intersectsPoint(point: Vector3): boolean;
  3684. intersectsSphere(sphere: BoundingSphere): boolean;
  3685. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  3686. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  3687. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  3688. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  3689. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  3690. }
  3691. }
  3692. declare module BABYLON {
  3693. interface ICullable {
  3694. isInFrustum(frustumPlanes: Plane[]): boolean;
  3695. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  3696. }
  3697. class BoundingInfo implements ICullable {
  3698. minimum: Vector3;
  3699. maximum: Vector3;
  3700. boundingBox: BoundingBox;
  3701. boundingSphere: BoundingSphere;
  3702. private _isLocked;
  3703. constructor(minimum: Vector3, maximum: Vector3);
  3704. isLocked: boolean;
  3705. update(world: Matrix): void;
  3706. /**
  3707. * Recreate the bounding info to be centered around a specific point given a specific extend.
  3708. * @param center New center of the bounding info
  3709. * @param extend New extend of the bounding info
  3710. */
  3711. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  3712. isInFrustum(frustumPlanes: Plane[]): boolean;
  3713. /**
  3714. * Gets the world distance between the min and max points of the bounding box
  3715. */
  3716. readonly diagonalLength: number;
  3717. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  3718. _checkCollision(collider: Collider): boolean;
  3719. intersectsPoint(point: Vector3): boolean;
  3720. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  3721. }
  3722. }
  3723. declare module BABYLON {
  3724. class BoundingSphere {
  3725. minimum: Vector3;
  3726. maximum: Vector3;
  3727. center: Vector3;
  3728. radius: number;
  3729. centerWorld: Vector3;
  3730. radiusWorld: number;
  3731. private _tempRadiusVector;
  3732. constructor(minimum: Vector3, maximum: Vector3);
  3733. _update(world: Matrix): void;
  3734. isInFrustum(frustumPlanes: Plane[]): boolean;
  3735. intersectsPoint(point: Vector3): boolean;
  3736. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  3737. }
  3738. }
  3739. declare module BABYLON {
  3740. class Ray {
  3741. origin: Vector3;
  3742. direction: Vector3;
  3743. length: number;
  3744. private _edge1;
  3745. private _edge2;
  3746. private _pvec;
  3747. private _tvec;
  3748. private _qvec;
  3749. private _tmpRay;
  3750. constructor(origin: Vector3, direction: Vector3, length?: number);
  3751. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  3752. intersectsBox(box: BoundingBox): boolean;
  3753. intersectsSphere(sphere: BoundingSphere): boolean;
  3754. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  3755. intersectsPlane(plane: Plane): Nullable<number>;
  3756. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  3757. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  3758. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  3759. private static smallnum;
  3760. private static rayl;
  3761. /**
  3762. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  3763. * @param sega the first point of the segment to test the intersection against
  3764. * @param segb the second point of the segment to test the intersection against
  3765. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  3766. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  3767. */
  3768. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  3769. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  3770. static Zero(): Ray;
  3771. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  3772. /**
  3773. * 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
  3774. * transformed to the given world matrix.
  3775. * @param origin The origin point
  3776. * @param end The end point
  3777. * @param world a matrix to transform the ray to. Default is the identity matrix.
  3778. */
  3779. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  3780. static Transform(ray: Ray, matrix: Matrix): Ray;
  3781. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  3782. }
  3783. }
  3784. declare module BABYLON {
  3785. class DebugLayer {
  3786. private _scene;
  3787. static InspectorURL: string;
  3788. private _inspector;
  3789. private BJSINSPECTOR;
  3790. constructor(scene: Scene);
  3791. /** Creates the inspector window. */
  3792. private _createInspector(config?);
  3793. isVisible(): boolean;
  3794. hide(): void;
  3795. show(config?: {
  3796. popup?: boolean;
  3797. initialTab?: number;
  3798. parentElement?: HTMLElement;
  3799. newColors?: {
  3800. backgroundColor?: string;
  3801. backgroundColorLighter?: string;
  3802. backgroundColorLighter2?: string;
  3803. backgroundColorLighter3?: string;
  3804. color?: string;
  3805. colorTop?: string;
  3806. colorBot?: string;
  3807. };
  3808. }): void;
  3809. }
  3810. }
  3811. declare module BABYLON {
  3812. class Debug {
  3813. static AxesViewer: {
  3814. new (scene: Scene, scaleLines?: number): {
  3815. _xline: Vector3[];
  3816. _yline: Vector3[];
  3817. _zline: Vector3[];
  3818. _xmesh: Nullable<LinesMesh>;
  3819. _ymesh: Nullable<LinesMesh>;
  3820. _zmesh: Nullable<LinesMesh>;
  3821. scene: Nullable<Scene>;
  3822. scaleLines: number;
  3823. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  3824. dispose(): void;
  3825. };
  3826. };
  3827. static BoneAxesViewer: {
  3828. new (scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number): {
  3829. mesh: Nullable<Mesh>;
  3830. bone: Nullable<Bone>;
  3831. pos: Vector3;
  3832. xaxis: Vector3;
  3833. yaxis: Vector3;
  3834. zaxis: Vector3;
  3835. update(): void;
  3836. dispose(): void;
  3837. _xline: Vector3[];
  3838. _yline: Vector3[];
  3839. _zline: Vector3[];
  3840. _xmesh: Nullable<LinesMesh>;
  3841. _ymesh: Nullable<LinesMesh>;
  3842. _zmesh: Nullable<LinesMesh>;
  3843. scene: Nullable<Scene>;
  3844. scaleLines: number;
  3845. };
  3846. };
  3847. static PhysicsViewer: {
  3848. new (scene: Scene): {
  3849. _impostors: Nullable<PhysicsImpostor>[];
  3850. _meshes: Nullable<AbstractMesh>[];
  3851. _scene: Nullable<Scene>;
  3852. _numMeshes: number;
  3853. _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  3854. _renderFunction: () => void;
  3855. _debugBoxMesh: Mesh;
  3856. _debugSphereMesh: Mesh;
  3857. _debugMaterial: StandardMaterial;
  3858. _updateDebugMeshes(): void;
  3859. showImpostor(impostor: PhysicsImpostor): void;
  3860. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  3861. _getDebugMaterial(scene: Scene): Material;
  3862. _getDebugBoxMesh(scene: Scene): AbstractMesh;
  3863. _getDebugSphereMesh(scene: Scene): AbstractMesh;
  3864. _getDebugMesh(impostor: PhysicsImpostor, scene: Scene): Nullable<AbstractMesh>;
  3865. dispose(): void;
  3866. };
  3867. };
  3868. static SkeletonViewer: {
  3869. new (skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number): {
  3870. color: Color3;
  3871. _scene: Scene;
  3872. _debugLines: Vector3[][];
  3873. _debugMesh: Nullable<LinesMesh>;
  3874. _isEnabled: boolean;
  3875. _renderFunction: () => void;
  3876. skeleton: Skeleton;
  3877. mesh: AbstractMesh;
  3878. autoUpdateBonesMatrices: boolean;
  3879. renderingGroupId: number;
  3880. isEnabled: boolean;
  3881. _getBonePosition(position: Vector3, bone: Bone, meshMat: Matrix, x?: number, y?: number, z?: number): void;
  3882. _getLinesForBonesWithLength(bones: Bone[], meshMat: Matrix): void;
  3883. _getLinesForBonesNoLength(bones: Bone[], meshMat: Matrix): void;
  3884. update(): void;
  3885. dispose(): void;
  3886. };
  3887. };
  3888. }
  3889. }
  3890. declare module BABYLON {
  3891. class RayHelper {
  3892. ray: Nullable<Ray>;
  3893. private _renderPoints;
  3894. private _renderLine;
  3895. private _renderFunction;
  3896. private _scene;
  3897. private _updateToMeshFunction;
  3898. private _attachedToMesh;
  3899. private _meshSpaceDirection;
  3900. private _meshSpaceOrigin;
  3901. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  3902. constructor(ray: Ray);
  3903. show(scene: Scene, color: Color3): void;
  3904. hide(): void;
  3905. private _render();
  3906. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  3907. detachFromMesh(): void;
  3908. private _updateToMesh();
  3909. dispose(): void;
  3910. }
  3911. }
  3912. declare module BABYLON {
  3913. class InstancingAttributeInfo {
  3914. /**
  3915. * Index/offset of the attribute in the vertex shader
  3916. */
  3917. index: number;
  3918. /**
  3919. * size of the attribute, 1, 2, 3 or 4
  3920. */
  3921. attributeSize: number;
  3922. /**
  3923. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  3924. * default is FLOAT
  3925. */
  3926. attribyteType: number;
  3927. /**
  3928. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  3929. */
  3930. normalized: boolean;
  3931. /**
  3932. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  3933. */
  3934. offset: number;
  3935. /**
  3936. * Name of the GLSL attribute, for debugging purpose only
  3937. */
  3938. attributeName: string;
  3939. }
  3940. /**
  3941. * Define options used to create a render target texture
  3942. */
  3943. class RenderTargetCreationOptions {
  3944. generateMipMaps?: boolean;
  3945. generateDepthBuffer?: boolean;
  3946. generateStencilBuffer?: boolean;
  3947. type?: number;
  3948. samplingMode?: number;
  3949. }
  3950. /**
  3951. * Regroup several parameters relative to the browser in use
  3952. */
  3953. class EngineCapabilities {
  3954. /** The maximum textures image */
  3955. maxTexturesImageUnits: number;
  3956. maxVertexTextureImageUnits: number;
  3957. maxCombinedTexturesImageUnits: number;
  3958. /** The maximum texture size */
  3959. maxTextureSize: number;
  3960. maxCubemapTextureSize: number;
  3961. maxRenderTextureSize: number;
  3962. maxVertexAttribs: number;
  3963. maxVaryingVectors: number;
  3964. maxVertexUniformVectors: number;
  3965. maxFragmentUniformVectors: number;
  3966. standardDerivatives: boolean;
  3967. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  3968. pvrtc: any;
  3969. etc1: any;
  3970. etc2: any;
  3971. astc: any;
  3972. textureFloat: boolean;
  3973. vertexArrayObject: boolean;
  3974. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  3975. maxAnisotropy: number;
  3976. instancedArrays: boolean;
  3977. uintIndices: boolean;
  3978. highPrecisionShaderSupported: boolean;
  3979. fragmentDepthSupported: boolean;
  3980. textureFloatLinearFiltering: boolean;
  3981. textureFloatRender: boolean;
  3982. textureHalfFloat: boolean;
  3983. textureHalfFloatLinearFiltering: boolean;
  3984. textureHalfFloatRender: boolean;
  3985. textureLOD: boolean;
  3986. drawBuffersExtension: boolean;
  3987. depthTextureExtension: boolean;
  3988. colorBufferFloat: boolean;
  3989. timerQuery: EXT_disjoint_timer_query;
  3990. canUseTimestampForTimerQuery: boolean;
  3991. }
  3992. interface EngineOptions extends WebGLContextAttributes {
  3993. limitDeviceRatio?: number;
  3994. autoEnableWebVR?: boolean;
  3995. disableWebGL2Support?: boolean;
  3996. audioEngine?: boolean;
  3997. deterministicLockstep?: boolean;
  3998. lockstepMaxSteps?: number;
  3999. doNotHandleContextLost?: boolean;
  4000. }
  4001. interface IDisplayChangedEventArgs {
  4002. vrDisplay: any;
  4003. vrSupported: boolean;
  4004. }
  4005. /**
  4006. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio.
  4007. */
  4008. class Engine {
  4009. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  4010. static ExceptionList: ({
  4011. key: string;
  4012. capture: string;
  4013. captureConstraint: number;
  4014. targets: string[];
  4015. } | {
  4016. key: string;
  4017. capture: null;
  4018. captureConstraint: null;
  4019. targets: string[];
  4020. })[];
  4021. static Instances: Engine[];
  4022. static readonly LastCreatedEngine: Nullable<Engine>;
  4023. static readonly LastCreatedScene: Nullable<Scene>;
  4024. /**
  4025. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  4026. */
  4027. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  4028. private static _ALPHA_DISABLE;
  4029. private static _ALPHA_ADD;
  4030. private static _ALPHA_COMBINE;
  4031. private static _ALPHA_SUBTRACT;
  4032. private static _ALPHA_MULTIPLY;
  4033. private static _ALPHA_MAXIMIZED;
  4034. private static _ALPHA_ONEONE;
  4035. private static _ALPHA_PREMULTIPLIED;
  4036. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  4037. private static _ALPHA_INTERPOLATE;
  4038. private static _ALPHA_SCREENMODE;
  4039. private static _DELAYLOADSTATE_NONE;
  4040. private static _DELAYLOADSTATE_LOADED;
  4041. private static _DELAYLOADSTATE_LOADING;
  4042. private static _DELAYLOADSTATE_NOTLOADED;
  4043. private static _TEXTUREFORMAT_ALPHA;
  4044. private static _TEXTUREFORMAT_LUMINANCE;
  4045. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  4046. private static _TEXTUREFORMAT_RGB;
  4047. private static _TEXTUREFORMAT_RGBA;
  4048. private static _TEXTURETYPE_UNSIGNED_INT;
  4049. private static _TEXTURETYPE_FLOAT;
  4050. private static _TEXTURETYPE_HALF_FLOAT;
  4051. private static _NEVER;
  4052. private static _ALWAYS;
  4053. private static _LESS;
  4054. private static _EQUAL;
  4055. private static _LEQUAL;
  4056. private static _GREATER;
  4057. private static _GEQUAL;
  4058. private static _NOTEQUAL;
  4059. static readonly NEVER: number;
  4060. static readonly ALWAYS: number;
  4061. static readonly LESS: number;
  4062. static readonly EQUAL: number;
  4063. static readonly LEQUAL: number;
  4064. static readonly GREATER: number;
  4065. static readonly GEQUAL: number;
  4066. static readonly NOTEQUAL: number;
  4067. private static _KEEP;
  4068. private static _REPLACE;
  4069. private static _INCR;
  4070. private static _DECR;
  4071. private static _INVERT;
  4072. private static _INCR_WRAP;
  4073. private static _DECR_WRAP;
  4074. static readonly KEEP: number;
  4075. static readonly REPLACE: number;
  4076. static readonly INCR: number;
  4077. static readonly DECR: number;
  4078. static readonly INVERT: number;
  4079. static readonly INCR_WRAP: number;
  4080. static readonly DECR_WRAP: number;
  4081. static readonly ALPHA_DISABLE: number;
  4082. static readonly ALPHA_ONEONE: number;
  4083. static readonly ALPHA_ADD: number;
  4084. static readonly ALPHA_COMBINE: number;
  4085. static readonly ALPHA_SUBTRACT: number;
  4086. static readonly ALPHA_MULTIPLY: number;
  4087. static readonly ALPHA_MAXIMIZED: number;
  4088. static readonly ALPHA_PREMULTIPLIED: number;
  4089. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4090. static readonly ALPHA_INTERPOLATE: number;
  4091. static readonly ALPHA_SCREENMODE: number;
  4092. static readonly DELAYLOADSTATE_NONE: number;
  4093. static readonly DELAYLOADSTATE_LOADED: number;
  4094. static readonly DELAYLOADSTATE_LOADING: number;
  4095. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4096. static readonly TEXTUREFORMAT_ALPHA: number;
  4097. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4098. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4099. static readonly TEXTUREFORMAT_RGB: number;
  4100. static readonly TEXTUREFORMAT_RGBA: number;
  4101. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4102. static readonly TEXTURETYPE_FLOAT: number;
  4103. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4104. private static _SCALEMODE_FLOOR;
  4105. private static _SCALEMODE_NEAREST;
  4106. private static _SCALEMODE_CEILING;
  4107. static readonly SCALEMODE_FLOOR: number;
  4108. static readonly SCALEMODE_NEAREST: number;
  4109. static readonly SCALEMODE_CEILING: number;
  4110. static readonly Version: string;
  4111. static CollisionsEpsilon: number;
  4112. static CodeRepository: string;
  4113. static ShadersRepository: string;
  4114. forcePOTTextures: boolean;
  4115. isFullscreen: boolean;
  4116. isPointerLock: boolean;
  4117. cullBackFaces: boolean;
  4118. renderEvenInBackground: boolean;
  4119. preventCacheWipeBetweenFrames: boolean;
  4120. enableOfflineSupport: boolean;
  4121. scenes: Scene[];
  4122. postProcesses: PostProcess[];
  4123. /**
  4124. * Observable event triggered each time the rendering canvas is resized
  4125. */
  4126. onResizeObservable: Observable<Engine>;
  4127. /**
  4128. * Observable event triggered each time the canvas loses focus
  4129. */
  4130. onCanvasBlurObservable: Observable<Engine>;
  4131. /**
  4132. * Observable event triggered each time the canvas gains focus
  4133. */
  4134. onCanvasFocusObservable: Observable<Engine>;
  4135. /**
  4136. * Observable event triggered each time the canvas receives pointerout event
  4137. */
  4138. onCanvasPointerOutObservable: Observable<Engine>;
  4139. /**
  4140. * Observable event triggered before each texture is initialized
  4141. */
  4142. onBeforeTextureInitObservable: Observable<Texture>;
  4143. private _vrDisplay;
  4144. private _vrSupported;
  4145. private _oldSize;
  4146. private _oldHardwareScaleFactor;
  4147. private _vrExclusivePointerMode;
  4148. readonly isInVRExclusivePointerMode: boolean;
  4149. disableUniformBuffers: boolean;
  4150. _uniformBuffers: UniformBuffer[];
  4151. readonly supportsUniformBuffers: boolean;
  4152. /**
  4153. * Observable raised when the engine begins a new frame
  4154. */
  4155. onBeginFrameObservable: Observable<Engine>;
  4156. /**
  4157. * Observable raised when the engine ends the current frame
  4158. */
  4159. onEndFrameObservable: Observable<Engine>;
  4160. /**
  4161. * Observable raised when the engine is about to compile a shader
  4162. */
  4163. onBeforeShaderCompilationObservable: Observable<Engine>;
  4164. /**
  4165. * Observable raised when the engine has jsut compiled a shader
  4166. */
  4167. onAfterShaderCompilationObservable: Observable<Engine>;
  4168. private _gl;
  4169. private _renderingCanvas;
  4170. private _windowIsBackground;
  4171. private _webGLVersion;
  4172. readonly needPOTTextures: boolean;
  4173. private _badOS;
  4174. readonly badOS: boolean;
  4175. private _badDesktopOS;
  4176. readonly badDesktopOS: boolean;
  4177. /**
  4178. * Gets or sets a value indicating if we want to disable texture binding optmization.
  4179. * This could be required on some buggy drivers which wants to have textures bound in a progressive order
  4180. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is.
  4181. */
  4182. disableTextureBindingOptimization: boolean;
  4183. static audioEngine: AudioEngine;
  4184. private _onFocus;
  4185. private _onBlur;
  4186. private _onCanvasPointerOut;
  4187. private _onCanvasBlur;
  4188. private _onCanvasFocus;
  4189. private _onFullscreenChange;
  4190. private _onPointerLockChange;
  4191. private _onVRDisplayPointerRestricted;
  4192. private _onVRDisplayPointerUnrestricted;
  4193. private _onVrDisplayConnect;
  4194. private _onVrDisplayDisconnect;
  4195. private _onVrDisplayPresentChange;
  4196. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  4197. onVRRequestPresentComplete: Observable<boolean>;
  4198. onVRRequestPresentStart: Observable<Engine>;
  4199. private _hardwareScalingLevel;
  4200. protected _caps: EngineCapabilities;
  4201. private _pointerLockRequested;
  4202. private _isStencilEnable;
  4203. private _colorWrite;
  4204. private _loadingScreen;
  4205. _drawCalls: PerfCounter;
  4206. _textureCollisions: PerfCounter;
  4207. private _glVersion;
  4208. private _glRenderer;
  4209. private _glVendor;
  4210. private _videoTextureSupported;
  4211. private _renderingQueueLaunched;
  4212. private _activeRenderLoops;
  4213. private _deterministicLockstep;
  4214. private _lockstepMaxSteps;
  4215. onContextLostObservable: Observable<Engine>;
  4216. onContextRestoredObservable: Observable<Engine>;
  4217. private _onContextLost;
  4218. private _onContextRestored;
  4219. private _contextWasLost;
  4220. private _doNotHandleContextLost;
  4221. private _performanceMonitor;
  4222. private _fps;
  4223. private _deltaTime;
  4224. /**
  4225. * Turn this value on if you want to pause FPS computation when in background
  4226. */
  4227. disablePerformanceMonitorInBackground: boolean;
  4228. readonly performanceMonitor: PerformanceMonitor;
  4229. protected _depthCullingState: _DepthCullingState;
  4230. protected _stencilState: _StencilState;
  4231. protected _alphaState: _AlphaState;
  4232. protected _alphaMode: number;
  4233. private _internalTexturesCache;
  4234. protected _activeChannel: number;
  4235. private _currentTextureChannel;
  4236. protected _boundTexturesCache: {
  4237. [key: string]: Nullable<InternalTexture>;
  4238. };
  4239. protected _currentEffect: Nullable<Effect>;
  4240. protected _currentProgram: Nullable<WebGLProgram>;
  4241. private _compiledEffects;
  4242. private _vertexAttribArraysEnabled;
  4243. protected _cachedViewport: Nullable<Viewport>;
  4244. private _cachedVertexArrayObject;
  4245. protected _cachedVertexBuffers: any;
  4246. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  4247. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  4248. protected _currentRenderTarget: Nullable<InternalTexture>;
  4249. private _uintIndicesCurrentlySet;
  4250. private _currentBoundBuffer;
  4251. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  4252. private _currentBufferPointers;
  4253. private _currentInstanceLocations;
  4254. private _currentInstanceBuffers;
  4255. private _textureUnits;
  4256. private _firstBoundInternalTextureTracker;
  4257. private _lastBoundInternalTextureTracker;
  4258. private _workingCanvas;
  4259. private _workingContext;
  4260. private _rescalePostProcess;
  4261. private _dummyFramebuffer;
  4262. private _externalData;
  4263. private _bindedRenderFunction;
  4264. private _vaoRecordInProgress;
  4265. private _mustWipeVertexAttributes;
  4266. private _emptyTexture;
  4267. private _emptyCubeTexture;
  4268. private _emptyTexture3D;
  4269. private _frameHandler;
  4270. private _nextFreeTextureSlots;
  4271. private _maxSimultaneousTextures;
  4272. private _activeRequests;
  4273. private _texturesSupported;
  4274. private _textureFormatInUse;
  4275. readonly texturesSupported: Array<string>;
  4276. readonly textureFormatInUse: Nullable<string>;
  4277. readonly currentViewport: Nullable<Viewport>;
  4278. readonly emptyTexture: InternalTexture;
  4279. readonly emptyTexture3D: InternalTexture;
  4280. readonly emptyCubeTexture: InternalTexture;
  4281. /**
  4282. * @constructor
  4283. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  4284. * @param antialias defines enable antialiasing (default: false)
  4285. * @param options defines further options to be sent to the getContext() function
  4286. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  4287. */
  4288. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  4289. private _rebuildInternalTextures();
  4290. private _rebuildEffects();
  4291. private _rebuildBuffers();
  4292. private _initGLContext();
  4293. readonly webGLVersion: number;
  4294. /**
  4295. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  4296. */
  4297. readonly isStencilEnable: boolean;
  4298. private _prepareWorkingCanvas();
  4299. resetTextureCache(): void;
  4300. isDeterministicLockStep(): boolean;
  4301. getLockstepMaxSteps(): number;
  4302. getGlInfo(): {
  4303. vendor: string;
  4304. renderer: string;
  4305. version: string;
  4306. };
  4307. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  4308. getRenderWidth(useScreen?: boolean): number;
  4309. getRenderHeight(useScreen?: boolean): number;
  4310. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  4311. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  4312. setHardwareScalingLevel(level: number): void;
  4313. getHardwareScalingLevel(): number;
  4314. getLoadedTexturesCache(): InternalTexture[];
  4315. getCaps(): EngineCapabilities;
  4316. /** The number of draw calls submitted last frame */
  4317. readonly drawCalls: number;
  4318. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  4319. getDepthFunction(): Nullable<number>;
  4320. setDepthFunction(depthFunc: number): void;
  4321. setDepthFunctionToGreater(): void;
  4322. setDepthFunctionToGreaterOrEqual(): void;
  4323. setDepthFunctionToLess(): void;
  4324. setDepthFunctionToLessOrEqual(): void;
  4325. getStencilBuffer(): boolean;
  4326. setStencilBuffer(enable: boolean): void;
  4327. getStencilMask(): number;
  4328. setStencilMask(mask: number): void;
  4329. getStencilFunction(): number;
  4330. getStencilFunctionReference(): number;
  4331. getStencilFunctionMask(): number;
  4332. setStencilFunction(stencilFunc: number): void;
  4333. setStencilFunctionReference(reference: number): void;
  4334. setStencilFunctionMask(mask: number): void;
  4335. getStencilOperationFail(): number;
  4336. getStencilOperationDepthFail(): number;
  4337. getStencilOperationPass(): number;
  4338. setStencilOperationFail(operation: number): void;
  4339. setStencilOperationDepthFail(operation: number): void;
  4340. setStencilOperationPass(operation: number): void;
  4341. setDitheringState(value: boolean): void;
  4342. setRasterizerState(value: boolean): void;
  4343. /**
  4344. * stop executing a render loop function and remove it from the execution array
  4345. * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
  4346. */
  4347. stopRenderLoop(renderFunction?: () => void): void;
  4348. _renderLoop(): void;
  4349. /**
  4350. * Register and execute a render loop. The engine can have more than one render function.
  4351. * @param {Function} renderFunction - the function to continuously execute starting the next render loop.
  4352. * @example
  4353. * engine.runRenderLoop(function () {
  4354. * scene.render()
  4355. * })
  4356. */
  4357. runRenderLoop(renderFunction: () => void): void;
  4358. /**
  4359. * Toggle full screen mode.
  4360. * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
  4361. * @param {any} options - an options object to be sent to the requestFullscreen function
  4362. */
  4363. switchFullscreen(requestPointerLock: boolean): void;
  4364. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  4365. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  4366. /**
  4367. * Set the WebGL's viewport
  4368. * @param {BABYLON.Viewport} viewport - the viewport element to be used.
  4369. * @param {number} [requiredWidth] - the width required for rendering. If not provided the rendering canvas' width is used.
  4370. * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
  4371. */
  4372. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  4373. /**
  4374. * Directly set the WebGL Viewport
  4375. * The x, y, width & height are directly passed to the WebGL call
  4376. * @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.
  4377. */
  4378. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  4379. beginFrame(): void;
  4380. endFrame(): void;
  4381. /**
  4382. * resize the view according to the canvas' size.
  4383. * @example
  4384. * window.addEventListener("resize", function () {
  4385. * engine.resize();
  4386. * });
  4387. */
  4388. resize(): void;
  4389. /**
  4390. * force a specific size of the canvas
  4391. * @param {number} width - the new canvas' width
  4392. * @param {number} height - the new canvas' height
  4393. */
  4394. setSize(width: number, height: number): void;
  4395. isVRDevicePresent(): boolean;
  4396. getVRDevice(): any;
  4397. initWebVR(): Observable<{
  4398. vrDisplay: any;
  4399. vrSupported: any;
  4400. }>;
  4401. enableVR(): void;
  4402. disableVR(): void;
  4403. private _onVRFullScreenTriggered;
  4404. private _getVRDisplays(callback);
  4405. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  4406. private bindUnboundFramebuffer(framebuffer);
  4407. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  4408. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  4409. generateMipMapsForCubemap(texture: InternalTexture): void;
  4410. flushFramebuffer(): void;
  4411. restoreDefaultFramebuffer(): void;
  4412. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  4413. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  4414. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  4415. private _resetVertexBufferBinding();
  4416. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4417. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4418. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  4419. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  4420. private _resetIndexBufferBinding();
  4421. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  4422. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  4423. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  4424. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  4425. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  4426. private bindIndexBuffer(buffer);
  4427. private bindBuffer(buffer, target);
  4428. updateArrayBuffer(data: Float32Array): void;
  4429. private vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  4430. private _bindIndexBufferWithCache(indexBuffer);
  4431. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  4432. recordVertexArrayObject(vertexBuffers: {
  4433. [key: string]: VertexBuffer;
  4434. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  4435. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  4436. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  4437. private _unbindVertexArrayObject();
  4438. bindBuffers(vertexBuffers: {
  4439. [key: string]: Nullable<VertexBuffer>;
  4440. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  4441. unbindInstanceAttributes(): void;
  4442. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  4443. _releaseBuffer(buffer: WebGLBuffer): boolean;
  4444. createInstancesBuffer(capacity: number): WebGLBuffer;
  4445. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  4446. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  4447. applyStates(): void;
  4448. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  4449. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4450. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4451. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  4452. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4453. private DrawMode(fillMode);
  4454. _releaseEffect(effect: Effect): void;
  4455. _deleteProgram(program: WebGLProgram): void;
  4456. /**
  4457. * @param baseName The base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  4458. * @param samplers An array of string used to represent textures
  4459. */
  4460. 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;
  4461. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  4462. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  4463. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  4464. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  4465. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  4466. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  4467. enableEffect(effect: Nullable<Effect>): void;
  4468. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4469. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4470. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4471. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4472. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4473. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4474. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4475. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4476. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4477. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4478. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4479. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4480. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  4481. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  4482. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  4483. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  4484. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  4485. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  4486. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  4487. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  4488. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  4489. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  4490. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  4491. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  4492. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  4493. setZOffset(value: number): void;
  4494. getZOffset(): number;
  4495. setDepthBuffer(enable: boolean): void;
  4496. getDepthWrite(): boolean;
  4497. setDepthWrite(enable: boolean): void;
  4498. setColorWrite(enable: boolean): void;
  4499. getColorWrite(): boolean;
  4500. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  4501. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  4502. getAlphaMode(): number;
  4503. wipeCaches(bruteForce?: boolean): void;
  4504. /**
  4505. * Set the compressed texture format to use, based on the formats you have, and the formats
  4506. * supported by the hardware / browser.
  4507. *
  4508. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  4509. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  4510. * to API arguments needed to compressed textures. This puts the burden on the container
  4511. * generator to house the arcane code for determining these for current & future formats.
  4512. *
  4513. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  4514. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  4515. *
  4516. * Note: The result of this call is not taken into account when a texture is base64.
  4517. *
  4518. * @param {Array<string>} formatsAvailable- The list of those format families you have created
  4519. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  4520. *
  4521. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  4522. * @returns The extension selected.
  4523. */
  4524. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  4525. _createTexture(): WebGLTexture;
  4526. /**
  4527. * Usually called from BABYLON.Texture.ts. Passed information to create a WebGLTexture.
  4528. * @param {string} urlArg- This contains one of the following:
  4529. * 1. A conventional http URL, e.g. 'http://...' or 'file://...'
  4530. * 2. A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  4531. * 3. An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  4532. *
  4533. * @param {boolean} noMipmap- When true, no mipmaps shall be generated. Ignored for compressed textures. They must be in the file.
  4534. * @param {boolean} invertY- When true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file.
  4535. * @param {Scene} scene- Needed for loading to the correct scene.
  4536. * @param {number} samplingMode- Mode with should be used sample / access the texture. Default: TRILINEAR
  4537. * @param {callback} onLoad- Optional callback to be called upon successful completion.
  4538. * @param {callback} onError- Optional callback to be called upon failure.
  4539. * @param {ArrayBuffer | HTMLImageElement} buffer- A source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
  4540. * @param {WebGLTexture} fallback- An internal argument in case the function must be called again, due to etc1 not having alpha capabilities.
  4541. * @param {number} format- Internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures.
  4542. *
  4543. * @returns {WebGLTexture} for assignment back into BABYLON.Texture
  4544. */
  4545. 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;
  4546. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  4547. private _getInternalFormat(format);
  4548. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  4549. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  4550. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  4551. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  4552. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  4553. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  4554. createRenderTargetTexture(size: number | {
  4555. width: number;
  4556. height: number;
  4557. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  4558. createMultipleRenderTarget(size: any, options: any): InternalTexture[];
  4559. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  4560. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  4561. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  4562. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  4563. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  4564. createRenderTargetCubeTexture(size: number, options?: RenderTargetCreationOptions): InternalTexture;
  4565. 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;
  4566. 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;
  4567. private setCubeMapTextureParams(gl, loadMipmap);
  4568. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  4569. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  4570. 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;
  4571. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  4572. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  4573. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  4574. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  4575. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  4576. _releaseFramebufferObjects(texture: InternalTexture): void;
  4577. _releaseTexture(texture: InternalTexture): void;
  4578. private setProgram(program);
  4579. private _boundUniforms;
  4580. bindSamplers(effect: Effect): void;
  4581. private _moveBoundTextureOnTop(internalTexture);
  4582. private _getCorrectTextureChannel(channel, internalTexture);
  4583. private _linkTrackers(previous, next);
  4584. private _removeDesignatedSlot(internalTexture);
  4585. private _activateCurrentTexture();
  4586. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean): void;
  4587. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  4588. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  4589. unbindAllTextures(): void;
  4590. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  4591. private _bindSamplerUniformToChannel(sourceSlot, destination);
  4592. private _setTexture(channel, texture, isPartOfTextureArray?);
  4593. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  4594. _setAnisotropicLevel(key: number, texture: BaseTexture): void;
  4595. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  4596. /**
  4597. * Add an externaly attached data from its key.
  4598. * This method call will fail and return false, if such key already exists.
  4599. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  4600. * @param key the unique key that identifies the data
  4601. * @param data the data object to associate to the key for this Engine instance
  4602. * @return true if no such key were already present and the data was added successfully, false otherwise
  4603. */
  4604. addExternalData<T>(key: string, data: T): boolean;
  4605. /**
  4606. * Get an externaly attached data from its key
  4607. * @param key the unique key that identifies the data
  4608. * @return the associated data, if present (can be null), or undefined if not present
  4609. */
  4610. getExternalData<T>(key: string): T;
  4611. /**
  4612. * Get an externaly attached data from its key, create it using a factory if it's not already present
  4613. * @param key the unique key that identifies the data
  4614. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  4615. * @return the associated data, can be null if the factory returned null.
  4616. */
  4617. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  4618. /**
  4619. * Remove an externaly attached data from the Engine instance
  4620. * @param key the unique key that identifies the data
  4621. * @return true if the data was successfully removed, false if it doesn't exist
  4622. */
  4623. removeExternalData(key: string): boolean;
  4624. unbindAllAttributes(): void;
  4625. releaseEffects(): void;
  4626. dispose(): void;
  4627. displayLoadingUI(): void;
  4628. hideLoadingUI(): void;
  4629. loadingScreen: ILoadingScreen;
  4630. loadingUIText: string;
  4631. loadingUIBackgroundColor: string;
  4632. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  4633. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  4634. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  4635. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  4636. getError(): number;
  4637. getFps(): number;
  4638. getDeltaTime(): number;
  4639. private _measureFps();
  4640. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  4641. private _canRenderToFloatFramebuffer();
  4642. private _canRenderToHalfFloatFramebuffer();
  4643. private _canRenderToFramebuffer(type);
  4644. _getWebGLTextureType(type: number): number;
  4645. _getRGBABufferInternalSizedFormat(type: number): number;
  4646. _getRGBAMultiSampleBufferFormat(type: number): number;
  4647. createQuery(): WebGLQuery;
  4648. deleteQuery(query: WebGLQuery): Engine;
  4649. isQueryResultAvailable(query: WebGLQuery): boolean;
  4650. getQueryResult(query: WebGLQuery): number;
  4651. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  4652. endOcclusionQuery(algorithmType: number): Engine;
  4653. private _createTimeQuery();
  4654. private _deleteTimeQuery(query);
  4655. private _getTimeQueryResult(query);
  4656. private _getTimeQueryAvailability(query);
  4657. private _currentNonTimestampToken;
  4658. startTimeQuery(): Nullable<_TimeToken>;
  4659. endTimeQuery(token: _TimeToken): int;
  4660. private getGlAlgorithmType(algorithmType);
  4661. createTransformFeedback(): WebGLTransformFeedback;
  4662. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  4663. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  4664. beginTransformFeedback(usePoints?: boolean): void;
  4665. endTransformFeedback(): void;
  4666. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  4667. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  4668. _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;
  4669. /** @ignore */
  4670. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  4671. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  4672. private _cascadeLoadFiles(rootUrl, scene, onfinish, files, onError?);
  4673. static isSupported(): boolean;
  4674. }
  4675. }
  4676. declare module BABYLON {
  4677. class NullEngineOptions {
  4678. renderWidth: number;
  4679. renderHeight: number;
  4680. textureSize: number;
  4681. deterministicLockstep: boolean;
  4682. lockstepMaxSteps: number;
  4683. }
  4684. /**
  4685. * The null engine class provides support for headless version of babylon.js.
  4686. * This can be used in server side scenario or for testing purposes
  4687. */
  4688. class NullEngine extends Engine {
  4689. private _options;
  4690. isDeterministicLockStep(): boolean;
  4691. getLockstepMaxSteps(): number;
  4692. constructor(options?: NullEngineOptions);
  4693. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4694. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  4695. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  4696. getRenderWidth(useScreen?: boolean): number;
  4697. getRenderHeight(useScreen?: boolean): number;
  4698. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  4699. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  4700. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  4701. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  4702. bindSamplers(effect: Effect): void;
  4703. enableEffect(effect: Effect): void;
  4704. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  4705. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  4706. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  4707. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  4708. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  4709. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  4710. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  4711. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  4712. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  4713. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  4714. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  4715. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  4716. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  4717. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  4718. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  4719. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  4720. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  4721. setFloat(uniform: WebGLUniformLocation, value: number): void;
  4722. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  4723. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  4724. setBool(uniform: WebGLUniformLocation, bool: number): void;
  4725. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  4726. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  4727. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  4728. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  4729. bindBuffers(vertexBuffers: {
  4730. [key: string]: VertexBuffer;
  4731. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  4732. wipeCaches(bruteForce?: boolean): void;
  4733. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  4734. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  4735. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4736. _createTexture(): WebGLTexture;
  4737. 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;
  4738. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  4739. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  4740. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  4741. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  4742. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4743. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  4744. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  4745. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  4746. _bindTexture(channel: number, texture: InternalTexture): void;
  4747. _releaseBuffer(buffer: WebGLBuffer): boolean;
  4748. }
  4749. }
  4750. interface WebGLRenderingContext {
  4751. readonly RASTERIZER_DISCARD: number;
  4752. readonly TEXTURE_3D: number;
  4753. readonly TEXTURE_2D_ARRAY: number;
  4754. readonly TEXTURE_WRAP_R: number;
  4755. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  4756. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  4757. 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;
  4758. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  4759. readonly TRANSFORM_FEEDBACK: number;
  4760. readonly INTERLEAVED_ATTRIBS: number;
  4761. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  4762. createTransformFeedback(): WebGLTransformFeedback;
  4763. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  4764. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  4765. beginTransformFeedback(primitiveMode: number): void;
  4766. endTransformFeedback(): void;
  4767. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  4768. }
  4769. interface ImageBitmap {
  4770. readonly width: number;
  4771. readonly height: number;
  4772. close(): void;
  4773. }
  4774. interface WebGLQuery extends WebGLObject {
  4775. }
  4776. declare var WebGLQuery: {
  4777. prototype: WebGLQuery;
  4778. new (): WebGLQuery;
  4779. };
  4780. interface WebGLSampler extends WebGLObject {
  4781. }
  4782. declare var WebGLSampler: {
  4783. prototype: WebGLSampler;
  4784. new (): WebGLSampler;
  4785. };
  4786. interface WebGLSync extends WebGLObject {
  4787. }
  4788. declare var WebGLSync: {
  4789. prototype: WebGLSync;
  4790. new (): WebGLSync;
  4791. };
  4792. interface WebGLTransformFeedback extends WebGLObject {
  4793. }
  4794. declare var WebGLTransformFeedback: {
  4795. prototype: WebGLTransformFeedback;
  4796. new (): WebGLTransformFeedback;
  4797. };
  4798. interface WebGLVertexArrayObject extends WebGLObject {
  4799. }
  4800. declare var WebGLVertexArrayObject: {
  4801. prototype: WebGLVertexArrayObject;
  4802. new (): WebGLVertexArrayObject;
  4803. };
  4804. declare module BABYLON {
  4805. class Collider {
  4806. /** Define if a collision was found */
  4807. collisionFound: boolean;
  4808. /**
  4809. * Define last intersection point in local space
  4810. */
  4811. intersectionPoint: Vector3;
  4812. /**
  4813. * Define last collided mesh
  4814. */
  4815. collidedMesh: Nullable<AbstractMesh>;
  4816. private _collisionPoint;
  4817. private _planeIntersectionPoint;
  4818. private _tempVector;
  4819. private _tempVector2;
  4820. private _tempVector3;
  4821. private _tempVector4;
  4822. private _edge;
  4823. private _baseToVertex;
  4824. private _destinationPoint;
  4825. private _slidePlaneNormal;
  4826. private _displacementVector;
  4827. _radius: Vector3;
  4828. _retry: number;
  4829. private _velocity;
  4830. private _basePoint;
  4831. private _epsilon;
  4832. _velocityWorldLength: number;
  4833. _basePointWorld: Vector3;
  4834. private _velocityWorld;
  4835. private _normalizedVelocity;
  4836. _initialVelocity: Vector3;
  4837. _initialPosition: Vector3;
  4838. private _nearestDistance;
  4839. private _collisionMask;
  4840. collisionMask: number;
  4841. /**
  4842. * Gets the plane normal used to compute the sliding response (in local space)
  4843. */
  4844. readonly slidePlaneNormal: Vector3;
  4845. _initialize(source: Vector3, dir: Vector3, e: number): void;
  4846. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  4847. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  4848. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  4849. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  4850. _getResponse(pos: Vector3, vel: Vector3): void;
  4851. }
  4852. }
  4853. declare module BABYLON {
  4854. var CollisionWorker: string;
  4855. interface ICollisionCoordinator {
  4856. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4857. init(scene: Scene): void;
  4858. destroy(): void;
  4859. onMeshAdded(mesh: AbstractMesh): void;
  4860. onMeshUpdated(mesh: AbstractMesh): void;
  4861. onMeshRemoved(mesh: AbstractMesh): void;
  4862. onGeometryAdded(geometry: Geometry): void;
  4863. onGeometryUpdated(geometry: Geometry): void;
  4864. onGeometryDeleted(geometry: Geometry): void;
  4865. }
  4866. interface SerializedMesh {
  4867. id: string;
  4868. name: string;
  4869. uniqueId: number;
  4870. geometryId: Nullable<string>;
  4871. sphereCenter: Array<number>;
  4872. sphereRadius: number;
  4873. boxMinimum: Array<number>;
  4874. boxMaximum: Array<number>;
  4875. worldMatrixFromCache: any;
  4876. subMeshes: Array<SerializedSubMesh>;
  4877. checkCollisions: boolean;
  4878. }
  4879. interface SerializedSubMesh {
  4880. position: number;
  4881. verticesStart: number;
  4882. verticesCount: number;
  4883. indexStart: number;
  4884. indexCount: number;
  4885. hasMaterial: boolean;
  4886. sphereCenter: Array<number>;
  4887. sphereRadius: number;
  4888. boxMinimum: Array<number>;
  4889. boxMaximum: Array<number>;
  4890. }
  4891. /**
  4892. * Interface describing the value associated with a geometry
  4893. */
  4894. interface SerializedGeometry {
  4895. /**
  4896. * Defines the unique ID of the geometry
  4897. */
  4898. id: string;
  4899. /**
  4900. * Defines the array containing the positions
  4901. */
  4902. positions: Float32Array;
  4903. /**
  4904. * Defines the array containing the indices
  4905. */
  4906. indices: Uint32Array;
  4907. /**
  4908. * Defines the array containing the normals
  4909. */
  4910. normals: Float32Array;
  4911. }
  4912. interface BabylonMessage {
  4913. taskType: WorkerTaskType;
  4914. payload: InitPayload | CollidePayload | UpdatePayload;
  4915. }
  4916. interface SerializedColliderToWorker {
  4917. position: Array<number>;
  4918. velocity: Array<number>;
  4919. radius: Array<number>;
  4920. }
  4921. enum WorkerTaskType {
  4922. INIT = 0,
  4923. UPDATE = 1,
  4924. COLLIDE = 2,
  4925. }
  4926. interface WorkerReply {
  4927. error: WorkerReplyType;
  4928. taskType: WorkerTaskType;
  4929. payload?: any;
  4930. }
  4931. interface CollisionReplyPayload {
  4932. newPosition: Array<number>;
  4933. collisionId: number;
  4934. collidedMeshUniqueId: number;
  4935. }
  4936. interface InitPayload {
  4937. }
  4938. interface CollidePayload {
  4939. collisionId: number;
  4940. collider: SerializedColliderToWorker;
  4941. maximumRetry: number;
  4942. excludedMeshUniqueId: Nullable<number>;
  4943. }
  4944. interface UpdatePayload {
  4945. updatedMeshes: {
  4946. [n: number]: SerializedMesh;
  4947. };
  4948. updatedGeometries: {
  4949. [s: string]: SerializedGeometry;
  4950. };
  4951. removedMeshes: Array<number>;
  4952. removedGeometries: Array<string>;
  4953. }
  4954. enum WorkerReplyType {
  4955. SUCCESS = 0,
  4956. UNKNOWN_ERROR = 1,
  4957. }
  4958. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  4959. private _scene;
  4960. private _scaledPosition;
  4961. private _scaledVelocity;
  4962. private _collisionsCallbackArray;
  4963. private _init;
  4964. private _runningUpdated;
  4965. private _worker;
  4966. private _addUpdateMeshesList;
  4967. private _addUpdateGeometriesList;
  4968. private _toRemoveMeshesArray;
  4969. private _toRemoveGeometryArray;
  4970. constructor();
  4971. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  4972. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  4973. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4974. init(scene: Scene): void;
  4975. destroy(): void;
  4976. onMeshAdded(mesh: AbstractMesh): void;
  4977. onMeshUpdated: (transformNode: TransformNode) => void;
  4978. onMeshRemoved(mesh: AbstractMesh): void;
  4979. onGeometryAdded(geometry: Geometry): void;
  4980. onGeometryUpdated: (geometry: Geometry) => void;
  4981. onGeometryDeleted(geometry: Geometry): void;
  4982. private _afterRender;
  4983. private _onMessageFromWorker;
  4984. }
  4985. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  4986. private _scene;
  4987. private _scaledPosition;
  4988. private _scaledVelocity;
  4989. private _finalPosition;
  4990. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4991. init(scene: Scene): void;
  4992. destroy(): void;
  4993. onMeshAdded(mesh: AbstractMesh): void;
  4994. onMeshUpdated(mesh: AbstractMesh): void;
  4995. onMeshRemoved(mesh: AbstractMesh): void;
  4996. onGeometryAdded(geometry: Geometry): void;
  4997. onGeometryUpdated(geometry: Geometry): void;
  4998. onGeometryDeleted(geometry: Geometry): void;
  4999. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5000. }
  5001. }
  5002. declare function importScripts(...urls: string[]): void;
  5003. declare module BABYLON {
  5004. var WorkerIncluded: boolean;
  5005. class CollisionCache {
  5006. private _meshes;
  5007. private _geometries;
  5008. getMeshes(): {
  5009. [n: number]: SerializedMesh;
  5010. };
  5011. getGeometries(): {
  5012. [s: number]: SerializedGeometry;
  5013. };
  5014. getMesh(id: any): SerializedMesh;
  5015. addMesh(mesh: SerializedMesh): void;
  5016. removeMesh(uniqueId: number): void;
  5017. getGeometry(id: string): SerializedGeometry;
  5018. addGeometry(geometry: SerializedGeometry): void;
  5019. removeGeometry(id: string): void;
  5020. }
  5021. class CollideWorker {
  5022. collider: Collider;
  5023. private _collisionCache;
  5024. private finalPosition;
  5025. private collisionsScalingMatrix;
  5026. private collisionTranformationMatrix;
  5027. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5028. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5029. private checkCollision(mesh);
  5030. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5031. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5032. private checkSubmeshCollision(subMesh);
  5033. }
  5034. interface ICollisionDetector {
  5035. onInit(payload: InitPayload): void;
  5036. onUpdate(payload: UpdatePayload): void;
  5037. onCollision(payload: CollidePayload): void;
  5038. }
  5039. class CollisionDetectorTransferable implements ICollisionDetector {
  5040. private _collisionCache;
  5041. onInit(payload: InitPayload): void;
  5042. onUpdate(payload: UpdatePayload): void;
  5043. onCollision(payload: CollidePayload): void;
  5044. }
  5045. }
  5046. declare module BABYLON {
  5047. class IntersectionInfo {
  5048. bu: Nullable<number>;
  5049. bv: Nullable<number>;
  5050. distance: number;
  5051. faceId: number;
  5052. subMeshId: number;
  5053. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5054. }
  5055. class PickingInfo {
  5056. hit: boolean;
  5057. distance: number;
  5058. pickedPoint: Nullable<Vector3>;
  5059. pickedMesh: Nullable<AbstractMesh>;
  5060. bu: number;
  5061. bv: number;
  5062. faceId: number;
  5063. subMeshId: number;
  5064. pickedSprite: Nullable<Sprite>;
  5065. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5066. getTextureCoordinates(): Nullable<Vector2>;
  5067. }
  5068. }
  5069. declare module BABYLON {
  5070. class KeyboardEventTypes {
  5071. static _KEYDOWN: number;
  5072. static _KEYUP: number;
  5073. static readonly KEYDOWN: number;
  5074. static readonly KEYUP: number;
  5075. }
  5076. class KeyboardInfo {
  5077. type: number;
  5078. event: KeyboardEvent;
  5079. constructor(type: number, event: KeyboardEvent);
  5080. }
  5081. /**
  5082. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  5083. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  5084. */
  5085. class KeyboardInfoPre extends KeyboardInfo {
  5086. constructor(type: number, event: KeyboardEvent);
  5087. skipOnPointerObservable: boolean;
  5088. }
  5089. }
  5090. declare module BABYLON {
  5091. class PointerEventTypes {
  5092. static _POINTERDOWN: number;
  5093. static _POINTERUP: number;
  5094. static _POINTERMOVE: number;
  5095. static _POINTERWHEEL: number;
  5096. static _POINTERPICK: number;
  5097. static _POINTERTAP: number;
  5098. static _POINTERDOUBLETAP: number;
  5099. static readonly POINTERDOWN: number;
  5100. static readonly POINTERUP: number;
  5101. static readonly POINTERMOVE: number;
  5102. static readonly POINTERWHEEL: number;
  5103. static readonly POINTERPICK: number;
  5104. static readonly POINTERTAP: number;
  5105. static readonly POINTERDOUBLETAP: number;
  5106. }
  5107. class PointerInfoBase {
  5108. type: number;
  5109. event: PointerEvent | MouseWheelEvent;
  5110. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  5111. }
  5112. /**
  5113. * This class is used to store pointer related info for the onPrePointerObservable event.
  5114. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  5115. */
  5116. class PointerInfoPre extends PointerInfoBase {
  5117. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  5118. localPosition: Vector2;
  5119. skipOnPointerObservable: boolean;
  5120. }
  5121. /**
  5122. * This type contains all the data related to a pointer event in Babylon.js.
  5123. * 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.
  5124. */
  5125. class PointerInfo extends PointerInfoBase {
  5126. pickInfo: Nullable<PickingInfo>;
  5127. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  5128. }
  5129. }
  5130. declare module BABYLON {
  5131. class StickValues {
  5132. x: number;
  5133. y: number;
  5134. constructor(x: number, y: number);
  5135. }
  5136. interface GamepadButtonChanges {
  5137. changed: boolean;
  5138. pressChanged: boolean;
  5139. touchChanged: boolean;
  5140. valueChanged: boolean;
  5141. }
  5142. class Gamepad {
  5143. id: string;
  5144. index: number;
  5145. browserGamepad: any;
  5146. type: number;
  5147. private _leftStick;
  5148. private _rightStick;
  5149. _isConnected: boolean;
  5150. private _leftStickAxisX;
  5151. private _leftStickAxisY;
  5152. private _rightStickAxisX;
  5153. private _rightStickAxisY;
  5154. private _onleftstickchanged;
  5155. private _onrightstickchanged;
  5156. static GAMEPAD: number;
  5157. static GENERIC: number;
  5158. static XBOX: number;
  5159. static POSE_ENABLED: number;
  5160. protected _invertLeftStickY: boolean;
  5161. readonly isConnected: boolean;
  5162. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  5163. onleftstickchanged(callback: (values: StickValues) => void): void;
  5164. onrightstickchanged(callback: (values: StickValues) => void): void;
  5165. leftStick: StickValues;
  5166. rightStick: StickValues;
  5167. update(): void;
  5168. dispose(): void;
  5169. }
  5170. class GenericPad extends Gamepad {
  5171. private _buttons;
  5172. private _onbuttondown;
  5173. private _onbuttonup;
  5174. onButtonDownObservable: Observable<number>;
  5175. onButtonUpObservable: Observable<number>;
  5176. onbuttondown(callback: (buttonPressed: number) => void): void;
  5177. onbuttonup(callback: (buttonReleased: number) => void): void;
  5178. constructor(id: string, index: number, browserGamepad: any);
  5179. private _setButtonValue(newValue, currentValue, buttonIndex);
  5180. update(): void;
  5181. dispose(): void;
  5182. }
  5183. }
  5184. declare module BABYLON {
  5185. class GamepadManager {
  5186. private _scene;
  5187. private _babylonGamepads;
  5188. private _oneGamepadConnected;
  5189. _isMonitoring: boolean;
  5190. private _gamepadEventSupported;
  5191. private _gamepadSupport;
  5192. onGamepadConnectedObservable: Observable<Gamepad>;
  5193. onGamepadDisconnectedObservable: Observable<Gamepad>;
  5194. private _onGamepadConnectedEvent;
  5195. private _onGamepadDisconnectedEvent;
  5196. constructor(_scene?: Scene | undefined);
  5197. readonly gamepads: Gamepad[];
  5198. getGamepadByType(type?: number): Nullable<Gamepad>;
  5199. dispose(): void;
  5200. private _addNewGamepad(gamepad);
  5201. private _startMonitoringGamepads();
  5202. private _stopMonitoringGamepads();
  5203. _checkGamepadsStatus(): void;
  5204. private _updateGamepadObjects();
  5205. }
  5206. }
  5207. declare module BABYLON {
  5208. enum Xbox360Button {
  5209. A = 0,
  5210. B = 1,
  5211. X = 2,
  5212. Y = 3,
  5213. Start = 4,
  5214. Back = 5,
  5215. LB = 6,
  5216. RB = 7,
  5217. LeftStick = 8,
  5218. RightStick = 9,
  5219. }
  5220. enum Xbox360Dpad {
  5221. Up = 0,
  5222. Down = 1,
  5223. Left = 2,
  5224. Right = 3,
  5225. }
  5226. class Xbox360Pad extends Gamepad {
  5227. private _leftTrigger;
  5228. private _rightTrigger;
  5229. private _onlefttriggerchanged;
  5230. private _onrighttriggerchanged;
  5231. private _onbuttondown;
  5232. private _onbuttonup;
  5233. private _ondpaddown;
  5234. private _ondpadup;
  5235. onButtonDownObservable: Observable<Xbox360Button>;
  5236. onButtonUpObservable: Observable<Xbox360Button>;
  5237. onPadDownObservable: Observable<Xbox360Dpad>;
  5238. onPadUpObservable: Observable<Xbox360Dpad>;
  5239. private _buttonA;
  5240. private _buttonB;
  5241. private _buttonX;
  5242. private _buttonY;
  5243. private _buttonBack;
  5244. private _buttonStart;
  5245. private _buttonLB;
  5246. private _buttonRB;
  5247. private _buttonLeftStick;
  5248. private _buttonRightStick;
  5249. private _dPadUp;
  5250. private _dPadDown;
  5251. private _dPadLeft;
  5252. private _dPadRight;
  5253. private _isXboxOnePad;
  5254. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  5255. onlefttriggerchanged(callback: (value: number) => void): void;
  5256. onrighttriggerchanged(callback: (value: number) => void): void;
  5257. leftTrigger: number;
  5258. rightTrigger: number;
  5259. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  5260. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  5261. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  5262. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  5263. private _setButtonValue(newValue, currentValue, buttonType);
  5264. private _setDPadValue(newValue, currentValue, buttonType);
  5265. buttonA: number;
  5266. buttonB: number;
  5267. buttonX: number;
  5268. buttonY: number;
  5269. buttonStart: number;
  5270. buttonBack: number;
  5271. buttonLB: number;
  5272. buttonRB: number;
  5273. buttonLeftStick: number;
  5274. buttonRightStick: number;
  5275. dPadUp: number;
  5276. dPadDown: number;
  5277. dPadLeft: number;
  5278. dPadRight: number;
  5279. update(): void;
  5280. dispose(): void;
  5281. }
  5282. }
  5283. declare module BABYLON {
  5284. /**
  5285. * Represents the different options available during the creation of
  5286. * a Environment helper.
  5287. *
  5288. * This can control the default ground, skybox and image processing setup of your scene.
  5289. */
  5290. interface IEnvironmentHelperOptions {
  5291. /**
  5292. * Specifies wether or not to create a ground.
  5293. * True by default.
  5294. */
  5295. createGround: boolean;
  5296. /**
  5297. * Specifies the ground size.
  5298. * 15 by default.
  5299. */
  5300. groundSize: number;
  5301. /**
  5302. * The texture used on the ground for the main color.
  5303. * Comes from the BabylonJS CDN by default.
  5304. *
  5305. * Remarks: Can be either a texture or a url.
  5306. */
  5307. groundTexture: string | BaseTexture;
  5308. /**
  5309. * The color mixed in the ground texture by default.
  5310. * BabylonJS clearColor by default.
  5311. */
  5312. groundColor: Color3;
  5313. /**
  5314. * Specifies the ground opacity.
  5315. * 1 by default.
  5316. */
  5317. groundOpacity: number;
  5318. /**
  5319. * Enables the ground to receive shadows.
  5320. * True by default.
  5321. */
  5322. enableGroundShadow: boolean;
  5323. /**
  5324. * Helps preventing the shadow to be fully black on the ground.
  5325. * 0.5 by default.
  5326. */
  5327. groundShadowLevel: number;
  5328. /**
  5329. * Creates a mirror texture attach to the ground.
  5330. * false by default.
  5331. */
  5332. enableGroundMirror: boolean;
  5333. /**
  5334. * Specifies the ground mirror size ratio.
  5335. * 0.3 by default as the default kernel is 64.
  5336. */
  5337. groundMirrorSizeRatio: number;
  5338. /**
  5339. * Specifies the ground mirror blur kernel size.
  5340. * 64 by default.
  5341. */
  5342. groundMirrorBlurKernel: number;
  5343. /**
  5344. * Specifies the ground mirror visibility amount.
  5345. * 1 by default
  5346. */
  5347. groundMirrorAmount: number;
  5348. /**
  5349. * Specifies the ground mirror reflectance weight.
  5350. * This uses the standard weight of the background material to setup the fresnel effect
  5351. * of the mirror.
  5352. * 1 by default.
  5353. */
  5354. groundMirrorFresnelWeight: number;
  5355. /**
  5356. * Specifies the ground mirror Falloff distance.
  5357. * This can helps reducing the size of the reflection.
  5358. * 0 by Default.
  5359. */
  5360. groundMirrorFallOffDistance: number;
  5361. /**
  5362. * Specifies the ground mirror texture type.
  5363. * Unsigned Int by Default.
  5364. */
  5365. groundMirrorTextureType: number;
  5366. /**
  5367. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  5368. * the shown objects.
  5369. */
  5370. groundYBias: number;
  5371. /**
  5372. * Specifies wether or not to create a skybox.
  5373. * True by default.
  5374. */
  5375. createSkybox: boolean;
  5376. /**
  5377. * Specifies the skybox size.
  5378. * 20 by default.
  5379. */
  5380. skyboxSize: number;
  5381. /**
  5382. * The texture used on the skybox for the main color.
  5383. * Comes from the BabylonJS CDN by default.
  5384. *
  5385. * Remarks: Can be either a texture or a url.
  5386. */
  5387. skyboxTexture: string | BaseTexture;
  5388. /**
  5389. * The color mixed in the skybox texture by default.
  5390. * BabylonJS clearColor by default.
  5391. */
  5392. skyboxColor: Color3;
  5393. /**
  5394. * The background rotation around the Y axis of the scene.
  5395. * This helps aligning the key lights of your scene with the background.
  5396. * 0 by default.
  5397. */
  5398. backgroundYRotation: number;
  5399. /**
  5400. * Compute automatically the size of the elements to best fit with the scene.
  5401. */
  5402. sizeAuto: boolean;
  5403. /**
  5404. * Default position of the rootMesh if autoSize is not true.
  5405. */
  5406. rootPosition: Vector3;
  5407. /**
  5408. * Sets up the image processing in the scene.
  5409. * true by default.
  5410. */
  5411. setupImageProcessing: boolean;
  5412. /**
  5413. * The texture used as your environment texture in the scene.
  5414. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  5415. *
  5416. * Remarks: Can be either a texture or a url.
  5417. */
  5418. environmentTexture: string | BaseTexture;
  5419. /**
  5420. * The value of the exposure to apply to the scene.
  5421. * 0.6 by default if setupImageProcessing is true.
  5422. */
  5423. cameraExposure: number;
  5424. /**
  5425. * The value of the contrast to apply to the scene.
  5426. * 1.6 by default if setupImageProcessing is true.
  5427. */
  5428. cameraContrast: number;
  5429. /**
  5430. * Specifies wether or not tonemapping should be enabled in the scene.
  5431. * true by default if setupImageProcessing is true.
  5432. */
  5433. toneMappingEnabled: boolean;
  5434. }
  5435. /**
  5436. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  5437. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  5438. * It also helps with the default setup of your imageProcessing configuration.
  5439. */
  5440. class EnvironmentHelper {
  5441. /**
  5442. * Default ground texture URL.
  5443. */
  5444. private static _groundTextureCDNUrl;
  5445. /**
  5446. * Default skybox texture URL.
  5447. */
  5448. private static _skyboxTextureCDNUrl;
  5449. /**
  5450. * Default environment texture URL.
  5451. */
  5452. private static _environmentTextureCDNUrl;
  5453. /**
  5454. * Creates the default options for the helper.
  5455. */
  5456. private static _getDefaultOptions();
  5457. private _rootMesh;
  5458. /**
  5459. * Gets the root mesh created by the helper.
  5460. */
  5461. readonly rootMesh: Mesh;
  5462. private _skybox;
  5463. /**
  5464. * Gets the skybox created by the helper.
  5465. */
  5466. readonly skybox: Nullable<Mesh>;
  5467. private _skyboxTexture;
  5468. /**
  5469. * Gets the skybox texture created by the helper.
  5470. */
  5471. readonly skyboxTexture: Nullable<BaseTexture>;
  5472. private _skyboxMaterial;
  5473. /**
  5474. * Gets the skybox material created by the helper.
  5475. */
  5476. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  5477. private _ground;
  5478. /**
  5479. * Gets the ground mesh created by the helper.
  5480. */
  5481. readonly ground: Nullable<Mesh>;
  5482. private _groundTexture;
  5483. /**
  5484. * Gets the ground texture created by the helper.
  5485. */
  5486. readonly groundTexture: Nullable<BaseTexture>;
  5487. private _groundMirror;
  5488. /**
  5489. * Gets the ground mirror created by the helper.
  5490. */
  5491. readonly groundMirror: Nullable<MirrorTexture>;
  5492. /**
  5493. * Gets the ground mirror render list to helps pushing the meshes
  5494. * you wish in the ground reflection.
  5495. */
  5496. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  5497. private _groundMaterial;
  5498. /**
  5499. * Gets the ground material created by the helper.
  5500. */
  5501. readonly groundMaterial: Nullable<BackgroundMaterial>;
  5502. /**
  5503. * Stores the creation options.
  5504. */
  5505. private readonly _scene;
  5506. private _options;
  5507. /**
  5508. * constructor
  5509. * @param options
  5510. * @param scene The scene to add the material to
  5511. */
  5512. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  5513. /**
  5514. * Updates the background according to the new options
  5515. * @param options
  5516. */
  5517. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  5518. /**
  5519. * Sets the primary color of all the available elements.
  5520. * @param color
  5521. */
  5522. setMainColor(color: Color3): void;
  5523. /**
  5524. * Setup the image processing according to the specified options.
  5525. */
  5526. private _setupImageProcessing();
  5527. /**
  5528. * Setup the environment texture according to the specified options.
  5529. */
  5530. private _setupEnvironmentTexture();
  5531. /**
  5532. * Setup the background according to the specified options.
  5533. */
  5534. private _setupBackground();
  5535. /**
  5536. * Get the scene sizes according to the setup.
  5537. */
  5538. private _getSceneSize();
  5539. /**
  5540. * Setup the ground according to the specified options.
  5541. */
  5542. private _setupGround(sceneSize);
  5543. /**
  5544. * Setup the ground material according to the specified options.
  5545. */
  5546. private _setupGroundMaterial();
  5547. /**
  5548. * Setup the ground diffuse texture according to the specified options.
  5549. */
  5550. private _setupGroundDiffuseTexture();
  5551. /**
  5552. * Setup the ground mirror texture according to the specified options.
  5553. */
  5554. private _setupGroundMirrorTexture(sceneSize);
  5555. /**
  5556. * Setup the ground to receive the mirror texture.
  5557. */
  5558. private _setupMirrorInGroundMaterial();
  5559. /**
  5560. * Setup the skybox according to the specified options.
  5561. */
  5562. private _setupSkybox(sceneSize);
  5563. /**
  5564. * Setup the skybox material according to the specified options.
  5565. */
  5566. private _setupSkyboxMaterial();
  5567. /**
  5568. * Setup the skybox reflection texture according to the specified options.
  5569. */
  5570. private _setupSkyboxReflectionTexture();
  5571. /**
  5572. * Dispose all the elements created by the Helper.
  5573. */
  5574. dispose(): void;
  5575. }
  5576. }
  5577. declare module BABYLON {
  5578. /**
  5579. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  5580. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  5581. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  5582. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  5583. */
  5584. class VideoDome extends Node {
  5585. /**
  5586. * The video texture being displayed on the sphere
  5587. */
  5588. protected _videoTexture: VideoTexture;
  5589. /**
  5590. * The skybox material
  5591. */
  5592. protected _material: BackgroundMaterial;
  5593. /**
  5594. * The surface used for the skybox
  5595. */
  5596. protected _mesh: Mesh;
  5597. /**
  5598. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  5599. * Also see the options.resolution property.
  5600. */
  5601. fovMultiplier: number;
  5602. /**
  5603. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  5604. * @param name Element's name, child elements will append suffixes for their own names.
  5605. * @param urlsOrVideo
  5606. * @param options An object containing optional or exposed sub element properties:
  5607. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  5608. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  5609. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  5610. * @param options **loop=true** Automatically loop video on end.
  5611. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  5612. */
  5613. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  5614. resolution?: number;
  5615. clickToPlay?: boolean;
  5616. autoPlay?: boolean;
  5617. loop?: boolean;
  5618. size?: number;
  5619. }, scene: Scene);
  5620. }
  5621. }
  5622. declare module BABYLON {
  5623. /**
  5624. * Effect layer options. This helps customizing the behaviour
  5625. * of the effect layer.
  5626. */
  5627. interface IEffectLayerOptions {
  5628. /**
  5629. * Multiplication factor apply to the canvas size to compute the render target size
  5630. * used to generated the objects (the smaller the faster).
  5631. */
  5632. mainTextureRatio: number;
  5633. /**
  5634. * Enforces a fixed size texture to ensure effect stability across devices.
  5635. */
  5636. mainTextureFixedSize?: number;
  5637. /**
  5638. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  5639. */
  5640. alphaBlendingMode: number;
  5641. /**
  5642. * The camera attached to the layer.
  5643. */
  5644. camera: Nullable<Camera>;
  5645. }
  5646. /**
  5647. * The effect layer Helps adding post process effect blended with the main pass.
  5648. *
  5649. * This can be for instance use to generate glow or higlight effects on the scene.
  5650. *
  5651. * The effect layer class can not be used directly and is intented to inherited from to be
  5652. * customized per effects.
  5653. */
  5654. abstract class EffectLayer {
  5655. /** The Friendly of the effect in the scene */
  5656. name: string;
  5657. private _vertexBuffers;
  5658. private _indexBuffer;
  5659. private _cachedDefines;
  5660. private _effectLayerMapGenerationEffect;
  5661. private _effectLayerOptions;
  5662. private _mergeEffect;
  5663. protected _scene: Scene;
  5664. protected _engine: Engine;
  5665. protected _maxSize: number;
  5666. protected _mainTextureDesiredSize: ISize;
  5667. protected _mainTexture: RenderTargetTexture;
  5668. protected _shouldRender: boolean;
  5669. protected _postProcesses: PostProcess[];
  5670. protected _textures: BaseTexture[];
  5671. protected _emissiveTextureAndColor: {
  5672. texture: Nullable<BaseTexture>;
  5673. color: Color4;
  5674. };
  5675. /**
  5676. * The clear color of the texture used to generate the glow map.
  5677. */
  5678. neutralColor: Color4;
  5679. /**
  5680. * Specifies wether the highlight layer is enabled or not.
  5681. */
  5682. isEnabled: boolean;
  5683. /**
  5684. * Gets the camera attached to the layer.
  5685. */
  5686. readonly camera: Nullable<Camera>;
  5687. /**
  5688. * An event triggered when the effect layer has been disposed.
  5689. */
  5690. onDisposeObservable: Observable<EffectLayer>;
  5691. /**
  5692. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  5693. */
  5694. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  5695. /**
  5696. * An event triggered when the generated texture is being merged in the scene.
  5697. */
  5698. onBeforeComposeObservable: Observable<EffectLayer>;
  5699. /**
  5700. * An event triggered when the generated texture has been merged in the scene.
  5701. */
  5702. onAfterComposeObservable: Observable<EffectLayer>;
  5703. /**
  5704. * An event triggered when the efffect layer changes its size.
  5705. */
  5706. onSizeChangedObservable: Observable<EffectLayer>;
  5707. /**
  5708. * Instantiates a new effect Layer and references it in the scene.
  5709. * @param name The name of the layer
  5710. * @param scene The scene to use the layer in
  5711. */
  5712. constructor(
  5713. /** The Friendly of the effect in the scene */
  5714. name: string, scene: Scene);
  5715. /**
  5716. * Get the effect name of the layer.
  5717. * @return The effect name
  5718. */
  5719. abstract getEffectName(): string;
  5720. /**
  5721. * Checks for the readiness of the element composing the layer.
  5722. * @param subMesh the mesh to check for
  5723. * @param useInstances specify wether or not to use instances to render the mesh
  5724. * @return true if ready otherwise, false
  5725. */
  5726. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  5727. /**
  5728. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  5729. * @returns true if the effect requires stencil during the main canvas render pass.
  5730. */
  5731. abstract needStencil(): boolean;
  5732. /**
  5733. * Create the merge effect. This is the shader use to blit the information back
  5734. * to the main canvas at the end of the scene rendering.
  5735. * @returns The effect containing the shader used to merge the effect on the main canvas
  5736. */
  5737. protected abstract _createMergeEffect(): Effect;
  5738. /**
  5739. * Creates the render target textures and post processes used in the effect layer.
  5740. */
  5741. protected abstract _createTextureAndPostProcesses(): void;
  5742. /**
  5743. * Implementation specific of rendering the generating effect on the main canvas.
  5744. * @param effect The effect used to render through
  5745. */
  5746. protected abstract _internalRender(effect: Effect): void;
  5747. /**
  5748. * Sets the required values for both the emissive texture and and the main color.
  5749. */
  5750. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  5751. /**
  5752. * Free any resources and references associated to a mesh.
  5753. * Internal use
  5754. * @param mesh The mesh to free.
  5755. */
  5756. abstract _disposeMesh(mesh: Mesh): void;
  5757. /**
  5758. * Initializes the effect layer with the required options.
  5759. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  5760. */
  5761. protected _init(options: Partial<IEffectLayerOptions>): void;
  5762. /**
  5763. * Generates the index buffer of the full screen quad blending to the main canvas.
  5764. */
  5765. private _generateIndexBuffer();
  5766. /**
  5767. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  5768. */
  5769. private _genrateVertexBuffer();
  5770. /**
  5771. * Sets the main texture desired size which is the closest power of two
  5772. * of the engine canvas size.
  5773. */
  5774. private _setMainTextureSize();
  5775. /**
  5776. * Creates the main texture for the effect layer.
  5777. */
  5778. protected _createMainTexture(): void;
  5779. /**
  5780. * Checks for the readiness of the element composing the layer.
  5781. * @param subMesh the mesh to check for
  5782. * @param useInstances specify wether or not to use instances to render the mesh
  5783. * @param emissiveTexture the associated emissive texture used to generate the glow
  5784. * @return true if ready otherwise, false
  5785. */
  5786. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  5787. /**
  5788. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  5789. */
  5790. render(): void;
  5791. /**
  5792. * Determine if a given mesh will be used in the current effect.
  5793. * @param mesh mesh to test
  5794. * @returns true if the mesh will be used
  5795. */
  5796. hasMesh(mesh: AbstractMesh): boolean;
  5797. /**
  5798. * Returns true if the layer contains information to display, otherwise false.
  5799. * @returns true if the glow layer should be rendered
  5800. */
  5801. shouldRender(): boolean;
  5802. /**
  5803. * Returns true if the mesh should render, otherwise false.
  5804. * @param mesh The mesh to render
  5805. * @returns true if it should render otherwise false
  5806. */
  5807. protected _shouldRenderMesh(mesh: Mesh): boolean;
  5808. /**
  5809. * Returns true if the mesh should render, otherwise false.
  5810. * @param mesh The mesh to render
  5811. * @returns true if it should render otherwise false
  5812. */
  5813. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  5814. /**
  5815. * Renders the submesh passed in parameter to the generation map.
  5816. */
  5817. protected _renderSubMesh(subMesh: SubMesh): void;
  5818. /**
  5819. * Rebuild the required buffers.
  5820. * @ignore Internal use only.
  5821. */
  5822. _rebuild(): void;
  5823. /**
  5824. * Dispose only the render target textures and post process.
  5825. */
  5826. private _disposeTextureAndPostProcesses();
  5827. /**
  5828. * Dispose the highlight layer and free resources.
  5829. */
  5830. dispose(): void;
  5831. }
  5832. }
  5833. declare module BABYLON {
  5834. /**
  5835. * Glow layer options. This helps customizing the behaviour
  5836. * of the glow layer.
  5837. */
  5838. interface IGlowLayerOptions {
  5839. /**
  5840. * Multiplication factor apply to the canvas size to compute the render target size
  5841. * used to generated the glowing objects (the smaller the faster).
  5842. */
  5843. mainTextureRatio: number;
  5844. /**
  5845. * Enforces a fixed size texture to ensure resize independant blur.
  5846. */
  5847. mainTextureFixedSize?: number;
  5848. /**
  5849. * How big is the kernel of the blur texture.
  5850. */
  5851. blurKernelSize: number;
  5852. /**
  5853. * The camera attached to the layer.
  5854. */
  5855. camera: Nullable<Camera>;
  5856. /**
  5857. * Enable MSAA by chosing the number of samples.
  5858. */
  5859. mainTextureSamples?: number;
  5860. }
  5861. /**
  5862. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  5863. *
  5864. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  5865. * glowy meshes to your scene.
  5866. *
  5867. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  5868. */
  5869. class GlowLayer extends EffectLayer {
  5870. name: string;
  5871. /**
  5872. * Effect Name of the layer.
  5873. */
  5874. static readonly EffectName: string;
  5875. /**
  5876. * The default blur kernel size used for the glow.
  5877. */
  5878. static DefaultBlurKernelSize: number;
  5879. /**
  5880. * The default texture size ratio used for the glow.
  5881. */
  5882. static DefaultTextureRatio: number;
  5883. /**
  5884. * Gets the kernel size of the blur.
  5885. */
  5886. /**
  5887. * Sets the kernel size of the blur.
  5888. */
  5889. blurKernelSize: number;
  5890. /**
  5891. * Gets the glow intensity.
  5892. */
  5893. /**
  5894. * Sets the glow intensity.
  5895. */
  5896. intensity: number;
  5897. private _options;
  5898. private _intensity;
  5899. private _horizontalBlurPostprocess1;
  5900. private _verticalBlurPostprocess1;
  5901. private _horizontalBlurPostprocess2;
  5902. private _verticalBlurPostprocess2;
  5903. private _blurTexture1;
  5904. private _blurTexture2;
  5905. private _postProcesses1;
  5906. private _postProcesses2;
  5907. private _includedOnlyMeshes;
  5908. private _excludedMeshes;
  5909. /**
  5910. * Callback used to let the user override the color selection on a per mesh basis
  5911. */
  5912. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  5913. /**
  5914. * Callback used to let the user override the texture selection on a per mesh basis
  5915. */
  5916. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  5917. /**
  5918. * Instantiates a new glow Layer and references it to the scene.
  5919. * @param name The name of the layer
  5920. * @param scene The scene to use the layer in
  5921. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  5922. */
  5923. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  5924. /**
  5925. * Get the effect name of the layer.
  5926. * @return The effect name
  5927. */
  5928. getEffectName(): string;
  5929. /**
  5930. * Create the merge effect. This is the shader use to blit the information back
  5931. * to the main canvas at the end of the scene rendering.
  5932. */
  5933. protected _createMergeEffect(): Effect;
  5934. /**
  5935. * Creates the render target textures and post processes used in the glow layer.
  5936. */
  5937. protected _createTextureAndPostProcesses(): void;
  5938. /**
  5939. * Checks for the readiness of the element composing the layer.
  5940. * @param subMesh the mesh to check for
  5941. * @param useInstances specify wether or not to use instances to render the mesh
  5942. * @param emissiveTexture the associated emissive texture used to generate the glow
  5943. * @return true if ready otherwise, false
  5944. */
  5945. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  5946. /**
  5947. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  5948. */
  5949. needStencil(): boolean;
  5950. /**
  5951. * Implementation specific of rendering the generating effect on the main canvas.
  5952. * @param effect The effect used to render through
  5953. */
  5954. protected _internalRender(effect: Effect): void;
  5955. /**
  5956. * Sets the required values for both the emissive texture and and the main color.
  5957. */
  5958. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  5959. /**
  5960. * Returns true if the mesh should render, otherwise false.
  5961. * @param mesh The mesh to render
  5962. * @returns true if it should render otherwise false
  5963. */
  5964. protected _shouldRenderMesh(mesh: Mesh): boolean;
  5965. /**
  5966. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  5967. * @param mesh The mesh to exclude from the glow layer
  5968. */
  5969. addExcludedMesh(mesh: Mesh): void;
  5970. /**
  5971. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  5972. * @param mesh The mesh to remove
  5973. */
  5974. removeExcludedMesh(mesh: Mesh): void;
  5975. /**
  5976. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  5977. * @param mesh The mesh to include in the glow layer
  5978. */
  5979. addIncludedOnlyMesh(mesh: Mesh): void;
  5980. /**
  5981. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  5982. * @param mesh The mesh to remove
  5983. */
  5984. removeIncludedOnlyMesh(mesh: Mesh): void;
  5985. /**
  5986. * Determine if a given mesh will be used in the glow layer
  5987. * @param mesh The mesh to test
  5988. * @returns true if the mesh will be highlighted by the current glow layer
  5989. */
  5990. hasMesh(mesh: AbstractMesh): boolean;
  5991. /**
  5992. * Free any resources and references associated to a mesh.
  5993. * Internal use
  5994. * @param mesh The mesh to free.
  5995. */
  5996. _disposeMesh(mesh: Mesh): void;
  5997. }
  5998. }
  5999. declare module BABYLON {
  6000. /**
  6001. * Highlight layer options. This helps customizing the behaviour
  6002. * of the highlight layer.
  6003. */
  6004. interface IHighlightLayerOptions {
  6005. /**
  6006. * Multiplication factor apply to the canvas size to compute the render target size
  6007. * used to generated the glowing objects (the smaller the faster).
  6008. */
  6009. mainTextureRatio: number;
  6010. /**
  6011. * Enforces a fixed size texture to ensure resize independant blur.
  6012. */
  6013. mainTextureFixedSize?: number;
  6014. /**
  6015. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  6016. * of the picture to blur (the smaller the faster).
  6017. */
  6018. blurTextureSizeRatio: number;
  6019. /**
  6020. * How big in texel of the blur texture is the vertical blur.
  6021. */
  6022. blurVerticalSize: number;
  6023. /**
  6024. * How big in texel of the blur texture is the horizontal blur.
  6025. */
  6026. blurHorizontalSize: number;
  6027. /**
  6028. * Alpha blending mode used to apply the blur. Default is combine.
  6029. */
  6030. alphaBlendingMode: number;
  6031. /**
  6032. * The camera attached to the layer.
  6033. */
  6034. camera: Nullable<Camera>;
  6035. /**
  6036. * Should we display highlight as a solid stroke?
  6037. */
  6038. isStroke?: boolean;
  6039. }
  6040. /**
  6041. * The highlight layer Helps adding a glow effect around a mesh.
  6042. *
  6043. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  6044. * glowy meshes to your scene.
  6045. *
  6046. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  6047. */
  6048. class HighlightLayer extends EffectLayer {
  6049. name: string;
  6050. /**
  6051. * Effect Name of the highlight layer.
  6052. */
  6053. static readonly EffectName: string;
  6054. /**
  6055. * The neutral color used during the preparation of the glow effect.
  6056. * This is black by default as the blend operation is a blend operation.
  6057. */
  6058. static NeutralColor: Color4;
  6059. /**
  6060. * Stencil value used for glowing meshes.
  6061. */
  6062. static GlowingMeshStencilReference: number;
  6063. /**
  6064. * Stencil value used for the other meshes in the scene.
  6065. */
  6066. static NormalMeshStencilReference: number;
  6067. /**
  6068. * Specifies whether or not the inner glow is ACTIVE in the layer.
  6069. */
  6070. innerGlow: boolean;
  6071. /**
  6072. * Specifies whether or not the outer glow is ACTIVE in the layer.
  6073. */
  6074. outerGlow: boolean;
  6075. /**
  6076. * Gets the horizontal size of the blur.
  6077. */
  6078. /**
  6079. * Specifies the horizontal size of the blur.
  6080. */
  6081. blurHorizontalSize: number;
  6082. /**
  6083. * Gets the vertical size of the blur.
  6084. */
  6085. /**
  6086. * Specifies the vertical size of the blur.
  6087. */
  6088. blurVerticalSize: number;
  6089. /**
  6090. * An event triggered when the highlight layer is being blurred.
  6091. */
  6092. onBeforeBlurObservable: Observable<HighlightLayer>;
  6093. /**
  6094. * An event triggered when the highlight layer has been blurred.
  6095. */
  6096. onAfterBlurObservable: Observable<HighlightLayer>;
  6097. private _instanceGlowingMeshStencilReference;
  6098. private _options;
  6099. private _downSamplePostprocess;
  6100. private _horizontalBlurPostprocess;
  6101. private _verticalBlurPostprocess;
  6102. private _blurTexture;
  6103. private _meshes;
  6104. private _excludedMeshes;
  6105. /**
  6106. * Instantiates a new highlight Layer and references it to the scene..
  6107. * @param name The name of the layer
  6108. * @param scene The scene to use the layer in
  6109. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  6110. */
  6111. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  6112. /**
  6113. * Get the effect name of the layer.
  6114. * @return The effect name
  6115. */
  6116. getEffectName(): string;
  6117. /**
  6118. * Create the merge effect. This is the shader use to blit the information back
  6119. * to the main canvas at the end of the scene rendering.
  6120. */
  6121. protected _createMergeEffect(): Effect;
  6122. /**
  6123. * Creates the render target textures and post processes used in the highlight layer.
  6124. */
  6125. protected _createTextureAndPostProcesses(): void;
  6126. /**
  6127. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  6128. */
  6129. needStencil(): boolean;
  6130. /**
  6131. * Checks for the readiness of the element composing the layer.
  6132. * @param subMesh the mesh to check for
  6133. * @param useInstances specify wether or not to use instances to render the mesh
  6134. * @param emissiveTexture the associated emissive texture used to generate the glow
  6135. * @return true if ready otherwise, false
  6136. */
  6137. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  6138. /**
  6139. * Implementation specific of rendering the generating effect on the main canvas.
  6140. * @param effect The effect used to render through
  6141. */
  6142. protected _internalRender(effect: Effect): void;
  6143. /**
  6144. * Returns true if the layer contains information to display, otherwise false.
  6145. */
  6146. shouldRender(): boolean;
  6147. /**
  6148. * Returns true if the mesh should render, otherwise false.
  6149. * @param mesh The mesh to render
  6150. * @returns true if it should render otherwise false
  6151. */
  6152. protected _shouldRenderMesh(mesh: Mesh): boolean;
  6153. /**
  6154. * Sets the required values for both the emissive texture and and the main color.
  6155. */
  6156. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  6157. /**
  6158. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  6159. * @param mesh The mesh to exclude from the highlight layer
  6160. */
  6161. addExcludedMesh(mesh: Mesh): void;
  6162. /**
  6163. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  6164. * @param mesh The mesh to highlight
  6165. */
  6166. removeExcludedMesh(mesh: Mesh): void;
  6167. /**
  6168. * Determine if a given mesh will be highlighted by the current HighlightLayer
  6169. * @param mesh mesh to test
  6170. * @returns true if the mesh will be highlighted by the current HighlightLayer
  6171. */
  6172. hasMesh(mesh: AbstractMesh): boolean;
  6173. /**
  6174. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  6175. * @param mesh The mesh to highlight
  6176. * @param color The color of the highlight
  6177. * @param glowEmissiveOnly Extract the glow from the emissive texture
  6178. */
  6179. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  6180. /**
  6181. * Remove a mesh from the highlight layer in order to make it stop glowing.
  6182. * @param mesh The mesh to highlight
  6183. */
  6184. removeMesh(mesh: Mesh): void;
  6185. /**
  6186. * Force the stencil to the normal expected value for none glowing parts
  6187. */
  6188. private _defaultStencilReference(mesh);
  6189. /**
  6190. * Free any resources and references associated to a mesh.
  6191. * Internal use
  6192. * @param mesh The mesh to free.
  6193. */
  6194. _disposeMesh(mesh: Mesh): void;
  6195. /**
  6196. * Dispose the highlight layer and free resources.
  6197. */
  6198. dispose(): void;
  6199. }
  6200. }
  6201. declare module BABYLON {
  6202. class Layer {
  6203. name: string;
  6204. texture: Nullable<Texture>;
  6205. isBackground: boolean;
  6206. color: Color4;
  6207. scale: Vector2;
  6208. offset: Vector2;
  6209. alphaBlendingMode: number;
  6210. alphaTest: boolean;
  6211. layerMask: number;
  6212. private _scene;
  6213. private _vertexBuffers;
  6214. private _indexBuffer;
  6215. private _effect;
  6216. private _alphaTestEffect;
  6217. /**
  6218. * An event triggered when the layer is disposed.
  6219. * @type {BABYLON.Observable}
  6220. */
  6221. onDisposeObservable: Observable<Layer>;
  6222. private _onDisposeObserver;
  6223. onDispose: () => void;
  6224. /**
  6225. * An event triggered before rendering the scene
  6226. * @type {BABYLON.Observable}
  6227. */
  6228. onBeforeRenderObservable: Observable<Layer>;
  6229. private _onBeforeRenderObserver;
  6230. onBeforeRender: () => void;
  6231. /**
  6232. * An event triggered after rendering the scene
  6233. * @type {BABYLON.Observable}
  6234. */
  6235. onAfterRenderObservable: Observable<Layer>;
  6236. private _onAfterRenderObserver;
  6237. onAfterRender: () => void;
  6238. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  6239. private _createIndexBuffer();
  6240. _rebuild(): void;
  6241. render(): void;
  6242. dispose(): void;
  6243. }
  6244. }
  6245. declare module BABYLON {
  6246. class LensFlare {
  6247. size: number;
  6248. position: number;
  6249. color: Color3;
  6250. texture: Nullable<Texture>;
  6251. alphaMode: number;
  6252. private _system;
  6253. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  6254. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  6255. dispose(): void;
  6256. }
  6257. }
  6258. declare module BABYLON {
  6259. class LensFlareSystem {
  6260. name: string;
  6261. lensFlares: LensFlare[];
  6262. borderLimit: number;
  6263. viewportBorder: number;
  6264. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  6265. layerMask: number;
  6266. id: string;
  6267. private _scene;
  6268. private _emitter;
  6269. private _vertexBuffers;
  6270. private _indexBuffer;
  6271. private _effect;
  6272. private _positionX;
  6273. private _positionY;
  6274. private _isEnabled;
  6275. constructor(name: string, emitter: any, scene: Scene);
  6276. isEnabled: boolean;
  6277. getScene(): Scene;
  6278. getEmitter(): any;
  6279. setEmitter(newEmitter: any): void;
  6280. getEmitterPosition(): Vector3;
  6281. computeEffectivePosition(globalViewport: Viewport): boolean;
  6282. _isVisible(): boolean;
  6283. render(): boolean;
  6284. dispose(): void;
  6285. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  6286. serialize(): any;
  6287. }
  6288. }
  6289. declare module BABYLON {
  6290. /**
  6291. * This class can be used to get instrumentation data from a Babylon engine
  6292. */
  6293. class EngineInstrumentation implements IDisposable {
  6294. engine: Engine;
  6295. private _captureGPUFrameTime;
  6296. private _gpuFrameTimeToken;
  6297. private _gpuFrameTime;
  6298. private _captureShaderCompilationTime;
  6299. private _shaderCompilationTime;
  6300. private _onBeginFrameObserver;
  6301. private _onEndFrameObserver;
  6302. private _onBeforeShaderCompilationObserver;
  6303. private _onAfterShaderCompilationObserver;
  6304. /**
  6305. * Gets the perf counter used for GPU frame time
  6306. */
  6307. readonly gpuFrameTimeCounter: PerfCounter;
  6308. /**
  6309. * Gets the GPU frame time capture status
  6310. */
  6311. /**
  6312. * Enable or disable the GPU frame time capture
  6313. */
  6314. captureGPUFrameTime: boolean;
  6315. /**
  6316. * Gets the perf counter used for shader compilation time
  6317. */
  6318. readonly shaderCompilationTimeCounter: PerfCounter;
  6319. /**
  6320. * Gets the shader compilation time capture status
  6321. */
  6322. /**
  6323. * Enable or disable the shader compilation time capture
  6324. */
  6325. captureShaderCompilationTime: boolean;
  6326. constructor(engine: Engine);
  6327. dispose(): void;
  6328. }
  6329. }
  6330. declare module BABYLON {
  6331. /**
  6332. * This class can be used to get instrumentation data from a Babylon engine
  6333. */
  6334. class SceneInstrumentation implements IDisposable {
  6335. scene: Scene;
  6336. private _captureActiveMeshesEvaluationTime;
  6337. private _activeMeshesEvaluationTime;
  6338. private _captureRenderTargetsRenderTime;
  6339. private _renderTargetsRenderTime;
  6340. private _captureFrameTime;
  6341. private _frameTime;
  6342. private _captureRenderTime;
  6343. private _renderTime;
  6344. private _captureInterFrameTime;
  6345. private _interFrameTime;
  6346. private _captureParticlesRenderTime;
  6347. private _particlesRenderTime;
  6348. private _captureSpritesRenderTime;
  6349. private _spritesRenderTime;
  6350. private _capturePhysicsTime;
  6351. private _physicsTime;
  6352. private _captureAnimationsTime;
  6353. private _animationsTime;
  6354. private _onBeforeActiveMeshesEvaluationObserver;
  6355. private _onAfterActiveMeshesEvaluationObserver;
  6356. private _onBeforeRenderTargetsRenderObserver;
  6357. private _onAfterRenderTargetsRenderObserver;
  6358. private _onAfterRenderObserver;
  6359. private _onBeforeDrawPhaseObserver;
  6360. private _onAfterDrawPhaseObserver;
  6361. private _onBeforeAnimationsObserver;
  6362. private _onBeforeParticlesRenderingObserver;
  6363. private _onAfterParticlesRenderingObserver;
  6364. private _onBeforeSpritesRenderingObserver;
  6365. private _onAfterSpritesRenderingObserver;
  6366. private _onBeforePhysicsObserver;
  6367. private _onAfterPhysicsObserver;
  6368. private _onAfterAnimationsObserver;
  6369. /**
  6370. * Gets the perf counter used for active meshes evaluation time
  6371. */
  6372. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  6373. /**
  6374. * Gets the active meshes evaluation time capture status
  6375. */
  6376. /**
  6377. * Enable or disable the active meshes evaluation time capture
  6378. */
  6379. captureActiveMeshesEvaluationTime: boolean;
  6380. /**
  6381. * Gets the perf counter used for render targets render time
  6382. */
  6383. readonly renderTargetsRenderTimeCounter: PerfCounter;
  6384. /**
  6385. * Gets the render targets render time capture status
  6386. */
  6387. /**
  6388. * Enable or disable the render targets render time capture
  6389. */
  6390. captureRenderTargetsRenderTime: boolean;
  6391. /**
  6392. * Gets the perf counter used for particles render time
  6393. */
  6394. readonly particlesRenderTimeCounter: PerfCounter;
  6395. /**
  6396. * Gets the particles render time capture status
  6397. */
  6398. /**
  6399. * Enable or disable the particles render time capture
  6400. */
  6401. captureParticlesRenderTime: boolean;
  6402. /**
  6403. * Gets the perf counter used for sprites render time
  6404. */
  6405. readonly spritesRenderTimeCounter: PerfCounter;
  6406. /**
  6407. * Gets the sprites render time capture status
  6408. */
  6409. /**
  6410. * Enable or disable the sprites render time capture
  6411. */
  6412. captureSpritesRenderTime: boolean;
  6413. /**
  6414. * Gets the perf counter used for physics time
  6415. */
  6416. readonly physicsTimeCounter: PerfCounter;
  6417. /**
  6418. * Gets the physics time capture status
  6419. */
  6420. /**
  6421. * Enable or disable the physics time capture
  6422. */
  6423. capturePhysicsTime: boolean;
  6424. /**
  6425. * Gets the perf counter used for animations time
  6426. */
  6427. readonly animationsTimeCounter: PerfCounter;
  6428. /**
  6429. * Gets the animations time capture status
  6430. */
  6431. /**
  6432. * Enable or disable the animations time capture
  6433. */
  6434. captureAnimationsTime: boolean;
  6435. /**
  6436. * Gets the perf counter used for frame time capture
  6437. */
  6438. readonly frameTimeCounter: PerfCounter;
  6439. /**
  6440. * Gets the frame time capture status
  6441. */
  6442. /**
  6443. * Enable or disable the frame time capture
  6444. */
  6445. captureFrameTime: boolean;
  6446. /**
  6447. * Gets the perf counter used for inter-frames time capture
  6448. */
  6449. readonly interFrameTimeCounter: PerfCounter;
  6450. /**
  6451. * Gets the inter-frames time capture status
  6452. */
  6453. /**
  6454. * Enable or disable the inter-frames time capture
  6455. */
  6456. captureInterFrameTime: boolean;
  6457. /**
  6458. * Gets the perf counter used for render time capture
  6459. */
  6460. readonly renderTimeCounter: PerfCounter;
  6461. /**
  6462. * Gets the render time capture status
  6463. */
  6464. /**
  6465. * Enable or disable the render time capture
  6466. */
  6467. captureRenderTime: boolean;
  6468. /**
  6469. * Gets the perf counter used for draw calls
  6470. */
  6471. readonly drawCallsCounter: PerfCounter;
  6472. /**
  6473. * Gets the perf counter used for texture collisions
  6474. */
  6475. readonly textureCollisionsCounter: PerfCounter;
  6476. constructor(scene: Scene);
  6477. dispose(): void;
  6478. }
  6479. }
  6480. declare module BABYLON {
  6481. class _TimeToken {
  6482. _startTimeQuery: Nullable<WebGLQuery>;
  6483. _endTimeQuery: Nullable<WebGLQuery>;
  6484. _timeElapsedQuery: Nullable<WebGLQuery>;
  6485. _timeElapsedQueryEnded: boolean;
  6486. }
  6487. }
  6488. declare module BABYLON {
  6489. /**
  6490. * A directional light is defined by a direction (what a surprise!).
  6491. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  6492. * 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.
  6493. * Documentation: https://doc.babylonjs.com/babylon101/lights
  6494. */
  6495. class DirectionalLight extends ShadowLight {
  6496. private _shadowFrustumSize;
  6497. /**
  6498. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  6499. */
  6500. /**
  6501. * Specifies a fix frustum size for the shadow generation.
  6502. */
  6503. shadowFrustumSize: number;
  6504. private _shadowOrthoScale;
  6505. /**
  6506. * Gets the shadow projection scale against the optimal computed one.
  6507. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  6508. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  6509. */
  6510. /**
  6511. * Sets the shadow projection scale against the optimal computed one.
  6512. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  6513. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  6514. */
  6515. shadowOrthoScale: number;
  6516. /**
  6517. * Automatically compute the projection matrix to best fit (including all the casters)
  6518. * on each frame.
  6519. */
  6520. autoUpdateExtends: boolean;
  6521. private _orthoLeft;
  6522. private _orthoRight;
  6523. private _orthoTop;
  6524. private _orthoBottom;
  6525. /**
  6526. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  6527. * The directional light is emitted from everywhere in the given direction.
  6528. * It can cast shawdows.
  6529. * Documentation : http://doc.babylonjs.com/tutorials/lights
  6530. * @param name The friendly name of the light
  6531. * @param direction The direction of the light
  6532. * @param scene The scene the light belongs to
  6533. */
  6534. constructor(name: string, direction: Vector3, scene: Scene);
  6535. /**
  6536. * Returns the string "DirectionalLight".
  6537. * @return The class name
  6538. */
  6539. getClassName(): string;
  6540. /**
  6541. * Returns the integer 1.
  6542. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  6543. */
  6544. getTypeID(): number;
  6545. /**
  6546. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  6547. * Returns the DirectionalLight Shadow projection matrix.
  6548. */
  6549. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  6550. /**
  6551. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  6552. * Returns the DirectionalLight Shadow projection matrix.
  6553. */
  6554. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  6555. /**
  6556. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  6557. * Returns the DirectionalLight Shadow projection matrix.
  6558. */
  6559. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  6560. protected _buildUniformLayout(): void;
  6561. /**
  6562. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  6563. * @param effect The effect to update
  6564. * @param lightIndex The index of the light in the effect to update
  6565. * @returns The directional light
  6566. */
  6567. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  6568. /**
  6569. * Gets the minZ used for shadow according to both the scene and the light.
  6570. *
  6571. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  6572. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  6573. * @param activeCamera The camera we are returning the min for
  6574. * @returns the depth min z
  6575. */
  6576. getDepthMinZ(activeCamera: Camera): number;
  6577. /**
  6578. * Gets the maxZ used for shadow according to both the scene and the light.
  6579. *
  6580. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  6581. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  6582. * @param activeCamera The camera we are returning the max for
  6583. * @returns the depth max z
  6584. */
  6585. getDepthMaxZ(activeCamera: Camera): number;
  6586. }
  6587. }
  6588. declare module BABYLON {
  6589. /**
  6590. * The HemisphericLight simulates the ambient environment light,
  6591. * so the passed direction is the light reflection direction, not the incoming direction.
  6592. */
  6593. class HemisphericLight extends Light {
  6594. /**
  6595. * The groundColor is the light in the opposite direction to the one specified during creation.
  6596. * 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.
  6597. */
  6598. groundColor: Color3;
  6599. /**
  6600. * The light reflection direction, not the incoming direction.
  6601. */
  6602. direction: Vector3;
  6603. private _worldMatrix;
  6604. /**
  6605. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  6606. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  6607. * The HemisphericLight can't cast shadows.
  6608. * Documentation : http://doc.babylonjs.com/tutorials/lights
  6609. * @param name The friendly name of the light
  6610. * @param direction The direction of the light reflection
  6611. * @param scene The scene the light belongs to
  6612. */
  6613. constructor(name: string, direction: Vector3, scene: Scene);
  6614. protected _buildUniformLayout(): void;
  6615. /**
  6616. * Returns the string "HemisphericLight".
  6617. * @return The class name
  6618. */
  6619. getClassName(): string;
  6620. /**
  6621. * Sets the HemisphericLight direction towards the passed target (Vector3).
  6622. * Returns the updated direction.
  6623. * @param target The target the direction should point to
  6624. * @return The computed direction
  6625. */
  6626. setDirectionToTarget(target: Vector3): Vector3;
  6627. /**
  6628. * Returns the shadow generator associated to the light.
  6629. * @returns Always null for hemispheric lights because it does not support shadows.
  6630. */
  6631. getShadowGenerator(): Nullable<ShadowGenerator>;
  6632. /**
  6633. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  6634. * @param effect The effect to update
  6635. * @param lightIndex The index of the light in the effect to update
  6636. * @returns The hemispheric light
  6637. */
  6638. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  6639. /**
  6640. * @ignore internal use only.
  6641. */
  6642. _getWorldMatrix(): Matrix;
  6643. /**
  6644. * Returns the integer 3.
  6645. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  6646. */
  6647. getTypeID(): number;
  6648. }
  6649. }
  6650. declare module BABYLON {
  6651. /**
  6652. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  6653. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  6654. * 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.
  6655. */
  6656. abstract class Light extends Node {
  6657. private static _LIGHTMAP_DEFAULT;
  6658. private static _LIGHTMAP_SPECULAR;
  6659. private static _LIGHTMAP_SHADOWSONLY;
  6660. /**
  6661. * If every light affecting the material is in this lightmapMode,
  6662. * material.lightmapTexture adds or multiplies
  6663. * (depends on material.useLightmapAsShadowmap)
  6664. * after every other light calculations.
  6665. */
  6666. static readonly LIGHTMAP_DEFAULT: number;
  6667. /**
  6668. * material.lightmapTexture as only diffuse lighting from this light
  6669. * adds only specular lighting from this light
  6670. * adds dynamic shadows
  6671. */
  6672. static readonly LIGHTMAP_SPECULAR: number;
  6673. /**
  6674. * material.lightmapTexture as only lighting
  6675. * no light calculation from this light
  6676. * only adds dynamic shadows from this light
  6677. */
  6678. static readonly LIGHTMAP_SHADOWSONLY: number;
  6679. private static _INTENSITYMODE_AUTOMATIC;
  6680. private static _INTENSITYMODE_LUMINOUSPOWER;
  6681. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  6682. private static _INTENSITYMODE_ILLUMINANCE;
  6683. private static _INTENSITYMODE_LUMINANCE;
  6684. /**
  6685. * Each light type uses the default quantity according to its type:
  6686. * point/spot lights use luminous intensity
  6687. * directional lights use illuminance
  6688. */
  6689. static readonly INTENSITYMODE_AUTOMATIC: number;
  6690. /**
  6691. * lumen (lm)
  6692. */
  6693. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  6694. /**
  6695. * candela (lm/sr)
  6696. */
  6697. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  6698. /**
  6699. * lux (lm/m^2)
  6700. */
  6701. static readonly INTENSITYMODE_ILLUMINANCE: number;
  6702. /**
  6703. * nit (cd/m^2)
  6704. */
  6705. static readonly INTENSITYMODE_LUMINANCE: number;
  6706. private static _LIGHTTYPEID_POINTLIGHT;
  6707. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  6708. private static _LIGHTTYPEID_SPOTLIGHT;
  6709. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  6710. /**
  6711. * Light type const id of the point light.
  6712. */
  6713. static readonly LIGHTTYPEID_POINTLIGHT: number;
  6714. /**
  6715. * Light type const id of the directional light.
  6716. */
  6717. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  6718. /**
  6719. * Light type const id of the spot light.
  6720. */
  6721. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  6722. /**
  6723. * Light type const id of the hemispheric light.
  6724. */
  6725. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  6726. /**
  6727. * Diffuse gives the basic color to an object.
  6728. */
  6729. diffuse: Color3;
  6730. /**
  6731. * Specular produces a highlight color on an object.
  6732. * Note: This is note affecting PBR materials.
  6733. */
  6734. specular: Color3;
  6735. /**
  6736. * Strength of the light.
  6737. * Note: By default it is define in the framework own unit.
  6738. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  6739. */
  6740. intensity: number;
  6741. /**
  6742. * Defines how far from the source the light is impacting in scene units.
  6743. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  6744. */
  6745. range: number;
  6746. /**
  6747. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  6748. * of light.
  6749. */
  6750. private _photometricScale;
  6751. private _intensityMode;
  6752. /**
  6753. * Gets the photometric scale used to interpret the intensity.
  6754. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  6755. */
  6756. /**
  6757. * Sets the photometric scale used to interpret the intensity.
  6758. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  6759. */
  6760. intensityMode: number;
  6761. private _radius;
  6762. /**
  6763. * Gets the light radius used by PBR Materials to simulate soft area lights.
  6764. */
  6765. /**
  6766. * sets the light radius used by PBR Materials to simulate soft area lights.
  6767. */
  6768. radius: number;
  6769. private _renderPriority;
  6770. /**
  6771. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  6772. * exceeding the number allowed of the materials.
  6773. */
  6774. renderPriority: number;
  6775. /**
  6776. * Defines wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  6777. * the current shadow generator.
  6778. */
  6779. shadowEnabled: boolean;
  6780. private _includedOnlyMeshes;
  6781. /**
  6782. * Gets the only meshes impacted by this light.
  6783. */
  6784. /**
  6785. * Sets the only meshes impacted by this light.
  6786. */
  6787. includedOnlyMeshes: AbstractMesh[];
  6788. private _excludedMeshes;
  6789. /**
  6790. * Gets the meshes not impacted by this light.
  6791. */
  6792. /**
  6793. * Sets the meshes not impacted by this light.
  6794. */
  6795. excludedMeshes: AbstractMesh[];
  6796. private _excludeWithLayerMask;
  6797. /**
  6798. * Gets the layer id use to find what meshes are not impacted by the light.
  6799. * Inactive if 0
  6800. */
  6801. /**
  6802. * Sets the layer id use to find what meshes are not impacted by the light.
  6803. * Inactive if 0
  6804. */
  6805. excludeWithLayerMask: number;
  6806. private _includeOnlyWithLayerMask;
  6807. /**
  6808. * Gets the layer id use to find what meshes are impacted by the light.
  6809. * Inactive if 0
  6810. */
  6811. /**
  6812. * Sets the layer id use to find what meshes are impacted by the light.
  6813. * Inactive if 0
  6814. */
  6815. includeOnlyWithLayerMask: number;
  6816. private _lightmapMode;
  6817. /**
  6818. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  6819. */
  6820. /**
  6821. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  6822. */
  6823. lightmapMode: number;
  6824. private _parentedWorldMatrix;
  6825. /**
  6826. * Shadow generator associted to the light.
  6827. * Internal use only.
  6828. */
  6829. _shadowGenerator: Nullable<IShadowGenerator>;
  6830. /**
  6831. * @ignore Internal use only.
  6832. */
  6833. _excludedMeshesIds: string[];
  6834. /**
  6835. * @ignore Internal use only.
  6836. */
  6837. _includedOnlyMeshesIds: string[];
  6838. /**
  6839. * The current light unifom buffer.
  6840. * @ignore Internal use only.
  6841. */
  6842. _uniformBuffer: UniformBuffer;
  6843. /**
  6844. * Creates a Light object in the scene.
  6845. * Documentation : http://doc.babylonjs.com/tutorials/lights
  6846. * @param name The firendly name of the light
  6847. * @param scene The scene the light belongs too
  6848. */
  6849. constructor(name: string, scene: Scene);
  6850. protected abstract _buildUniformLayout(): void;
  6851. /**
  6852. * Sets the passed Effect "effect" with the Light information.
  6853. * @param effect The effect to update
  6854. * @param lightIndex The index of the light in the effect to update
  6855. * @returns The light
  6856. */
  6857. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  6858. /**
  6859. * @ignore internal use only.
  6860. */
  6861. abstract _getWorldMatrix(): Matrix;
  6862. /**
  6863. * Returns the string "Light".
  6864. * @returns the class name
  6865. */
  6866. getClassName(): string;
  6867. /**
  6868. * Converts the light information to a readable string for debug purpose.
  6869. * @param fullDetails Supports for multiple levels of logging within scene loading
  6870. * @returns the human readable light info
  6871. */
  6872. toString(fullDetails?: boolean): string;
  6873. /**
  6874. * Set the enabled state of this node.
  6875. * @param value - the new enabled state
  6876. * @see isEnabled
  6877. */
  6878. setEnabled(value: boolean): void;
  6879. /**
  6880. * Returns the Light associated shadow generator if any.
  6881. * @return the associated shadow generator.
  6882. */
  6883. getShadowGenerator(): Nullable<IShadowGenerator>;
  6884. /**
  6885. * Returns a Vector3, the absolute light position in the World.
  6886. * @returns the world space position of the light
  6887. */
  6888. getAbsolutePosition(): Vector3;
  6889. /**
  6890. * Specifies if the light will affect the passed mesh.
  6891. * @param mesh The mesh to test against the light
  6892. * @return true the mesh is affected otherwise, false.
  6893. */
  6894. canAffectMesh(mesh: AbstractMesh): boolean;
  6895. /**
  6896. * Computes and Returns the light World matrix.
  6897. * @returns the world matrix
  6898. */
  6899. getWorldMatrix(): Matrix;
  6900. /**
  6901. * Sort function to order lights for rendering.
  6902. * @param a First Light object to compare to second.
  6903. * @param b Second Light object to compare first.
  6904. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  6905. */
  6906. static CompareLightsPriority(a: Light, b: Light): number;
  6907. /**
  6908. * Disposes the light.
  6909. */
  6910. dispose(): void;
  6911. /**
  6912. * Returns the light type ID (integer).
  6913. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  6914. */
  6915. getTypeID(): number;
  6916. /**
  6917. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  6918. * @returns the scaled intensity in intensity mode unit
  6919. */
  6920. getScaledIntensity(): number;
  6921. /**
  6922. * Returns a new Light object, named "name", from the current one.
  6923. * @param name The name of the cloned light
  6924. * @returns the new created light
  6925. */
  6926. clone(name: string): Nullable<Light>;
  6927. /**
  6928. * Serializes the current light into a Serialization object.
  6929. * @returns the serialized object.
  6930. */
  6931. serialize(): any;
  6932. /**
  6933. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  6934. * This new light is named "name" and added to the passed scene.
  6935. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  6936. * @param name The friendly name of the light
  6937. * @param scene The scene the new light will belong to
  6938. * @returns the constructor function
  6939. */
  6940. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  6941. /**
  6942. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  6943. * @param parsedLight The JSON representation of the light
  6944. * @param scene The scene to create the parsed light in
  6945. * @returns the created light after parsing
  6946. */
  6947. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  6948. private _hookArrayForExcluded(array);
  6949. private _hookArrayForIncludedOnly(array);
  6950. private _resyncMeshes();
  6951. /**
  6952. * Forces the meshes to update their light related information in their rendering used effects
  6953. * @ignore Internal Use Only
  6954. */
  6955. _markMeshesAsLightDirty(): void;
  6956. /**
  6957. * Recomputes the cached photometric scale if needed.
  6958. */
  6959. private _computePhotometricScale();
  6960. /**
  6961. * Returns the Photometric Scale according to the light type and intensity mode.
  6962. */
  6963. private _getPhotometricScale();
  6964. /**
  6965. * Reorder the light in the scene according to their defined priority.
  6966. * @ignore Internal Use Only
  6967. */
  6968. _reorderLightsInScene(): void;
  6969. }
  6970. }
  6971. declare module BABYLON {
  6972. /**
  6973. * A point light is a light defined by an unique point in world space.
  6974. * The light is emitted in every direction from this point.
  6975. * A good example of a point light is a standard light bulb.
  6976. * Documentation: https://doc.babylonjs.com/babylon101/lights
  6977. */
  6978. class PointLight extends ShadowLight {
  6979. private _shadowAngle;
  6980. /**
  6981. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  6982. * This specifies what angle the shadow will use to be created.
  6983. *
  6984. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  6985. */
  6986. /**
  6987. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  6988. * This specifies what angle the shadow will use to be created.
  6989. *
  6990. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  6991. */
  6992. shadowAngle: number;
  6993. /**
  6994. * Gets the direction if it has been set.
  6995. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  6996. */
  6997. /**
  6998. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  6999. */
  7000. direction: Vector3;
  7001. /**
  7002. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  7003. * A PointLight emits the light in every direction.
  7004. * It can cast shadows.
  7005. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  7006. * ```javascript
  7007. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  7008. * ```
  7009. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7010. * @param name The light friendly name
  7011. * @param position The position of the point light in the scene
  7012. * @param scene The scene the lights belongs to
  7013. */
  7014. constructor(name: string, position: Vector3, scene: Scene);
  7015. /**
  7016. * Returns the string "PointLight"
  7017. * @returns the class name
  7018. */
  7019. getClassName(): string;
  7020. /**
  7021. * Returns the integer 0.
  7022. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7023. */
  7024. getTypeID(): number;
  7025. /**
  7026. * Specifies wether or not the shadowmap should be a cube texture.
  7027. * @returns true if the shadowmap needs to be a cube texture.
  7028. */
  7029. needCube(): boolean;
  7030. /**
  7031. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  7032. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7033. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7034. */
  7035. getShadowDirection(faceIndex?: number): Vector3;
  7036. /**
  7037. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  7038. * - fov = PI / 2
  7039. * - aspect ratio : 1.0
  7040. * - z-near and far equal to the active camera minZ and maxZ.
  7041. * Returns the PointLight.
  7042. */
  7043. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7044. protected _buildUniformLayout(): void;
  7045. /**
  7046. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  7047. * @param effect The effect to update
  7048. * @param lightIndex The index of the light in the effect to update
  7049. * @returns The point light
  7050. */
  7051. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  7052. }
  7053. }
  7054. declare module BABYLON {
  7055. /**
  7056. * Interface describing all the common properties and methods a shadow light needs to implement.
  7057. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  7058. * as well as binding the different shadow properties to the effects.
  7059. */
  7060. interface IShadowLight extends Light {
  7061. /**
  7062. * The light id in the scene (used in scene.findLighById for instance)
  7063. */
  7064. id: string;
  7065. /**
  7066. * The position the shdow will be casted from.
  7067. */
  7068. position: Vector3;
  7069. /**
  7070. * In 2d mode (needCube being false), the direction used to cast the shadow.
  7071. */
  7072. direction: Vector3;
  7073. /**
  7074. * The transformed position. Position of the light in world space taking parenting in account.
  7075. */
  7076. transformedPosition: Vector3;
  7077. /**
  7078. * The transformed direction. Direction of the light in world space taking parenting in account.
  7079. */
  7080. transformedDirection: Vector3;
  7081. /**
  7082. * The friendly name of the light in the scene.
  7083. */
  7084. name: string;
  7085. /**
  7086. * Defines the shadow projection clipping minimum z value.
  7087. */
  7088. shadowMinZ: number;
  7089. /**
  7090. * Defines the shadow projection clipping maximum z value.
  7091. */
  7092. shadowMaxZ: number;
  7093. /**
  7094. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  7095. * @returns true if the information has been computed, false if it does not need to (no parenting)
  7096. */
  7097. computeTransformedInformation(): boolean;
  7098. /**
  7099. * Gets the scene the light belongs to.
  7100. * @returns The scene
  7101. */
  7102. getScene(): Scene;
  7103. /**
  7104. * Callback defining a custom Projection Matrix Builder.
  7105. * This can be used to override the default projection matrix computation.
  7106. */
  7107. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  7108. /**
  7109. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  7110. * @param matrix The materix to updated with the projection information
  7111. * @param viewMatrix The transform matrix of the light
  7112. * @param renderList The list of mesh to render in the map
  7113. * @returns The current light
  7114. */
  7115. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  7116. /**
  7117. * Gets the current depth scale used in ESM.
  7118. * @returns The scale
  7119. */
  7120. getDepthScale(): number;
  7121. /**
  7122. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  7123. * @returns true if a cube texture needs to be use
  7124. */
  7125. needCube(): boolean;
  7126. /**
  7127. * Detects if the projection matrix requires to be recomputed this frame.
  7128. * @returns true if it requires to be recomputed otherwise, false.
  7129. */
  7130. needProjectionMatrixCompute(): boolean;
  7131. /**
  7132. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  7133. */
  7134. forceProjectionMatrixCompute(): void;
  7135. /**
  7136. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  7137. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7138. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7139. */
  7140. getShadowDirection(faceIndex?: number): Vector3;
  7141. /**
  7142. * Gets the minZ used for shadow according to both the scene and the light.
  7143. * @param activeCamera The camera we are returning the min for
  7144. * @returns the depth min z
  7145. */
  7146. getDepthMinZ(activeCamera: Camera): number;
  7147. /**
  7148. * Gets the maxZ used for shadow according to both the scene and the light.
  7149. * @param activeCamera The camera we are returning the max for
  7150. * @returns the depth max z
  7151. */
  7152. getDepthMaxZ(activeCamera: Camera): number;
  7153. }
  7154. /**
  7155. * Base implementation of @see IShadowLight
  7156. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  7157. */
  7158. abstract class ShadowLight extends Light implements IShadowLight {
  7159. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7160. protected _position: Vector3;
  7161. protected _setPosition(value: Vector3): void;
  7162. /**
  7163. * Sets the position the shadow will be casted from. Also use as the light position for both
  7164. * point and spot lights.
  7165. */
  7166. /**
  7167. * Sets the position the shadow will be casted from. Also use as the light position for both
  7168. * point and spot lights.
  7169. */
  7170. position: Vector3;
  7171. protected _direction: Vector3;
  7172. protected _setDirection(value: Vector3): void;
  7173. /**
  7174. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  7175. * Also use as the light direction on spot and directional lights.
  7176. */
  7177. /**
  7178. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  7179. * Also use as the light direction on spot and directional lights.
  7180. */
  7181. direction: Vector3;
  7182. private _shadowMinZ;
  7183. /**
  7184. * Gets the shadow projection clipping minimum z value.
  7185. */
  7186. /**
  7187. * Sets the shadow projection clipping minimum z value.
  7188. */
  7189. shadowMinZ: number;
  7190. private _shadowMaxZ;
  7191. /**
  7192. * Sets the shadow projection clipping maximum z value.
  7193. */
  7194. /**
  7195. * Gets the shadow projection clipping maximum z value.
  7196. */
  7197. shadowMaxZ: number;
  7198. /**
  7199. * Callback defining a custom Projection Matrix Builder.
  7200. * This can be used to override the default projection matrix computation.
  7201. */
  7202. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  7203. /**
  7204. * The transformed position. Position of the light in world space taking parenting in account.
  7205. */
  7206. transformedPosition: Vector3;
  7207. /**
  7208. * The transformed direction. Direction of the light in world space taking parenting in account.
  7209. */
  7210. transformedDirection: Vector3;
  7211. private _worldMatrix;
  7212. private _needProjectionMatrixCompute;
  7213. /**
  7214. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  7215. * @returns true if the information has been computed, false if it does not need to (no parenting)
  7216. */
  7217. computeTransformedInformation(): boolean;
  7218. /**
  7219. * Return the depth scale used for the shadow map.
  7220. * @returns the depth scale.
  7221. */
  7222. getDepthScale(): number;
  7223. /**
  7224. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  7225. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7226. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7227. */
  7228. getShadowDirection(faceIndex?: number): Vector3;
  7229. /**
  7230. * Returns the ShadowLight absolute position in the World.
  7231. * @returns the position vector in world space
  7232. */
  7233. getAbsolutePosition(): Vector3;
  7234. /**
  7235. * Sets the ShadowLight direction toward the passed target.
  7236. * @param target The point tot target in local space
  7237. * @returns the updated ShadowLight direction
  7238. */
  7239. setDirectionToTarget(target: Vector3): Vector3;
  7240. /**
  7241. * Returns the light rotation in euler definition.
  7242. * @returns the x y z rotation in local space.
  7243. */
  7244. getRotation(): Vector3;
  7245. /**
  7246. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  7247. * @returns true if a cube texture needs to be use
  7248. */
  7249. needCube(): boolean;
  7250. /**
  7251. * Detects if the projection matrix requires to be recomputed this frame.
  7252. * @returns true if it requires to be recomputed otherwise, false.
  7253. */
  7254. needProjectionMatrixCompute(): boolean;
  7255. /**
  7256. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  7257. */
  7258. forceProjectionMatrixCompute(): void;
  7259. /**
  7260. * Get the world matrix of the sahdow lights.
  7261. * @ignore Internal Use Only
  7262. */
  7263. _getWorldMatrix(): Matrix;
  7264. /**
  7265. * Gets the minZ used for shadow according to both the scene and the light.
  7266. * @param activeCamera The camera we are returning the min for
  7267. * @returns the depth min z
  7268. */
  7269. getDepthMinZ(activeCamera: Camera): number;
  7270. /**
  7271. * Gets the maxZ used for shadow according to both the scene and the light.
  7272. * @param activeCamera The camera we are returning the max for
  7273. * @returns the depth max z
  7274. */
  7275. getDepthMaxZ(activeCamera: Camera): number;
  7276. /**
  7277. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  7278. * @param matrix The materix to updated with the projection information
  7279. * @param viewMatrix The transform matrix of the light
  7280. * @param renderList The list of mesh to render in the map
  7281. * @returns The current light
  7282. */
  7283. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  7284. }
  7285. }
  7286. declare module BABYLON {
  7287. /**
  7288. * A spot light is defined by a position, a direction, an angle, and an exponent.
  7289. * These values define a cone of light starting from the position, emitting toward the direction.
  7290. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  7291. * and the exponent defines the speed of the decay of the light with distance (reach).
  7292. * Documentation: https://doc.babylonjs.com/babylon101/lights
  7293. */
  7294. class SpotLight extends ShadowLight {
  7295. private _angle;
  7296. /**
  7297. * Gets the cone angle of the spot light in Radians.
  7298. */
  7299. /**
  7300. * Sets the cone angle of the spot light in Radians.
  7301. */
  7302. angle: number;
  7303. private _shadowAngleScale;
  7304. /**
  7305. * Allows scaling the angle of the light for shadow generation only.
  7306. */
  7307. /**
  7308. * Allows scaling the angle of the light for shadow generation only.
  7309. */
  7310. shadowAngleScale: number;
  7311. /**
  7312. * The light decay speed with the distance from the emission spot.
  7313. */
  7314. exponent: number;
  7315. private _projectionTextureMatrix;
  7316. /**
  7317. * Allows reading the projecton texture
  7318. */
  7319. readonly projectionTextureMatrix: Matrix;
  7320. protected _projectionTextureLightNear: number;
  7321. /**
  7322. * Gets the near clip of the Spotlight for texture projection.
  7323. */
  7324. /**
  7325. * Sets the near clip of the Spotlight for texture projection.
  7326. */
  7327. projectionTextureLightNear: number;
  7328. protected _projectionTextureLightFar: number;
  7329. /**
  7330. * Gets the far clip of the Spotlight for texture projection.
  7331. */
  7332. /**
  7333. * Sets the far clip of the Spotlight for texture projection.
  7334. */
  7335. projectionTextureLightFar: number;
  7336. protected _projectionTextureUpDirection: Vector3;
  7337. /**
  7338. * Gets the Up vector of the Spotlight for texture projection.
  7339. */
  7340. /**
  7341. * Sets the Up vector of the Spotlight for texture projection.
  7342. */
  7343. projectionTextureUpDirection: Vector3;
  7344. private _projectionTexture;
  7345. /**
  7346. * Gets the projection texture of the light.
  7347. */
  7348. /**
  7349. * Sets the projection texture of the light.
  7350. */
  7351. projectionTexture: Nullable<BaseTexture>;
  7352. private _projectionTextureViewLightDirty;
  7353. private _projectionTextureProjectionLightDirty;
  7354. private _projectionTextureDirty;
  7355. private _projectionTextureViewTargetVector;
  7356. private _projectionTextureViewLightMatrix;
  7357. private _projectionTextureProjectionLightMatrix;
  7358. private _projectionTextureScalingMatrix;
  7359. /**
  7360. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  7361. * It can cast shadows.
  7362. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7363. * @param name The light friendly name
  7364. * @param position The position of the spot light in the scene
  7365. * @param direction The direction of the light in the scene
  7366. * @param angle The cone angle of the light in Radians
  7367. * @param exponent The light decay speed with the distance from the emission spot
  7368. * @param scene The scene the lights belongs to
  7369. */
  7370. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  7371. /**
  7372. * Returns the string "SpotLight".
  7373. * @returns the class name
  7374. */
  7375. getClassName(): string;
  7376. /**
  7377. * Returns the integer 2.
  7378. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7379. */
  7380. getTypeID(): number;
  7381. /**
  7382. * Overrides the direction setter to recompute the projection texture view light Matrix.
  7383. */
  7384. protected _setDirection(value: Vector3): void;
  7385. /**
  7386. * Overrides the position setter to recompute the projection texture view light Matrix.
  7387. */
  7388. protected _setPosition(value: Vector3): void;
  7389. /**
  7390. * 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.
  7391. * Returns the SpotLight.
  7392. */
  7393. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7394. protected _computeProjectionTextureViewLightMatrix(): void;
  7395. protected _computeProjectionTextureProjectionLightMatrix(): void;
  7396. /**
  7397. * Main function for light texture projection matrix computing.
  7398. */
  7399. protected _computeProjectionTextureMatrix(): void;
  7400. protected _buildUniformLayout(): void;
  7401. /**
  7402. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  7403. * @param effect The effect to update
  7404. * @param lightIndex The index of the light in the effect to update
  7405. * @returns The spot light
  7406. */
  7407. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  7408. /**
  7409. * Disposes the light and the associated resources.
  7410. */
  7411. dispose(): void;
  7412. }
  7413. }
  7414. declare module BABYLON {
  7415. interface ILoadingScreen {
  7416. displayLoadingUI: () => void;
  7417. hideLoadingUI: () => void;
  7418. loadingUIBackgroundColor: string;
  7419. loadingUIText: string;
  7420. }
  7421. class DefaultLoadingScreen implements ILoadingScreen {
  7422. private _renderingCanvas;
  7423. private _loadingText;
  7424. private _loadingDivBackgroundColor;
  7425. private _loadingDiv;
  7426. private _loadingTextDiv;
  7427. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  7428. displayLoadingUI(): void;
  7429. hideLoadingUI(): void;
  7430. loadingUIText: string;
  7431. loadingUIBackgroundColor: string;
  7432. private _resizeLoadingUI;
  7433. }
  7434. }
  7435. declare module BABYLON {
  7436. class SceneLoaderProgressEvent {
  7437. readonly lengthComputable: boolean;
  7438. readonly loaded: number;
  7439. readonly total: number;
  7440. constructor(lengthComputable: boolean, loaded: number, total: number);
  7441. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  7442. }
  7443. interface ISceneLoaderPluginExtensions {
  7444. [extension: string]: {
  7445. isBinary: boolean;
  7446. };
  7447. }
  7448. interface ISceneLoaderPluginFactory {
  7449. name: string;
  7450. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  7451. canDirectLoad?: (data: string) => boolean;
  7452. }
  7453. interface ISceneLoaderPlugin {
  7454. /**
  7455. * The friendly name of this plugin.
  7456. */
  7457. name: string;
  7458. /**
  7459. * The file extensions supported by this plugin.
  7460. */
  7461. extensions: string | ISceneLoaderPluginExtensions;
  7462. /**
  7463. * Import meshes into a scene.
  7464. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  7465. * @param scene The scene to import into
  7466. * @param data The data to import
  7467. * @param rootUrl The root url for scene and resources
  7468. * @param meshes The meshes array to import into
  7469. * @param particleSystems The particle systems array to import into
  7470. * @param skeletons The skeletons array to import into
  7471. * @param onError The callback when import fails
  7472. * @returns True if successful or false otherwise
  7473. */
  7474. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  7475. /**
  7476. * Load into a scene.
  7477. * @param scene The scene to load into
  7478. * @param data The data to import
  7479. * @param rootUrl The root url for scene and resources
  7480. * @param onError The callback when import fails
  7481. * @returns true if successful or false otherwise
  7482. */
  7483. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  7484. /**
  7485. * The callback that returns true if the data can be directly loaded.
  7486. */
  7487. canDirectLoad?: (data: string) => boolean;
  7488. /**
  7489. * The callback that allows custom handling of the root url based on the response url.
  7490. */
  7491. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  7492. /**
  7493. * Load into an asset container.
  7494. * @param scene The scene to load into
  7495. * @param data The data to import
  7496. * @param rootUrl The root url for scene and resources
  7497. * @param onError The callback when import fails
  7498. * @returns The loaded asset container
  7499. */
  7500. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  7501. }
  7502. interface ISceneLoaderPluginAsync {
  7503. /**
  7504. * The friendly name of this plugin.
  7505. */
  7506. name: string;
  7507. /**
  7508. * The file extensions supported by this plugin.
  7509. */
  7510. extensions: string | ISceneLoaderPluginExtensions;
  7511. /**
  7512. * Import meshes into a scene.
  7513. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  7514. * @param scene The scene to import into
  7515. * @param data The data to import
  7516. * @param rootUrl The root url for scene and resources
  7517. * @param onProgress The callback when the load progresses
  7518. * @returns The loaded meshes, particle systems, and skeletons
  7519. */
  7520. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  7521. meshes: AbstractMesh[];
  7522. particleSystems: ParticleSystem[];
  7523. skeletons: Skeleton[];
  7524. }>;
  7525. /**
  7526. * Load into a scene.
  7527. * @param scene The scene to load into
  7528. * @param data The data to import
  7529. * @param rootUrl The root url for scene and resources
  7530. * @param onProgress The callback when the load progresses
  7531. * @returns Nothing
  7532. */
  7533. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  7534. /**
  7535. * The callback that returns true if the data can be directly loaded.
  7536. */
  7537. canDirectLoad?: (data: string) => boolean;
  7538. /**
  7539. * The callback that allows custom handling of the root url based on the response url.
  7540. */
  7541. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  7542. /**
  7543. * Load into an asset container.
  7544. * @param scene The scene to load into
  7545. * @param data The data to import
  7546. * @param rootUrl The root url for scene and resources
  7547. * @param onProgress The callback when the load progresses
  7548. * @returns The loaded asset container
  7549. */
  7550. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  7551. }
  7552. class SceneLoader {
  7553. private static _ForceFullSceneLoadingForIncremental;
  7554. private static _ShowLoadingScreen;
  7555. private static _CleanBoneMatrixWeights;
  7556. static readonly NO_LOGGING: number;
  7557. static readonly MINIMAL_LOGGING: number;
  7558. static readonly SUMMARY_LOGGING: number;
  7559. static readonly DETAILED_LOGGING: number;
  7560. private static _loggingLevel;
  7561. static ForceFullSceneLoadingForIncremental: boolean;
  7562. static ShowLoadingScreen: boolean;
  7563. static loggingLevel: number;
  7564. static CleanBoneMatrixWeights: boolean;
  7565. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  7566. private static _registeredPlugins;
  7567. private static _getDefaultPlugin();
  7568. private static _getPluginForExtension(extension);
  7569. private static _getPluginForDirectLoad(data);
  7570. private static _getPluginForFilename(sceneFilename);
  7571. private static _getDirectLoad(sceneFilename);
  7572. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  7573. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  7574. static IsPluginForExtensionAvailable(extension: string): boolean;
  7575. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  7576. /**
  7577. * Import meshes into a scene
  7578. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  7579. * @param rootUrl a string that defines the root url for scene and resources
  7580. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7581. * @param scene the instance of BABYLON.Scene to append to
  7582. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  7583. * @param onProgress a callback with a progress event for each file being loaded
  7584. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  7585. * @param pluginExtension the extension used to determine the plugin
  7586. * @returns The loaded plugin
  7587. */
  7588. 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>;
  7589. /**
  7590. * Import meshes into a scene
  7591. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  7592. * @param rootUrl a string that defines the root url for scene and resources
  7593. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7594. * @param scene the instance of BABYLON.Scene to append to
  7595. * @param onProgress a callback with a progress event for each file being loaded
  7596. * @param pluginExtension the extension used to determine the plugin
  7597. * @returns The loaded list of imported meshes, particleSystems, and skeletons
  7598. */
  7599. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  7600. meshes: AbstractMesh[];
  7601. particleSystems: ParticleSystem[];
  7602. skeletons: Skeleton[];
  7603. }>;
  7604. /**
  7605. * Load a scene
  7606. * @param rootUrl a string that defines the root url for scene and resources
  7607. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7608. * @param engine is the instance of BABYLON.Engine to use to create the scene
  7609. * @param onSuccess a callback with the scene when import succeeds
  7610. * @param onProgress a callback with a progress event for each file being loaded
  7611. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  7612. * @param pluginExtension the extension used to determine the plugin
  7613. * @returns The loaded plugin
  7614. */
  7615. 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>;
  7616. /**
  7617. * Load a scene
  7618. * @param rootUrl a string that defines the root url for scene and resources
  7619. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7620. * @param engine is the instance of BABYLON.Engine to use to create the scene
  7621. * @param onProgress a callback with a progress event for each file being loaded
  7622. * @param pluginExtension the extension used to determine the plugin
  7623. * @returns The loaded scene
  7624. */
  7625. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  7626. /**
  7627. * Append a scene
  7628. * @param rootUrl a string that defines the root url for scene and resources
  7629. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7630. * @param scene is the instance of BABYLON.Scene to append to
  7631. * @param onSuccess a callback with the scene when import succeeds
  7632. * @param onProgress a callback with a progress event for each file being loaded
  7633. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  7634. * @param pluginExtension the extension used to determine the plugin
  7635. * @returns The loaded plugin
  7636. */
  7637. 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>;
  7638. /**
  7639. * Append a scene
  7640. * @param rootUrl a string that defines the root url for scene and resources
  7641. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7642. * @param scene is the instance of BABYLON.Scene to append to
  7643. * @param onProgress a callback with a progress event for each file being loaded
  7644. * @param pluginExtension the extension used to determine the plugin
  7645. * @returns The given scene
  7646. */
  7647. static AppendAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  7648. /**
  7649. * Load a scene into an asset container
  7650. * @param rootUrl a string that defines the root url for scene and resources
  7651. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7652. * @param scene is the instance of BABYLON.Scene to append to
  7653. * @param onSuccess a callback with the scene when import succeeds
  7654. * @param onProgress a callback with a progress event for each file being loaded
  7655. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  7656. * @param pluginExtension the extension used to determine the plugin
  7657. * @returns The loaded plugin
  7658. */
  7659. 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>;
  7660. /**
  7661. * Load a scene into an asset container
  7662. * @param rootUrl a string that defines the root url for scene and resources
  7663. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  7664. * @param scene is the instance of BABYLON.Scene to append to
  7665. * @param onProgress a callback with a progress event for each file being loaded
  7666. * @param pluginExtension the extension used to determine the plugin
  7667. * @returns The loaded asset container
  7668. */
  7669. static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  7670. }
  7671. }
  7672. declare module BABYLON {
  7673. /**
  7674. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7675. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7676. * 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;
  7677. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7678. */
  7679. class ColorCurves {
  7680. private _dirty;
  7681. private _tempColor;
  7682. private _globalCurve;
  7683. private _highlightsCurve;
  7684. private _midtonesCurve;
  7685. private _shadowsCurve;
  7686. private _positiveCurve;
  7687. private _negativeCurve;
  7688. private _globalHue;
  7689. private _globalDensity;
  7690. private _globalSaturation;
  7691. private _globalExposure;
  7692. /**
  7693. * Gets the global Hue value.
  7694. * 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).
  7695. */
  7696. /**
  7697. * Sets the global Hue value.
  7698. * 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).
  7699. */
  7700. globalHue: number;
  7701. /**
  7702. * Gets the global Density value.
  7703. * 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.
  7704. * Values less than zero provide a filter of opposite hue.
  7705. */
  7706. /**
  7707. * Sets the global Density value.
  7708. * 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.
  7709. * Values less than zero provide a filter of opposite hue.
  7710. */
  7711. globalDensity: number;
  7712. /**
  7713. * Gets the global Saturation value.
  7714. * 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.
  7715. */
  7716. /**
  7717. * Sets the global Saturation value.
  7718. * 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.
  7719. */
  7720. globalSaturation: number;
  7721. private _highlightsHue;
  7722. private _highlightsDensity;
  7723. private _highlightsSaturation;
  7724. private _highlightsExposure;
  7725. /**
  7726. * Gets the highlights Hue value.
  7727. * 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).
  7728. */
  7729. /**
  7730. * Sets the highlights Hue value.
  7731. * 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).
  7732. */
  7733. highlightsHue: number;
  7734. /**
  7735. * Gets the highlights Density value.
  7736. * 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.
  7737. * Values less than zero provide a filter of opposite hue.
  7738. */
  7739. /**
  7740. * Sets the highlights Density value.
  7741. * 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.
  7742. * Values less than zero provide a filter of opposite hue.
  7743. */
  7744. highlightsDensity: number;
  7745. /**
  7746. * Gets the highlights Saturation value.
  7747. * 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.
  7748. */
  7749. /**
  7750. * Sets the highlights Saturation value.
  7751. * 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.
  7752. */
  7753. highlightsSaturation: number;
  7754. /**
  7755. * Gets the highlights Exposure value.
  7756. * 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.
  7757. */
  7758. /**
  7759. * Sets the highlights Exposure value.
  7760. * 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.
  7761. */
  7762. highlightsExposure: number;
  7763. private _midtonesHue;
  7764. private _midtonesDensity;
  7765. private _midtonesSaturation;
  7766. private _midtonesExposure;
  7767. /**
  7768. * Gets the midtones Hue value.
  7769. * 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).
  7770. */
  7771. /**
  7772. * Sets the midtones Hue value.
  7773. * 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).
  7774. */
  7775. midtonesHue: number;
  7776. /**
  7777. * Gets the midtones Density value.
  7778. * 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.
  7779. * Values less than zero provide a filter of opposite hue.
  7780. */
  7781. /**
  7782. * Sets the midtones Density value.
  7783. * 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.
  7784. * Values less than zero provide a filter of opposite hue.
  7785. */
  7786. midtonesDensity: number;
  7787. /**
  7788. * Gets the midtones Saturation value.
  7789. * 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.
  7790. */
  7791. /**
  7792. * Sets the midtones Saturation value.
  7793. * 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.
  7794. */
  7795. midtonesSaturation: number;
  7796. /**
  7797. * Gets the midtones Exposure value.
  7798. * 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.
  7799. */
  7800. /**
  7801. * Sets the midtones Exposure value.
  7802. * 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.
  7803. */
  7804. midtonesExposure: number;
  7805. private _shadowsHue;
  7806. private _shadowsDensity;
  7807. private _shadowsSaturation;
  7808. private _shadowsExposure;
  7809. /**
  7810. * Gets the shadows Hue value.
  7811. * 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).
  7812. */
  7813. /**
  7814. * Sets the shadows Hue value.
  7815. * 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).
  7816. */
  7817. shadowsHue: number;
  7818. /**
  7819. * Gets the shadows Density value.
  7820. * 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.
  7821. * Values less than zero provide a filter of opposite hue.
  7822. */
  7823. /**
  7824. * Sets the shadows Density value.
  7825. * 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.
  7826. * Values less than zero provide a filter of opposite hue.
  7827. */
  7828. shadowsDensity: number;
  7829. /**
  7830. * Gets the shadows Saturation value.
  7831. * 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.
  7832. */
  7833. /**
  7834. * Sets the shadows Saturation value.
  7835. * 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.
  7836. */
  7837. shadowsSaturation: number;
  7838. /**
  7839. * Gets the shadows Exposure value.
  7840. * 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.
  7841. */
  7842. /**
  7843. * Sets the shadows Exposure value.
  7844. * 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.
  7845. */
  7846. shadowsExposure: number;
  7847. getClassName(): string;
  7848. /**
  7849. * Binds the color curves to the shader.
  7850. * @param colorCurves The color curve to bind
  7851. * @param effect The effect to bind to
  7852. */
  7853. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7854. /**
  7855. * Prepare the list of uniforms associated with the ColorCurves effects.
  7856. * @param uniformsList The list of uniforms used in the effect
  7857. */
  7858. static PrepareUniforms(uniformsList: string[]): void;
  7859. /**
  7860. * Returns color grading data based on a hue, density, saturation and exposure value.
  7861. * @param filterHue The hue of the color filter.
  7862. * @param filterDensity The density of the color filter.
  7863. * @param saturation The saturation.
  7864. * @param exposure The exposure.
  7865. * @param result The result data container.
  7866. */
  7867. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  7868. /**
  7869. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7870. * @param value The input slider value in range [-100,100].
  7871. * @returns Adjusted value.
  7872. */
  7873. private static applyColorGradingSliderNonlinear(value);
  7874. /**
  7875. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7876. * @param hue The hue (H) input.
  7877. * @param saturation The saturation (S) input.
  7878. * @param brightness The brightness (B) input.
  7879. * @result An RGBA color represented as Vector4.
  7880. */
  7881. private static fromHSBToRef(hue, saturation, brightness, result);
  7882. /**
  7883. * Returns a value clamped between min and max
  7884. * @param value The value to clamp
  7885. * @param min The minimum of value
  7886. * @param max The maximum of value
  7887. * @returns The clamped value.
  7888. */
  7889. private static clamp(value, min, max);
  7890. /**
  7891. * Clones the current color curve instance.
  7892. * @return The cloned curves
  7893. */
  7894. clone(): ColorCurves;
  7895. /**
  7896. * Serializes the current color curve instance to a json representation.
  7897. * @return a JSON representation
  7898. */
  7899. serialize(): any;
  7900. /**
  7901. * Parses the color curve from a json representation.
  7902. * @param source the JSON source to parse
  7903. * @return The parsed curves
  7904. */
  7905. static Parse(source: any): ColorCurves;
  7906. }
  7907. }
  7908. declare module BABYLON {
  7909. /**
  7910. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  7911. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  7912. */
  7913. class EffectFallbacks {
  7914. private _defines;
  7915. private _currentRank;
  7916. private _maxRank;
  7917. private _mesh;
  7918. /**
  7919. * Removes the fallback from the bound mesh.
  7920. */
  7921. unBindMesh(): void;
  7922. /**
  7923. * Adds a fallback on the specified property.
  7924. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  7925. * @param define The name of the define in the shader
  7926. */
  7927. addFallback(rank: number, define: string): void;
  7928. /**
  7929. * Sets the mesh to use CPU skinning when needing to fallback.
  7930. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  7931. * @param mesh The mesh to use the fallbacks.
  7932. */
  7933. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  7934. /**
  7935. * Checks to see if more fallbacks are still availible.
  7936. */
  7937. readonly isMoreFallbacks: boolean;
  7938. /**
  7939. * Removes the defines that shoould be removed when falling back.
  7940. * @param currentDefines defines the current define statements for the shader.
  7941. * @param effect defines the current effect we try to compile
  7942. * @returns The resulting defines with defines of the current rank removed.
  7943. */
  7944. reduce(currentDefines: string, effect: Effect): string;
  7945. }
  7946. /**
  7947. * Options to be used when creating an effect.
  7948. */
  7949. class EffectCreationOptions {
  7950. /**
  7951. * Atrributes that will be used in the shader.
  7952. */
  7953. attributes: string[];
  7954. /**
  7955. * Uniform varible names that will be set in the shader.
  7956. */
  7957. uniformsNames: string[];
  7958. /**
  7959. * Uniform buffer varible names that will be set in the shader.
  7960. */
  7961. uniformBuffersNames: string[];
  7962. /**
  7963. * Sampler texture variable names that will be set in the shader.
  7964. */
  7965. samplers: string[];
  7966. /**
  7967. * Define statements that will be set in the shader.
  7968. */
  7969. defines: any;
  7970. /**
  7971. * Possible fallbacks for this effect to improve performance when needed.
  7972. */
  7973. fallbacks: Nullable<EffectFallbacks>;
  7974. /**
  7975. * Callback that will be called when the shader is compiled.
  7976. */
  7977. onCompiled: Nullable<(effect: Effect) => void>;
  7978. /**
  7979. * Callback that will be called if an error occurs during shader compilation.
  7980. */
  7981. onError: Nullable<(effect: Effect, errors: string) => void>;
  7982. /**
  7983. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  7984. */
  7985. indexParameters: any;
  7986. /**
  7987. * Max number of lights that can be used in the shader.
  7988. */
  7989. maxSimultaneousLights: number;
  7990. /**
  7991. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  7992. */
  7993. transformFeedbackVaryings: Nullable<string[]>;
  7994. }
  7995. /**
  7996. * Effect containing vertex and fragment shader that can be executed on an object.
  7997. */
  7998. class Effect {
  7999. /**
  8000. * Name of the effect.
  8001. */
  8002. name: any;
  8003. /**
  8004. * String container all the define statements that should be set on the shader.
  8005. */
  8006. defines: string;
  8007. /**
  8008. * Callback that will be called when the shader is compiled.
  8009. */
  8010. onCompiled: Nullable<(effect: Effect) => void>;
  8011. /**
  8012. * Callback that will be called if an error occurs during shader compilation.
  8013. */
  8014. onError: Nullable<(effect: Effect, errors: string) => void>;
  8015. /**
  8016. * Callback that will be called when effect is bound.
  8017. */
  8018. onBind: Nullable<(effect: Effect) => void>;
  8019. /**
  8020. * Unique ID of the effect.
  8021. */
  8022. uniqueId: number;
  8023. /**
  8024. * Observable that will be called when the shader is compiled.
  8025. */
  8026. onCompileObservable: Observable<Effect>;
  8027. /**
  8028. * Observable that will be called if an error occurs during shader compilation.
  8029. */
  8030. onErrorObservable: Observable<Effect>;
  8031. /**
  8032. * Observable that will be called when effect is bound.
  8033. */
  8034. onBindObservable: Observable<Effect>;
  8035. private static _uniqueIdSeed;
  8036. private _engine;
  8037. private _uniformBuffersNames;
  8038. private _uniformsNames;
  8039. private _samplers;
  8040. private _isReady;
  8041. private _compilationError;
  8042. private _attributesNames;
  8043. private _attributes;
  8044. private _uniforms;
  8045. /**
  8046. * Key for the effect.
  8047. */
  8048. _key: string;
  8049. private _indexParameters;
  8050. private _fallbacks;
  8051. private _vertexSourceCode;
  8052. private _fragmentSourceCode;
  8053. private _vertexSourceCodeOverride;
  8054. private _fragmentSourceCodeOverride;
  8055. private _transformFeedbackVaryings;
  8056. /**
  8057. * Compiled shader to webGL program.
  8058. */
  8059. _program: WebGLProgram;
  8060. private _valueCache;
  8061. private static _baseCache;
  8062. /**
  8063. * Instantiates an effect.
  8064. * An effect can be used to create/manage/execute vertex and fragment shaders.
  8065. * @param baseName Name of the effect.
  8066. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  8067. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  8068. * @param samplers List of sampler variables that will be passed to the shader.
  8069. * @param engine Engine to be used to render the effect
  8070. * @param defines Define statements to be added to the shader.
  8071. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  8072. * @param onCompiled Callback that will be called when the shader is compiled.
  8073. * @param onError Callback that will be called if an error occurs during shader compilation.
  8074. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  8075. */
  8076. 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);
  8077. /**
  8078. * Unique key for this effect
  8079. */
  8080. readonly key: string;
  8081. /**
  8082. * If the effect has been compiled and prepared.
  8083. * @returns if the effect is compiled and prepared.
  8084. */
  8085. isReady(): boolean;
  8086. /**
  8087. * The engine the effect was initialized with.
  8088. * @returns the engine.
  8089. */
  8090. getEngine(): Engine;
  8091. /**
  8092. * The compiled webGL program for the effect
  8093. * @returns the webGL program.
  8094. */
  8095. getProgram(): WebGLProgram;
  8096. /**
  8097. * The set of names of attribute variables for the shader.
  8098. * @returns An array of attribute names.
  8099. */
  8100. getAttributesNames(): string[];
  8101. /**
  8102. * Returns the attribute at the given index.
  8103. * @param index The index of the attribute.
  8104. * @returns The location of the attribute.
  8105. */
  8106. getAttributeLocation(index: number): number;
  8107. /**
  8108. * Returns the attribute based on the name of the variable.
  8109. * @param name of the attribute to look up.
  8110. * @returns the attribute location.
  8111. */
  8112. getAttributeLocationByName(name: string): number;
  8113. /**
  8114. * The number of attributes.
  8115. * @returns the numnber of attributes.
  8116. */
  8117. getAttributesCount(): number;
  8118. /**
  8119. * Gets the index of a uniform variable.
  8120. * @param uniformName of the uniform to look up.
  8121. * @returns the index.
  8122. */
  8123. getUniformIndex(uniformName: string): number;
  8124. /**
  8125. * Returns the attribute based on the name of the variable.
  8126. * @param uniformName of the uniform to look up.
  8127. * @returns the location of the uniform.
  8128. */
  8129. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  8130. /**
  8131. * Returns an array of sampler variable names
  8132. * @returns The array of sampler variable neames.
  8133. */
  8134. getSamplers(): string[];
  8135. /**
  8136. * The error from the last compilation.
  8137. * @returns the error string.
  8138. */
  8139. getCompilationError(): string;
  8140. /**
  8141. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  8142. * @param func The callback to be used.
  8143. */
  8144. executeWhenCompiled(func: (effect: Effect) => void): void;
  8145. /** @ignore */
  8146. _loadVertexShaderAsync(vertex: any): Promise<any>;
  8147. /** @ignore */
  8148. _loadFragmentShaderAsync(fragment: any): Promise<any>;
  8149. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  8150. private _processShaderConversion(sourceCode, isFragment);
  8151. private _processIncludesAsync(sourceCode);
  8152. private _processPrecision(source);
  8153. /**
  8154. * Recompiles the webGL program
  8155. * @param vertexSourceCode The source code for the vertex shader.
  8156. * @param fragmentSourceCode The source code for the fragment shader.
  8157. * @param onCompiled Callback called when completed.
  8158. * @param onError Callback called on error.
  8159. */
  8160. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  8161. /**
  8162. * Gets the uniform locations of the the specified variable names
  8163. * @param names THe names of the variables to lookup.
  8164. * @returns Array of locations in the same order as variable names.
  8165. */
  8166. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  8167. /**
  8168. * Prepares the effect
  8169. */
  8170. _prepareEffect(): void;
  8171. /**
  8172. * Checks if the effect is supported. (Must be called after compilation)
  8173. */
  8174. readonly isSupported: boolean;
  8175. /**
  8176. * Binds a texture to the engine to be used as output of the shader.
  8177. * @param channel Name of the output variable.
  8178. * @param texture Texture to bind.
  8179. */
  8180. _bindTexture(channel: string, texture: InternalTexture): void;
  8181. /**
  8182. * Sets a texture on the engine to be used in the shader.
  8183. * @param channel Name of the sampler variable.
  8184. * @param texture Texture to set.
  8185. */
  8186. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  8187. /**
  8188. * Sets an array of textures on the engine to be used in the shader.
  8189. * @param channel Name of the variable.
  8190. * @param textures Textures to set.
  8191. */
  8192. setTextureArray(channel: string, textures: BaseTexture[]): void;
  8193. /**
  8194. * 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)
  8195. * @param channel Name of the sampler variable.
  8196. * @param postProcess Post process to get the input texture from.
  8197. */
  8198. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  8199. /** @ignore */
  8200. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  8201. /** @ignore */
  8202. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8203. /** @ignore */
  8204. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8205. /** @ignore */
  8206. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8207. /**
  8208. * Binds a buffer to a uniform.
  8209. * @param buffer Buffer to bind.
  8210. * @param name Name of the uniform variable to bind to.
  8211. */
  8212. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  8213. /**
  8214. * Binds block to a uniform.
  8215. * @param blockName Name of the block to bind.
  8216. * @param index Index to bind.
  8217. */
  8218. bindUniformBlock(blockName: string, index: number): void;
  8219. /**
  8220. * Sets an interger value on a uniform variable.
  8221. * @param uniformName Name of the variable.
  8222. * @param value Value to be set.
  8223. * @returns this effect.
  8224. */
  8225. setInt(uniformName: string, value: number): Effect;
  8226. /**
  8227. * Sets an int array on a uniform variable.
  8228. * @param uniformName Name of the variable.
  8229. * @param array array to be set.
  8230. * @returns this effect.
  8231. */
  8232. setIntArray(uniformName: string, array: Int32Array): Effect;
  8233. /**
  8234. * 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)
  8235. * @param uniformName Name of the variable.
  8236. * @param array array to be set.
  8237. * @returns this effect.
  8238. */
  8239. setIntArray2(uniformName: string, array: Int32Array): Effect;
  8240. /**
  8241. * 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)
  8242. * @param uniformName Name of the variable.
  8243. * @param array array to be set.
  8244. * @returns this effect.
  8245. */
  8246. setIntArray3(uniformName: string, array: Int32Array): Effect;
  8247. /**
  8248. * 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)
  8249. * @param uniformName Name of the variable.
  8250. * @param array array to be set.
  8251. * @returns this effect.
  8252. */
  8253. setIntArray4(uniformName: string, array: Int32Array): Effect;
  8254. /**
  8255. * Sets an float array on a uniform variable.
  8256. * @param uniformName Name of the variable.
  8257. * @param array array to be set.
  8258. * @returns this effect.
  8259. */
  8260. setFloatArray(uniformName: string, array: Float32Array): Effect;
  8261. /**
  8262. * 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)
  8263. * @param uniformName Name of the variable.
  8264. * @param array array to be set.
  8265. * @returns this effect.
  8266. */
  8267. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  8268. /**
  8269. * 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)
  8270. * @param uniformName Name of the variable.
  8271. * @param array array to be set.
  8272. * @returns this effect.
  8273. */
  8274. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  8275. /**
  8276. * 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)
  8277. * @param uniformName Name of the variable.
  8278. * @param array array to be set.
  8279. * @returns this effect.
  8280. */
  8281. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  8282. /**
  8283. * Sets an array on a uniform variable.
  8284. * @param uniformName Name of the variable.
  8285. * @param array array to be set.
  8286. * @returns this effect.
  8287. */
  8288. setArray(uniformName: string, array: number[]): Effect;
  8289. /**
  8290. * 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)
  8291. * @param uniformName Name of the variable.
  8292. * @param array array to be set.
  8293. * @returns this effect.
  8294. */
  8295. setArray2(uniformName: string, array: number[]): Effect;
  8296. /**
  8297. * 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)
  8298. * @param uniformName Name of the variable.
  8299. * @param array array to be set.
  8300. * @returns this effect.
  8301. */
  8302. setArray3(uniformName: string, array: number[]): Effect;
  8303. /**
  8304. * 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)
  8305. * @param uniformName Name of the variable.
  8306. * @param array array to be set.
  8307. * @returns this effect.
  8308. */
  8309. setArray4(uniformName: string, array: number[]): Effect;
  8310. /**
  8311. * Sets matrices on a uniform variable.
  8312. * @param uniformName Name of the variable.
  8313. * @param matrices matrices to be set.
  8314. * @returns this effect.
  8315. */
  8316. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  8317. /**
  8318. * Sets matrix on a uniform variable.
  8319. * @param uniformName Name of the variable.
  8320. * @param matrix matrix to be set.
  8321. * @returns this effect.
  8322. */
  8323. setMatrix(uniformName: string, matrix: Matrix): Effect;
  8324. /**
  8325. * 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)
  8326. * @param uniformName Name of the variable.
  8327. * @param matrix matrix to be set.
  8328. * @returns this effect.
  8329. */
  8330. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  8331. /**
  8332. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8333. * @param uniformName Name of the variable.
  8334. * @param matrix matrix to be set.
  8335. * @returns this effect.
  8336. */
  8337. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  8338. /**
  8339. * Sets a float on a uniform variable.
  8340. * @param uniformName Name of the variable.
  8341. * @param value value to be set.
  8342. * @returns this effect.
  8343. */
  8344. setFloat(uniformName: string, value: number): Effect;
  8345. /**
  8346. * Sets a boolean on a uniform variable.
  8347. * @param uniformName Name of the variable.
  8348. * @param bool value to be set.
  8349. * @returns this effect.
  8350. */
  8351. setBool(uniformName: string, bool: boolean): Effect;
  8352. /**
  8353. * Sets a Vector2 on a uniform variable.
  8354. * @param uniformName Name of the variable.
  8355. * @param vector2 vector2 to be set.
  8356. * @returns this effect.
  8357. */
  8358. setVector2(uniformName: string, vector2: Vector2): Effect;
  8359. /**
  8360. * Sets a float2 on a uniform variable.
  8361. * @param uniformName Name of the variable.
  8362. * @param x First float in float2.
  8363. * @param y Second float in float2.
  8364. * @returns this effect.
  8365. */
  8366. setFloat2(uniformName: string, x: number, y: number): Effect;
  8367. /**
  8368. * Sets a Vector3 on a uniform variable.
  8369. * @param uniformName Name of the variable.
  8370. * @param vector3 Value to be set.
  8371. * @returns this effect.
  8372. */
  8373. setVector3(uniformName: string, vector3: Vector3): Effect;
  8374. /**
  8375. * Sets a float3 on a uniform variable.
  8376. * @param uniformName Name of the variable.
  8377. * @param x First float in float3.
  8378. * @param y Second float in float3.
  8379. * @param z Third float in float3.
  8380. * @returns this effect.
  8381. */
  8382. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  8383. /**
  8384. * Sets a Vector4 on a uniform variable.
  8385. * @param uniformName Name of the variable.
  8386. * @param vector4 Value to be set.
  8387. * @returns this effect.
  8388. */
  8389. setVector4(uniformName: string, vector4: Vector4): Effect;
  8390. /**
  8391. * Sets a float4 on a uniform variable.
  8392. * @param uniformName Name of the variable.
  8393. * @param x First float in float4.
  8394. * @param y Second float in float4.
  8395. * @param z Third float in float4.
  8396. * @param w Fourth float in float4.
  8397. * @returns this effect.
  8398. */
  8399. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  8400. /**
  8401. * Sets a Color3 on a uniform variable.
  8402. * @param uniformName Name of the variable.
  8403. * @param color3 Value to be set.
  8404. * @returns this effect.
  8405. */
  8406. setColor3(uniformName: string, color3: Color3): Effect;
  8407. /**
  8408. * Sets a Color4 on a uniform variable.
  8409. * @param uniformName Name of the variable.
  8410. * @param color3 Value to be set.
  8411. * @param alpha Alpha value to be set.
  8412. * @returns this effect.
  8413. */
  8414. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  8415. /**
  8416. * Store of each shader (The can be looked up using effect.key)
  8417. */
  8418. static ShadersStore: {
  8419. [key: string]: string;
  8420. };
  8421. /**
  8422. * Store of each included file for a shader (The can be looked up using effect.key)
  8423. */
  8424. static IncludesShadersStore: {
  8425. [key: string]: string;
  8426. };
  8427. /**
  8428. * Resets the cache of effects.
  8429. */
  8430. static ResetCache(): void;
  8431. }
  8432. }
  8433. declare module BABYLON {
  8434. class FresnelParameters {
  8435. private _isEnabled;
  8436. isEnabled: boolean;
  8437. leftColor: Color3;
  8438. rightColor: Color3;
  8439. bias: number;
  8440. power: number;
  8441. clone(): FresnelParameters;
  8442. serialize(): any;
  8443. static Parse(parsedFresnelParameters: any): FresnelParameters;
  8444. }
  8445. }
  8446. declare module BABYLON {
  8447. /**
  8448. * Interface to follow in your material defines to integrate easily the
  8449. * Image proccessing functions.
  8450. */
  8451. interface IImageProcessingConfigurationDefines {
  8452. IMAGEPROCESSING: boolean;
  8453. VIGNETTE: boolean;
  8454. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8455. VIGNETTEBLENDMODEOPAQUE: boolean;
  8456. TONEMAPPING: boolean;
  8457. CONTRAST: boolean;
  8458. EXPOSURE: boolean;
  8459. COLORCURVES: boolean;
  8460. COLORGRADING: boolean;
  8461. COLORGRADING3D: boolean;
  8462. SAMPLER3DGREENDEPTH: boolean;
  8463. SAMPLER3DBGRMAP: boolean;
  8464. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8465. }
  8466. /**
  8467. * This groups together the common properties used for image processing either in direct forward pass
  8468. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8469. * or not.
  8470. */
  8471. class ImageProcessingConfiguration {
  8472. /**
  8473. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8474. */
  8475. colorCurves: Nullable<ColorCurves>;
  8476. private _colorCurvesEnabled;
  8477. /**
  8478. * Gets wether the color curves effect is enabled.
  8479. */
  8480. /**
  8481. * Sets wether the color curves effect is enabled.
  8482. */
  8483. colorCurvesEnabled: boolean;
  8484. /**
  8485. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8486. */
  8487. colorGradingTexture: Nullable<BaseTexture>;
  8488. private _colorGradingEnabled;
  8489. /**
  8490. * Gets wether the color grading effect is enabled.
  8491. */
  8492. /**
  8493. * Sets wether the color grading effect is enabled.
  8494. */
  8495. colorGradingEnabled: boolean;
  8496. private _colorGradingWithGreenDepth;
  8497. /**
  8498. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8499. */
  8500. /**
  8501. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8502. */
  8503. colorGradingWithGreenDepth: boolean;
  8504. private _colorGradingBGR;
  8505. /**
  8506. * Gets wether the color grading texture contains BGR values.
  8507. */
  8508. /**
  8509. * Sets wether the color grading texture contains BGR values.
  8510. */
  8511. colorGradingBGR: boolean;
  8512. _exposure: number;
  8513. /**
  8514. * Gets the Exposure used in the effect.
  8515. */
  8516. /**
  8517. * Sets the Exposure used in the effect.
  8518. */
  8519. exposure: number;
  8520. private _toneMappingEnabled;
  8521. /**
  8522. * Gets wether the tone mapping effect is enabled.
  8523. */
  8524. /**
  8525. * Sets wether the tone mapping effect is enabled.
  8526. */
  8527. toneMappingEnabled: boolean;
  8528. protected _contrast: number;
  8529. /**
  8530. * Gets the contrast used in the effect.
  8531. */
  8532. /**
  8533. * Sets the contrast used in the effect.
  8534. */
  8535. contrast: number;
  8536. /**
  8537. * Vignette stretch size.
  8538. */
  8539. vignetteStretch: number;
  8540. /**
  8541. * Vignette centre X Offset.
  8542. */
  8543. vignetteCentreX: number;
  8544. /**
  8545. * Vignette centre Y Offset.
  8546. */
  8547. vignetteCentreY: number;
  8548. /**
  8549. * Vignette weight or intensity of the vignette effect.
  8550. */
  8551. vignetteWeight: number;
  8552. /**
  8553. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8554. * if vignetteEnabled is set to true.
  8555. */
  8556. vignetteColor: Color4;
  8557. /**
  8558. * Camera field of view used by the Vignette effect.
  8559. */
  8560. vignetteCameraFov: number;
  8561. private _vignetteBlendMode;
  8562. /**
  8563. * Gets the vignette blend mode allowing different kind of effect.
  8564. */
  8565. /**
  8566. * Sets the vignette blend mode allowing different kind of effect.
  8567. */
  8568. vignetteBlendMode: number;
  8569. private _vignetteEnabled;
  8570. /**
  8571. * Gets wether the vignette effect is enabled.
  8572. */
  8573. /**
  8574. * Sets wether the vignette effect is enabled.
  8575. */
  8576. vignetteEnabled: boolean;
  8577. private _applyByPostProcess;
  8578. /**
  8579. * Gets wether the image processing is applied through a post process or not.
  8580. */
  8581. /**
  8582. * Sets wether the image processing is applied through a post process or not.
  8583. */
  8584. applyByPostProcess: boolean;
  8585. private _isEnabled;
  8586. /**
  8587. * Gets wether the image processing is enabled or not.
  8588. */
  8589. /**
  8590. * Sets wether the image processing is enabled or not.
  8591. */
  8592. isEnabled: boolean;
  8593. /**
  8594. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8595. * @type {BABYLON.Observable}
  8596. */
  8597. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8598. /**
  8599. * Method called each time the image processing information changes requires to recompile the effect.
  8600. */
  8601. protected _updateParameters(): void;
  8602. getClassName(): string;
  8603. /**
  8604. * Prepare the list of uniforms associated with the Image Processing effects.
  8605. * @param uniformsList The list of uniforms used in the effect
  8606. * @param defines the list of defines currently in use
  8607. */
  8608. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8609. /**
  8610. * Prepare the list of samplers associated with the Image Processing effects.
  8611. * @param uniformsList The list of uniforms used in the effect
  8612. * @param defines the list of defines currently in use
  8613. */
  8614. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8615. /**
  8616. * Prepare the list of defines associated to the shader.
  8617. * @param defines the list of defines to complete
  8618. */
  8619. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8620. /**
  8621. * Returns true if all the image processing information are ready.
  8622. */
  8623. isReady(): boolean;
  8624. /**
  8625. * Binds the image processing to the shader.
  8626. * @param effect The effect to bind to
  8627. */
  8628. bind(effect: Effect, aspectRatio?: number): void;
  8629. /**
  8630. * Clones the current image processing instance.
  8631. * @return The cloned image processing
  8632. */
  8633. clone(): ImageProcessingConfiguration;
  8634. /**
  8635. * Serializes the current image processing instance to a json representation.
  8636. * @return a JSON representation
  8637. */
  8638. serialize(): any;
  8639. /**
  8640. * Parses the image processing from a json representation.
  8641. * @param source the JSON source to parse
  8642. * @return The parsed image processing
  8643. */
  8644. static Parse(source: any): ImageProcessingConfiguration;
  8645. private static _VIGNETTEMODE_MULTIPLY;
  8646. private static _VIGNETTEMODE_OPAQUE;
  8647. /**
  8648. * Used to apply the vignette as a mix with the pixel color.
  8649. */
  8650. static readonly VIGNETTEMODE_MULTIPLY: number;
  8651. /**
  8652. * Used to apply the vignette as a replacement of the pixel color.
  8653. */
  8654. static readonly VIGNETTEMODE_OPAQUE: number;
  8655. }
  8656. }
  8657. declare module BABYLON {
  8658. /**
  8659. * Manages the defines for the Material.
  8660. */
  8661. class MaterialDefines {
  8662. private _keys;
  8663. private _isDirty;
  8664. _renderId: number;
  8665. _areLightsDirty: boolean;
  8666. _areAttributesDirty: boolean;
  8667. _areTexturesDirty: boolean;
  8668. _areFresnelDirty: boolean;
  8669. _areMiscDirty: boolean;
  8670. _areImageProcessingDirty: boolean;
  8671. _normals: boolean;
  8672. _uvs: boolean;
  8673. _needNormals: boolean;
  8674. _needUVs: boolean;
  8675. /**
  8676. * Specifies if the material needs to be re-calculated.
  8677. */
  8678. readonly isDirty: boolean;
  8679. /**
  8680. * Marks the material to indicate that it has been re-calculated.
  8681. */
  8682. markAsProcessed(): void;
  8683. /**
  8684. * Marks the material to indicate that it needs to be re-calculated.
  8685. */
  8686. markAsUnprocessed(): void;
  8687. /**
  8688. * Marks the material to indicate all of its defines need to be re-calculated.
  8689. */
  8690. markAllAsDirty(): void;
  8691. /**
  8692. * Marks the material to indicate that image processing needs to be re-calculated.
  8693. */
  8694. markAsImageProcessingDirty(): void;
  8695. /**
  8696. * Marks the material to indicate the lights need to be re-calculated.
  8697. */
  8698. markAsLightDirty(): void;
  8699. /**
  8700. * Marks the attribute state as changed.
  8701. */
  8702. markAsAttributesDirty(): void;
  8703. /**
  8704. * Marks the texture state as changed.
  8705. */
  8706. markAsTexturesDirty(): void;
  8707. /**
  8708. * Marks the fresnel state as changed.
  8709. */
  8710. markAsFresnelDirty(): void;
  8711. /**
  8712. * Marks the misc state as changed.
  8713. */
  8714. markAsMiscDirty(): void;
  8715. /**
  8716. * Rebuilds the material defines.
  8717. */
  8718. rebuild(): void;
  8719. /**
  8720. * Specifies if two material defines are equal.
  8721. * @param other - A material define instance to compare to.
  8722. * @returns - Boolean indicating if the material defines are equal (true) or not (false).
  8723. */
  8724. isEqual(other: MaterialDefines): boolean;
  8725. /**
  8726. * Clones this instance's defines to another instance.
  8727. * @param other - material defines to clone values to.
  8728. */
  8729. cloneTo(other: MaterialDefines): void;
  8730. /**
  8731. * Resets the material define values.
  8732. */
  8733. reset(): void;
  8734. /**
  8735. * Converts the material define values to a string.
  8736. * @returns - String of material define information.
  8737. */
  8738. toString(): string;
  8739. }
  8740. /**
  8741. * This offers the main features of a material in BJS.
  8742. */
  8743. class Material implements IAnimatable {
  8744. private static _TriangleFillMode;
  8745. private static _WireFrameFillMode;
  8746. private static _PointFillMode;
  8747. private static _PointListDrawMode;
  8748. private static _LineListDrawMode;
  8749. private static _LineLoopDrawMode;
  8750. private static _LineStripDrawMode;
  8751. private static _TriangleStripDrawMode;
  8752. private static _TriangleFanDrawMode;
  8753. /**
  8754. * Returns the triangle fill mode.
  8755. */
  8756. static readonly TriangleFillMode: number;
  8757. /**
  8758. * Returns the wireframe mode.
  8759. */
  8760. static readonly WireFrameFillMode: number;
  8761. /**
  8762. * Returns the point fill mode.
  8763. */
  8764. static readonly PointFillMode: number;
  8765. /**
  8766. * Returns the point list draw mode.
  8767. */
  8768. static readonly PointListDrawMode: number;
  8769. /**
  8770. * Returns the line list draw mode.
  8771. */
  8772. static readonly LineListDrawMode: number;
  8773. /**
  8774. * Returns the line loop draw mode.
  8775. */
  8776. static readonly LineLoopDrawMode: number;
  8777. /**
  8778. * Returns the line strip draw mode.
  8779. */
  8780. static readonly LineStripDrawMode: number;
  8781. /**
  8782. * Returns the triangle strip draw mode.
  8783. */
  8784. static readonly TriangleStripDrawMode: number;
  8785. /**
  8786. * Returns the triangle fan draw mode.
  8787. */
  8788. static readonly TriangleFanDrawMode: number;
  8789. /**
  8790. * Stores the clock-wise side orientation.
  8791. */
  8792. private static _ClockWiseSideOrientation;
  8793. /**
  8794. * Stores the counter clock-wise side orientation.
  8795. */
  8796. private static _CounterClockWiseSideOrientation;
  8797. /**
  8798. * Returns the clock-wise side orientation.
  8799. */
  8800. static readonly ClockWiseSideOrientation: number;
  8801. /**
  8802. * Returns the counter clock-wise side orientation.
  8803. */
  8804. static readonly CounterClockWiseSideOrientation: number;
  8805. /**
  8806. * The dirty texture flag value.
  8807. */
  8808. private static _TextureDirtyFlag;
  8809. /**
  8810. * The dirty light flag value.
  8811. */
  8812. private static _LightDirtyFlag;
  8813. /**
  8814. * The dirty fresnel flag value.
  8815. */
  8816. private static _FresnelDirtyFlag;
  8817. /**
  8818. * The dirty attribute flag value.
  8819. */
  8820. private static _AttributesDirtyFlag;
  8821. /**
  8822. * The dirty misc flag value.
  8823. */
  8824. private static _MiscDirtyFlag;
  8825. /**
  8826. * Returns the dirty texture flag value.
  8827. */
  8828. static readonly TextureDirtyFlag: number;
  8829. /**
  8830. * Returns the dirty light flag value.
  8831. */
  8832. static readonly LightDirtyFlag: number;
  8833. /**
  8834. * Returns the dirty fresnel flag value.
  8835. */
  8836. static readonly FresnelDirtyFlag: number;
  8837. /**
  8838. * Returns the dirty attributes flag value.
  8839. */
  8840. static readonly AttributesDirtyFlag: number;
  8841. /**
  8842. * Returns the dirty misc flag value.
  8843. */
  8844. static readonly MiscDirtyFlag: number;
  8845. /**
  8846. * The ID of the material.
  8847. */
  8848. id: string;
  8849. /**
  8850. * The name of the material.
  8851. */
  8852. name: string;
  8853. /**
  8854. * Specifies if the ready state should be checked on each call.
  8855. */
  8856. checkReadyOnEveryCall: boolean;
  8857. /**
  8858. * Specifies if the ready state should be checked once.
  8859. */
  8860. checkReadyOnlyOnce: boolean;
  8861. /**
  8862. * The state of the material.
  8863. */
  8864. state: string;
  8865. /**
  8866. * The alpha value of the material.
  8867. */
  8868. protected _alpha: number;
  8869. /**
  8870. * Gets the alpha value of the material.
  8871. */
  8872. /**
  8873. * Sets the alpha value of the material.
  8874. */
  8875. alpha: number;
  8876. /**
  8877. * Specifies if back face culling is enabled.
  8878. */
  8879. protected _backFaceCulling: boolean;
  8880. /**
  8881. * Gets the back-face culling state.
  8882. */
  8883. /**
  8884. * Sets the back-face culling state.
  8885. */
  8886. backFaceCulling: boolean;
  8887. /**
  8888. * Stores the value for side orientation.
  8889. */
  8890. sideOrientation: number;
  8891. /**
  8892. * Callback triggered when the material is compiled.
  8893. */
  8894. onCompiled: (effect: Effect) => void;
  8895. /**
  8896. * Callback triggered when an error occurs.
  8897. */
  8898. onError: (effect: Effect, errors: string) => void;
  8899. /**
  8900. * Callback triggered to get the render target textures.
  8901. */
  8902. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  8903. /**
  8904. * Specifies if the material should be serialized.
  8905. */
  8906. doNotSerialize: boolean;
  8907. /**
  8908. * Specifies if the effect should be stored on sub meshes.
  8909. */
  8910. storeEffectOnSubMeshes: boolean;
  8911. /**
  8912. * Stores the animations for the material.
  8913. */
  8914. animations: Array<Animation>;
  8915. /**
  8916. * An event triggered when the material is disposed.
  8917. * @type {BABYLON.Observable}
  8918. */
  8919. onDisposeObservable: Observable<Material>;
  8920. /**
  8921. * An observer which watches for dispose events.
  8922. * @type {BABYLON.Observer}
  8923. */
  8924. private _onDisposeObserver;
  8925. /**
  8926. * Called during a dispose event.
  8927. */
  8928. onDispose: () => void;
  8929. /**
  8930. * An event triggered when the material is bound.
  8931. * @type {BABYLON.Observable}
  8932. */
  8933. onBindObservable: Observable<AbstractMesh>;
  8934. /**
  8935. * An observer which watches for bind events.
  8936. * @type {BABYLON.Observer}
  8937. */
  8938. private _onBindObserver;
  8939. /**
  8940. * Called during a bind event.
  8941. */
  8942. onBind: (Mesh: AbstractMesh) => void;
  8943. /**
  8944. * An event triggered when the material is unbound.
  8945. * @type {BABYLON.Observable}
  8946. */
  8947. onUnBindObservable: Observable<Material>;
  8948. /**
  8949. * Stores the value of the alpha mode.
  8950. */
  8951. private _alphaMode;
  8952. /**
  8953. * Gets the value of the alpha mode.
  8954. */
  8955. /**
  8956. * Sets the value of the alpha mode.
  8957. */
  8958. alphaMode: number;
  8959. /**
  8960. * Stores the state of the need depth pre-pass value.
  8961. */
  8962. private _needDepthPrePass;
  8963. /**
  8964. * Gets the depth pre-pass value.
  8965. */
  8966. /**
  8967. * Sets the need depth pre-pass value.
  8968. */
  8969. needDepthPrePass: boolean;
  8970. /**
  8971. * Specifies if depth writing should be disabled.
  8972. */
  8973. disableDepthWrite: boolean;
  8974. /**
  8975. * Specifies if depth writing should be forced.
  8976. */
  8977. forceDepthWrite: boolean;
  8978. /**
  8979. * Specifies if there should be a separate pass for culling.
  8980. */
  8981. separateCullingPass: boolean;
  8982. /**
  8983. * Stores the state specifing if fog should be enabled.
  8984. */
  8985. private _fogEnabled;
  8986. /**
  8987. * Gets the value of the fog enabled state.
  8988. */
  8989. /**
  8990. * Sets the state for enabling fog.
  8991. */
  8992. fogEnabled: boolean;
  8993. /**
  8994. * Stores the size of points.
  8995. */
  8996. pointSize: number;
  8997. /**
  8998. * Stores the z offset value.
  8999. */
  9000. zOffset: number;
  9001. /**
  9002. * Gets a value specifying if wireframe mode is enabled.
  9003. */
  9004. /**
  9005. * Sets the state of wireframe mode.
  9006. */
  9007. wireframe: boolean;
  9008. /**
  9009. * Gets the value specifying if point clouds are enabled.
  9010. */
  9011. /**
  9012. * Sets the state of point cloud mode.
  9013. */
  9014. pointsCloud: boolean;
  9015. /**
  9016. * Gets the material fill mode.
  9017. */
  9018. /**
  9019. * Sets the material fill mode.
  9020. */
  9021. fillMode: number;
  9022. /**
  9023. * Stores the effects for the material.
  9024. */
  9025. _effect: Nullable<Effect>;
  9026. /**
  9027. * Specifies if the material was previously ready.
  9028. */
  9029. _wasPreviouslyReady: boolean;
  9030. /**
  9031. * Specifies if uniform buffers should be used.
  9032. */
  9033. private _useUBO;
  9034. /**
  9035. * Stores a reference to the scene.
  9036. */
  9037. private _scene;
  9038. /**
  9039. * Stores the fill mode state.
  9040. */
  9041. private _fillMode;
  9042. /**
  9043. * Specifies if the depth write state should be cached.
  9044. */
  9045. private _cachedDepthWriteState;
  9046. /**
  9047. * Stores the uniform buffer.
  9048. */
  9049. protected _uniformBuffer: UniformBuffer;
  9050. /**
  9051. * Creates a material instance.
  9052. * @param name - The name of the material.
  9053. * @param scene - The BJS scene to reference.
  9054. * @param doNotAdd - Specifies if the material should be added to the scene.
  9055. */
  9056. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  9057. /**
  9058. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  9059. * subclasses should override adding information pertainent to themselves.
  9060. * @returns - String with material information.
  9061. */
  9062. toString(fullDetails?: boolean): string;
  9063. /**
  9064. * Gets the class name of the material.
  9065. * @returns - String with the class name of the material.
  9066. */
  9067. getClassName(): string;
  9068. /**
  9069. * Specifies if updates for the material been locked.
  9070. */
  9071. readonly isFrozen: boolean;
  9072. /**
  9073. * Locks updates for the material.
  9074. */
  9075. freeze(): void;
  9076. /**
  9077. * Unlocks updates for the material.
  9078. */
  9079. unfreeze(): void;
  9080. /**
  9081. * Specifies if the material is ready to be used.
  9082. * @param mesh - BJS mesh.
  9083. * @param useInstances - Specifies if instances should be used.
  9084. * @returns - Boolean indicating if the material is ready to be used.
  9085. */
  9086. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  9087. /**
  9088. * Specifies that the submesh is ready to be used.
  9089. * @param mesh - BJS mesh.
  9090. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  9091. * @param useInstances - Specifies that instances should be used.
  9092. * @returns - boolean indicating that the submesh is ready or not.
  9093. */
  9094. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  9095. /**
  9096. * Returns the material effect.
  9097. * @returns - Nullable material effect.
  9098. */
  9099. getEffect(): Nullable<Effect>;
  9100. /**
  9101. * Returns the BJS scene.
  9102. * @returns - BJS Scene.
  9103. */
  9104. getScene(): Scene;
  9105. /**
  9106. * Specifies if the material will require alpha blending
  9107. * @returns - Boolean specifying if alpha blending is needed.
  9108. */
  9109. needAlphaBlending(): boolean;
  9110. /**
  9111. * Specifies if the mesh will require alpha blending.
  9112. * @param mesh - BJS mesh.
  9113. * @returns - Boolean specifying if alpha blending is needed for the mesh.
  9114. */
  9115. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  9116. /**
  9117. * Specifies if this material should be rendered in alpha test mode.
  9118. * @returns - Boolean specifying if an alpha test is needed.
  9119. */
  9120. needAlphaTesting(): boolean;
  9121. /**
  9122. * Gets the texture used for the alpha test.
  9123. * @returns - Nullable alpha test texture.
  9124. */
  9125. getAlphaTestTexture(): Nullable<BaseTexture>;
  9126. /**
  9127. * Marks the material to indicate that it needs to be re-calculated.
  9128. */
  9129. markDirty(): void;
  9130. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  9131. /**
  9132. * Binds the material to the mesh.
  9133. * @param world - World transformation matrix.
  9134. * @param mesh - Mesh to bind the material to.
  9135. */
  9136. bind(world: Matrix, mesh?: Mesh): void;
  9137. /**
  9138. * Binds the submesh to the material.
  9139. * @param world - World transformation matrix.
  9140. * @param mesh - Mesh containing the submesh.
  9141. * @param subMesh - Submesh to bind the material to.
  9142. */
  9143. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  9144. /**
  9145. * Binds the world matrix to the material.
  9146. * @param world - World transformation matrix.
  9147. */
  9148. bindOnlyWorldMatrix(world: Matrix): void;
  9149. /**
  9150. * Binds the scene's uniform buffer to the effect.
  9151. * @param effect - Effect to bind to the scene uniform buffer.
  9152. * @param sceneUbo - Scene uniform buffer.
  9153. */
  9154. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  9155. /**
  9156. * Binds the view matrix to the effect.
  9157. * @param effect - Effect to bind the view matrix to.
  9158. */
  9159. bindView(effect: Effect): void;
  9160. /**
  9161. * Binds the view projection matrix to the effect.
  9162. * @param effect - Effect to bind the view projection matrix to.
  9163. */
  9164. bindViewProjection(effect: Effect): void;
  9165. /**
  9166. * Specifies if material alpha testing should be turned on for the mesh.
  9167. * @param mesh - BJS mesh.
  9168. */
  9169. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  9170. /**
  9171. * Processes to execute after binding the material to a mesh.
  9172. * @param mesh - BJS mesh.
  9173. */
  9174. protected _afterBind(mesh?: Mesh): void;
  9175. /**
  9176. * Unbinds the material from the mesh.
  9177. */
  9178. unbind(): void;
  9179. /**
  9180. * Gets the active textures from the material.
  9181. * @returns - Array of textures.
  9182. */
  9183. getActiveTextures(): BaseTexture[];
  9184. /**
  9185. * Specifies if the material uses a texture.
  9186. * @param texture - Texture to check against the material.
  9187. * @returns - Boolean specifying if the material uses the texture.
  9188. */
  9189. hasTexture(texture: BaseTexture): boolean;
  9190. /**
  9191. * Makes a duplicate of the material, and gives it a new name.
  9192. * @param name - Name to call the duplicated material.
  9193. * @returns - Nullable cloned material
  9194. */
  9195. clone(name: string): Nullable<Material>;
  9196. /**
  9197. * Gets the meshes bound to the material.
  9198. * @returns - Array of meshes bound to the material.
  9199. */
  9200. getBindedMeshes(): AbstractMesh[];
  9201. /**
  9202. * Force shader compilation
  9203. * @param mesh - BJS mesh.
  9204. * @param onCompiled - function to execute once the material is compiled.
  9205. * @param options - options to pass to this function.
  9206. */
  9207. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  9208. clipPlane: boolean;
  9209. }>): void;
  9210. /**
  9211. * Force shader compilation.
  9212. * @param mesh The mesh that will use this material
  9213. * @param options Additional options for compiling the shaders
  9214. * @returns A promise that resolves when the compilation completes
  9215. */
  9216. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  9217. clipPlane: boolean;
  9218. }>): Promise<void>;
  9219. /**
  9220. * Marks a define in the material to indicate that it needs to be re-computed.
  9221. * @param flag - Material define flag.
  9222. */
  9223. markAsDirty(flag: number): void;
  9224. /**
  9225. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated.
  9226. * @param func - function which checks material defines against the submeshes.
  9227. */
  9228. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  9229. /**
  9230. * Indicates that image processing needs to be re-calculated for all submeshes.
  9231. */
  9232. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  9233. /**
  9234. * Indicates that textures need to be re-calculated for all submeshes.
  9235. */
  9236. protected _markAllSubMeshesAsTexturesDirty(): void;
  9237. /**
  9238. * Indicates that fresnel needs to be re-calculated for all submeshes.
  9239. */
  9240. protected _markAllSubMeshesAsFresnelDirty(): void;
  9241. /**
  9242. * Indicates that fresnel and misc need to be re-calculated for all submeshes.
  9243. */
  9244. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  9245. /**
  9246. * Indicates that lights need to be re-calculated for all submeshes.
  9247. */
  9248. protected _markAllSubMeshesAsLightsDirty(): void;
  9249. /**
  9250. * Indicates that attributes need to be re-calculated for all submeshes.
  9251. */
  9252. protected _markAllSubMeshesAsAttributesDirty(): void;
  9253. /**
  9254. * Indicates that misc needs to be re-calculated for all submeshes.
  9255. */
  9256. protected _markAllSubMeshesAsMiscDirty(): void;
  9257. /**
  9258. * Indicates that textures and misc need to be re-calculated for all submeshes.
  9259. */
  9260. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  9261. /**
  9262. * Disposes the material.
  9263. * @param forceDisposeEffect - Specifies if effects should be force disposed.
  9264. * @param forceDisposeTextures - Specifies if textures should be force disposed.
  9265. */
  9266. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  9267. /**
  9268. * Serializes this material.
  9269. * @returns - serialized material object.
  9270. */
  9271. serialize(): any;
  9272. /**
  9273. * Creates a MultiMaterial from parse MultiMaterial data.
  9274. * @param parsedMultiMaterial - Parsed MultiMaterial data.
  9275. * @param scene - BJS scene.
  9276. * @returns - MultiMaterial.
  9277. */
  9278. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  9279. /**
  9280. * Creates a material from parsed material data.
  9281. * @param parsedMaterial - Parsed material data.
  9282. * @param scene - BJS scene.
  9283. * @param rootUrl - Root URL containing the material information.
  9284. * @returns - Parsed material.
  9285. */
  9286. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  9287. }
  9288. }
  9289. declare module BABYLON {
  9290. /**
  9291. * "Static Class" containing the most commonly used helper while dealing with material for
  9292. * rendering purpose.
  9293. *
  9294. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9295. *
  9296. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9297. */
  9298. class MaterialHelper {
  9299. /**
  9300. * Bind the current view position to an effect.
  9301. * @param effect The effect to be bound
  9302. * @param scene The scene the eyes position is used from
  9303. */
  9304. static BindEyePosition(effect: Effect, scene: Scene): void;
  9305. /**
  9306. * Helps preparing the defines values about the UVs in used in the effect.
  9307. * UVs are shared as much as we can accross chanels in the shaders.
  9308. * @param texture The texture we are preparing the UVs for
  9309. * @param defines The defines to update
  9310. * @param key The chanel key "diffuse", "specular"... used in the shader
  9311. */
  9312. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9313. /**
  9314. * Binds a texture matrix value to its corrsponding uniform
  9315. * @param texture The texture to bind the matrix for
  9316. * @param uniformBuffer The uniform buffer receivin the data
  9317. * @param key The chanel key "diffuse", "specular"... used in the shader
  9318. */
  9319. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9320. /**
  9321. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9322. * @param mesh defines the current mesh
  9323. * @param scene defines the current scene
  9324. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9325. * @param pointsCloud defines if point cloud rendering has to be turned on
  9326. * @param fogEnabled defines if fog has to be turned on
  9327. * @param alphaTest defines if alpha testing has to be turned on
  9328. * @param defines defines the current list of defines
  9329. */
  9330. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9331. /**
  9332. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9333. * @param scene defines the current scene
  9334. * @param engine defines the current engine
  9335. * @param defines specifies the list of active defines
  9336. * @param useInstances defines if instances have to be turned on
  9337. * @param useClipPlane defines if clip plane have to be turned on
  9338. */
  9339. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9340. /**
  9341. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9342. * @param mesh The mesh containing the geometry data we will draw
  9343. * @param defines The defines to update
  9344. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9345. * @param useBones Precise whether bones should be used or not (override mesh info)
  9346. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9347. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9348. * @returns false if defines are considered not dirty and have not been checked
  9349. */
  9350. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9351. /**
  9352. * Prepares the defines related to the light information passed in parameter
  9353. * @param scene The scene we are intending to draw
  9354. * @param mesh The mesh the effect is compiling for
  9355. * @param defines The defines to update
  9356. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9357. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9358. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9359. * @returns true if normals will be required for the rest of the effect
  9360. */
  9361. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9362. /**
  9363. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9364. * that won t be acctive due to defines being turned off.
  9365. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9366. * @param samplersList The samplers list
  9367. * @param defines The defines helping in the list generation
  9368. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9369. */
  9370. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9371. /**
  9372. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9373. * @param defines The defines to update while falling back
  9374. * @param fallbacks The authorized effect fallbacks
  9375. * @param maxSimultaneousLights The maximum number of lights allowed
  9376. * @param rank the current rank of the Effect
  9377. * @returns The newly affected rank
  9378. */
  9379. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9380. /**
  9381. * Prepares the list of attributes required for morph targets according to the effect defines.
  9382. * @param attribs The current list of supported attribs
  9383. * @param mesh The mesh to prepare the morph targets attributes for
  9384. * @param defines The current Defines of the effect
  9385. */
  9386. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9387. /**
  9388. * Prepares the list of attributes required for bones according to the effect defines.
  9389. * @param attribs The current list of supported attribs
  9390. * @param mesh The mesh to prepare the bones attributes for
  9391. * @param defines The current Defines of the effect
  9392. * @param fallbacks The current efffect fallback strategy
  9393. */
  9394. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9395. /**
  9396. * Prepares the list of attributes required for instances according to the effect defines.
  9397. * @param attribs The current list of supported attribs
  9398. * @param defines The current Defines of the effect
  9399. */
  9400. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9401. /**
  9402. * Binds the light shadow information to the effect for the given mesh.
  9403. * @param light The light containing the generator
  9404. * @param scene The scene the lights belongs to
  9405. * @param mesh The mesh we are binding the information to render
  9406. * @param lightIndex The light index in the effect used to render the mesh
  9407. * @param effect The effect we are binding the data to
  9408. */
  9409. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9410. /**
  9411. * Binds the light information to the effect.
  9412. * @param light The light containing the generator
  9413. * @param effect The effect we are binding the data to
  9414. * @param lightIndex The light index in the effect used to render
  9415. */
  9416. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9417. /**
  9418. * Binds the lights information from the scene to the effect for the given mesh.
  9419. * @param scene The scene the lights belongs to
  9420. * @param mesh The mesh we are binding the information to render
  9421. * @param effect The effect we are binding the data to
  9422. * @param defines The generated defines for the effect
  9423. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9424. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9425. */
  9426. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9427. /**
  9428. * Binds the fog information from the scene to the effect for the given mesh.
  9429. * @param scene The scene the lights belongs to
  9430. * @param mesh The mesh we are binding the information to render
  9431. * @param effect The effect we are binding the data to
  9432. */
  9433. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  9434. /**
  9435. * Binds the bones information from the mesh to the effect.
  9436. * @param mesh The mesh we are binding the information to render
  9437. * @param effect The effect we are binding the data to
  9438. */
  9439. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9440. /**
  9441. * Binds the morph targets information from the mesh to the effect.
  9442. * @param abstractMesh The mesh we are binding the information to render
  9443. * @param effect The effect we are binding the data to
  9444. */
  9445. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9446. /**
  9447. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9448. * @param defines The generated defines used in the effect
  9449. * @param effect The effect we are binding the data to
  9450. * @param scene The scene we are willing to render with logarithmic scale for
  9451. */
  9452. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9453. /**
  9454. * Binds the clip plane information from the scene to the effect.
  9455. * @param scene The scene the clip plane information are extracted from
  9456. * @param effect The effect we are binding the data to
  9457. */
  9458. static BindClipPlane(effect: Effect, scene: Scene): void;
  9459. }
  9460. }
  9461. declare module BABYLON {
  9462. class MultiMaterial extends Material {
  9463. private _subMaterials;
  9464. subMaterials: Nullable<Material>[];
  9465. constructor(name: string, scene: Scene);
  9466. private _hookArray(array);
  9467. getSubMaterial(index: number): Nullable<Material>;
  9468. getActiveTextures(): BaseTexture[];
  9469. getClassName(): string;
  9470. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  9471. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  9472. serialize(): any;
  9473. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  9474. }
  9475. }
  9476. declare module BABYLON {
  9477. class PushMaterial extends Material {
  9478. protected _activeEffect: Effect;
  9479. protected _normalMatrix: Matrix;
  9480. constructor(name: string, scene: Scene);
  9481. getEffect(): Effect;
  9482. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  9483. /**
  9484. * Binds the given world matrix to the active effect
  9485. *
  9486. * @param world the matrix to bind
  9487. */
  9488. bindOnlyWorldMatrix(world: Matrix): void;
  9489. /**
  9490. * Binds the given normal matrix to the active effect
  9491. *
  9492. * @param normalMatrix the matrix to bind
  9493. */
  9494. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  9495. bind(world: Matrix, mesh?: Mesh): void;
  9496. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  9497. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  9498. }
  9499. }
  9500. declare module BABYLON {
  9501. class ShaderMaterial extends Material {
  9502. private _shaderPath;
  9503. private _options;
  9504. private _textures;
  9505. private _textureArrays;
  9506. private _floats;
  9507. private _ints;
  9508. private _floatsArrays;
  9509. private _colors3;
  9510. private _colors3Arrays;
  9511. private _colors4;
  9512. private _vectors2;
  9513. private _vectors3;
  9514. private _vectors4;
  9515. private _matrices;
  9516. private _matrices3x3;
  9517. private _matrices2x2;
  9518. private _vectors2Arrays;
  9519. private _vectors3Arrays;
  9520. private _cachedWorldViewMatrix;
  9521. private _renderId;
  9522. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  9523. getClassName(): string;
  9524. needAlphaBlending(): boolean;
  9525. needAlphaTesting(): boolean;
  9526. private _checkUniform(uniformName);
  9527. setTexture(name: string, texture: Texture): ShaderMaterial;
  9528. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  9529. setFloat(name: string, value: number): ShaderMaterial;
  9530. setInt(name: string, value: number): ShaderMaterial;
  9531. setFloats(name: string, value: number[]): ShaderMaterial;
  9532. setColor3(name: string, value: Color3): ShaderMaterial;
  9533. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  9534. setColor4(name: string, value: Color4): ShaderMaterial;
  9535. setVector2(name: string, value: Vector2): ShaderMaterial;
  9536. setVector3(name: string, value: Vector3): ShaderMaterial;
  9537. setVector4(name: string, value: Vector4): ShaderMaterial;
  9538. setMatrix(name: string, value: Matrix): ShaderMaterial;
  9539. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  9540. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  9541. setArray2(name: string, value: number[]): ShaderMaterial;
  9542. setArray3(name: string, value: number[]): ShaderMaterial;
  9543. private _checkCache(scene, mesh?, useInstances?);
  9544. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  9545. bindOnlyWorldMatrix(world: Matrix): void;
  9546. bind(world: Matrix, mesh?: Mesh): void;
  9547. getActiveTextures(): BaseTexture[];
  9548. hasTexture(texture: BaseTexture): boolean;
  9549. clone(name: string): ShaderMaterial;
  9550. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  9551. serialize(): any;
  9552. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  9553. }
  9554. }
  9555. declare module BABYLON {
  9556. /** @ignore */
  9557. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  9558. MAINUV1: boolean;
  9559. MAINUV2: boolean;
  9560. DIFFUSE: boolean;
  9561. DIFFUSEDIRECTUV: number;
  9562. AMBIENT: boolean;
  9563. AMBIENTDIRECTUV: number;
  9564. OPACITY: boolean;
  9565. OPACITYDIRECTUV: number;
  9566. OPACITYRGB: boolean;
  9567. REFLECTION: boolean;
  9568. EMISSIVE: boolean;
  9569. EMISSIVEDIRECTUV: number;
  9570. SPECULAR: boolean;
  9571. SPECULARDIRECTUV: number;
  9572. BUMP: boolean;
  9573. BUMPDIRECTUV: number;
  9574. PARALLAX: boolean;
  9575. PARALLAXOCCLUSION: boolean;
  9576. SPECULAROVERALPHA: boolean;
  9577. CLIPPLANE: boolean;
  9578. ALPHATEST: boolean;
  9579. DEPTHPREPASS: boolean;
  9580. ALPHAFROMDIFFUSE: boolean;
  9581. POINTSIZE: boolean;
  9582. FOG: boolean;
  9583. SPECULARTERM: boolean;
  9584. DIFFUSEFRESNEL: boolean;
  9585. OPACITYFRESNEL: boolean;
  9586. REFLECTIONFRESNEL: boolean;
  9587. REFRACTIONFRESNEL: boolean;
  9588. EMISSIVEFRESNEL: boolean;
  9589. FRESNEL: boolean;
  9590. NORMAL: boolean;
  9591. UV1: boolean;
  9592. UV2: boolean;
  9593. VERTEXCOLOR: boolean;
  9594. VERTEXALPHA: boolean;
  9595. NUM_BONE_INFLUENCERS: number;
  9596. BonesPerMesh: number;
  9597. INSTANCES: boolean;
  9598. GLOSSINESS: boolean;
  9599. ROUGHNESS: boolean;
  9600. EMISSIVEASILLUMINATION: boolean;
  9601. LINKEMISSIVEWITHDIFFUSE: boolean;
  9602. REFLECTIONFRESNELFROMSPECULAR: boolean;
  9603. LIGHTMAP: boolean;
  9604. LIGHTMAPDIRECTUV: number;
  9605. OBJECTSPACE_NORMALMAP: boolean;
  9606. USELIGHTMAPASSHADOWMAP: boolean;
  9607. REFLECTIONMAP_3D: boolean;
  9608. REFLECTIONMAP_SPHERICAL: boolean;
  9609. REFLECTIONMAP_PLANAR: boolean;
  9610. REFLECTIONMAP_CUBIC: boolean;
  9611. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  9612. REFLECTIONMAP_PROJECTION: boolean;
  9613. REFLECTIONMAP_SKYBOX: boolean;
  9614. REFLECTIONMAP_EXPLICIT: boolean;
  9615. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  9616. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  9617. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  9618. INVERTCUBICMAP: boolean;
  9619. LOGARITHMICDEPTH: boolean;
  9620. REFRACTION: boolean;
  9621. REFRACTIONMAP_3D: boolean;
  9622. REFLECTIONOVERALPHA: boolean;
  9623. TWOSIDEDLIGHTING: boolean;
  9624. SHADOWFLOAT: boolean;
  9625. MORPHTARGETS: boolean;
  9626. MORPHTARGETS_NORMAL: boolean;
  9627. MORPHTARGETS_TANGENT: boolean;
  9628. NUM_MORPH_INFLUENCERS: number;
  9629. NONUNIFORMSCALING: boolean;
  9630. PREMULTIPLYALPHA: boolean;
  9631. IMAGEPROCESSING: boolean;
  9632. VIGNETTE: boolean;
  9633. VIGNETTEBLENDMODEMULTIPLY: boolean;
  9634. VIGNETTEBLENDMODEOPAQUE: boolean;
  9635. TONEMAPPING: boolean;
  9636. CONTRAST: boolean;
  9637. COLORCURVES: boolean;
  9638. COLORGRADING: boolean;
  9639. COLORGRADING3D: boolean;
  9640. SAMPLER3DGREENDEPTH: boolean;
  9641. SAMPLER3DBGRMAP: boolean;
  9642. IMAGEPROCESSINGPOSTPROCESS: boolean;
  9643. EXPOSURE: boolean;
  9644. constructor();
  9645. setReflectionMode(modeToEnable: string): void;
  9646. }
  9647. class StandardMaterial extends PushMaterial {
  9648. private _diffuseTexture;
  9649. diffuseTexture: Nullable<BaseTexture>;
  9650. private _ambientTexture;
  9651. ambientTexture: Nullable<BaseTexture>;
  9652. private _opacityTexture;
  9653. opacityTexture: Nullable<BaseTexture>;
  9654. private _reflectionTexture;
  9655. reflectionTexture: Nullable<BaseTexture>;
  9656. private _emissiveTexture;
  9657. emissiveTexture: Nullable<BaseTexture>;
  9658. private _specularTexture;
  9659. specularTexture: Nullable<BaseTexture>;
  9660. private _bumpTexture;
  9661. bumpTexture: Nullable<BaseTexture>;
  9662. private _lightmapTexture;
  9663. lightmapTexture: Nullable<BaseTexture>;
  9664. private _refractionTexture;
  9665. refractionTexture: Nullable<BaseTexture>;
  9666. ambientColor: Color3;
  9667. diffuseColor: Color3;
  9668. specularColor: Color3;
  9669. emissiveColor: Color3;
  9670. specularPower: number;
  9671. private _useAlphaFromDiffuseTexture;
  9672. useAlphaFromDiffuseTexture: boolean;
  9673. private _useEmissiveAsIllumination;
  9674. useEmissiveAsIllumination: boolean;
  9675. private _linkEmissiveWithDiffuse;
  9676. linkEmissiveWithDiffuse: boolean;
  9677. private _useSpecularOverAlpha;
  9678. useSpecularOverAlpha: boolean;
  9679. private _useReflectionOverAlpha;
  9680. useReflectionOverAlpha: boolean;
  9681. private _disableLighting;
  9682. disableLighting: boolean;
  9683. private _useObjectSpaceNormalMap;
  9684. /**
  9685. * Allows using an object space normal map (instead of tangent space).
  9686. */
  9687. useObjectSpaceNormalMap: boolean;
  9688. private _useParallax;
  9689. useParallax: boolean;
  9690. private _useParallaxOcclusion;
  9691. useParallaxOcclusion: boolean;
  9692. parallaxScaleBias: number;
  9693. private _roughness;
  9694. roughness: number;
  9695. indexOfRefraction: number;
  9696. invertRefractionY: boolean;
  9697. private _useLightmapAsShadowmap;
  9698. useLightmapAsShadowmap: boolean;
  9699. private _diffuseFresnelParameters;
  9700. diffuseFresnelParameters: FresnelParameters;
  9701. private _opacityFresnelParameters;
  9702. opacityFresnelParameters: FresnelParameters;
  9703. private _reflectionFresnelParameters;
  9704. reflectionFresnelParameters: FresnelParameters;
  9705. private _refractionFresnelParameters;
  9706. refractionFresnelParameters: FresnelParameters;
  9707. private _emissiveFresnelParameters;
  9708. emissiveFresnelParameters: FresnelParameters;
  9709. private _useReflectionFresnelFromSpecular;
  9710. useReflectionFresnelFromSpecular: boolean;
  9711. private _useGlossinessFromSpecularMapAlpha;
  9712. useGlossinessFromSpecularMapAlpha: boolean;
  9713. private _maxSimultaneousLights;
  9714. maxSimultaneousLights: number;
  9715. /**
  9716. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  9717. */
  9718. private _invertNormalMapX;
  9719. invertNormalMapX: boolean;
  9720. /**
  9721. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  9722. */
  9723. private _invertNormalMapY;
  9724. invertNormalMapY: boolean;
  9725. /**
  9726. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  9727. */
  9728. private _twoSidedLighting;
  9729. twoSidedLighting: boolean;
  9730. /**
  9731. * Default configuration related to image processing available in the standard Material.
  9732. */
  9733. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  9734. /**
  9735. * Gets the image processing configuration used either in this material.
  9736. */
  9737. /**
  9738. * Sets the Default image processing configuration used either in the this material.
  9739. *
  9740. * If sets to null, the scene one is in use.
  9741. */
  9742. imageProcessingConfiguration: ImageProcessingConfiguration;
  9743. /**
  9744. * Keep track of the image processing observer to allow dispose and replace.
  9745. */
  9746. private _imageProcessingObserver;
  9747. /**
  9748. * Attaches a new image processing configuration to the Standard Material.
  9749. * @param configuration
  9750. */
  9751. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  9752. /**
  9753. * Gets wether the color curves effect is enabled.
  9754. */
  9755. /**
  9756. * Sets wether the color curves effect is enabled.
  9757. */
  9758. cameraColorCurvesEnabled: boolean;
  9759. /**
  9760. * Gets wether the color grading effect is enabled.
  9761. */
  9762. /**
  9763. * Gets wether the color grading effect is enabled.
  9764. */
  9765. cameraColorGradingEnabled: boolean;
  9766. /**
  9767. * Gets wether tonemapping is enabled or not.
  9768. */
  9769. /**
  9770. * Sets wether tonemapping is enabled or not
  9771. */
  9772. cameraToneMappingEnabled: boolean;
  9773. /**
  9774. * The camera exposure used on this material.
  9775. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  9776. * This corresponds to a photographic exposure.
  9777. */
  9778. /**
  9779. * The camera exposure used on this material.
  9780. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  9781. * This corresponds to a photographic exposure.
  9782. */
  9783. cameraExposure: number;
  9784. /**
  9785. * Gets The camera contrast used on this material.
  9786. */
  9787. /**
  9788. * Sets The camera contrast used on this material.
  9789. */
  9790. cameraContrast: number;
  9791. /**
  9792. * Gets the Color Grading 2D Lookup Texture.
  9793. */
  9794. /**
  9795. * Sets the Color Grading 2D Lookup Texture.
  9796. */
  9797. cameraColorGradingTexture: Nullable<BaseTexture>;
  9798. /**
  9799. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  9800. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  9801. * 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;
  9802. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  9803. */
  9804. /**
  9805. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  9806. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  9807. * 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;
  9808. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  9809. */
  9810. cameraColorCurves: Nullable<ColorCurves>;
  9811. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  9812. protected _renderTargets: SmartArray<RenderTargetTexture>;
  9813. protected _worldViewProjectionMatrix: Matrix;
  9814. protected _globalAmbientColor: Color3;
  9815. protected _useLogarithmicDepth: boolean;
  9816. constructor(name: string, scene: Scene);
  9817. getClassName(): string;
  9818. useLogarithmicDepth: boolean;
  9819. needAlphaBlending(): boolean;
  9820. needAlphaTesting(): boolean;
  9821. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  9822. getAlphaTestTexture(): Nullable<BaseTexture>;
  9823. /**
  9824. * Child classes can use it to update shaders
  9825. */
  9826. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  9827. buildUniformLayout(): void;
  9828. unbind(): void;
  9829. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  9830. getAnimatables(): IAnimatable[];
  9831. getActiveTextures(): BaseTexture[];
  9832. hasTexture(texture: BaseTexture): boolean;
  9833. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  9834. clone(name: string): StandardMaterial;
  9835. serialize(): any;
  9836. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  9837. static _DiffuseTextureEnabled: boolean;
  9838. static DiffuseTextureEnabled: boolean;
  9839. static _AmbientTextureEnabled: boolean;
  9840. static AmbientTextureEnabled: boolean;
  9841. static _OpacityTextureEnabled: boolean;
  9842. static OpacityTextureEnabled: boolean;
  9843. static _ReflectionTextureEnabled: boolean;
  9844. static ReflectionTextureEnabled: boolean;
  9845. static _EmissiveTextureEnabled: boolean;
  9846. static EmissiveTextureEnabled: boolean;
  9847. static _SpecularTextureEnabled: boolean;
  9848. static SpecularTextureEnabled: boolean;
  9849. static _BumpTextureEnabled: boolean;
  9850. static BumpTextureEnabled: boolean;
  9851. static _LightmapTextureEnabled: boolean;
  9852. static LightmapTextureEnabled: boolean;
  9853. static _RefractionTextureEnabled: boolean;
  9854. static RefractionTextureEnabled: boolean;
  9855. static _ColorGradingTextureEnabled: boolean;
  9856. static ColorGradingTextureEnabled: boolean;
  9857. static _FresnelEnabled: boolean;
  9858. static FresnelEnabled: boolean;
  9859. }
  9860. }
  9861. declare module BABYLON {
  9862. class UniformBuffer {
  9863. private _engine;
  9864. private _buffer;
  9865. private _data;
  9866. private _bufferData;
  9867. private _dynamic?;
  9868. private _uniformLocations;
  9869. private _uniformSizes;
  9870. private _uniformLocationPointer;
  9871. private _needSync;
  9872. private _noUBO;
  9873. private _currentEffect;
  9874. private static _MAX_UNIFORM_SIZE;
  9875. private static _tempBuffer;
  9876. /**
  9877. * Wrapper for updateUniform.
  9878. * @method updateMatrix3x3
  9879. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9880. * @param {Float32Array} matrix
  9881. */
  9882. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  9883. /**
  9884. * Wrapper for updateUniform.
  9885. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9886. * @param {Float32Array} matrix
  9887. */
  9888. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  9889. /**
  9890. * Wrapper for updateUniform.
  9891. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9892. * @param {number} x
  9893. */
  9894. updateFloat: (name: string, x: number) => void;
  9895. /**
  9896. * Wrapper for updateUniform.
  9897. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9898. * @param {number} x
  9899. * @param {number} y
  9900. * @param {string} [suffix] Suffix to add to the uniform name.
  9901. */
  9902. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  9903. /**
  9904. * Wrapper for updateUniform.
  9905. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9906. * @param {number} x
  9907. * @param {number} y
  9908. * @param {number} z
  9909. * @param {string} [suffix] Suffix to add to the uniform name.
  9910. */
  9911. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  9912. /**
  9913. * Wrapper for updateUniform.
  9914. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9915. * @param {number} x
  9916. * @param {number} y
  9917. * @param {number} z
  9918. * @param {number} w
  9919. * @param {string} [suffix] Suffix to add to the uniform name.
  9920. */
  9921. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  9922. /**
  9923. * Wrapper for updateUniform.
  9924. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9925. * @param {Matrix} A 4x4 matrix.
  9926. */
  9927. updateMatrix: (name: string, mat: Matrix) => void;
  9928. /**
  9929. * Wrapper for updateUniform.
  9930. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9931. * @param {Vector3} vector
  9932. */
  9933. updateVector3: (name: string, vector: Vector3) => void;
  9934. /**
  9935. * Wrapper for updateUniform.
  9936. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9937. * @param {Vector4} vector
  9938. */
  9939. updateVector4: (name: string, vector: Vector4) => void;
  9940. /**
  9941. * Wrapper for updateUniform.
  9942. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9943. * @param {Color3} color
  9944. * @param {string} [suffix] Suffix to add to the uniform name.
  9945. */
  9946. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  9947. /**
  9948. * Wrapper for updateUniform.
  9949. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9950. * @param {Color3} color
  9951. * @param {number} alpha
  9952. * @param {string} [suffix] Suffix to add to the uniform name.
  9953. */
  9954. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  9955. /**
  9956. * Uniform buffer objects.
  9957. *
  9958. * Handles blocks of uniform on the GPU.
  9959. *
  9960. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  9961. *
  9962. * For more information, please refer to :
  9963. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  9964. */
  9965. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  9966. /**
  9967. * Indicates if the buffer is using the WebGL2 UBO implementation,
  9968. * or just falling back on setUniformXXX calls.
  9969. */
  9970. readonly useUbo: boolean;
  9971. /**
  9972. * Indicates if the WebGL underlying uniform buffer is in sync
  9973. * with the javascript cache data.
  9974. */
  9975. readonly isSync: boolean;
  9976. /**
  9977. * Indicates if the WebGL underlying uniform buffer is dynamic.
  9978. * Also, a dynamic UniformBuffer will disable cache verification and always
  9979. * update the underlying WebGL uniform buffer to the GPU.
  9980. */
  9981. isDynamic(): boolean;
  9982. /**
  9983. * The data cache on JS side.
  9984. */
  9985. getData(): Float32Array;
  9986. /**
  9987. * The underlying WebGL Uniform buffer.
  9988. */
  9989. getBuffer(): Nullable<WebGLBuffer>;
  9990. /**
  9991. * std140 layout specifies how to align data within an UBO structure.
  9992. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  9993. * for specs.
  9994. */
  9995. private _fillAlignment(size);
  9996. /**
  9997. * Adds an uniform in the buffer.
  9998. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  9999. * for the layout to be correct !
  10000. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10001. * @param {number|number[]} size Data size, or data directly.
  10002. */
  10003. addUniform(name: string, size: number | number[]): void;
  10004. /**
  10005. * Wrapper for addUniform.
  10006. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10007. * @param {Matrix} mat A 4x4 matrix.
  10008. */
  10009. addMatrix(name: string, mat: Matrix): void;
  10010. /**
  10011. * Wrapper for addUniform.
  10012. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10013. * @param {number} x
  10014. * @param {number} y
  10015. */
  10016. addFloat2(name: string, x: number, y: number): void;
  10017. /**
  10018. * Wrapper for addUniform.
  10019. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10020. * @param {number} x
  10021. * @param {number} y
  10022. * @param {number} z
  10023. */
  10024. addFloat3(name: string, x: number, y: number, z: number): void;
  10025. /**
  10026. * Wrapper for addUniform.
  10027. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10028. * @param {Color3} color
  10029. */
  10030. addColor3(name: string, color: Color3): void;
  10031. /**
  10032. * Wrapper for addUniform.
  10033. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10034. * @param {Color3} color
  10035. * @param {number} alpha
  10036. */
  10037. addColor4(name: string, color: Color3, alpha: number): void;
  10038. /**
  10039. * Wrapper for addUniform.
  10040. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10041. * @param {Vector3} vector
  10042. */
  10043. addVector3(name: string, vector: Vector3): void;
  10044. /**
  10045. * Wrapper for addUniform.
  10046. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10047. */
  10048. addMatrix3x3(name: string): void;
  10049. /**
  10050. * Wrapper for addUniform.
  10051. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10052. */
  10053. addMatrix2x2(name: string): void;
  10054. /**
  10055. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  10056. */
  10057. create(): void;
  10058. _rebuild(): void;
  10059. /**
  10060. * Updates the WebGL Uniform Buffer on the GPU.
  10061. * If the `dynamic` flag is set to true, no cache comparison is done.
  10062. * Otherwise, the buffer will be updated only if the cache differs.
  10063. */
  10064. update(): void;
  10065. /**
  10066. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  10067. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  10068. * @param {number[]|Float32Array} data Flattened data
  10069. * @param {number} size Size of the data.
  10070. */
  10071. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  10072. private _updateMatrix3x3ForUniform(name, matrix);
  10073. private _updateMatrix3x3ForEffect(name, matrix);
  10074. private _updateMatrix2x2ForEffect(name, matrix);
  10075. private _updateMatrix2x2ForUniform(name, matrix);
  10076. private _updateFloatForEffect(name, x);
  10077. private _updateFloatForUniform(name, x);
  10078. private _updateFloat2ForEffect(name, x, y, suffix?);
  10079. private _updateFloat2ForUniform(name, x, y, suffix?);
  10080. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  10081. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  10082. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  10083. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  10084. private _updateMatrixForEffect(name, mat);
  10085. private _updateMatrixForUniform(name, mat);
  10086. private _updateVector3ForEffect(name, vector);
  10087. private _updateVector3ForUniform(name, vector);
  10088. private _updateVector4ForEffect(name, vector);
  10089. private _updateVector4ForUniform(name, vector);
  10090. private _updateColor3ForEffect(name, color, suffix?);
  10091. private _updateColor3ForUniform(name, color, suffix?);
  10092. private _updateColor4ForEffect(name, color, alpha, suffix?);
  10093. private _updateColor4ForUniform(name, color, alpha, suffix?);
  10094. /**
  10095. * Sets a sampler uniform on the effect.
  10096. * @param {string} name Name of the sampler.
  10097. * @param {Texture} texture
  10098. */
  10099. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  10100. /**
  10101. * Directly updates the value of the uniform in the cache AND on the GPU.
  10102. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  10103. * @param {number[]|Float32Array} data Flattened data
  10104. */
  10105. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  10106. /**
  10107. * Binds this uniform buffer to an effect.
  10108. * @param {Effect} effect
  10109. * @param {string} name Name of the uniform block in the shader.
  10110. */
  10111. bindToEffect(effect: Effect, name: string): void;
  10112. /**
  10113. * Disposes the uniform buffer.
  10114. */
  10115. dispose(): void;
  10116. }
  10117. }
  10118. declare module BABYLON {
  10119. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  10120. static OCCLUSION_TYPE_NONE: number;
  10121. static OCCLUSION_TYPE_OPTIMISTIC: number;
  10122. static OCCLUSION_TYPE_STRICT: number;
  10123. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  10124. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  10125. static readonly BILLBOARDMODE_NONE: number;
  10126. static readonly BILLBOARDMODE_X: number;
  10127. static readonly BILLBOARDMODE_Y: number;
  10128. static readonly BILLBOARDMODE_Z: number;
  10129. static readonly BILLBOARDMODE_ALL: number;
  10130. private _facetPositions;
  10131. private _facetNormals;
  10132. private _facetPartitioning;
  10133. private _facetNb;
  10134. private _partitioningSubdivisions;
  10135. private _partitioningBBoxRatio;
  10136. private _facetDataEnabled;
  10137. private _facetParameters;
  10138. private _bbSize;
  10139. private _subDiv;
  10140. private _facetDepthSort;
  10141. private _facetDepthSortEnabled;
  10142. private _depthSortedIndices;
  10143. private _depthSortedFacets;
  10144. private _facetDepthSortFunction;
  10145. private _facetDepthSortFrom;
  10146. private _facetDepthSortOrigin;
  10147. private _invertedMatrix;
  10148. /**
  10149. * Read-only : the number of facets in the mesh
  10150. */
  10151. readonly facetNb: number;
  10152. /**
  10153. * The number (integer) of subdivisions per axis in the partioning space
  10154. */
  10155. partitioningSubdivisions: number;
  10156. /**
  10157. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  10158. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box.
  10159. */
  10160. partitioningBBoxRatio: number;
  10161. /**
  10162. * Boolean : must the facet be depth sorted on next call to `updateFacetData()` ?
  10163. * Works only for updatable meshes.
  10164. * Doesn't work with multi-materials.
  10165. */
  10166. mustDepthSortFacets: boolean;
  10167. /**
  10168. * The location (Vector3) where the facet depth sort must be computed from.
  10169. * By default, the active camera position.
  10170. * Used only when facet depth sort is enabled.
  10171. */
  10172. facetDepthSortFrom: Vector3;
  10173. /**
  10174. * Read-only boolean : is the feature facetData enabled ?
  10175. */
  10176. readonly isFacetDataEnabled: boolean;
  10177. _updateNonUniformScalingState(value: boolean): boolean;
  10178. /**
  10179. * An event triggered when this mesh collides with another one
  10180. * @type {BABYLON.Observable}
  10181. */
  10182. onCollideObservable: Observable<AbstractMesh>;
  10183. private _onCollideObserver;
  10184. onCollide: () => void;
  10185. /**
  10186. * An event triggered when the collision's position changes
  10187. * @type {BABYLON.Observable}
  10188. */
  10189. onCollisionPositionChangeObservable: Observable<Vector3>;
  10190. private _onCollisionPositionChangeObserver;
  10191. onCollisionPositionChange: () => void;
  10192. /**
  10193. * An event triggered when material is changed
  10194. * @type {BABYLON.Observable}
  10195. */
  10196. onMaterialChangedObservable: Observable<AbstractMesh>;
  10197. definedFacingForward: boolean;
  10198. /**
  10199. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  10200. * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  10201. * or
  10202. * 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.
  10203. * for more info check WebGl documentations
  10204. */
  10205. occlusionQueryAlgorithmType: number;
  10206. /**
  10207. * 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:
  10208. * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  10209. * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  10210. * 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.
  10211. */
  10212. occlusionType: number;
  10213. /**
  10214. * 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.
  10215. * The default value is -1 which means don't break the query and wait till the result.
  10216. */
  10217. occlusionRetryCount: number;
  10218. private _occlusionInternalRetryCounter;
  10219. protected _isOccluded: boolean;
  10220. /**
  10221. * 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.
  10222. */
  10223. isOccluded: boolean;
  10224. private _isOcclusionQueryInProgress;
  10225. /**
  10226. * Flag to check the progress status of the query
  10227. */
  10228. readonly isOcclusionQueryInProgress: boolean;
  10229. private _occlusionQuery;
  10230. private _visibility;
  10231. /**
  10232. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  10233. */
  10234. /**
  10235. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  10236. */
  10237. visibility: number;
  10238. alphaIndex: number;
  10239. isVisible: boolean;
  10240. isPickable: boolean;
  10241. showBoundingBox: boolean;
  10242. showSubMeshesBoundingBox: boolean;
  10243. isBlocker: boolean;
  10244. enablePointerMoveEvents: boolean;
  10245. renderingGroupId: number;
  10246. private _material;
  10247. material: Nullable<Material>;
  10248. private _receiveShadows;
  10249. receiveShadows: boolean;
  10250. renderOutline: boolean;
  10251. outlineColor: Color3;
  10252. outlineWidth: number;
  10253. renderOverlay: boolean;
  10254. overlayColor: Color3;
  10255. overlayAlpha: number;
  10256. private _hasVertexAlpha;
  10257. hasVertexAlpha: boolean;
  10258. private _useVertexColors;
  10259. useVertexColors: boolean;
  10260. private _computeBonesUsingShaders;
  10261. computeBonesUsingShaders: boolean;
  10262. private _numBoneInfluencers;
  10263. numBoneInfluencers: number;
  10264. private _applyFog;
  10265. applyFog: boolean;
  10266. useOctreeForRenderingSelection: boolean;
  10267. useOctreeForPicking: boolean;
  10268. useOctreeForCollisions: boolean;
  10269. private _layerMask;
  10270. layerMask: number;
  10271. /**
  10272. * True if the mesh must be rendered in any case.
  10273. */
  10274. alwaysSelectAsActiveMesh: boolean;
  10275. /**
  10276. * This scene's action manager
  10277. * @type {BABYLON.ActionManager}
  10278. */
  10279. actionManager: Nullable<ActionManager>;
  10280. physicsImpostor: Nullable<PhysicsImpostor>;
  10281. private _checkCollisions;
  10282. private _collisionMask;
  10283. private _collisionGroup;
  10284. ellipsoid: Vector3;
  10285. ellipsoidOffset: Vector3;
  10286. private _collider;
  10287. private _oldPositionForCollisions;
  10288. private _diffPositionForCollisions;
  10289. collisionMask: number;
  10290. collisionGroup: number;
  10291. edgesWidth: number;
  10292. edgesColor: Color4;
  10293. _edgesRenderer: Nullable<EdgesRenderer>;
  10294. private _collisionsTransformMatrix;
  10295. private _collisionsScalingMatrix;
  10296. _masterMesh: Nullable<AbstractMesh>;
  10297. _boundingInfo: Nullable<BoundingInfo>;
  10298. _renderId: number;
  10299. subMeshes: SubMesh[];
  10300. _submeshesOctree: Octree<SubMesh>;
  10301. _intersectionsInProgress: AbstractMesh[];
  10302. _unIndexed: boolean;
  10303. _lightSources: Light[];
  10304. readonly _positions: Nullable<Vector3[]>;
  10305. _waitingActions: any;
  10306. _waitingFreezeWorldMatrix: Nullable<boolean>;
  10307. private _skeleton;
  10308. _bonesTransformMatrices: Nullable<Float32Array>;
  10309. skeleton: Nullable<Skeleton>;
  10310. constructor(name: string, scene?: Nullable<Scene>);
  10311. /**
  10312. * Returns the string "AbstractMesh"
  10313. */
  10314. getClassName(): string;
  10315. /**
  10316. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  10317. */
  10318. toString(fullDetails?: boolean): string;
  10319. _rebuild(): void;
  10320. _resyncLightSources(): void;
  10321. _resyncLighSource(light: Light): void;
  10322. _removeLightSource(light: Light): void;
  10323. private _markSubMeshesAsDirty(func);
  10324. _markSubMeshesAsLightDirty(): void;
  10325. _markSubMeshesAsAttributesDirty(): void;
  10326. _markSubMeshesAsMiscDirty(): void;
  10327. /**
  10328. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  10329. * Default : (1.0, 1.0, 1.0)
  10330. */
  10331. /**
  10332. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  10333. * Default : (1.0, 1.0, 1.0)
  10334. */
  10335. scaling: Vector3;
  10336. /**
  10337. * Disables the mesh edger rendering mode.
  10338. * Returns the AbstractMesh.
  10339. */
  10340. disableEdgesRendering(): AbstractMesh;
  10341. /**
  10342. * Enables the edge rendering mode on the mesh.
  10343. * This mode makes the mesh edges visible.
  10344. * Returns the AbstractMesh.
  10345. */
  10346. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  10347. /**
  10348. * Returns true if the mesh is blocked. Used by the class Mesh.
  10349. * Returns the boolean `false` by default.
  10350. */
  10351. readonly isBlocked: boolean;
  10352. /**
  10353. * Returns the mesh itself by default, used by the class Mesh.
  10354. * Returned type : AbstractMesh
  10355. */
  10356. getLOD(camera: Camera): AbstractMesh;
  10357. /**
  10358. * Returns 0 by default, used by the class Mesh.
  10359. * Returns an integer.
  10360. */
  10361. getTotalVertices(): number;
  10362. /**
  10363. * Returns null by default, used by the class Mesh.
  10364. * Returned type : integer array
  10365. */
  10366. getIndices(): Nullable<IndicesArray>;
  10367. /**
  10368. * Returns the array of the requested vertex data kind. Used by the class Mesh. Returns null here.
  10369. * Returned type : float array or Float32Array
  10370. */
  10371. getVerticesData(kind: string): Nullable<FloatArray>;
  10372. /**
  10373. * Sets the vertex data of the mesh geometry for the requested `kind`.
  10374. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  10375. * The `data` are either a numeric array either a Float32Array.
  10376. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  10377. * 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).
  10378. * Note that a new underlying VertexBuffer object is created each call.
  10379. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  10380. *
  10381. * Possible `kind` values :
  10382. * - BABYLON.VertexBuffer.PositionKind
  10383. * - BABYLON.VertexBuffer.UVKind
  10384. * - BABYLON.VertexBuffer.UV2Kind
  10385. * - BABYLON.VertexBuffer.UV3Kind
  10386. * - BABYLON.VertexBuffer.UV4Kind
  10387. * - BABYLON.VertexBuffer.UV5Kind
  10388. * - BABYLON.VertexBuffer.UV6Kind
  10389. * - BABYLON.VertexBuffer.ColorKind
  10390. * - BABYLON.VertexBuffer.MatricesIndicesKind
  10391. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  10392. * - BABYLON.VertexBuffer.MatricesWeightsKind
  10393. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  10394. *
  10395. * Returns the Mesh.
  10396. */
  10397. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  10398. /**
  10399. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  10400. * If the mesh has no geometry, it is simply returned as it is.
  10401. * The `data` are either a numeric array either a Float32Array.
  10402. * No new underlying VertexBuffer object is created.
  10403. * 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.
  10404. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  10405. *
  10406. * Possible `kind` values :
  10407. * - BABYLON.VertexBuffer.PositionKind
  10408. * - BABYLON.VertexBuffer.UVKind
  10409. * - BABYLON.VertexBuffer.UV2Kind
  10410. * - BABYLON.VertexBuffer.UV3Kind
  10411. * - BABYLON.VertexBuffer.UV4Kind
  10412. * - BABYLON.VertexBuffer.UV5Kind
  10413. * - BABYLON.VertexBuffer.UV6Kind
  10414. * - BABYLON.VertexBuffer.ColorKind
  10415. * - BABYLON.VertexBuffer.MatricesIndicesKind
  10416. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  10417. * - BABYLON.VertexBuffer.MatricesWeightsKind
  10418. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  10419. *
  10420. * Returns the Mesh.
  10421. */
  10422. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  10423. /**
  10424. * Sets the mesh indices.
  10425. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  10426. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  10427. * This method creates a new index buffer each call.
  10428. * Returns the Mesh.
  10429. */
  10430. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  10431. /** Returns false by default, used by the class Mesh.
  10432. * Returns a boolean
  10433. */
  10434. isVerticesDataPresent(kind: string): boolean;
  10435. /**
  10436. * Returns the mesh BoundingInfo object or creates a new one and returns it if undefined.
  10437. * Returns a BoundingInfo
  10438. */
  10439. getBoundingInfo(): BoundingInfo;
  10440. /**
  10441. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units).
  10442. * @param includeDescendants Take the hierarchy's bounding box instead of the mesh's bounding box.
  10443. */
  10444. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  10445. /**
  10446. * Sets a mesh new object BoundingInfo.
  10447. * Returns the AbstractMesh.
  10448. */
  10449. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  10450. readonly useBones: boolean;
  10451. _preActivate(): void;
  10452. _preActivateForIntermediateRendering(renderId: number): void;
  10453. _activate(renderId: number): void;
  10454. /**
  10455. * Returns the latest update of the World matrix
  10456. * Returns a Matrix.
  10457. */
  10458. getWorldMatrix(): Matrix;
  10459. /**
  10460. * Returns the latest update of the World matrix determinant.
  10461. */
  10462. protected _getWorldMatrixDeterminant(): number;
  10463. /**
  10464. * Perform relative position change from the point of view of behind the front of the mesh.
  10465. * This is performed taking into account the meshes current rotation, so you do not have to care.
  10466. * Supports definition of mesh facing forward or backward.
  10467. * @param {number} amountRight
  10468. * @param {number} amountUp
  10469. * @param {number} amountForward
  10470. *
  10471. * Returns the AbstractMesh.
  10472. */
  10473. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  10474. /**
  10475. * Calculate relative position change from the point of view of behind the front of the mesh.
  10476. * This is performed taking into account the meshes current rotation, so you do not have to care.
  10477. * Supports definition of mesh facing forward or backward.
  10478. * @param {number} amountRight
  10479. * @param {number} amountUp
  10480. * @param {number} amountForward
  10481. *
  10482. * Returns a new Vector3.
  10483. */
  10484. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  10485. /**
  10486. * Perform relative rotation change from the point of view of behind the front of the mesh.
  10487. * Supports definition of mesh facing forward or backward.
  10488. * @param {number} flipBack
  10489. * @param {number} twirlClockwise
  10490. * @param {number} tiltRight
  10491. *
  10492. * Returns the AbstractMesh.
  10493. */
  10494. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  10495. /**
  10496. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  10497. * Supports definition of mesh facing forward or backward.
  10498. * @param {number} flipBack
  10499. * @param {number} twirlClockwise
  10500. * @param {number} tiltRight
  10501. *
  10502. * Returns a new Vector3.
  10503. */
  10504. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  10505. /**
  10506. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  10507. * @param includeDescendants Include bounding info from descendants as well (true by default).
  10508. */
  10509. getHierarchyBoundingVectors(includeDescendants?: boolean): {
  10510. min: Vector3;
  10511. max: Vector3;
  10512. };
  10513. /**
  10514. * Updates the mesh BoundingInfo object and all its children BoundingInfo objects also.
  10515. * Returns the AbstractMesh.
  10516. */
  10517. _updateBoundingInfo(): AbstractMesh;
  10518. /**
  10519. * Update a mesh's children BoundingInfo objects only.
  10520. * Returns the AbstractMesh.
  10521. */
  10522. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  10523. protected _afterComputeWorldMatrix(): void;
  10524. /**
  10525. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  10526. * A mesh is in the frustum if its bounding box intersects the frustum.
  10527. * Boolean returned.
  10528. */
  10529. isInFrustum(frustumPlanes: Plane[]): boolean;
  10530. /**
  10531. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  10532. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  10533. * Boolean returned.
  10534. */
  10535. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  10536. /**
  10537. * True if the mesh intersects another mesh or a SolidParticle object.
  10538. * 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)
  10539. * includeDescendants can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  10540. * Returns a boolean.
  10541. */
  10542. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  10543. /**
  10544. * Returns true if the passed point (Vector3) is inside the mesh bounding box.
  10545. * Returns a boolean.
  10546. */
  10547. intersectsPoint(point: Vector3): boolean;
  10548. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  10549. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  10550. /**
  10551. * Returns the distance from the mesh to the active camera.
  10552. * Returns a float.
  10553. */
  10554. getDistanceToCamera(camera?: Nullable<Camera>): number;
  10555. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  10556. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  10557. /**
  10558. * Property checkCollisions : Boolean, whether the camera should check the collisions against the mesh.
  10559. * Default `false`.
  10560. */
  10561. checkCollisions: boolean;
  10562. /**
  10563. * Gets Collider object used to compute collisions (not physics)
  10564. */
  10565. readonly collider: Collider;
  10566. moveWithCollisions(displacement: Vector3): AbstractMesh;
  10567. private _onCollisionPositionChange;
  10568. /**
  10569. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  10570. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree.
  10571. * Returns an Octree of submeshes.
  10572. */
  10573. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  10574. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  10575. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  10576. _checkCollision(collider: Collider): AbstractMesh;
  10577. _generatePointsArray(): boolean;
  10578. /**
  10579. * Checks if the passed Ray intersects with the mesh.
  10580. * Returns an object PickingInfo.
  10581. */
  10582. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  10583. /**
  10584. * Clones the mesh, used by the class Mesh.
  10585. * Just returns `null` for an AbstractMesh.
  10586. */
  10587. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  10588. /**
  10589. * Disposes all the mesh submeshes.
  10590. * Returns the AbstractMesh.
  10591. */
  10592. releaseSubMeshes(): AbstractMesh;
  10593. /**
  10594. * Disposes the AbstractMesh.
  10595. * By default, all the mesh children are also disposed unless the parameter `doNotRecurse` is set to `true`.
  10596. * Returns nothing.
  10597. */
  10598. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10599. /**
  10600. * Adds the passed mesh as a child to the current mesh.
  10601. * Returns the AbstractMesh.
  10602. */
  10603. addChild(mesh: AbstractMesh): AbstractMesh;
  10604. /**
  10605. * Removes the passed mesh from the current mesh children list.
  10606. * Returns the AbstractMesh.
  10607. */
  10608. removeChild(mesh: AbstractMesh): AbstractMesh;
  10609. /**
  10610. * Initialize the facet data arrays : facetNormals, facetPositions and facetPartitioning.
  10611. * Returns the AbstractMesh.
  10612. */
  10613. private _initFacetData();
  10614. /**
  10615. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  10616. * This method can be called within the render loop.
  10617. * 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.
  10618. * Returns the AbstractMesh.
  10619. */
  10620. updateFacetData(): AbstractMesh;
  10621. /**
  10622. * Returns the facetLocalNormals array.
  10623. * The normals are expressed in the mesh local space.
  10624. */
  10625. getFacetLocalNormals(): Vector3[];
  10626. /**
  10627. * Returns the facetLocalPositions array.
  10628. * The facet positions are expressed in the mesh local space.
  10629. */
  10630. getFacetLocalPositions(): Vector3[];
  10631. /**
  10632. * Returns the facetLocalPartioning array.
  10633. */
  10634. getFacetLocalPartitioning(): number[][];
  10635. /**
  10636. * Returns the i-th facet position in the world system.
  10637. * This method allocates a new Vector3 per call.
  10638. */
  10639. getFacetPosition(i: number): Vector3;
  10640. /**
  10641. * Sets the reference Vector3 with the i-th facet position in the world system.
  10642. * Returns the AbstractMesh.
  10643. */
  10644. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  10645. /**
  10646. * Returns the i-th facet normal in the world system.
  10647. * This method allocates a new Vector3 per call.
  10648. */
  10649. getFacetNormal(i: number): Vector3;
  10650. /**
  10651. * Sets the reference Vector3 with the i-th facet normal in the world system.
  10652. * Returns the AbstractMesh.
  10653. */
  10654. getFacetNormalToRef(i: number, ref: Vector3): this;
  10655. /**
  10656. * 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).
  10657. */
  10658. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  10659. /**
  10660. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found.
  10661. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) World projection on the facet.
  10662. * 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.
  10663. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  10664. * 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.
  10665. */
  10666. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  10667. /**
  10668. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found.
  10669. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) local projection on the facet.
  10670. * 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.
  10671. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  10672. * 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.
  10673. */
  10674. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  10675. /**
  10676. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  10677. */
  10678. getFacetDataParameters(): any;
  10679. /**
  10680. * Disables the feature FacetData and frees the related memory.
  10681. * Returns the AbstractMesh.
  10682. */
  10683. disableFacetData(): AbstractMesh;
  10684. /**
  10685. * Updates the AbstractMesh indices array. Actually, used by the Mesh object.
  10686. * Returns the mesh.
  10687. */
  10688. updateIndices(indices: IndicesArray): AbstractMesh;
  10689. /**
  10690. * The mesh Geometry. Actually used by the Mesh object.
  10691. * Returns a blank geometry object.
  10692. */
  10693. /**
  10694. * Creates new normals data for the mesh.
  10695. * @param updatable.
  10696. */
  10697. createNormals(updatable: boolean): void;
  10698. /**
  10699. * Align the mesh with a normal.
  10700. * Returns the mesh.
  10701. */
  10702. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  10703. protected checkOcclusionQuery(): void;
  10704. }
  10705. }
  10706. declare module BABYLON {
  10707. class Buffer {
  10708. private _engine;
  10709. private _buffer;
  10710. private _data;
  10711. private _updatable;
  10712. private _strideSize;
  10713. private _instanced;
  10714. private _instanceDivisor;
  10715. constructor(engine: any, data: FloatArray, updatable: boolean, stride: number, postponeInternalCreation?: boolean, instanced?: boolean);
  10716. createVertexBuffer(kind: string, offset: number, size: number, stride?: number): VertexBuffer;
  10717. isUpdatable(): boolean;
  10718. getData(): Nullable<FloatArray>;
  10719. getBuffer(): Nullable<WebGLBuffer>;
  10720. getStrideSize(): number;
  10721. getIsInstanced(): boolean;
  10722. instanceDivisor: number;
  10723. create(data?: Nullable<FloatArray>): void;
  10724. _rebuild(): void;
  10725. update(data: FloatArray): void;
  10726. updateDirectly(data: Float32Array, offset: number, vertexCount?: number): void;
  10727. dispose(): void;
  10728. }
  10729. }
  10730. declare module BABYLON {
  10731. class CSG {
  10732. private polygons;
  10733. matrix: Matrix;
  10734. position: Vector3;
  10735. rotation: Vector3;
  10736. rotationQuaternion: Nullable<Quaternion>;
  10737. scaling: Vector3;
  10738. static FromMesh(mesh: Mesh): CSG;
  10739. private static FromPolygons(polygons);
  10740. clone(): CSG;
  10741. union(csg: CSG): CSG;
  10742. unionInPlace(csg: CSG): void;
  10743. subtract(csg: CSG): CSG;
  10744. subtractInPlace(csg: CSG): void;
  10745. intersect(csg: CSG): CSG;
  10746. intersectInPlace(csg: CSG): void;
  10747. inverse(): CSG;
  10748. inverseInPlace(): void;
  10749. copyTransformAttributes(csg: CSG): CSG;
  10750. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  10751. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  10752. }
  10753. }
  10754. declare module BABYLON {
  10755. /**
  10756. * Class used to store geometry data (vertex buffers + index buffer)
  10757. */
  10758. class Geometry implements IGetSetVerticesData {
  10759. /**
  10760. * Gets or sets the unique ID of the geometry
  10761. */
  10762. id: string;
  10763. /**
  10764. * Gets the delay loading state of the geometry (none by default which means not delayed)
  10765. */
  10766. delayLoadState: number;
  10767. /**
  10768. * Gets the file containing the data to load when running in delay load state
  10769. */
  10770. delayLoadingFile: Nullable<string>;
  10771. /**
  10772. * Callback called when the geometry is updated
  10773. */
  10774. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  10775. private _scene;
  10776. private _engine;
  10777. private _meshes;
  10778. private _totalVertices;
  10779. private _indices;
  10780. private _vertexBuffers;
  10781. private _isDisposed;
  10782. private _extend;
  10783. private _boundingBias;
  10784. /** @ignore */
  10785. _delayInfo: Array<string>;
  10786. private _indexBuffer;
  10787. private _indexBufferIsUpdatable;
  10788. /** @ignore */
  10789. _boundingInfo: Nullable<BoundingInfo>;
  10790. /** @ignore */
  10791. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  10792. /** @ignore */
  10793. _softwareSkinningRenderId: number;
  10794. private _vertexArrayObjects;
  10795. private _updatable;
  10796. /** @ignore */
  10797. _positions: Nullable<Vector3[]>;
  10798. /**
  10799. * 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
  10800. */
  10801. /**
  10802. * 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
  10803. */
  10804. boundingBias: Vector2;
  10805. /**
  10806. * Static function used to attach a new empty geometry to a mesh
  10807. * @param mesh defines the mesh to attach the geometry to
  10808. * @returns the new {BABYLON.Geometry}
  10809. */
  10810. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  10811. /**
  10812. * Creates a new geometry
  10813. * @param id defines the unique ID
  10814. * @param scene defines the hosting scene
  10815. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  10816. * @param updatable defines if geometry must be updatable (false by default)
  10817. * @param mesh defines the mesh that will be associated with the geometry
  10818. */
  10819. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  10820. /**
  10821. * Gets the current extend of the geometry
  10822. */
  10823. readonly extend: {
  10824. minimum: Vector3;
  10825. maximum: Vector3;
  10826. };
  10827. /**
  10828. * Gets the hosting scene
  10829. * @returns the hosting {BABYLON.Scene}
  10830. */
  10831. getScene(): Scene;
  10832. /**
  10833. * Gets the hosting engine
  10834. * @returns the hosting {BABYLON.Engine}
  10835. */
  10836. getEngine(): Engine;
  10837. /**
  10838. * Defines if the geometry is ready to use
  10839. * @returns true if the geometry is ready to be used
  10840. */
  10841. isReady(): boolean;
  10842. /**
  10843. * Gets a value indicating that the geometry should not be serialized
  10844. */
  10845. readonly doNotSerialize: boolean;
  10846. /** @ignore */
  10847. _rebuild(): void;
  10848. /**
  10849. * Affects all gemetry data in one call
  10850. * @param vertexData defines the geometry data
  10851. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  10852. */
  10853. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  10854. /**
  10855. * Set specific vertex data
  10856. * @param kind defines the data kind (Position, normal, etc...)
  10857. * @param data defines the vertex data to use
  10858. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  10859. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  10860. */
  10861. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  10862. /**
  10863. * Removes a specific vertex data
  10864. * @param kind defines the data kind (Position, normal, etc...)
  10865. */
  10866. removeVerticesData(kind: string): void;
  10867. /**
  10868. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  10869. * @param buffer defines the vertex buffer to use
  10870. */
  10871. setVerticesBuffer(buffer: VertexBuffer): void;
  10872. /**
  10873. * Update a specific vertex buffer
  10874. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  10875. * It will do nothing if the buffer is not updatable
  10876. * @param kind defines the data kind (Position, normal, etc...)
  10877. * @param data defines the data to use
  10878. * @param offset defines the offset in the target buffer where to store the data
  10879. */
  10880. updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void;
  10881. /**
  10882. * Update a specific vertex buffer
  10883. * This function will create a new buffer if the current one is not updatable
  10884. * @param kind defines the data kind (Position, normal, etc...)
  10885. * @param data defines the data to use
  10886. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  10887. */
  10888. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  10889. private updateBoundingInfo(updateExtends, data);
  10890. /** @ignore */
  10891. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  10892. /**
  10893. * Gets total number of vertices
  10894. * @returns the total number of vertices
  10895. */
  10896. getTotalVertices(): number;
  10897. /**
  10898. * Gets a specific vertex data attached to this geometry
  10899. * @param kind defines the data kind (Position, normal, etc...)
  10900. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  10901. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  10902. * @returns a float array containing vertex data
  10903. */
  10904. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  10905. /**
  10906. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  10907. * @param kind defines the data kind (Position, normal, etc...)
  10908. * @returns true if the vertex buffer with the specified kind is updatable
  10909. */
  10910. isVertexBufferUpdatable(kind: string): boolean;
  10911. /**
  10912. * Gets a specific vertex buffer
  10913. * @param kind defines the data kind (Position, normal, etc...)
  10914. * @returns a {BABYLON.VertexBuffer}
  10915. */
  10916. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  10917. /**
  10918. * Returns all vertex buffers
  10919. * @return an object holding all vertex buffers indexed by kind
  10920. */
  10921. getVertexBuffers(): Nullable<{
  10922. [key: string]: VertexBuffer;
  10923. }>;
  10924. /**
  10925. * Gets a boolean indicating if specific vertex buffer is present
  10926. * @param kind defines the data kind (Position, normal, etc...)
  10927. * @returns true if data is present
  10928. */
  10929. isVerticesDataPresent(kind: string): boolean;
  10930. /**
  10931. * Gets a list of all attached data kinds (Position, normal, etc...)
  10932. * @returns a list of string containing all kinds
  10933. */
  10934. getVerticesDataKinds(): string[];
  10935. /**
  10936. * Update index buffer
  10937. * @param indices defines the indices to store in the index buffer
  10938. * @param offset defines the offset in the target buffer where to store the data
  10939. */
  10940. updateIndices(indices: IndicesArray, offset?: number): void;
  10941. /**
  10942. * Creates a new index buffer
  10943. * @param indices defines the indices to store in the index buffer
  10944. * @param totalVertices defines the total number of vertices (could be null)
  10945. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  10946. */
  10947. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  10948. /**
  10949. * Return the total number of indices
  10950. * @returns the total number of indices
  10951. */
  10952. getTotalIndices(): number;
  10953. /**
  10954. * Gets the index buffer array
  10955. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  10956. * @returns the index buffer array
  10957. */
  10958. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  10959. /**
  10960. * Gets the index buffer
  10961. * @return the index buffer
  10962. */
  10963. getIndexBuffer(): Nullable<WebGLBuffer>;
  10964. /** @ignore */
  10965. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  10966. /**
  10967. * Release the associated resources for a specific mesh
  10968. * @param mesh defines the source mesh
  10969. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  10970. */
  10971. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  10972. /**
  10973. * Apply current geometry to a given mesh
  10974. * @param mesh defines the mesh to apply geometry to
  10975. */
  10976. applyToMesh(mesh: Mesh): void;
  10977. private updateExtend(data?, stride?);
  10978. private _applyToMesh(mesh);
  10979. private notifyUpdate(kind?);
  10980. /**
  10981. * Load the geometry if it was flagged as delay loaded
  10982. * @param scene defines the hosting scene
  10983. * @param onLoaded defines a callback called when the geometry is loaded
  10984. */
  10985. load(scene: Scene, onLoaded?: () => void): void;
  10986. private _queueLoad(scene, onLoaded?);
  10987. /**
  10988. * Invert the geometry to move from a right handed system to a left handed one.
  10989. */
  10990. toLeftHanded(): void;
  10991. /** @ignore */
  10992. _resetPointsArrayCache(): void;
  10993. /** @ignore */
  10994. _generatePointsArray(): boolean;
  10995. /**
  10996. * Gets a value indicating if the geometry is disposed
  10997. * @returns true if the geometry was disposed
  10998. */
  10999. isDisposed(): boolean;
  11000. private _disposeVertexArrayObjects();
  11001. /**
  11002. * Free all associated resources
  11003. */
  11004. dispose(): void;
  11005. /**
  11006. * Clone the current geometry into a new geometry
  11007. * @param id defines the unique ID of the new geometry
  11008. * @returns a new geometry object
  11009. */
  11010. copy(id: string): Geometry;
  11011. /**
  11012. * Serialize the current geometry info (and not the vertices data) into a JSON object
  11013. * @return a JSON representation of the current geometry data (without the vertices data)
  11014. */
  11015. serialize(): any;
  11016. private toNumberArray(origin);
  11017. /**
  11018. * Serialize all vertices data into a JSON oject
  11019. * @returns a JSON representation of the current geometry data
  11020. */
  11021. serializeVerticeData(): any;
  11022. /**
  11023. * Extracts a clone of a mesh geometry
  11024. * @param mesh defines the source mesh
  11025. * @param id defines the unique ID of the new geometry object
  11026. * @returns the new geometry object
  11027. */
  11028. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  11029. /**
  11030. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  11031. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  11032. * Be aware Math.random() could cause collisions, but:
  11033. * "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"
  11034. * @returns a string containing a new GUID
  11035. */
  11036. static RandomId(): string;
  11037. /** @ignore */
  11038. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  11039. private static _CleanMatricesWeights(parsedGeometry, mesh);
  11040. /**
  11041. * Create a new geometry from persisted data (Using .babylon file format)
  11042. * @param parsedVertexData defines the persisted data
  11043. * @param scene defines the hosting scene
  11044. * @param rootUrl defines the root url to use to load assets (like delayed data)
  11045. * @returns the new geometry object
  11046. */
  11047. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  11048. }
  11049. /**
  11050. * Abstract class used to provide common services for all typed geometries
  11051. */
  11052. class _PrimitiveGeometry extends Geometry {
  11053. private _canBeRegenerated;
  11054. private _beingRegenerated;
  11055. /**
  11056. * Creates a new typed geometry
  11057. * @param id defines the unique ID of the geometry
  11058. * @param scene defines the hosting scene
  11059. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  11060. * @param mesh defines the hosting mesh (can be null)
  11061. */
  11062. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  11063. /**
  11064. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  11065. * @returns true if the geometry can be regenerated
  11066. */
  11067. canBeRegenerated(): boolean;
  11068. /**
  11069. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  11070. */
  11071. regenerate(): void;
  11072. /**
  11073. * Clone the geometry
  11074. * @param id defines the unique ID of the new geometry
  11075. * @returns the new geometry
  11076. */
  11077. asNewGeometry(id: string): Geometry;
  11078. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  11079. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  11080. /** @ignore */
  11081. _regenerateVertexData(): VertexData;
  11082. copy(id: string): Geometry;
  11083. serialize(): any;
  11084. }
  11085. /**
  11086. * Creates a ribbon geometry
  11087. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  11088. */
  11089. class RibbonGeometry extends _PrimitiveGeometry {
  11090. /**
  11091. * Defines the array of paths to use
  11092. */
  11093. pathArray: Vector3[][];
  11094. /**
  11095. * Defines if the last and first points of each path in your pathArray must be joined
  11096. */
  11097. closeArray: boolean;
  11098. /**
  11099. * Defines if the last and first points of each path in your pathArray must be joined
  11100. */
  11101. closePath: boolean;
  11102. /**
  11103. * Defines the offset between points
  11104. */
  11105. offset: number;
  11106. /**
  11107. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11108. */
  11109. side: number;
  11110. /**
  11111. * Creates a ribbon geometry
  11112. * @param id defines the unique ID of the geometry
  11113. * @param scene defines the hosting scene
  11114. * @param pathArray defines the array of paths to use
  11115. * @param closeArray defines if the last path and the first path must be joined
  11116. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  11117. * @param offset defines the offset between points
  11118. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  11119. * @param mesh defines the hosting mesh (can be null)
  11120. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11121. */
  11122. constructor(id: string, scene: Scene,
  11123. /**
  11124. * Defines the array of paths to use
  11125. */
  11126. pathArray: Vector3[][],
  11127. /**
  11128. * Defines if the last and first points of each path in your pathArray must be joined
  11129. */
  11130. closeArray: boolean,
  11131. /**
  11132. * Defines if the last and first points of each path in your pathArray must be joined
  11133. */
  11134. closePath: boolean,
  11135. /**
  11136. * Defines the offset between points
  11137. */
  11138. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  11139. /**
  11140. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11141. */
  11142. side?: number);
  11143. /** @ignore */
  11144. _regenerateVertexData(): VertexData;
  11145. copy(id: string): Geometry;
  11146. }
  11147. /**
  11148. * Creates a box geometry
  11149. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  11150. */
  11151. class BoxGeometry extends _PrimitiveGeometry {
  11152. /**
  11153. * Defines the zise of the box (width, height and depth are the same)
  11154. */
  11155. size: number;
  11156. /**
  11157. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11158. */
  11159. side: number;
  11160. /**
  11161. * Creates a box geometry
  11162. * @param id defines the unique ID of the geometry
  11163. * @param scene defines the hosting scene
  11164. * @param size defines the zise of the box (width, height and depth are the same)
  11165. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  11166. * @param mesh defines the hosting mesh (can be null)
  11167. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11168. */
  11169. constructor(id: string, scene: Scene,
  11170. /**
  11171. * Defines the zise of the box (width, height and depth are the same)
  11172. */
  11173. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  11174. /**
  11175. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11176. */
  11177. side?: number);
  11178. _regenerateVertexData(): VertexData;
  11179. copy(id: string): Geometry;
  11180. serialize(): any;
  11181. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  11182. }
  11183. /**
  11184. * Creates a sphere geometry
  11185. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  11186. */
  11187. class SphereGeometry extends _PrimitiveGeometry {
  11188. /**
  11189. * Defines the number of segments to use to create the sphere
  11190. */
  11191. segments: number;
  11192. /**
  11193. * Defines the diameter of the sphere
  11194. */
  11195. diameter: number;
  11196. /**
  11197. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11198. */
  11199. side: number;
  11200. /**
  11201. * Create a new sphere geometry
  11202. * @param id defines the unique ID of the geometry
  11203. * @param scene defines the hosting scene
  11204. * @param segments defines the number of segments to use to create the sphere
  11205. * @param diameter defines the diameter of the sphere
  11206. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  11207. * @param mesh defines the hosting mesh (can be null)
  11208. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11209. */
  11210. constructor(id: string, scene: Scene,
  11211. /**
  11212. * Defines the number of segments to use to create the sphere
  11213. */
  11214. segments: number,
  11215. /**
  11216. * Defines the diameter of the sphere
  11217. */
  11218. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  11219. /**
  11220. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11221. */
  11222. side?: number);
  11223. _regenerateVertexData(): VertexData;
  11224. copy(id: string): Geometry;
  11225. serialize(): any;
  11226. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  11227. }
  11228. /**
  11229. * Creates a disc geometry
  11230. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  11231. */
  11232. class DiscGeometry extends _PrimitiveGeometry {
  11233. /**
  11234. * Defines the radius of the disc
  11235. */
  11236. radius: number;
  11237. /**
  11238. * Defines the tesselation factor to apply to the disc
  11239. */
  11240. tessellation: number;
  11241. /**
  11242. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11243. */
  11244. side: number;
  11245. /**
  11246. * Creates a new disc geometry
  11247. * @param id defines the unique ID of the geometry
  11248. * @param scene defines the hosting scene
  11249. * @param radius defines the radius of the disc
  11250. * @param tessellation defines the tesselation factor to apply to the disc
  11251. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  11252. * @param mesh defines the hosting mesh (can be null)
  11253. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11254. */
  11255. constructor(id: string, scene: Scene,
  11256. /**
  11257. * Defines the radius of the disc
  11258. */
  11259. radius: number,
  11260. /**
  11261. * Defines the tesselation factor to apply to the disc
  11262. */
  11263. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  11264. /**
  11265. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11266. */
  11267. side?: number);
  11268. _regenerateVertexData(): VertexData;
  11269. copy(id: string): Geometry;
  11270. }
  11271. /**
  11272. * Creates a new cylinder geometry
  11273. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  11274. */
  11275. class CylinderGeometry extends _PrimitiveGeometry {
  11276. /**
  11277. * Defines the height of the cylinder
  11278. */
  11279. height: number;
  11280. /**
  11281. * Defines the diameter of the cylinder's top cap
  11282. */
  11283. diameterTop: number;
  11284. /**
  11285. * Defines the diameter of the cylinder's bottom cap
  11286. */
  11287. diameterBottom: number;
  11288. /**
  11289. * Defines the tessellation factor to apply to the cylinder
  11290. */
  11291. tessellation: number;
  11292. /**
  11293. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  11294. */
  11295. subdivisions: number;
  11296. /**
  11297. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11298. */
  11299. side: number;
  11300. /**
  11301. * Creates a new cylinder geometry
  11302. * @param id defines the unique ID of the geometry
  11303. * @param scene defines the hosting scene
  11304. * @param height defines the height of the cylinder
  11305. * @param diameterTop defines the diameter of the cylinder's top cap
  11306. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  11307. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  11308. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  11309. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  11310. * @param mesh defines the hosting mesh (can be null)
  11311. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11312. */
  11313. constructor(id: string, scene: Scene,
  11314. /**
  11315. * Defines the height of the cylinder
  11316. */
  11317. height: number,
  11318. /**
  11319. * Defines the diameter of the cylinder's top cap
  11320. */
  11321. diameterTop: number,
  11322. /**
  11323. * Defines the diameter of the cylinder's bottom cap
  11324. */
  11325. diameterBottom: number,
  11326. /**
  11327. * Defines the tessellation factor to apply to the cylinder
  11328. */
  11329. tessellation: number,
  11330. /**
  11331. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  11332. */
  11333. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  11334. /**
  11335. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11336. */
  11337. side?: number);
  11338. _regenerateVertexData(): VertexData;
  11339. copy(id: string): Geometry;
  11340. serialize(): any;
  11341. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  11342. }
  11343. /**
  11344. * Creates a new torus geometry
  11345. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  11346. */
  11347. class TorusGeometry extends _PrimitiveGeometry {
  11348. /**
  11349. * Defines the diameter of the torus
  11350. */
  11351. diameter: number;
  11352. /**
  11353. * Defines the thickness of the torus (ie. internal diameter)
  11354. */
  11355. thickness: number;
  11356. /**
  11357. * Defines the tesselation factor to apply to the torus
  11358. */
  11359. tessellation: number;
  11360. /**
  11361. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11362. */
  11363. side: number;
  11364. /**
  11365. * Creates a new torus geometry
  11366. * @param id defines the unique ID of the geometry
  11367. * @param scene defines the hosting scene
  11368. * @param diameter defines the diameter of the torus
  11369. * @param thickness defines the thickness of the torus (ie. internal diameter)
  11370. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  11371. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  11372. * @param mesh defines the hosting mesh (can be null)
  11373. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11374. */
  11375. constructor(id: string, scene: Scene,
  11376. /**
  11377. * Defines the diameter of the torus
  11378. */
  11379. diameter: number,
  11380. /**
  11381. * Defines the thickness of the torus (ie. internal diameter)
  11382. */
  11383. thickness: number,
  11384. /**
  11385. * Defines the tesselation factor to apply to the torus
  11386. */
  11387. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  11388. /**
  11389. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11390. */
  11391. side?: number);
  11392. _regenerateVertexData(): VertexData;
  11393. copy(id: string): Geometry;
  11394. serialize(): any;
  11395. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  11396. }
  11397. /**
  11398. * Creates a new ground geometry
  11399. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  11400. */
  11401. class GroundGeometry extends _PrimitiveGeometry {
  11402. /**
  11403. * Defines the width of the ground
  11404. */
  11405. width: number;
  11406. /**
  11407. * Defines the height of the ground
  11408. */
  11409. height: number;
  11410. /**
  11411. * Defines the subdivisions to apply to the ground
  11412. */
  11413. subdivisions: number;
  11414. /**
  11415. * Creates a new ground geometry
  11416. * @param id defines the unique ID of the geometry
  11417. * @param scene defines the hosting scene
  11418. * @param width defines the width of the ground
  11419. * @param height defines the height of the ground
  11420. * @param subdivisions defines the subdivisions to apply to the ground
  11421. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  11422. * @param mesh defines the hosting mesh (can be null)
  11423. */
  11424. constructor(id: string, scene: Scene,
  11425. /**
  11426. * Defines the width of the ground
  11427. */
  11428. width: number,
  11429. /**
  11430. * Defines the height of the ground
  11431. */
  11432. height: number,
  11433. /**
  11434. * Defines the subdivisions to apply to the ground
  11435. */
  11436. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  11437. _regenerateVertexData(): VertexData;
  11438. copy(id: string): Geometry;
  11439. serialize(): any;
  11440. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  11441. }
  11442. /**
  11443. * Creates a tiled ground geometry
  11444. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  11445. */
  11446. class TiledGroundGeometry extends _PrimitiveGeometry {
  11447. /**
  11448. * Defines the minimum value on X axis
  11449. */
  11450. xmin: number;
  11451. /**
  11452. * Defines the minimum value on Z axis
  11453. */
  11454. zmin: number;
  11455. /**
  11456. * Defines the maximum value on X axis
  11457. */
  11458. xmax: number;
  11459. /**
  11460. * Defines the maximum value on Z axis
  11461. */
  11462. zmax: number;
  11463. /**
  11464. * Defines the subdivisions to apply to the ground
  11465. */
  11466. subdivisions: {
  11467. w: number;
  11468. h: number;
  11469. };
  11470. /**
  11471. * Defines the precision to use when computing the tiles
  11472. */
  11473. precision: {
  11474. w: number;
  11475. h: number;
  11476. };
  11477. /**
  11478. * Creates a tiled ground geometry
  11479. * @param id defines the unique ID of the geometry
  11480. * @param scene defines the hosting scene
  11481. * @param xmin defines the minimum value on X axis
  11482. * @param zmin defines the minimum value on Z axis
  11483. * @param xmax defines the maximum value on X axis
  11484. * @param zmax defines the maximum value on Z axis
  11485. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  11486. * @param precision defines the precision to use when computing the tiles
  11487. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  11488. * @param mesh defines the hosting mesh (can be null)
  11489. */
  11490. constructor(id: string, scene: Scene,
  11491. /**
  11492. * Defines the minimum value on X axis
  11493. */
  11494. xmin: number,
  11495. /**
  11496. * Defines the minimum value on Z axis
  11497. */
  11498. zmin: number,
  11499. /**
  11500. * Defines the maximum value on X axis
  11501. */
  11502. xmax: number,
  11503. /**
  11504. * Defines the maximum value on Z axis
  11505. */
  11506. zmax: number,
  11507. /**
  11508. * Defines the subdivisions to apply to the ground
  11509. */
  11510. subdivisions: {
  11511. w: number;
  11512. h: number;
  11513. },
  11514. /**
  11515. * Defines the precision to use when computing the tiles
  11516. */
  11517. precision: {
  11518. w: number;
  11519. h: number;
  11520. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  11521. _regenerateVertexData(): VertexData;
  11522. copy(id: string): Geometry;
  11523. }
  11524. /**
  11525. * Creates a plane geometry
  11526. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  11527. */
  11528. class PlaneGeometry extends _PrimitiveGeometry {
  11529. /**
  11530. * Defines the size of the plane (width === height)
  11531. */
  11532. size: number;
  11533. /**
  11534. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11535. */
  11536. side: number;
  11537. /**
  11538. * Creates a plane geometry
  11539. * @param id defines the unique ID of the geometry
  11540. * @param scene defines the hosting scene
  11541. * @param size defines the size of the plane (width === height)
  11542. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  11543. * @param mesh defines the hosting mesh (can be null)
  11544. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11545. */
  11546. constructor(id: string, scene: Scene,
  11547. /**
  11548. * Defines the size of the plane (width === height)
  11549. */
  11550. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  11551. /**
  11552. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11553. */
  11554. side?: number);
  11555. _regenerateVertexData(): VertexData;
  11556. copy(id: string): Geometry;
  11557. serialize(): any;
  11558. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  11559. }
  11560. /**
  11561. * Creates a torus knot geometry
  11562. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  11563. */
  11564. class TorusKnotGeometry extends _PrimitiveGeometry {
  11565. /**
  11566. * Defines the radius of the torus knot
  11567. */
  11568. radius: number;
  11569. /**
  11570. * Defines the thickness of the torus knot tube
  11571. */
  11572. tube: number;
  11573. /**
  11574. * Defines the number of radial segments
  11575. */
  11576. radialSegments: number;
  11577. /**
  11578. * Defines the number of tubular segments
  11579. */
  11580. tubularSegments: number;
  11581. /**
  11582. * Defines the first number of windings
  11583. */
  11584. p: number;
  11585. /**
  11586. * Defines the second number of windings
  11587. */
  11588. q: number;
  11589. /**
  11590. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11591. */
  11592. side: number;
  11593. /**
  11594. * Creates a torus knot geometry
  11595. * @param id defines the unique ID of the geometry
  11596. * @param scene defines the hosting scene
  11597. * @param radius defines the radius of the torus knot
  11598. * @param tube defines the thickness of the torus knot tube
  11599. * @param radialSegments defines the number of radial segments
  11600. * @param tubularSegments defines the number of tubular segments
  11601. * @param p defines the first number of windings
  11602. * @param q defines the second number of windings
  11603. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  11604. * @param mesh defines the hosting mesh (can be null)
  11605. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11606. */
  11607. constructor(id: string, scene: Scene,
  11608. /**
  11609. * Defines the radius of the torus knot
  11610. */
  11611. radius: number,
  11612. /**
  11613. * Defines the thickness of the torus knot tube
  11614. */
  11615. tube: number,
  11616. /**
  11617. * Defines the number of radial segments
  11618. */
  11619. radialSegments: number,
  11620. /**
  11621. * Defines the number of tubular segments
  11622. */
  11623. tubularSegments: number,
  11624. /**
  11625. * Defines the first number of windings
  11626. */
  11627. p: number,
  11628. /**
  11629. * Defines the second number of windings
  11630. */
  11631. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  11632. /**
  11633. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  11634. */
  11635. side?: number);
  11636. _regenerateVertexData(): VertexData;
  11637. copy(id: string): Geometry;
  11638. serialize(): any;
  11639. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  11640. }
  11641. }
  11642. declare module BABYLON {
  11643. class GroundMesh extends Mesh {
  11644. generateOctree: boolean;
  11645. private _heightQuads;
  11646. _subdivisionsX: number;
  11647. _subdivisionsY: number;
  11648. _width: number;
  11649. _height: number;
  11650. _minX: number;
  11651. _maxX: number;
  11652. _minZ: number;
  11653. _maxZ: number;
  11654. constructor(name: string, scene: Scene);
  11655. getClassName(): string;
  11656. readonly subdivisions: number;
  11657. readonly subdivisionsX: number;
  11658. readonly subdivisionsY: number;
  11659. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  11660. /**
  11661. * Returns a height (y) value in the Worl system :
  11662. * the ground altitude at the coordinates (x, z) expressed in the World system.
  11663. * Returns the ground y position if (x, z) are outside the ground surface.
  11664. */
  11665. getHeightAtCoordinates(x: number, z: number): number;
  11666. /**
  11667. * Returns a normalized vector (Vector3) orthogonal to the ground
  11668. * at the ground coordinates (x, z) expressed in the World system.
  11669. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  11670. */
  11671. getNormalAtCoordinates(x: number, z: number): Vector3;
  11672. /**
  11673. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  11674. * at the ground coordinates (x, z) expressed in the World system.
  11675. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  11676. * Returns the GroundMesh.
  11677. */
  11678. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  11679. /**
  11680. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  11681. * if the ground has been updated.
  11682. * This can be used in the render loop.
  11683. * Returns the GroundMesh.
  11684. */
  11685. updateCoordinateHeights(): GroundMesh;
  11686. private _getFacetAt(x, z);
  11687. private _initHeightQuads();
  11688. private _computeHeightQuads();
  11689. serialize(serializationObject: any): void;
  11690. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  11691. }
  11692. }
  11693. declare module BABYLON {
  11694. /**
  11695. * Creates an instance based on a source mesh.
  11696. */
  11697. class InstancedMesh extends AbstractMesh {
  11698. private _sourceMesh;
  11699. private _currentLOD;
  11700. constructor(name: string, source: Mesh);
  11701. /**
  11702. * Returns the string "InstancedMesh".
  11703. */
  11704. getClassName(): string;
  11705. readonly receiveShadows: boolean;
  11706. readonly material: Nullable<Material>;
  11707. readonly visibility: number;
  11708. readonly skeleton: Nullable<Skeleton>;
  11709. readonly renderingGroupId: number;
  11710. /**
  11711. * Returns the total number of vertices (integer).
  11712. */
  11713. getTotalVertices(): number;
  11714. readonly sourceMesh: Mesh;
  11715. /**
  11716. * Is this node ready to be used/rendered
  11717. * @return {boolean} is it ready
  11718. */
  11719. isReady(): boolean;
  11720. /**
  11721. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  11722. */
  11723. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  11724. /**
  11725. * Sets the vertex data of the mesh geometry for the requested `kind`.
  11726. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  11727. * The `data` are either a numeric array either a Float32Array.
  11728. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  11729. * 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).
  11730. * Note that a new underlying VertexBuffer object is created each call.
  11731. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  11732. *
  11733. * Possible `kind` values :
  11734. * - BABYLON.VertexBuffer.PositionKind
  11735. * - BABYLON.VertexBuffer.UVKind
  11736. * - BABYLON.VertexBuffer.UV2Kind
  11737. * - BABYLON.VertexBuffer.UV3Kind
  11738. * - BABYLON.VertexBuffer.UV4Kind
  11739. * - BABYLON.VertexBuffer.UV5Kind
  11740. * - BABYLON.VertexBuffer.UV6Kind
  11741. * - BABYLON.VertexBuffer.ColorKind
  11742. * - BABYLON.VertexBuffer.MatricesIndicesKind
  11743. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  11744. * - BABYLON.VertexBuffer.MatricesWeightsKind
  11745. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  11746. *
  11747. * Returns the Mesh.
  11748. */
  11749. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  11750. /**
  11751. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  11752. * If the mesh has no geometry, it is simply returned as it is.
  11753. * The `data` are either a numeric array either a Float32Array.
  11754. * No new underlying VertexBuffer object is created.
  11755. * 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.
  11756. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  11757. *
  11758. * Possible `kind` values :
  11759. * - BABYLON.VertexBuffer.PositionKind
  11760. * - BABYLON.VertexBuffer.UVKind
  11761. * - BABYLON.VertexBuffer.UV2Kind
  11762. * - BABYLON.VertexBuffer.UV3Kind
  11763. * - BABYLON.VertexBuffer.UV4Kind
  11764. * - BABYLON.VertexBuffer.UV5Kind
  11765. * - BABYLON.VertexBuffer.UV6Kind
  11766. * - BABYLON.VertexBuffer.ColorKind
  11767. * - BABYLON.VertexBuffer.MatricesIndicesKind
  11768. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  11769. * - BABYLON.VertexBuffer.MatricesWeightsKind
  11770. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  11771. *
  11772. * Returns the Mesh.
  11773. */
  11774. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  11775. /**
  11776. * Sets the mesh indices.
  11777. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  11778. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  11779. * This method creates a new index buffer each call.
  11780. * Returns the Mesh.
  11781. */
  11782. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  11783. /**
  11784. * Boolean : True if the mesh owns the requested kind of data.
  11785. */
  11786. isVerticesDataPresent(kind: string): boolean;
  11787. /**
  11788. * Returns an array of indices (IndicesArray).
  11789. */
  11790. getIndices(): Nullable<IndicesArray>;
  11791. readonly _positions: Nullable<Vector3[]>;
  11792. /**
  11793. * Sets a new updated BoundingInfo to the mesh.
  11794. * Returns the mesh.
  11795. */
  11796. refreshBoundingInfo(): InstancedMesh;
  11797. _preActivate(): InstancedMesh;
  11798. _activate(renderId: number): InstancedMesh;
  11799. /**
  11800. * Returns the current associated LOD AbstractMesh.
  11801. */
  11802. getLOD(camera: Camera): AbstractMesh;
  11803. _syncSubMeshes(): InstancedMesh;
  11804. _generatePointsArray(): boolean;
  11805. /**
  11806. * Creates a new InstancedMesh from the current mesh.
  11807. * - name (string) : the cloned mesh name
  11808. * - newParent (optional Node) : the optional Node to parent the clone to.
  11809. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  11810. *
  11811. * Returns the clone.
  11812. */
  11813. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  11814. /**
  11815. * Disposes the InstancedMesh.
  11816. * Returns nothing.
  11817. */
  11818. dispose(doNotRecurse?: boolean): void;
  11819. }
  11820. }
  11821. declare module BABYLON {
  11822. class LinesMesh extends Mesh {
  11823. useVertexColor: boolean | undefined;
  11824. useVertexAlpha: boolean | undefined;
  11825. color: Color3;
  11826. alpha: number;
  11827. /**
  11828. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  11829. * This margin is expressed in world space coordinates, so its value may vary.
  11830. * Default value is 0.1
  11831. * @returns the intersection Threshold value.
  11832. */
  11833. /**
  11834. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  11835. * This margin is expressed in world space coordinates, so its value may vary.
  11836. * @param value the new threshold to apply
  11837. */
  11838. intersectionThreshold: number;
  11839. private _intersectionThreshold;
  11840. private _colorShader;
  11841. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  11842. /**
  11843. * Returns the string "LineMesh"
  11844. */
  11845. getClassName(): string;
  11846. material: Material;
  11847. readonly checkCollisions: boolean;
  11848. createInstance(name: string): InstancedMesh;
  11849. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  11850. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  11851. dispose(doNotRecurse?: boolean): void;
  11852. /**
  11853. * Returns a new LineMesh object cloned from the current one.
  11854. */
  11855. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  11856. }
  11857. }
  11858. declare module BABYLON {
  11859. class _InstancesBatch {
  11860. mustReturn: boolean;
  11861. visibleInstances: Nullable<InstancedMesh[]>[];
  11862. renderSelf: boolean[];
  11863. }
  11864. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  11865. static _FRONTSIDE: number;
  11866. static _BACKSIDE: number;
  11867. static _DOUBLESIDE: number;
  11868. static _DEFAULTSIDE: number;
  11869. static _NO_CAP: number;
  11870. static _CAP_START: number;
  11871. static _CAP_END: number;
  11872. static _CAP_ALL: number;
  11873. /**
  11874. * Mesh side orientation : usually the external or front surface
  11875. */
  11876. static readonly FRONTSIDE: number;
  11877. /**
  11878. * Mesh side orientation : usually the internal or back surface
  11879. */
  11880. static readonly BACKSIDE: number;
  11881. /**
  11882. * Mesh side orientation : both internal and external or front and back surfaces
  11883. */
  11884. static readonly DOUBLESIDE: number;
  11885. /**
  11886. * Mesh side orientation : by default, `FRONTSIDE`
  11887. */
  11888. static readonly DEFAULTSIDE: number;
  11889. /**
  11890. * Mesh cap setting : no cap
  11891. */
  11892. static readonly NO_CAP: number;
  11893. /**
  11894. * Mesh cap setting : one cap at the beginning of the mesh
  11895. */
  11896. static readonly CAP_START: number;
  11897. /**
  11898. * Mesh cap setting : one cap at the end of the mesh
  11899. */
  11900. static readonly CAP_END: number;
  11901. /**
  11902. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  11903. */
  11904. static readonly CAP_ALL: number;
  11905. /**
  11906. * An event triggered before rendering the mesh
  11907. * @type {BABYLON.Observable}
  11908. */
  11909. onBeforeRenderObservable: Observable<Mesh>;
  11910. /**
  11911. * An event triggered after rendering the mesh
  11912. * @type {BABYLON.Observable}
  11913. */
  11914. onAfterRenderObservable: Observable<Mesh>;
  11915. /**
  11916. * An event triggered before drawing the mesh
  11917. * @type {BABYLON.Observable}
  11918. */
  11919. onBeforeDrawObservable: Observable<Mesh>;
  11920. private _onBeforeDrawObserver;
  11921. onBeforeDraw: () => void;
  11922. delayLoadState: number;
  11923. instances: InstancedMesh[];
  11924. delayLoadingFile: string;
  11925. _binaryInfo: any;
  11926. private _LODLevels;
  11927. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  11928. private _morphTargetManager;
  11929. morphTargetManager: Nullable<MorphTargetManager>;
  11930. _geometry: Nullable<Geometry>;
  11931. _delayInfo: Array<string>;
  11932. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  11933. _visibleInstances: any;
  11934. private _renderIdForInstances;
  11935. private _batchCache;
  11936. private _instancesBufferSize;
  11937. private _instancesBuffer;
  11938. private _instancesData;
  11939. private _overridenInstanceCount;
  11940. private _effectiveMaterial;
  11941. _shouldGenerateFlatShading: boolean;
  11942. private _preActivateId;
  11943. _originalBuilderSideOrientation: number;
  11944. overrideMaterialSideOrientation: Nullable<number>;
  11945. private _areNormalsFrozen;
  11946. private _sourcePositions;
  11947. private _sourceNormals;
  11948. private _source;
  11949. readonly source: Nullable<Mesh>;
  11950. isUnIndexed: boolean;
  11951. /**
  11952. * @constructor
  11953. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  11954. * @param {Scene} scene The scene to add this mesh to.
  11955. * @param {Node} parent The parent of this mesh, if it has one
  11956. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  11957. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  11958. * When false, achieved by calling a clone(), also passing False.
  11959. * This will make creation of children, recursive.
  11960. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  11961. */
  11962. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  11963. /**
  11964. * Returns the string "Mesh".
  11965. */
  11966. getClassName(): string;
  11967. /**
  11968. * Returns a string.
  11969. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  11970. */
  11971. toString(fullDetails?: boolean): string;
  11972. /**
  11973. * True if the mesh has some Levels Of Details (LOD).
  11974. * Returns a boolean.
  11975. */
  11976. readonly hasLODLevels: boolean;
  11977. /**
  11978. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  11979. * @returns an array of {BABYLON.MeshLODLevel}
  11980. */
  11981. getLODLevels(): MeshLODLevel[];
  11982. private _sortLODLevels();
  11983. /**
  11984. * Add a mesh as LOD level triggered at the given distance.
  11985. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  11986. * @param {number} distance The distance from the center of the object to show this level
  11987. * @param {Mesh} mesh The mesh to be added as LOD level
  11988. * @return {Mesh} This mesh (for chaining)
  11989. */
  11990. addLODLevel(distance: number, mesh: Mesh): Mesh;
  11991. /**
  11992. * Returns the LOD level mesh at the passed distance or null if not found.
  11993. * It is related to the method `addLODLevel(distance, mesh)`.
  11994. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  11995. * Returns an object Mesh or `null`.
  11996. */
  11997. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  11998. /**
  11999. * Remove a mesh from the LOD array
  12000. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  12001. * @param {Mesh} mesh The mesh to be removed.
  12002. * @return {Mesh} This mesh (for chaining)
  12003. */
  12004. removeLODLevel(mesh: Mesh): Mesh;
  12005. /**
  12006. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  12007. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  12008. */
  12009. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  12010. /**
  12011. * Returns the mesh internal Geometry object.
  12012. */
  12013. readonly geometry: Nullable<Geometry>;
  12014. /**
  12015. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  12016. */
  12017. getTotalVertices(): number;
  12018. /**
  12019. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  12020. * 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.
  12021. * You can force the copy with forceCopy === true
  12022. * Returns null if the mesh has no geometry or no vertex buffer.
  12023. * Possible `kind` values :
  12024. * - BABYLON.VertexBuffer.PositionKind
  12025. * - BABYLON.VertexBuffer.UVKind
  12026. * - BABYLON.VertexBuffer.UV2Kind
  12027. * - BABYLON.VertexBuffer.UV3Kind
  12028. * - BABYLON.VertexBuffer.UV4Kind
  12029. * - BABYLON.VertexBuffer.UV5Kind
  12030. * - BABYLON.VertexBuffer.UV6Kind
  12031. * - BABYLON.VertexBuffer.ColorKind
  12032. * - BABYLON.VertexBuffer.MatricesIndicesKind
  12033. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  12034. * - BABYLON.VertexBuffer.MatricesWeightsKind
  12035. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  12036. */
  12037. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  12038. /**
  12039. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  12040. * Returns `null` if the mesh has no geometry.
  12041. * Possible `kind` values :
  12042. * - BABYLON.VertexBuffer.PositionKind
  12043. * - BABYLON.VertexBuffer.UVKind
  12044. * - BABYLON.VertexBuffer.UV2Kind
  12045. * - BABYLON.VertexBuffer.UV3Kind
  12046. * - BABYLON.VertexBuffer.UV4Kind
  12047. * - BABYLON.VertexBuffer.UV5Kind
  12048. * - BABYLON.VertexBuffer.UV6Kind
  12049. * - BABYLON.VertexBuffer.ColorKind
  12050. * - BABYLON.VertexBuffer.MatricesIndicesKind
  12051. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  12052. * - BABYLON.VertexBuffer.MatricesWeightsKind
  12053. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  12054. */
  12055. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  12056. /**
  12057. * Returns a boolean depending on the existence of the Vertex Data for the requested `kind`.
  12058. * Possible `kind` values :
  12059. * - BABYLON.VertexBuffer.PositionKind
  12060. * - BABYLON.VertexBuffer.UVKind
  12061. * - BABYLON.VertexBuffer.UV2Kind
  12062. * - BABYLON.VertexBuffer.UV3Kind
  12063. * - BABYLON.VertexBuffer.UV4Kind
  12064. * - BABYLON.VertexBuffer.UV5Kind
  12065. * - BABYLON.VertexBuffer.UV6Kind
  12066. * - BABYLON.VertexBuffer.ColorKind
  12067. * - BABYLON.VertexBuffer.MatricesIndicesKind
  12068. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  12069. * - BABYLON.VertexBuffer.MatricesWeightsKind
  12070. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  12071. */
  12072. isVerticesDataPresent(kind: string): boolean;
  12073. /**
  12074. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  12075. * Possible `kind` values :
  12076. * - BABYLON.VertexBuffer.PositionKind
  12077. * - BABYLON.VertexBuffer.UVKind
  12078. * - BABYLON.VertexBuffer.UV2Kind
  12079. * - BABYLON.VertexBuffer.UV3Kind
  12080. * - BABYLON.VertexBuffer.UV4Kind
  12081. * - BABYLON.VertexBuffer.UV5Kind
  12082. * - BABYLON.VertexBuffer.UV6Kind
  12083. * - BABYLON.VertexBuffer.ColorKind
  12084. * - BABYLON.VertexBuffer.MatricesIndicesKind
  12085. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  12086. * - BABYLON.VertexBuffer.MatricesWeightsKind
  12087. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  12088. */
  12089. isVertexBufferUpdatable(kind: string): boolean;
  12090. /**
  12091. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  12092. * Possible `kind` values :
  12093. * - BABYLON.VertexBuffer.PositionKind
  12094. * - BABYLON.VertexBuffer.UVKind
  12095. * - BABYLON.VertexBuffer.UV2Kind
  12096. * - BABYLON.VertexBuffer.UV3Kind
  12097. * - BABYLON.VertexBuffer.UV4Kind
  12098. * - BABYLON.VertexBuffer.UV5Kind
  12099. * - BABYLON.VertexBuffer.UV6Kind
  12100. * - BABYLON.VertexBuffer.ColorKind
  12101. * - BABYLON.VertexBuffer.MatricesIndicesKind
  12102. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  12103. * - BABYLON.VertexBuffer.MatricesWeightsKind
  12104. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  12105. */
  12106. getVerticesDataKinds(): string[];
  12107. /**
  12108. * Returns a positive integer : the total number of indices in this mesh geometry.
  12109. * Returns zero if the mesh has no geometry.
  12110. */
  12111. getTotalIndices(): number;
  12112. /**
  12113. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12114. * 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.
  12115. * Returns an empty array if the mesh has no geometry.
  12116. */
  12117. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  12118. readonly isBlocked: boolean;
  12119. /**
  12120. * Determine if the current mesh is ready to be rendered
  12121. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  12122. * @returns true if all associated assets are ready (material, textures, shaders)
  12123. */
  12124. isReady(forceInstanceSupport?: boolean): boolean;
  12125. /**
  12126. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  12127. * This property is pertinent only for updatable parametric shapes.
  12128. */
  12129. readonly areNormalsFrozen: boolean;
  12130. /**
  12131. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  12132. * It has no effect at all on other shapes.
  12133. * It prevents the mesh normals from being recomputed on next `positions` array update.
  12134. * Returns the Mesh.
  12135. */
  12136. freezeNormals(): Mesh;
  12137. /**
  12138. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  12139. * It has no effect at all on other shapes.
  12140. * It reactivates the mesh normals computation if it was previously frozen.
  12141. * Returns the Mesh.
  12142. */
  12143. unfreezeNormals(): Mesh;
  12144. /**
  12145. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  12146. */
  12147. overridenInstanceCount: number;
  12148. _preActivate(): Mesh;
  12149. _preActivateForIntermediateRendering(renderId: number): Mesh;
  12150. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  12151. /**
  12152. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12153. * This means the mesh underlying bounding box and sphere are recomputed.
  12154. * Returns the Mesh.
  12155. */
  12156. refreshBoundingInfo(): Mesh;
  12157. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  12158. private _getPositionData(applySkeleton);
  12159. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  12160. subdivide(count: number): void;
  12161. /**
  12162. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12163. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12164. * The `data` are either a numeric array either a Float32Array.
  12165. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12166. * 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).
  12167. * Note that a new underlying VertexBuffer object is created each call.
  12168. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12169. *
  12170. * Possible `kind` values :
  12171. * - BABYLON.VertexBuffer.PositionKind
  12172. * - BABYLON.VertexBuffer.UVKind
  12173. * - BABYLON.VertexBuffer.UV2Kind
  12174. * - BABYLON.VertexBuffer.UV3Kind
  12175. * - BABYLON.VertexBuffer.UV4Kind
  12176. * - BABYLON.VertexBuffer.UV5Kind
  12177. * - BABYLON.VertexBuffer.UV6Kind
  12178. * - BABYLON.VertexBuffer.ColorKind
  12179. * - BABYLON.VertexBuffer.MatricesIndicesKind
  12180. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  12181. * - BABYLON.VertexBuffer.MatricesWeightsKind
  12182. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  12183. *
  12184. * Returns the Mesh.
  12185. */
  12186. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12187. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  12188. /**
  12189. * Sets the mesh VertexBuffer.
  12190. * Returns the Mesh.
  12191. */
  12192. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  12193. /**
  12194. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12195. * If the mesh has no geometry, it is simply returned as it is.
  12196. * The `data` are either a numeric array either a Float32Array.
  12197. * No new underlying VertexBuffer object is created.
  12198. * 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.
  12199. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12200. *
  12201. * Possible `kind` values :
  12202. * - BABYLON.VertexBuffer.PositionKind
  12203. * - BABYLON.VertexBuffer.UVKind
  12204. * - BABYLON.VertexBuffer.UV2Kind
  12205. * - BABYLON.VertexBuffer.UV3Kind
  12206. * - BABYLON.VertexBuffer.UV4Kind
  12207. * - BABYLON.VertexBuffer.UV5Kind
  12208. * - BABYLON.VertexBuffer.UV6Kind
  12209. * - BABYLON.VertexBuffer.ColorKind
  12210. * - BABYLON.VertexBuffer.MatricesIndicesKind
  12211. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  12212. * - BABYLON.VertexBuffer.MatricesWeightsKind
  12213. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  12214. *
  12215. * Returns the Mesh.
  12216. */
  12217. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12218. /**
  12219. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  12220. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  12221. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  12222. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  12223. * Returns the Mesh.
  12224. */
  12225. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  12226. /**
  12227. * Creates a un-shared specific occurence of the geometry for the mesh.
  12228. * Returns the Mesh.
  12229. */
  12230. makeGeometryUnique(): Mesh;
  12231. /**
  12232. * Sets the mesh indices.
  12233. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12234. * Type is Uint16Array by default unless the mesh has more than 65536 vertices.
  12235. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12236. * This method creates a new index buffer each call.
  12237. * Returns the Mesh.
  12238. */
  12239. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  12240. /**
  12241. * Update the current index buffer
  12242. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  12243. * Returns the Mesh.
  12244. */
  12245. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  12246. /**
  12247. * Invert the geometry to move from a right handed system to a left handed one.
  12248. * Returns the Mesh.
  12249. */
  12250. toLeftHanded(): Mesh;
  12251. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  12252. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  12253. /**
  12254. * Registers for this mesh a javascript function called just before the rendering process.
  12255. * This function is passed the current mesh.
  12256. * Return the Mesh.
  12257. */
  12258. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  12259. /**
  12260. * Disposes a previously registered javascript function called before the rendering.
  12261. * This function is passed the current mesh.
  12262. * Returns the Mesh.
  12263. */
  12264. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  12265. /**
  12266. * Registers for this mesh a javascript function called just after the rendering is complete.
  12267. * This function is passed the current mesh.
  12268. * Returns the Mesh.
  12269. */
  12270. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  12271. /**
  12272. * Disposes a previously registered javascript function called after the rendering.
  12273. * This function is passed the current mesh.
  12274. * Return the Mesh.
  12275. */
  12276. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  12277. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  12278. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  12279. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  12280. /**
  12281. * Triggers the draw call for the mesh.
  12282. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  12283. * Returns the Mesh.
  12284. */
  12285. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  12286. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  12287. /**
  12288. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  12289. */
  12290. getEmittedParticleSystems(): IParticleSystem[];
  12291. /**
  12292. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  12293. */
  12294. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  12295. _checkDelayState(): Mesh;
  12296. private _queueLoad(scene);
  12297. /**
  12298. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  12299. */
  12300. isInFrustum(frustumPlanes: Plane[]): boolean;
  12301. /**
  12302. * Sets the mesh material by the material or multiMaterial `id` property.
  12303. * The material `id` is a string identifying the material or the multiMaterial.
  12304. * This method returns the Mesh.
  12305. */
  12306. setMaterialByID(id: string): Mesh;
  12307. /**
  12308. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  12309. */
  12310. getAnimatables(): IAnimatable[];
  12311. /**
  12312. * Modifies the mesh geometry according to the passed transformation matrix.
  12313. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  12314. * The mesh normals are modified accordingly the same transformation.
  12315. * tuto : http://doc.babylonjs.com/tutorials/How_Rotations_and_Translations_Work#baking-transform
  12316. * Note that, under the hood, this method sets a new VertexBuffer each call.
  12317. * Returns the Mesh.
  12318. */
  12319. bakeTransformIntoVertices(transform: Matrix): Mesh;
  12320. /**
  12321. * Modifies the mesh geometry according to its own current World Matrix.
  12322. * The mesh World Matrix is then reset.
  12323. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  12324. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  12325. * Note that, under the hood, this method sets a new VertexBuffer each call.
  12326. * Returns the Mesh.
  12327. */
  12328. bakeCurrentTransformIntoVertices(): Mesh;
  12329. readonly _positions: Nullable<Vector3[]>;
  12330. _resetPointsArrayCache(): Mesh;
  12331. _generatePointsArray(): boolean;
  12332. /**
  12333. * Returns a new Mesh object generated from the current mesh properties.
  12334. * This method must not get confused with createInstance().
  12335. * The parameter `name` is a string, the name given to the new mesh.
  12336. * The optional parameter `newParent` can be any Node object (default `null`).
  12337. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  12338. * 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.
  12339. */
  12340. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  12341. /**
  12342. * Disposes the Mesh.
  12343. * By default, all the mesh children are also disposed unless the parameter `doNotRecurse` is set to `true`.
  12344. * Returns nothing.
  12345. */
  12346. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12347. /**
  12348. * Modifies the mesh geometry according to a displacement map.
  12349. * 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.
  12350. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  12351. * This method returns nothing.
  12352. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  12353. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  12354. * 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.
  12355. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  12356. * The parameter `uvScale` is an optional vector2 used to scale UV.
  12357. *
  12358. * Returns the Mesh.
  12359. */
  12360. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  12361. /**
  12362. * Modifies the mesh geometry according to a displacementMap buffer.
  12363. * 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.
  12364. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  12365. * This method returns nothing.
  12366. * 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.
  12367. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  12368. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  12369. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  12370. * The parameter `uvScale` is an optional vector2 used to scale UV.
  12371. *
  12372. * Returns the Mesh.
  12373. */
  12374. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  12375. /**
  12376. * Modify the mesh to get a flat shading rendering.
  12377. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  12378. * This method returns the Mesh.
  12379. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  12380. */
  12381. convertToFlatShadedMesh(): Mesh;
  12382. /**
  12383. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  12384. * In other words, more vertices, no more indices and a single bigger VBO.
  12385. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  12386. * Returns the Mesh.
  12387. */
  12388. convertToUnIndexedMesh(): Mesh;
  12389. /**
  12390. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  12391. * This method returns the Mesh.
  12392. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  12393. */
  12394. flipFaces(flipNormals?: boolean): Mesh;
  12395. /**
  12396. * Creates a new InstancedMesh object from the mesh model.
  12397. * An instance shares the same properties and the same material than its model.
  12398. * Only these properties of each instance can then be set individually :
  12399. * - position
  12400. * - rotation
  12401. * - rotationQuaternion
  12402. * - setPivotMatrix
  12403. * - scaling
  12404. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  12405. * Warning : this method is not supported for Line mesh and LineSystem
  12406. */
  12407. createInstance(name: string): InstancedMesh;
  12408. /**
  12409. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  12410. * After this call, all the mesh instances have the same submeshes than the current mesh.
  12411. * This method returns the Mesh.
  12412. */
  12413. synchronizeInstances(): Mesh;
  12414. /**
  12415. * Simplify the mesh according to the given array of settings.
  12416. * Function will return immediately and will simplify async. It returns the Mesh.
  12417. * @param settings a collection of simplification settings.
  12418. * @param parallelProcessing should all levels calculate parallel or one after the other.
  12419. * @param type the type of simplification to run.
  12420. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  12421. */
  12422. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  12423. /**
  12424. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  12425. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  12426. * This should be used together with the simplification to avoid disappearing triangles.
  12427. * Returns the Mesh.
  12428. * @param successCallback an optional success callback to be called after the optimization finished.
  12429. */
  12430. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  12431. serialize(serializationObject: any): void;
  12432. _syncGeometryWithMorphTargetManager(): void;
  12433. /**
  12434. * Returns a new Mesh object parsed from the source provided.
  12435. * The parameter `parsedMesh` is the source.
  12436. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  12437. */
  12438. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  12439. /**
  12440. * Creates a ribbon mesh.
  12441. * Please consider using the same method from the MeshBuilder class instead.
  12442. * 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.
  12443. *
  12444. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  12445. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  12446. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  12447. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  12448. * 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.
  12449. * 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.
  12450. * 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
  12451. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12452. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12453. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12454. */
  12455. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  12456. /**
  12457. * Creates a plane polygonal mesh. By default, this is a disc.
  12458. * Please consider using the same method from the MeshBuilder class instead.
  12459. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  12460. * 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.
  12461. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12462. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12463. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12464. */
  12465. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  12466. /**
  12467. * Creates a box mesh.
  12468. * Please consider using the same method from the MeshBuilder class instead.
  12469. * The parameter `size` sets the size (float) of each box side (default 1).
  12470. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12471. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12472. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12473. */
  12474. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  12475. /**
  12476. * Creates a sphere mesh.
  12477. * Please consider using the same method from the MeshBuilder class instead.
  12478. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  12479. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  12480. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12481. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12482. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12483. */
  12484. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  12485. /**
  12486. * Creates a cylinder or a cone mesh.
  12487. * Please consider using the same method from the MeshBuilder class instead.
  12488. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  12489. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  12490. * 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.
  12491. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  12492. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  12493. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12494. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12495. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12496. */
  12497. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  12498. /**
  12499. * Creates a torus mesh.
  12500. * Please consider using the same method from the MeshBuilder class instead.
  12501. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  12502. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  12503. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  12504. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12505. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12506. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12507. */
  12508. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  12509. /**
  12510. * Creates a torus knot mesh.
  12511. * Please consider using the same method from the MeshBuilder class instead.
  12512. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  12513. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  12514. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  12515. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  12516. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12517. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12518. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12519. */
  12520. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  12521. /**
  12522. * Creates a line mesh.
  12523. * Please consider using the same method from the MeshBuilder class instead.
  12524. * 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.
  12525. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  12526. * The parameter `points` is an array successive Vector3.
  12527. * 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
  12528. * When updating an instance, remember that only point positions can change, not the number of points.
  12529. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12530. */
  12531. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  12532. /**
  12533. * Creates a dashed line mesh.
  12534. * Please consider using the same method from the MeshBuilder class instead.
  12535. * 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.
  12536. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  12537. * The parameter `points` is an array successive Vector3.
  12538. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  12539. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  12540. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  12541. * 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
  12542. * When updating an instance, remember that only point positions can change, not the number of points.
  12543. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12544. */
  12545. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  12546. /**
  12547. * Creates a polygon mesh.
  12548. * Please consider using the same method from the MeshBuilder class instead.
  12549. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  12550. * 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.
  12551. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12552. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12553. * Remember you can only change the shape positions, not their number when updating a polygon.
  12554. */
  12555. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  12556. /**
  12557. * Creates an extruded polygon mesh, with depth in the Y direction.
  12558. * Please consider using the same method from the MeshBuilder class instead.
  12559. */
  12560. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  12561. /**
  12562. * Creates an extruded shape mesh.
  12563. * 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.
  12564. * Please consider using the same method from the MeshBuilder class instead.
  12565. *
  12566. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  12567. * 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
  12568. * extruded along the Z axis.
  12569. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  12570. * 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.
  12571. * The parameter `scale` (float, default 1) is the value to scale the shape.
  12572. * 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
  12573. * 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
  12574. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  12575. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12576. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12577. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12578. */
  12579. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  12580. /**
  12581. * Creates an custom extruded shape mesh.
  12582. * 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.
  12583. * Please consider using the same method from the MeshBuilder class instead.
  12584. *
  12585. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  12586. * 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
  12587. * extruded along the Z axis.
  12588. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  12589. * 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
  12590. * and the distance of this point from the begining of the path :
  12591. * ```javascript
  12592. * var rotationFunction = function(i, distance) {
  12593. * // do things
  12594. * return rotationValue; }
  12595. * ```
  12596. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  12597. * 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
  12598. * and the distance of this point from the begining of the path :
  12599. * ```javascript
  12600. * var scaleFunction = function(i, distance) {
  12601. * // do things
  12602. * return scaleValue;}
  12603. * ```
  12604. * It must returns a float value that will be the scale value applied to the shape on each path point.
  12605. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  12606. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  12607. * 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
  12608. * 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
  12609. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  12610. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12611. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12612. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12613. */
  12614. 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;
  12615. /**
  12616. * Creates lathe mesh.
  12617. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  12618. * Please consider using the same method from the MeshBuilder class instead.
  12619. * 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
  12620. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  12621. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  12622. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  12623. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12624. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12625. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12626. */
  12627. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  12628. /**
  12629. * Creates a plane mesh.
  12630. * Please consider using the same method from the MeshBuilder class instead.
  12631. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  12632. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12633. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12634. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12635. */
  12636. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  12637. /**
  12638. * Creates a ground mesh.
  12639. * Please consider using the same method from the MeshBuilder class instead.
  12640. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  12641. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  12642. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12643. */
  12644. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  12645. /**
  12646. * Creates a tiled ground mesh.
  12647. * Please consider using the same method from the MeshBuilder class instead.
  12648. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  12649. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  12650. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  12651. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  12652. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  12653. * numbers of subdivisions on the ground width and height of each tile.
  12654. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12655. */
  12656. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  12657. w: number;
  12658. h: number;
  12659. }, precision: {
  12660. w: number;
  12661. h: number;
  12662. }, scene: Scene, updatable?: boolean): Mesh;
  12663. /**
  12664. * Creates a ground mesh from a height map.
  12665. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  12666. * Please consider using the same method from the MeshBuilder class instead.
  12667. * The parameter `url` sets the URL of the height map image resource.
  12668. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  12669. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  12670. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  12671. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  12672. * 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).
  12673. * This function is passed the newly built mesh :
  12674. * ```javascript
  12675. * function(mesh) { // do things
  12676. * return; }
  12677. * ```
  12678. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12679. */
  12680. 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;
  12681. /**
  12682. * Creates a tube mesh.
  12683. * 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.
  12684. * Please consider using the same method from the MeshBuilder class instead.
  12685. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  12686. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  12687. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  12688. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  12689. * 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.
  12690. * It must return a radius value (positive float) :
  12691. * ```javascript
  12692. * var radiusFunction = function(i, distance) {
  12693. * // do things
  12694. * return radius; }
  12695. * ```
  12696. * 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
  12697. * 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
  12698. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12699. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12700. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12701. */
  12702. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  12703. (i: number, distance: number): number;
  12704. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  12705. /**
  12706. * Creates a polyhedron mesh.
  12707. * Please consider using the same method from the MeshBuilder class instead.
  12708. * 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
  12709. * to choose the wanted type.
  12710. * The parameter `size` (positive float, default 1) sets the polygon size.
  12711. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  12712. * 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`.
  12713. * 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
  12714. * 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)`).
  12715. * 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
  12716. * 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.
  12717. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12718. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12719. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12720. */
  12721. static CreatePolyhedron(name: string, options: {
  12722. type?: number;
  12723. size?: number;
  12724. sizeX?: number;
  12725. sizeY?: number;
  12726. sizeZ?: number;
  12727. custom?: any;
  12728. faceUV?: Vector4[];
  12729. faceColors?: Color4[];
  12730. updatable?: boolean;
  12731. sideOrientation?: number;
  12732. }, scene: Scene): Mesh;
  12733. /**
  12734. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  12735. * Please consider using the same method from the MeshBuilder class instead.
  12736. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  12737. * 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`).
  12738. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  12739. * 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.
  12740. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12741. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12742. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12743. */
  12744. static CreateIcoSphere(name: string, options: {
  12745. radius?: number;
  12746. flat?: boolean;
  12747. subdivisions?: number;
  12748. sideOrientation?: number;
  12749. updatable?: boolean;
  12750. }, scene: Scene): Mesh;
  12751. /**
  12752. * Creates a decal mesh.
  12753. * Please consider using the same method from the MeshBuilder class instead.
  12754. * 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.
  12755. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  12756. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  12757. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  12758. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  12759. */
  12760. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  12761. /**
  12762. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  12763. */
  12764. setPositionsForCPUSkinning(): Float32Array;
  12765. /**
  12766. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  12767. */
  12768. setNormalsForCPUSkinning(): Float32Array;
  12769. /**
  12770. * Updates the vertex buffer by applying transformation from the bones.
  12771. * Returns the Mesh.
  12772. *
  12773. * @param {skeleton} skeleton to apply
  12774. */
  12775. applySkeleton(skeleton: Skeleton): Mesh;
  12776. /**
  12777. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  12778. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  12779. */
  12780. static MinMax(meshes: AbstractMesh[]): {
  12781. min: Vector3;
  12782. max: Vector3;
  12783. };
  12784. /**
  12785. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  12786. */
  12787. static Center(meshesOrMinMaxVector: {
  12788. min: Vector3;
  12789. max: Vector3;
  12790. } | AbstractMesh[]): Vector3;
  12791. /**
  12792. * Merge the array of meshes into a single mesh for performance reasons.
  12793. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  12794. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  12795. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  12796. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  12797. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  12798. */
  12799. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  12800. }
  12801. }
  12802. declare module BABYLON {
  12803. interface IGetSetVerticesData {
  12804. isVerticesDataPresent(kind: string): boolean;
  12805. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  12806. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  12807. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  12808. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  12809. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  12810. }
  12811. class VertexData {
  12812. positions: Nullable<FloatArray>;
  12813. normals: Nullable<FloatArray>;
  12814. tangents: Nullable<FloatArray>;
  12815. uvs: Nullable<FloatArray>;
  12816. uvs2: Nullable<FloatArray>;
  12817. uvs3: Nullable<FloatArray>;
  12818. uvs4: Nullable<FloatArray>;
  12819. uvs5: Nullable<FloatArray>;
  12820. uvs6: Nullable<FloatArray>;
  12821. colors: Nullable<FloatArray>;
  12822. matricesIndices: Nullable<FloatArray>;
  12823. matricesWeights: Nullable<FloatArray>;
  12824. matricesIndicesExtra: Nullable<FloatArray>;
  12825. matricesWeightsExtra: Nullable<FloatArray>;
  12826. indices: Nullable<IndicesArray>;
  12827. set(data: FloatArray, kind: string): void;
  12828. /**
  12829. * Associates the vertexData to the passed Mesh.
  12830. * Sets it as updatable or not (default `false`).
  12831. * Returns the VertexData.
  12832. */
  12833. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  12834. /**
  12835. * Associates the vertexData to the passed Geometry.
  12836. * Sets it as updatable or not (default `false`).
  12837. * Returns the VertexData.
  12838. */
  12839. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  12840. /**
  12841. * Updates the associated mesh.
  12842. * Returns the VertexData.
  12843. */
  12844. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  12845. /**
  12846. * Updates the associated geometry.
  12847. * Returns the VertexData.
  12848. */
  12849. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  12850. private _applyTo(meshOrGeometry, updatable?);
  12851. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  12852. /**
  12853. * Transforms each position and each normal of the vertexData according to the passed Matrix.
  12854. * Returns the VertexData.
  12855. */
  12856. transform(matrix: Matrix): VertexData;
  12857. /**
  12858. * Merges the passed VertexData into the current one.
  12859. * Returns the modified VertexData.
  12860. */
  12861. merge(other: VertexData): VertexData;
  12862. private _mergeElement(source, other);
  12863. private _validate();
  12864. /**
  12865. * Serializes the VertexData.
  12866. * Returns a serialized object.
  12867. */
  12868. serialize(): any;
  12869. /**
  12870. * Returns the object VertexData associated to the passed mesh.
  12871. */
  12872. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  12873. /**
  12874. * Returns the object VertexData associated to the passed geometry.
  12875. */
  12876. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  12877. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  12878. /**
  12879. * Creates the vertexData of the Ribbon.
  12880. */
  12881. static CreateRibbon(options: {
  12882. pathArray: Vector3[][];
  12883. closeArray?: boolean;
  12884. closePath?: boolean;
  12885. offset?: number;
  12886. sideOrientation?: number;
  12887. frontUVs?: Vector4;
  12888. backUVs?: Vector4;
  12889. invertUV?: boolean;
  12890. uvs?: Vector2[];
  12891. colors?: Color4[];
  12892. }): VertexData;
  12893. /**
  12894. * Creates the VertexData of the Box.
  12895. */
  12896. static CreateBox(options: {
  12897. size?: number;
  12898. width?: number;
  12899. height?: number;
  12900. depth?: number;
  12901. faceUV?: Vector4[];
  12902. faceColors?: Color4[];
  12903. sideOrientation?: number;
  12904. frontUVs?: Vector4;
  12905. backUVs?: Vector4;
  12906. }): VertexData;
  12907. /**
  12908. * Creates the VertexData of the Sphere.
  12909. */
  12910. static CreateSphere(options: {
  12911. segments?: number;
  12912. diameter?: number;
  12913. diameterX?: number;
  12914. diameterY?: number;
  12915. diameterZ?: number;
  12916. arc?: number;
  12917. slice?: number;
  12918. sideOrientation?: number;
  12919. frontUVs?: Vector4;
  12920. backUVs?: Vector4;
  12921. }): VertexData;
  12922. /**
  12923. * Creates the VertexData of the Cylinder or Cone.
  12924. */
  12925. static CreateCylinder(options: {
  12926. height?: number;
  12927. diameterTop?: number;
  12928. diameterBottom?: number;
  12929. diameter?: number;
  12930. tessellation?: number;
  12931. subdivisions?: number;
  12932. arc?: number;
  12933. faceColors?: Color4[];
  12934. faceUV?: Vector4[];
  12935. hasRings?: boolean;
  12936. enclose?: boolean;
  12937. sideOrientation?: number;
  12938. frontUVs?: Vector4;
  12939. backUVs?: Vector4;
  12940. }): VertexData;
  12941. /**
  12942. * Creates the VertexData of the Torus.
  12943. */
  12944. static CreateTorus(options: {
  12945. diameter?: number;
  12946. thickness?: number;
  12947. tessellation?: number;
  12948. sideOrientation?: number;
  12949. frontUVs?: Vector4;
  12950. backUVs?: Vector4;
  12951. }): VertexData;
  12952. /**
  12953. * Creates the VertexData of the LineSystem.
  12954. */
  12955. static CreateLineSystem(options: {
  12956. lines: Vector3[][];
  12957. colors?: Nullable<Color4[][]>;
  12958. }): VertexData;
  12959. /**
  12960. * Create the VertexData of the DashedLines.
  12961. */
  12962. static CreateDashedLines(options: {
  12963. points: Vector3[];
  12964. dashSize?: number;
  12965. gapSize?: number;
  12966. dashNb?: number;
  12967. }): VertexData;
  12968. /**
  12969. * Creates the VertexData of the Ground.
  12970. */
  12971. static CreateGround(options: {
  12972. width?: number;
  12973. height?: number;
  12974. subdivisions?: number;
  12975. subdivisionsX?: number;
  12976. subdivisionsY?: number;
  12977. }): VertexData;
  12978. /**
  12979. * Creates the VertexData of the TiledGround.
  12980. */
  12981. static CreateTiledGround(options: {
  12982. xmin: number;
  12983. zmin: number;
  12984. xmax: number;
  12985. zmax: number;
  12986. subdivisions?: {
  12987. w: number;
  12988. h: number;
  12989. };
  12990. precision?: {
  12991. w: number;
  12992. h: number;
  12993. };
  12994. }): VertexData;
  12995. /**
  12996. * Creates the VertexData of the Ground designed from a heightmap.
  12997. */
  12998. static CreateGroundFromHeightMap(options: {
  12999. width: number;
  13000. height: number;
  13001. subdivisions: number;
  13002. minHeight: number;
  13003. maxHeight: number;
  13004. colorFilter: Color3;
  13005. buffer: Uint8Array;
  13006. bufferWidth: number;
  13007. bufferHeight: number;
  13008. }): VertexData;
  13009. /**
  13010. * Creates the VertexData of the Plane.
  13011. */
  13012. static CreatePlane(options: {
  13013. size?: number;
  13014. width?: number;
  13015. height?: number;
  13016. sideOrientation?: number;
  13017. frontUVs?: Vector4;
  13018. backUVs?: Vector4;
  13019. }): VertexData;
  13020. /**
  13021. * Creates the VertexData of the Disc or regular Polygon.
  13022. */
  13023. static CreateDisc(options: {
  13024. radius?: number;
  13025. tessellation?: number;
  13026. arc?: number;
  13027. sideOrientation?: number;
  13028. frontUVs?: Vector4;
  13029. backUVs?: Vector4;
  13030. }): VertexData;
  13031. /**
  13032. * Re-creates the VertexData of the Polygon for sideOrientation.
  13033. */
  13034. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  13035. /**
  13036. * Creates the VertexData of the IcoSphere.
  13037. */
  13038. static CreateIcoSphere(options: {
  13039. radius?: number;
  13040. radiusX?: number;
  13041. radiusY?: number;
  13042. radiusZ?: number;
  13043. flat?: boolean;
  13044. subdivisions?: number;
  13045. sideOrientation?: number;
  13046. frontUVs?: Vector4;
  13047. backUVs?: Vector4;
  13048. }): VertexData;
  13049. /**
  13050. * Creates the VertexData of the Polyhedron.
  13051. */
  13052. static CreatePolyhedron(options: {
  13053. type?: number;
  13054. size?: number;
  13055. sizeX?: number;
  13056. sizeY?: number;
  13057. sizeZ?: number;
  13058. custom?: any;
  13059. faceUV?: Vector4[];
  13060. faceColors?: Color4[];
  13061. flat?: boolean;
  13062. sideOrientation?: number;
  13063. frontUVs?: Vector4;
  13064. backUVs?: Vector4;
  13065. }): VertexData;
  13066. /**
  13067. * Creates the VertexData of the Torus Knot.
  13068. */
  13069. static CreateTorusKnot(options: {
  13070. radius?: number;
  13071. tube?: number;
  13072. radialSegments?: number;
  13073. tubularSegments?: number;
  13074. p?: number;
  13075. q?: number;
  13076. sideOrientation?: number;
  13077. frontUVs?: Vector4;
  13078. backUVs?: Vector4;
  13079. }): VertexData;
  13080. /**
  13081. * @param {any} - positions (number[] or Float32Array)
  13082. * @param {any} - indices (number[] or Uint16Array)
  13083. * @param {any} - normals (number[] or Float32Array)
  13084. * options (optional) :
  13085. * facetPositions : optional array of facet positions (vector3)
  13086. * facetNormals : optional array of facet normals (vector3)
  13087. * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  13088. * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  13089. * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  13090. * bbSize : optional bounding box size data, required for facetPartitioning computation
  13091. * bInfo : optional bounding info, required for facetPartitioning computation
  13092. * useRightHandedSystem: optional boolean to for right handed system computation
  13093. * depthSort : optional boolean to enable the facet depth sort computation
  13094. * distanceTo : optional Vector3 to compute the facet depth from this location
  13095. * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  13096. */
  13097. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  13098. facetNormals?: any;
  13099. facetPositions?: any;
  13100. facetPartitioning?: any;
  13101. ratio?: number;
  13102. bInfo?: any;
  13103. bbSize?: Vector3;
  13104. subDiv?: any;
  13105. useRightHandedSystem?: boolean;
  13106. depthSort?: boolean;
  13107. distanceTo?: Vector3;
  13108. depthSortedFacets?: any;
  13109. }): void;
  13110. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  13111. /**
  13112. * Creates a new VertexData from the imported parameters.
  13113. */
  13114. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  13115. }
  13116. }
  13117. declare module BABYLON {
  13118. class MeshBuilder {
  13119. private static updateSideOrientation(orientation?);
  13120. /**
  13121. * Creates a box mesh.
  13122. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  13123. * The parameter `size` sets the size (float) of each box side (default 1).
  13124. * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`).
  13125. * 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).
  13126. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  13127. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  13128. * 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).
  13129. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  13130. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13131. */
  13132. static CreateBox(name: string, options: {
  13133. size?: number;
  13134. width?: number;
  13135. height?: number;
  13136. depth?: number;
  13137. faceUV?: Vector4[];
  13138. faceColors?: Color4[];
  13139. sideOrientation?: number;
  13140. frontUVs?: Vector4;
  13141. backUVs?: Vector4;
  13142. updatable?: boolean;
  13143. }, scene?: Nullable<Scene>): Mesh;
  13144. /**
  13145. * Creates a sphere mesh.
  13146. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  13147. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  13148. * 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`).
  13149. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  13150. * 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
  13151. * 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).
  13152. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  13153. * 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).
  13154. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  13155. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13156. */
  13157. static CreateSphere(name: string, options: {
  13158. segments?: number;
  13159. diameter?: number;
  13160. diameterX?: number;
  13161. diameterY?: number;
  13162. diameterZ?: number;
  13163. arc?: number;
  13164. slice?: number;
  13165. sideOrientation?: number;
  13166. frontUVs?: Vector4;
  13167. backUVs?: Vector4;
  13168. updatable?: boolean;
  13169. }, scene: any): Mesh;
  13170. /**
  13171. * Creates a plane polygonal mesh. By default, this is a disc.
  13172. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#disc
  13173. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  13174. * 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.
  13175. * 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
  13176. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  13177. * 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).
  13178. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  13179. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13180. */
  13181. static CreateDisc(name: string, options: {
  13182. radius?: number;
  13183. tessellation?: number;
  13184. arc?: number;
  13185. updatable?: boolean;
  13186. sideOrientation?: number;
  13187. frontUVs?: Vector4;
  13188. backUVs?: Vector4;
  13189. }, scene?: Nullable<Scene>): Mesh;
  13190. /**
  13191. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  13192. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#icosphere
  13193. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  13194. * 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`).
  13195. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  13196. * 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.
  13197. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  13198. * 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).
  13199. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  13200. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13201. */
  13202. static CreateIcoSphere(name: string, options: {
  13203. radius?: number;
  13204. radiusX?: number;
  13205. radiusY?: number;
  13206. radiusZ?: number;
  13207. flat?: boolean;
  13208. subdivisions?: number;
  13209. sideOrientation?: number;
  13210. frontUVs?: Vector4;
  13211. backUVs?: Vector4;
  13212. updatable?: boolean;
  13213. }, scene: Scene): Mesh;
  13214. /**
  13215. * Creates a ribbon mesh.
  13216. * 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.
  13217. *
  13218. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  13219. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  13220. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  13221. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  13222. * 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.
  13223. * 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.
  13224. * 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
  13225. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  13226. * 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).
  13227. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  13228. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  13229. * 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.
  13230. * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values.
  13231. * 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
  13232. * if you set `closePath` to `true`, there's one extra vertex per path in the geometry.
  13233. * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time.
  13234. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13235. */
  13236. static CreateRibbon(name: string, options: {
  13237. pathArray: Vector3[][];
  13238. closeArray?: boolean;
  13239. closePath?: boolean;
  13240. offset?: number;
  13241. updatable?: boolean;
  13242. sideOrientation?: number;
  13243. frontUVs?: Vector4;
  13244. backUVs?: Vector4;
  13245. instance?: Mesh;
  13246. invertUV?: boolean;
  13247. uvs?: Vector2[];
  13248. colors?: Color4[];
  13249. }, scene?: Nullable<Scene>): Mesh;
  13250. /**
  13251. * Creates a cylinder or a cone mesh.
  13252. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  13253. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  13254. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  13255. * 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.
  13256. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  13257. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  13258. * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  13259. * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  13260. * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  13261. * 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).
  13262. * 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
  13263. * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  13264. * 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
  13265. * 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.
  13266. * If `enclose` is false, a ring surface is one element.
  13267. * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  13268. * 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
  13269. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  13270. * 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).
  13271. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  13272. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13273. */
  13274. static CreateCylinder(name: string, options: {
  13275. height?: number;
  13276. diameterTop?: number;
  13277. diameterBottom?: number;
  13278. diameter?: number;
  13279. tessellation?: number;
  13280. subdivisions?: number;
  13281. arc?: number;
  13282. faceColors?: Color4[];
  13283. faceUV?: Vector4[];
  13284. updatable?: boolean;
  13285. hasRings?: boolean;
  13286. enclose?: boolean;
  13287. sideOrientation?: number;
  13288. frontUVs?: Vector4;
  13289. backUVs?: Vector4;
  13290. }, scene: any): Mesh;
  13291. /**
  13292. * Creates a torus mesh.
  13293. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  13294. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  13295. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  13296. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  13297. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  13298. * 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).
  13299. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  13300. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13301. */
  13302. static CreateTorus(name: string, options: {
  13303. diameter?: number;
  13304. thickness?: number;
  13305. tessellation?: number;
  13306. updatable?: boolean;
  13307. sideOrientation?: number;
  13308. frontUVs?: Vector4;
  13309. backUVs?: Vector4;
  13310. }, scene: any): Mesh;
  13311. /**
  13312. * Creates a torus knot mesh.
  13313. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  13314. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  13315. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  13316. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  13317. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  13318. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  13319. * 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).
  13320. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  13321. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13322. */
  13323. static CreateTorusKnot(name: string, options: {
  13324. radius?: number;
  13325. tube?: number;
  13326. radialSegments?: number;
  13327. tubularSegments?: number;
  13328. p?: number;
  13329. q?: number;
  13330. updatable?: boolean;
  13331. sideOrientation?: number;
  13332. frontUVs?: Vector4;
  13333. backUVs?: Vector4;
  13334. }, scene: any): Mesh;
  13335. /**
  13336. * Creates a line system mesh.
  13337. * A line system is a pool of many lines gathered in a single mesh.
  13338. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#linesystem
  13339. * 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.
  13340. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function.
  13341. * The parameter `lines` is an array of lines, each line being an array of successive Vector3.
  13342. * 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
  13343. * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point.
  13344. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need the alpha blending (faster).
  13345. * 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
  13346. * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines.
  13347. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13348. */
  13349. static CreateLineSystem(name: string, options: {
  13350. lines: Vector3[][];
  13351. updatable: boolean;
  13352. instance: Nullable<LinesMesh>;
  13353. colors?: Nullable<Color4[][]>;
  13354. useVertexAlpha?: boolean;
  13355. }, scene: Nullable<Scene>): LinesMesh;
  13356. /**
  13357. * Creates a line mesh.
  13358. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lines
  13359. * 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.
  13360. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  13361. * The parameter `points` is an array successive Vector3.
  13362. * 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
  13363. * The optional parameter `colors` is an array of successive Color4, one per line point.
  13364. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need alpha blending (faster).
  13365. * When updating an instance, remember that only point positions can change, not the number of points.
  13366. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13367. */
  13368. static CreateLines(name: string, options: {
  13369. points: Vector3[];
  13370. updatable: boolean;
  13371. instance: Nullable<LinesMesh>;
  13372. colors?: Color4[];
  13373. useVertexAlpha?: boolean;
  13374. }, scene?: Nullable<Scene>): LinesMesh;
  13375. /**
  13376. * Creates a dashed line mesh.
  13377. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#dashed-lines
  13378. * 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.
  13379. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  13380. * The parameter `points` is an array successive Vector3.
  13381. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  13382. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  13383. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  13384. * 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
  13385. * When updating an instance, remember that only point positions can change, not the number of points.
  13386. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13387. */
  13388. static CreateDashedLines(name: string, options: {
  13389. points: Vector3[];
  13390. dashSize?: number;
  13391. gapSize?: number;
  13392. dashNb?: number;
  13393. updatable?: boolean;
  13394. instance?: LinesMesh;
  13395. }, scene?: Nullable<Scene>): LinesMesh;
  13396. /**
  13397. * Creates an extruded shape mesh.
  13398. * 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.
  13399. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#extruded-shapes
  13400. *
  13401. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  13402. * 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
  13403. * extruded along the Z axis.
  13404. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  13405. * 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.
  13406. * The parameter `scale` (float, default 1) is the value to scale the shape.
  13407. * 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
  13408. * 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
  13409. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  13410. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  13411. * 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).
  13412. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  13413. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  13414. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13415. */
  13416. static ExtrudeShape(name: string, options: {
  13417. shape: Vector3[];
  13418. path: Vector3[];
  13419. scale?: number;
  13420. rotation?: number;
  13421. cap?: number;
  13422. updatable?: boolean;
  13423. sideOrientation?: number;
  13424. frontUVs?: Vector4;
  13425. backUVs?: Vector4;
  13426. instance?: Mesh;
  13427. invertUV?: boolean;
  13428. }, scene?: Nullable<Scene>): Mesh;
  13429. /**
  13430. * Creates an custom extruded shape mesh.
  13431. * 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.
  13432. * tuto :http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#custom-extruded-shapes
  13433. *
  13434. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  13435. * 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
  13436. * extruded along the Z axis.
  13437. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  13438. * 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
  13439. * and the distance of this point from the begining of the path :
  13440. * ```javascript
  13441. * var rotationFunction = function(i, distance) {
  13442. * // do things
  13443. * return rotationValue; }
  13444. * ```
  13445. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  13446. * 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
  13447. * and the distance of this point from the begining of the path :
  13448. * ```javascript
  13449. * var scaleFunction = function(i, distance) {
  13450. * // do things
  13451. * return scaleValue;}
  13452. * ```
  13453. * It must returns a float value that will be the scale value applied to the shape on each path point.
  13454. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  13455. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  13456. * 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
  13457. * 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
  13458. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  13459. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  13460. * 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).
  13461. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  13462. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  13463. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13464. */
  13465. static ExtrudeShapeCustom(name: string, options: {
  13466. shape: Vector3[];
  13467. path: Vector3[];
  13468. scaleFunction?: any;
  13469. rotationFunction?: any;
  13470. ribbonCloseArray?: boolean;
  13471. ribbonClosePath?: boolean;
  13472. cap?: number;
  13473. updatable?: boolean;
  13474. sideOrientation?: number;
  13475. frontUVs?: Vector4;
  13476. backUVs?: Vector4;
  13477. instance?: Mesh;
  13478. invertUV?: boolean;
  13479. }, scene: Scene): Mesh;
  13480. /**
  13481. * Creates lathe mesh.
  13482. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  13483. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lathe
  13484. *
  13485. * 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
  13486. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  13487. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  13488. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  13489. * 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.
  13490. * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc".
  13491. * 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
  13492. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  13493. * 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).
  13494. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  13495. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  13496. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13497. */
  13498. static CreateLathe(name: string, options: {
  13499. shape: Vector3[];
  13500. radius?: number;
  13501. tessellation?: number;
  13502. arc?: number;
  13503. closed?: boolean;
  13504. updatable?: boolean;
  13505. sideOrientation?: number;
  13506. frontUVs?: Vector4;
  13507. backUVs?: Vector4;
  13508. cap?: number;
  13509. invertUV?: boolean;
  13510. }, scene: Scene): Mesh;
  13511. /**
  13512. * Creates a plane mesh.
  13513. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  13514. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  13515. * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`).
  13516. * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane.
  13517. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  13518. * 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).
  13519. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  13520. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13521. */
  13522. static CreatePlane(name: string, options: {
  13523. size?: number;
  13524. width?: number;
  13525. height?: number;
  13526. sideOrientation?: number;
  13527. frontUVs?: Vector4;
  13528. backUVs?: Vector4;
  13529. updatable?: boolean;
  13530. sourcePlane?: Plane;
  13531. }, scene: Scene): Mesh;
  13532. /**
  13533. * Creates a ground mesh.
  13534. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  13535. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  13536. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  13537. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13538. */
  13539. static CreateGround(name: string, options: {
  13540. width?: number;
  13541. height?: number;
  13542. subdivisions?: number;
  13543. subdivisionsX?: number;
  13544. subdivisionsY?: number;
  13545. updatable?: boolean;
  13546. }, scene: any): Mesh;
  13547. /**
  13548. * Creates a tiled ground mesh.
  13549. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  13550. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  13551. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  13552. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  13553. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  13554. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  13555. * numbers of subdivisions on the ground width and height of each tile.
  13556. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13557. */
  13558. static CreateTiledGround(name: string, options: {
  13559. xmin: number;
  13560. zmin: number;
  13561. xmax: number;
  13562. zmax: number;
  13563. subdivisions?: {
  13564. w: number;
  13565. h: number;
  13566. };
  13567. precision?: {
  13568. w: number;
  13569. h: number;
  13570. };
  13571. updatable?: boolean;
  13572. }, scene: Scene): Mesh;
  13573. /**
  13574. * Creates a ground mesh from a height map.
  13575. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  13576. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  13577. * The parameter `url` sets the URL of the height map image resource.
  13578. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  13579. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  13580. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  13581. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  13582. * 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.
  13583. * 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).
  13584. * This function is passed the newly built mesh :
  13585. * ```javascript
  13586. * function(mesh) { // do things
  13587. * return; }
  13588. * ```
  13589. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13590. */
  13591. static CreateGroundFromHeightMap(name: string, url: string, options: {
  13592. width?: number;
  13593. height?: number;
  13594. subdivisions?: number;
  13595. minHeight?: number;
  13596. maxHeight?: number;
  13597. colorFilter?: Color3;
  13598. updatable?: boolean;
  13599. onReady?: (mesh: GroundMesh) => void;
  13600. }, scene: Scene): GroundMesh;
  13601. /**
  13602. * Creates a polygon mesh.
  13603. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  13604. * 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.
  13605. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  13606. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13607. * 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).
  13608. * Remember you can only change the shape positions, not their number when updating a polygon.
  13609. */
  13610. static CreatePolygon(name: string, options: {
  13611. shape: Vector3[];
  13612. holes?: Vector3[][];
  13613. depth?: number;
  13614. faceUV?: Vector4[];
  13615. faceColors?: Color4[];
  13616. updatable?: boolean;
  13617. sideOrientation?: number;
  13618. frontUVs?: Vector4;
  13619. backUVs?: Vector4;
  13620. }, scene: Scene): Mesh;
  13621. /**
  13622. * Creates an extruded polygon mesh, with depth in the Y direction.
  13623. * 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).
  13624. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  13625. */
  13626. static ExtrudePolygon(name: string, options: {
  13627. shape: Vector3[];
  13628. holes?: Vector3[][];
  13629. depth?: number;
  13630. faceUV?: Vector4[];
  13631. faceColors?: Color4[];
  13632. updatable?: boolean;
  13633. sideOrientation?: number;
  13634. frontUVs?: Vector4;
  13635. backUVs?: Vector4;
  13636. }, scene: Scene): Mesh;
  13637. /**
  13638. * Creates a tube mesh.
  13639. * 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.
  13640. *
  13641. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  13642. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  13643. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  13644. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  13645. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  13646. * 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.
  13647. * It must return a radius value (positive float) :
  13648. * ```javascript
  13649. * var radiusFunction = function(i, distance) {
  13650. * // do things
  13651. * return radius; }
  13652. * ```
  13653. * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc.
  13654. * 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
  13655. * 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
  13656. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  13657. * 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).
  13658. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  13659. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  13660. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13661. */
  13662. static CreateTube(name: string, options: {
  13663. path: Vector3[];
  13664. radius?: number;
  13665. tessellation?: number;
  13666. radiusFunction?: {
  13667. (i: number, distance: number): number;
  13668. };
  13669. cap?: number;
  13670. arc?: number;
  13671. updatable?: boolean;
  13672. sideOrientation?: number;
  13673. frontUVs?: Vector4;
  13674. backUVs?: Vector4;
  13675. instance?: Mesh;
  13676. invertUV?: boolean;
  13677. }, scene: Scene): Mesh;
  13678. /**
  13679. * Creates a polyhedron mesh.
  13680. *
  13681. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#polyhedron
  13682. * 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
  13683. * to choose the wanted type.
  13684. * The parameter `size` (positive float, default 1) sets the polygon size.
  13685. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  13686. * 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`.
  13687. * 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
  13688. * 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)`).
  13689. * 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
  13690. * 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.
  13691. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  13692. * 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).
  13693. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  13694. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13695. */
  13696. static CreatePolyhedron(name: string, options: {
  13697. type?: number;
  13698. size?: number;
  13699. sizeX?: number;
  13700. sizeY?: number;
  13701. sizeZ?: number;
  13702. custom?: any;
  13703. faceUV?: Vector4[];
  13704. faceColors?: Color4[];
  13705. flat?: boolean;
  13706. updatable?: boolean;
  13707. sideOrientation?: number;
  13708. frontUVs?: Vector4;
  13709. backUVs?: Vector4;
  13710. }, scene: Scene): Mesh;
  13711. /**
  13712. * Creates a decal mesh.
  13713. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#decals
  13714. * 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.
  13715. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  13716. * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates.
  13717. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  13718. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  13719. */
  13720. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  13721. position?: Vector3;
  13722. normal?: Vector3;
  13723. size?: Vector3;
  13724. angle?: number;
  13725. }): Mesh;
  13726. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  13727. }
  13728. }
  13729. declare module BABYLON {
  13730. class MeshLODLevel {
  13731. distance: number;
  13732. mesh: Mesh;
  13733. constructor(distance: number, mesh: Mesh);
  13734. }
  13735. }
  13736. declare module BABYLON {
  13737. /**
  13738. * A simplifier interface for future simplification implementations.
  13739. */
  13740. interface ISimplifier {
  13741. /**
  13742. * Simplification of a given mesh according to the given settings.
  13743. * Since this requires computation, it is assumed that the function runs async.
  13744. * @param settings The settings of the simplification, including quality and distance
  13745. * @param successCallback A callback that will be called after the mesh was simplified.
  13746. * @param errorCallback in case of an error, this callback will be called. optional.
  13747. */
  13748. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  13749. }
  13750. /**
  13751. * Expected simplification settings.
  13752. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  13753. */
  13754. interface ISimplificationSettings {
  13755. quality: number;
  13756. distance: number;
  13757. optimizeMesh?: boolean;
  13758. }
  13759. class SimplificationSettings implements ISimplificationSettings {
  13760. quality: number;
  13761. distance: number;
  13762. optimizeMesh: boolean | undefined;
  13763. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  13764. }
  13765. interface ISimplificationTask {
  13766. settings: Array<ISimplificationSettings>;
  13767. simplificationType: SimplificationType;
  13768. mesh: Mesh;
  13769. successCallback?: () => void;
  13770. parallelProcessing: boolean;
  13771. }
  13772. class SimplificationQueue {
  13773. private _simplificationArray;
  13774. running: boolean;
  13775. constructor();
  13776. addTask(task: ISimplificationTask): void;
  13777. executeNext(): void;
  13778. runSimplification(task: ISimplificationTask): void;
  13779. private getSimplifier(task);
  13780. }
  13781. /**
  13782. * The implemented types of simplification.
  13783. * At the moment only Quadratic Error Decimation is implemented.
  13784. */
  13785. enum SimplificationType {
  13786. QUADRATIC = 0,
  13787. }
  13788. class DecimationTriangle {
  13789. vertices: Array<DecimationVertex>;
  13790. normal: Vector3;
  13791. error: Array<number>;
  13792. deleted: boolean;
  13793. isDirty: boolean;
  13794. borderFactor: number;
  13795. deletePending: boolean;
  13796. originalOffset: number;
  13797. constructor(vertices: Array<DecimationVertex>);
  13798. }
  13799. class DecimationVertex {
  13800. position: Vector3;
  13801. id: number;
  13802. q: QuadraticMatrix;
  13803. isBorder: boolean;
  13804. triangleStart: number;
  13805. triangleCount: number;
  13806. originalOffsets: Array<number>;
  13807. constructor(position: Vector3, id: number);
  13808. updatePosition(newPosition: Vector3): void;
  13809. }
  13810. class QuadraticMatrix {
  13811. data: Array<number>;
  13812. constructor(data?: Array<number>);
  13813. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  13814. addInPlace(matrix: QuadraticMatrix): void;
  13815. addArrayInPlace(data: Array<number>): void;
  13816. add(matrix: QuadraticMatrix): QuadraticMatrix;
  13817. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  13818. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  13819. }
  13820. class Reference {
  13821. vertexId: number;
  13822. triangleId: number;
  13823. constructor(vertexId: number, triangleId: number);
  13824. }
  13825. /**
  13826. * An implementation of the Quadratic Error simplification algorithm.
  13827. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  13828. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  13829. * @author RaananW
  13830. */
  13831. class QuadraticErrorSimplification implements ISimplifier {
  13832. private _mesh;
  13833. private triangles;
  13834. private vertices;
  13835. private references;
  13836. private _reconstructedMesh;
  13837. syncIterations: number;
  13838. aggressiveness: number;
  13839. decimationIterations: number;
  13840. boundingBoxEpsilon: number;
  13841. constructor(_mesh: Mesh);
  13842. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  13843. private runDecimation(settings, submeshIndex, successCallback);
  13844. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  13845. private init(callback);
  13846. private reconstructMesh(submeshIndex);
  13847. private initDecimatedMesh();
  13848. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  13849. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  13850. private identifyBorder();
  13851. private updateMesh(identifyBorders?);
  13852. private vertexError(q, point);
  13853. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  13854. }
  13855. }
  13856. declare module BABYLON {
  13857. class Polygon {
  13858. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  13859. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  13860. static Parse(input: string): Vector2[];
  13861. static StartingAt(x: number, y: number): Path2;
  13862. }
  13863. class PolygonMeshBuilder {
  13864. private _points;
  13865. private _outlinepoints;
  13866. private _holes;
  13867. private _name;
  13868. private _scene;
  13869. private _epoints;
  13870. private _eholes;
  13871. private _addToepoint(points);
  13872. constructor(name: string, contours: Path2, scene: Scene);
  13873. constructor(name: string, contours: Vector2[], scene: Scene);
  13874. addHole(hole: Vector2[]): PolygonMeshBuilder;
  13875. build(updatable?: boolean, depth?: number): Mesh;
  13876. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  13877. }
  13878. }
  13879. declare module BABYLON {
  13880. class BaseSubMesh {
  13881. _materialDefines: Nullable<MaterialDefines>;
  13882. _materialEffect: Nullable<Effect>;
  13883. readonly effect: Nullable<Effect>;
  13884. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  13885. }
  13886. class SubMesh extends BaseSubMesh implements ICullable {
  13887. materialIndex: number;
  13888. verticesStart: number;
  13889. verticesCount: number;
  13890. indexStart: number;
  13891. indexCount: number;
  13892. linesIndexCount: number;
  13893. private _mesh;
  13894. private _renderingMesh;
  13895. private _boundingInfo;
  13896. private _linesIndexBuffer;
  13897. _lastColliderWorldVertices: Nullable<Vector3[]>;
  13898. _trianglePlanes: Plane[];
  13899. _lastColliderTransformMatrix: Matrix;
  13900. _renderId: number;
  13901. _alphaIndex: number;
  13902. _distanceToCamera: number;
  13903. _id: number;
  13904. private _currentMaterial;
  13905. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  13906. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  13907. readonly IsGlobal: boolean;
  13908. /**
  13909. * Returns the submesh BoudingInfo object.
  13910. */
  13911. getBoundingInfo(): BoundingInfo;
  13912. /**
  13913. * Sets the submesh BoundingInfo.
  13914. * Return the SubMesh.
  13915. */
  13916. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  13917. /**
  13918. * Returns the mesh of the current submesh.
  13919. */
  13920. getMesh(): AbstractMesh;
  13921. /**
  13922. * Returns the rendering mesh of the submesh.
  13923. */
  13924. getRenderingMesh(): Mesh;
  13925. /**
  13926. * Returns the submesh material.
  13927. */
  13928. getMaterial(): Nullable<Material>;
  13929. /**
  13930. * Sets a new updated BoundingInfo object to the submesh.
  13931. * Returns the SubMesh.
  13932. */
  13933. refreshBoundingInfo(): SubMesh;
  13934. _checkCollision(collider: Collider): boolean;
  13935. /**
  13936. * Updates the submesh BoundingInfo.
  13937. * Returns the Submesh.
  13938. */
  13939. updateBoundingInfo(world: Matrix): SubMesh;
  13940. /**
  13941. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  13942. * Boolean returned.
  13943. */
  13944. isInFrustum(frustumPlanes: Plane[]): boolean;
  13945. /**
  13946. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  13947. * Boolean returned.
  13948. */
  13949. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  13950. /**
  13951. * Renders the submesh.
  13952. * Returns it.
  13953. */
  13954. render(enableAlphaMode: boolean): SubMesh;
  13955. /**
  13956. * Returns a new Index Buffer.
  13957. * Type returned : WebGLBuffer.
  13958. */
  13959. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  13960. /**
  13961. * True is the passed Ray intersects the submesh bounding box.
  13962. * Boolean returned.
  13963. */
  13964. canIntersects(ray: Ray): boolean;
  13965. /**
  13966. * Returns an object IntersectionInfo.
  13967. */
  13968. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  13969. _rebuild(): void;
  13970. /**
  13971. * Creates a new Submesh from the passed Mesh.
  13972. */
  13973. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  13974. /**
  13975. * Disposes the Submesh.
  13976. * Returns nothing.
  13977. */
  13978. dispose(): void;
  13979. /**
  13980. * Creates a new Submesh from the passed parameters :
  13981. * - materialIndex (integer) : the index of the main mesh material.
  13982. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  13983. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  13984. * - mesh (Mesh) : the main mesh to create the submesh from.
  13985. * - renderingMesh (optional Mesh) : rendering mesh.
  13986. */
  13987. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  13988. }
  13989. }
  13990. declare module BABYLON {
  13991. class TransformNode extends Node {
  13992. static BILLBOARDMODE_NONE: number;
  13993. static BILLBOARDMODE_X: number;
  13994. static BILLBOARDMODE_Y: number;
  13995. static BILLBOARDMODE_Z: number;
  13996. static BILLBOARDMODE_ALL: number;
  13997. private _rotation;
  13998. private _rotationQuaternion;
  13999. protected _scaling: Vector3;
  14000. protected _isDirty: boolean;
  14001. private _transformToBoneReferal;
  14002. billboardMode: number;
  14003. scalingDeterminant: number;
  14004. infiniteDistance: boolean;
  14005. position: Vector3;
  14006. _poseMatrix: Matrix;
  14007. private _localWorld;
  14008. _worldMatrix: Matrix;
  14009. _worldMatrixDeterminant: number;
  14010. private _absolutePosition;
  14011. private _pivotMatrix;
  14012. private _pivotMatrixInverse;
  14013. private _postMultiplyPivotMatrix;
  14014. protected _isWorldMatrixFrozen: boolean;
  14015. /**
  14016. * An event triggered after the world matrix is updated
  14017. * @type {BABYLON.Observable}
  14018. */
  14019. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14020. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14021. /**
  14022. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  14023. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  14024. * Default : (0.0, 0.0, 0.0)
  14025. */
  14026. rotation: Vector3;
  14027. /**
  14028. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  14029. * Default : (1.0, 1.0, 1.0)
  14030. */
  14031. /**
  14032. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  14033. * Default : (1.0, 1.0, 1.0)
  14034. */
  14035. scaling: Vector3;
  14036. /**
  14037. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  14038. * It's null by default.
  14039. * 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)
  14040. */
  14041. rotationQuaternion: Nullable<Quaternion>;
  14042. /**
  14043. * Returns the latest update of the World matrix
  14044. * Returns a Matrix.
  14045. */
  14046. getWorldMatrix(): Matrix;
  14047. /**
  14048. * Returns the latest update of the World matrix determinant.
  14049. */
  14050. protected _getWorldMatrixDeterminant(): number;
  14051. /**
  14052. * Returns directly the latest state of the mesh World matrix.
  14053. * A Matrix is returned.
  14054. */
  14055. readonly worldMatrixFromCache: Matrix;
  14056. /**
  14057. * Copies the paramater passed Matrix into the mesh Pose matrix.
  14058. * Returns the AbstractMesh.
  14059. */
  14060. updatePoseMatrix(matrix: Matrix): TransformNode;
  14061. /**
  14062. * Returns the mesh Pose matrix.
  14063. * Returned object : Matrix
  14064. */
  14065. getPoseMatrix(): Matrix;
  14066. _isSynchronized(): boolean;
  14067. _initCache(): void;
  14068. markAsDirty(property: string): TransformNode;
  14069. /**
  14070. * Returns the current mesh absolute position.
  14071. * Retuns a Vector3.
  14072. */
  14073. readonly absolutePosition: Vector3;
  14074. /**
  14075. * Sets a new matrix to apply before all other transformation
  14076. * @param matrix defines the transform matrix
  14077. * @returns the current TransformNode
  14078. */
  14079. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14080. /**
  14081. * Sets a new pivot matrix to the current node
  14082. * @param matrix defines the new pivot matrix to use
  14083. * @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
  14084. * @returns the current TransformNode
  14085. */
  14086. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  14087. /**
  14088. * Returns the mesh pivot matrix.
  14089. * Default : Identity.
  14090. * A Matrix is returned.
  14091. */
  14092. getPivotMatrix(): Matrix;
  14093. /**
  14094. * Prevents the World matrix to be computed any longer.
  14095. * Returns the AbstractMesh.
  14096. */
  14097. freezeWorldMatrix(): TransformNode;
  14098. /**
  14099. * Allows back the World matrix computation.
  14100. * Returns the AbstractMesh.
  14101. */
  14102. unfreezeWorldMatrix(): this;
  14103. /**
  14104. * True if the World matrix has been frozen.
  14105. * Returns a boolean.
  14106. */
  14107. readonly isWorldMatrixFrozen: boolean;
  14108. /**
  14109. * Retuns the mesh absolute position in the World.
  14110. * Returns a Vector3.
  14111. */
  14112. getAbsolutePosition(): Vector3;
  14113. /**
  14114. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14115. * Returns the AbstractMesh.
  14116. */
  14117. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14118. /**
  14119. * Sets the mesh position in its local space.
  14120. * Returns the AbstractMesh.
  14121. */
  14122. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14123. /**
  14124. * Returns the mesh position in the local space from the current World matrix values.
  14125. * Returns a new Vector3.
  14126. */
  14127. getPositionExpressedInLocalSpace(): Vector3;
  14128. /**
  14129. * Translates the mesh along the passed Vector3 in its local space.
  14130. * Returns the AbstractMesh.
  14131. */
  14132. locallyTranslate(vector3: Vector3): TransformNode;
  14133. private static _lookAtVectorCache;
  14134. /**
  14135. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14136. * @param targetPoint the position (must be in same space as current mesh) to look at
  14137. * @param yawCor optional yaw (y-axis) correction in radians
  14138. * @param pitchCor optional pitch (x-axis) correction in radians
  14139. * @param rollCor optional roll (z-axis) correction in radians
  14140. * @param space the choosen space of the target
  14141. * @returns the TransformNode.
  14142. */
  14143. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14144. /**
  14145. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14146. * This Vector3 is expressed in the World space.
  14147. */
  14148. getDirection(localAxis: Vector3): Vector3;
  14149. /**
  14150. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14151. * localAxis is expressed in the mesh local space.
  14152. * result is computed in the Wordl space from the mesh World matrix.
  14153. * Returns the AbstractMesh.
  14154. */
  14155. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14156. /**
  14157. * Sets a new pivot point to the current node
  14158. * @param point defines the new pivot point to use
  14159. * @param space defines if the point is in world or local space (local by default)
  14160. * @returns the current TransformNode
  14161. */
  14162. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14163. /**
  14164. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14165. */
  14166. getPivotPoint(): Vector3;
  14167. /**
  14168. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14169. * Returns the AbstractMesh.
  14170. */
  14171. getPivotPointToRef(result: Vector3): TransformNode;
  14172. /**
  14173. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14174. */
  14175. getAbsolutePivotPoint(): Vector3;
  14176. /**
  14177. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14178. * Returns the AbstractMesh.
  14179. */
  14180. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14181. /**
  14182. * Defines the passed node as the parent of the current node.
  14183. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14184. * Returns the TransformNode.
  14185. */
  14186. setParent(node: Nullable<Node>): TransformNode;
  14187. private _nonUniformScaling;
  14188. readonly nonUniformScaling: boolean;
  14189. _updateNonUniformScalingState(value: boolean): boolean;
  14190. /**
  14191. * Attach the current TransformNode to another TransformNode associated with a bone
  14192. * @param bone Bone affecting the TransformNode
  14193. * @param affectedTransformNode TransformNode associated with the bone
  14194. */
  14195. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14196. detachFromBone(): TransformNode;
  14197. private static _rotationAxisCache;
  14198. /**
  14199. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14200. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  14201. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14202. * The passed axis is also normalized.
  14203. * Returns the AbstractMesh.
  14204. */
  14205. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14206. /**
  14207. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14208. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14209. * The passed axis is also normalized.
  14210. * Returns the AbstractMesh.
  14211. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14212. */
  14213. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14214. /**
  14215. * Translates the mesh along the axis vector for the passed distance in the given space.
  14216. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  14217. * Returns the AbstractMesh.
  14218. */
  14219. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14220. /**
  14221. * Adds a rotation step to the mesh current rotation.
  14222. * x, y, z are Euler angles expressed in radians.
  14223. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14224. * This means this rotation is made in the mesh local space only.
  14225. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14226. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14227. * ```javascript
  14228. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14229. * ```
  14230. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14231. * 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.
  14232. * Returns the AbstractMesh.
  14233. */
  14234. addRotation(x: number, y: number, z: number): TransformNode;
  14235. /**
  14236. * Computes the mesh World matrix and returns it.
  14237. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  14238. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  14239. * If the parameter `force`is set to `true`, the actual computation is done.
  14240. * Returns the mesh World Matrix.
  14241. */
  14242. computeWorldMatrix(force?: boolean): Matrix;
  14243. protected _afterComputeWorldMatrix(): void;
  14244. /**
  14245. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14246. * @param func: callback function to add
  14247. *
  14248. * Returns the TransformNode.
  14249. */
  14250. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14251. /**
  14252. * Removes a registered callback function.
  14253. * Returns the TransformNode.
  14254. */
  14255. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14256. /**
  14257. * Clone the current transform node
  14258. * Returns the new transform node
  14259. * @param name Name of the new clone
  14260. * @param newParent New parent for the clone
  14261. * @param doNotCloneChildren Do not clone children hierarchy
  14262. */
  14263. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14264. serialize(currentSerializationObject?: any): any;
  14265. /**
  14266. * Returns a new TransformNode object parsed from the source provided.
  14267. * The parameter `parsedMesh` is the source.
  14268. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14269. */
  14270. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14271. /**
  14272. * Disposes the TransformNode.
  14273. * By default, all the children are also disposed unless the parameter `doNotRecurse` is set to `true`.
  14274. * Returns nothing.
  14275. */
  14276. dispose(doNotRecurse?: boolean): void;
  14277. }
  14278. }
  14279. declare module BABYLON {
  14280. class VertexBuffer {
  14281. private _buffer;
  14282. private _kind;
  14283. private _offset;
  14284. private _size;
  14285. private _stride;
  14286. private _ownsBuffer;
  14287. constructor(engine: any, data: FloatArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number);
  14288. _rebuild(): void;
  14289. /**
  14290. * Returns the kind of the VertexBuffer (string).
  14291. */
  14292. getKind(): string;
  14293. /**
  14294. * Boolean : is the VertexBuffer updatable ?
  14295. */
  14296. isUpdatable(): boolean;
  14297. /**
  14298. * Returns an array of numbers or a Float32Array containing the VertexBuffer data.
  14299. */
  14300. getData(): Nullable<FloatArray>;
  14301. /**
  14302. * Returns the WebGLBuffer associated to the VertexBuffer.
  14303. */
  14304. getBuffer(): Nullable<WebGLBuffer>;
  14305. /**
  14306. * Returns the stride of the VertexBuffer (integer).
  14307. */
  14308. getStrideSize(): number;
  14309. /**
  14310. * Returns the offset (integer).
  14311. */
  14312. getOffset(): number;
  14313. /**
  14314. * Returns the VertexBuffer total size (integer).
  14315. */
  14316. getSize(): number;
  14317. /**
  14318. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  14319. */
  14320. getIsInstanced(): boolean;
  14321. /**
  14322. * Returns the instancing divisor, zero for non-instanced (integer).
  14323. */
  14324. getInstanceDivisor(): number;
  14325. /**
  14326. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  14327. * Returns the created WebGLBuffer.
  14328. */
  14329. create(data?: FloatArray): void;
  14330. /**
  14331. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  14332. * This function will create a new buffer if the current one is not updatable
  14333. * Returns the updated WebGLBuffer.
  14334. */
  14335. update(data: FloatArray): void;
  14336. /**
  14337. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  14338. * Returns the directly updated WebGLBuffer.
  14339. */
  14340. updateDirectly(data: Float32Array, offset: number): void;
  14341. /**
  14342. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  14343. */
  14344. dispose(): void;
  14345. private static _PositionKind;
  14346. private static _NormalKind;
  14347. private static _TangentKind;
  14348. private static _UVKind;
  14349. private static _UV2Kind;
  14350. private static _UV3Kind;
  14351. private static _UV4Kind;
  14352. private static _UV5Kind;
  14353. private static _UV6Kind;
  14354. private static _ColorKind;
  14355. private static _MatricesIndicesKind;
  14356. private static _MatricesWeightsKind;
  14357. private static _MatricesIndicesExtraKind;
  14358. private static _MatricesWeightsExtraKind;
  14359. static readonly PositionKind: string;
  14360. static readonly NormalKind: string;
  14361. static readonly TangentKind: string;
  14362. static readonly UVKind: string;
  14363. static readonly UV2Kind: string;
  14364. static readonly UV3Kind: string;
  14365. static readonly UV4Kind: string;
  14366. static readonly UV5Kind: string;
  14367. static readonly UV6Kind: string;
  14368. static readonly ColorKind: string;
  14369. static readonly MatricesIndicesKind: string;
  14370. static readonly MatricesWeightsKind: string;
  14371. static readonly MatricesIndicesExtraKind: string;
  14372. static readonly MatricesWeightsExtraKind: string;
  14373. /**
  14374. * Deduces the stride given a kind.
  14375. * @param kind The kind string to deduce
  14376. * @returns The deduced stride
  14377. */
  14378. static DeduceStride(kind: string): number;
  14379. }
  14380. }
  14381. declare module BABYLON {
  14382. class Scalar {
  14383. /**
  14384. * Two pi constants convenient for computation.
  14385. */
  14386. static TwoPi: number;
  14387. /**
  14388. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  14389. */
  14390. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  14391. /**
  14392. * Returns a string : the upper case translation of the number i to hexadecimal.
  14393. */
  14394. static ToHex(i: number): string;
  14395. /**
  14396. * Returns -1 if value is negative and +1 is value is positive.
  14397. * Returns the value itself if it's equal to zero.
  14398. */
  14399. static Sign(value: number): number;
  14400. /**
  14401. * Returns the value itself if it's between min and max.
  14402. * Returns min if the value is lower than min.
  14403. * Returns max if the value is greater than max.
  14404. */
  14405. static Clamp(value: number, min?: number, max?: number): number;
  14406. /**
  14407. * Returns the log2 of value.
  14408. */
  14409. static Log2(value: number): number;
  14410. /**
  14411. * Loops the value, so that it is never larger than length and never smaller than 0.
  14412. *
  14413. * This is similar to the modulo operator but it works with floating point numbers.
  14414. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  14415. * With t = 5 and length = 2.5, the result would be 0.0.
  14416. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  14417. */
  14418. static Repeat(value: number, length: number): number;
  14419. /**
  14420. * Normalize the value between 0.0 and 1.0 using min and max values
  14421. */
  14422. static Normalize(value: number, min: number, max: number): number;
  14423. /**
  14424. * Denormalize the value from 0.0 and 1.0 using min and max values
  14425. */
  14426. static Denormalize(normalized: number, min: number, max: number): number;
  14427. /**
  14428. * Calculates the shortest difference between two given angles given in degrees.
  14429. */
  14430. static DeltaAngle(current: number, target: number): number;
  14431. /**
  14432. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  14433. *
  14434. * The returned value will move back and forth between 0 and length
  14435. */
  14436. static PingPong(tx: number, length: number): number;
  14437. /**
  14438. * Interpolates between min and max with smoothing at the limits.
  14439. *
  14440. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  14441. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  14442. */
  14443. static SmoothStep(from: number, to: number, tx: number): number;
  14444. /**
  14445. * Moves a value current towards target.
  14446. *
  14447. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  14448. * Negative values of maxDelta pushes the value away from target.
  14449. */
  14450. static MoveTowards(current: number, target: number, maxDelta: number): number;
  14451. /**
  14452. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14453. *
  14454. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  14455. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  14456. */
  14457. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  14458. /**
  14459. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  14460. */
  14461. static Lerp(start: number, end: number, amount: number): number;
  14462. /**
  14463. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14464. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  14465. */
  14466. static LerpAngle(start: number, end: number, amount: number): number;
  14467. /**
  14468. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  14469. */
  14470. static InverseLerp(a: number, b: number, value: number): number;
  14471. /**
  14472. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  14473. */
  14474. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  14475. /**
  14476. * Returns a random float number between and min and max values
  14477. */
  14478. static RandomRange(min: number, max: number): number;
  14479. /**
  14480. * This function returns percentage of a number in a given range.
  14481. *
  14482. * RangeToPercent(40,20,60) will return 0.5 (50%)
  14483. * RangeToPercent(34,0,100) will return 0.34 (34%)
  14484. */
  14485. static RangeToPercent(number: number, min: number, max: number): number;
  14486. /**
  14487. * This function returns number that corresponds to the percentage in a given range.
  14488. *
  14489. * PercentToRange(0.34,0,100) will return 34.
  14490. */
  14491. static PercentToRange(percent: number, min: number, max: number): number;
  14492. /**
  14493. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  14494. * @param angle The angle to normalize in radian.
  14495. * @return The converted angle.
  14496. */
  14497. static NormalizeRadians(angle: number): number;
  14498. }
  14499. }
  14500. declare module BABYLON {
  14501. const ToGammaSpace: number;
  14502. const ToLinearSpace = 2.2;
  14503. const Epsilon = 0.001;
  14504. /**
  14505. * Class used to hold a RBG color
  14506. */
  14507. class Color3 {
  14508. /**
  14509. * Defines the red component (between 0 and 1, default is 0)
  14510. */
  14511. r: number;
  14512. /**
  14513. * Defines the green component (between 0 and 1, default is 0)
  14514. */
  14515. g: number;
  14516. /**
  14517. * Defines the blue component (between 0 and 1, default is 0)
  14518. */
  14519. b: number;
  14520. /**
  14521. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  14522. * @param r defines the red component (between 0 and 1, default is 0)
  14523. * @param g defines the green component (between 0 and 1, default is 0)
  14524. * @param b defines the blue component (between 0 and 1, default is 0)
  14525. */
  14526. constructor(
  14527. /**
  14528. * Defines the red component (between 0 and 1, default is 0)
  14529. */
  14530. r?: number,
  14531. /**
  14532. * Defines the green component (between 0 and 1, default is 0)
  14533. */
  14534. g?: number,
  14535. /**
  14536. * Defines the blue component (between 0 and 1, default is 0)
  14537. */
  14538. b?: number);
  14539. /**
  14540. * Creates a string with the Color3 current values
  14541. * @returns the string representation of the Color3 object
  14542. */
  14543. toString(): string;
  14544. /**
  14545. * Returns the string "Color3"
  14546. * @returns "Color3"
  14547. */
  14548. getClassName(): string;
  14549. /**
  14550. * Compute the Color3 hash code
  14551. * @returns an unique number that can be used to hash Color3 objects
  14552. */
  14553. getHashCode(): number;
  14554. /**
  14555. * Stores in the passed array from the passed starting index the red, green, blue values as successive elements
  14556. * @param array defines the array where to store the r,g,b components
  14557. * @param index defines an optional index in the target array to define where to start storing values
  14558. * @returns the current Color3 object
  14559. */
  14560. toArray(array: FloatArray, index?: number): Color3;
  14561. /**
  14562. * Returns a new {BABYLON.Color4} object from the current Color3 and the passed alpha
  14563. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  14564. * @returns a new {BABYLON.Color4} object
  14565. */
  14566. toColor4(alpha?: number): Color4;
  14567. /**
  14568. * Returns a new array populated with 3 numeric elements : red, green and blue values
  14569. * @returns the new array
  14570. */
  14571. asArray(): number[];
  14572. /**
  14573. * Returns the luminance value
  14574. * @returns a float value
  14575. */
  14576. toLuminance(): number;
  14577. /**
  14578. * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object
  14579. * @param otherColor defines the second operand
  14580. * @returns the new Color3 object
  14581. */
  14582. multiply(otherColor: Color3): Color3;
  14583. /**
  14584. * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result"
  14585. * @param otherColor defines the second operand
  14586. * @param result defines the Color3 object where to store the result
  14587. * @returns the current Color3
  14588. */
  14589. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  14590. /**
  14591. * Determines equality between Color3 objects
  14592. * @param otherColor defines the second operand
  14593. * @returns true if the rgb values are equal to the passed ones
  14594. */
  14595. equals(otherColor: Color3): boolean;
  14596. /**
  14597. * Determines equality between the current Color3 object and a set of r,b,g values
  14598. * @param r defines the red component to check
  14599. * @param g defines the green component to check
  14600. * @param b defines the blue component to check
  14601. * @returns true if the rgb values are equal to the passed ones
  14602. */
  14603. equalsFloats(r: number, g: number, b: number): boolean;
  14604. /**
  14605. * Multiplies in place each rgb value by scale
  14606. * @param scale defines the scaling factor
  14607. * @returns the updated Color3.
  14608. */
  14609. scale(scale: number): Color3;
  14610. /**
  14611. * Multiplies the rgb values by scale and stores the result into "result"
  14612. * @param scale defines the scaling factor
  14613. * @param result defines the Color3 object where to store the result
  14614. * @returns the unmodified current Color3.
  14615. */
  14616. scaleToRef(scale: number, result: Color3): Color3;
  14617. /**
  14618. * Clamps the rgb values by the min and max values and stores the result into "result"
  14619. * @param min defines minimum clamping value (default is 0)
  14620. * @param max defines maximum clamping value (default is 1)
  14621. * @param result defines color to store the result into
  14622. * @returns the original Color3
  14623. */
  14624. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  14625. /**
  14626. * Creates a new Color3 set with the added values of the current Color3 and of the passed one
  14627. * @param otherColor defines the second operand
  14628. * @returns the new Color3
  14629. */
  14630. add(otherColor: Color3): Color3;
  14631. /**
  14632. * Stores the result of the addition of the current Color3 and passed one rgb values into "result"
  14633. * @param otherColor defines the second operand
  14634. * @param result defines Color3 object to store the result into
  14635. * @returns the unmodified current Color3
  14636. */
  14637. addToRef(otherColor: Color3, result: Color3): Color3;
  14638. /**
  14639. * Returns a new Color3 set with the subtracted values of the passed one from the current Color3
  14640. * @param otherColor defines the second operand
  14641. * @returns the new Color3
  14642. */
  14643. subtract(otherColor: Color3): Color3;
  14644. /**
  14645. * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result"
  14646. * @param otherColor defines the second operand
  14647. * @param result defines Color3 object to store the result into
  14648. * @returns the unmodified current Color3
  14649. */
  14650. subtractToRef(otherColor: Color3, result: Color3): Color3;
  14651. /**
  14652. * Copy the current object
  14653. * @returns a new Color3 copied the current one
  14654. */
  14655. clone(): Color3;
  14656. /**
  14657. * Copies the rgb values from the source in the current Color3
  14658. * @param source defines the source Color3 object
  14659. * @returns the updated Color3 object
  14660. */
  14661. copyFrom(source: Color3): Color3;
  14662. /**
  14663. * Updates the Color3 rgb values from the passed floats
  14664. * @param r defines the red component to read from
  14665. * @param g defines the green component to read from
  14666. * @param b defines the blue component to read from
  14667. * @returns the current Color3 object
  14668. */
  14669. copyFromFloats(r: number, g: number, b: number): Color3;
  14670. /**
  14671. * Updates the Color3 rgb values from the passed floats
  14672. * @param r defines the red component to read from
  14673. * @param g defines the green component to read from
  14674. * @param b defines the blue component to read from
  14675. * @returns the current Color3 object
  14676. */
  14677. set(r: number, g: number, b: number): Color3;
  14678. /**
  14679. * Compute the Color3 hexadecimal code as a string
  14680. * @returns a string containing the hexadecimal representation of the Color3 object
  14681. */
  14682. toHexString(): string;
  14683. /**
  14684. * Computes a new Color3 converted from the current one to linear space
  14685. * @returns a new Color3 object
  14686. */
  14687. toLinearSpace(): Color3;
  14688. /**
  14689. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  14690. * @param convertedColor defines the Color3 object where to store the linear space version
  14691. * @returns the unmodified Color3
  14692. */
  14693. toLinearSpaceToRef(convertedColor: Color3): Color3;
  14694. /**
  14695. * Computes a new Color3 converted from the current one to gamma space
  14696. * @returns a new Color3 object
  14697. */
  14698. toGammaSpace(): Color3;
  14699. /**
  14700. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  14701. * @param convertedColor defines the Color3 object where to store the gamma space version
  14702. * @returns the unmodified Color3
  14703. */
  14704. toGammaSpaceToRef(convertedColor: Color3): Color3;
  14705. /**
  14706. * Creates a new Color3 from the string containing valid hexadecimal values
  14707. * @param hex defines a string containing valid hexadecimal values
  14708. * @returns a new Color3 object
  14709. */
  14710. static FromHexString(hex: string): Color3;
  14711. /**
  14712. * Creates a new Vector3 from the starting index of the passed array
  14713. * @param array defines the source array
  14714. * @param offset defines an offset in the source array
  14715. * @returns a new Color3 object
  14716. */
  14717. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  14718. /**
  14719. * Creates a new Color3 from integer values (< 256)
  14720. * @param r defines the red component to read from (value between 0 and 255)
  14721. * @param g defines the green component to read from (value between 0 and 255)
  14722. * @param b defines the blue component to read from (value between 0 and 255)
  14723. * @returns a new Color3 object
  14724. */
  14725. static FromInts(r: number, g: number, b: number): Color3;
  14726. /**
  14727. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  14728. * @param start defines the start Color3 value
  14729. * @param end defines the end Color3 value
  14730. * @param amount defines the gradient value between start and end
  14731. * @returns a new Color3 object
  14732. */
  14733. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  14734. /**
  14735. * Returns a Color3 value containing a red color
  14736. * @returns a new Color3 object
  14737. */
  14738. static Red(): Color3;
  14739. /**
  14740. * Returns a Color3 value containing a green color
  14741. * @returns a new Color3 object
  14742. */
  14743. static Green(): Color3;
  14744. /**
  14745. * Returns a Color3 value containing a blue color
  14746. * @returns a new Color3 object
  14747. */
  14748. static Blue(): Color3;
  14749. /**
  14750. * Returns a Color3 value containing a black color
  14751. * @returns a new Color3 object
  14752. */
  14753. static Black(): Color3;
  14754. /**
  14755. * Returns a Color3 value containing a white color
  14756. * @returns a new Color3 object
  14757. */
  14758. static White(): Color3;
  14759. /**
  14760. * Returns a Color3 value containing a purple color
  14761. * @returns a new Color3 object
  14762. */
  14763. static Purple(): Color3;
  14764. /**
  14765. * Returns a Color3 value containing a magenta color
  14766. * @returns a new Color3 object
  14767. */
  14768. static Magenta(): Color3;
  14769. /**
  14770. * Returns a Color3 value containing a yellow color
  14771. * @returns a new Color3 object
  14772. */
  14773. static Yellow(): Color3;
  14774. /**
  14775. * Returns a Color3 value containing a gray color
  14776. * @returns a new Color3 object
  14777. */
  14778. static Gray(): Color3;
  14779. /**
  14780. * Returns a Color3 value containing a teal color
  14781. * @returns a new Color3 object
  14782. */
  14783. static Teal(): Color3;
  14784. /**
  14785. * Returns a Color3 value containing a random color
  14786. * @returns a new Color3 object
  14787. */
  14788. static Random(): Color3;
  14789. }
  14790. /**
  14791. * Class used to hold a RBGA color
  14792. */
  14793. class Color4 {
  14794. /**
  14795. * Defines the red component (between 0 and 1, default is 0)
  14796. */
  14797. r: number;
  14798. /**
  14799. * Defines the green component (between 0 and 1, default is 0)
  14800. */
  14801. g: number;
  14802. /**
  14803. * Defines the blue component (between 0 and 1, default is 0)
  14804. */
  14805. b: number;
  14806. /**
  14807. * Defines the alpha component (between 0 and 1, default is 1)
  14808. */
  14809. a: number;
  14810. /**
  14811. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  14812. * @param r defines the red component (between 0 and 1, default is 0)
  14813. * @param g defines the green component (between 0 and 1, default is 0)
  14814. * @param b defines the blue component (between 0 and 1, default is 0)
  14815. * @param a defines the alpha component (between 0 and 1, default is 1)
  14816. */
  14817. constructor(
  14818. /**
  14819. * Defines the red component (between 0 and 1, default is 0)
  14820. */
  14821. r?: number,
  14822. /**
  14823. * Defines the green component (between 0 and 1, default is 0)
  14824. */
  14825. g?: number,
  14826. /**
  14827. * Defines the blue component (between 0 and 1, default is 0)
  14828. */
  14829. b?: number,
  14830. /**
  14831. * Defines the alpha component (between 0 and 1, default is 1)
  14832. */
  14833. a?: number);
  14834. /**
  14835. * Adds in place the passed Color4 values to the current Color4 object
  14836. * @param right defines the second operand
  14837. * @returns the current updated Color4 object
  14838. */
  14839. addInPlace(right: Color4): Color4;
  14840. /**
  14841. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  14842. * @returns the new array
  14843. */
  14844. asArray(): number[];
  14845. /**
  14846. * Stores from the starting index in the passed array the Color4 successive values
  14847. * @param array defines the array where to store the r,g,b components
  14848. * @param index defines an optional index in the target array to define where to start storing values
  14849. * @returns the current Color4 object
  14850. */
  14851. toArray(array: number[], index?: number): Color4;
  14852. /**
  14853. * Creates a new Color4 set with the added values of the current Color4 and of the passed one
  14854. * @param right defines the second operand
  14855. * @returns a new Color4 object
  14856. */
  14857. add(right: Color4): Color4;
  14858. /**
  14859. * Creates a new Color4 set with the subtracted values of the passed one from the current Color4
  14860. * @param right defines the second operand
  14861. * @returns a new Color4 object
  14862. */
  14863. subtract(right: Color4): Color4;
  14864. /**
  14865. * Subtracts the passed ones from the current Color4 values and stores the results in "result"
  14866. * @param right defines the second operand
  14867. * @param result defines the Color4 object where to store the result
  14868. * @returns the current Color4 object
  14869. */
  14870. subtractToRef(right: Color4, result: Color4): Color4;
  14871. /**
  14872. * Creates a new Color4 with the current Color4 values multiplied by scale
  14873. * @param scale defines the scaling factor to apply
  14874. * @returns a new Color4 object
  14875. */
  14876. scale(scale: number): Color4;
  14877. /**
  14878. * Multiplies the current Color4 values by scale and stores the result in "result"
  14879. * @param scale defines the scaling factor to apply
  14880. * @param result defines the Color4 object where to store the result
  14881. * @returns the current Color4.
  14882. */
  14883. scaleToRef(scale: number, result: Color4): Color4;
  14884. /**
  14885. * Clamps the rgb values by the min and max values and stores the result into "result"
  14886. * @param min defines minimum clamping value (default is 0)
  14887. * @param max defines maximum clamping value (default is 1)
  14888. * @param result defines color to store the result into.
  14889. * @returns the cuurent Color4
  14890. */
  14891. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  14892. /**
  14893. * Multipy an Color4 value by another and return a new Color4 object
  14894. * @param color defines the Color4 value to multiply by
  14895. * @returns a new Color4 object
  14896. */
  14897. multiply(color: Color4): Color4;
  14898. /**
  14899. * Multipy a Color4 value by another and push the result in a reference value
  14900. * @param color defines the Color4 value to multiply by
  14901. * @param result defines the Color4 to fill the result in
  14902. * @returns the result Color4
  14903. */
  14904. multiplyToRef(color: Color4, result: Color4): Color4;
  14905. /**
  14906. * Creates a string with the Color4 current values
  14907. * @returns the string representation of the Color4 object
  14908. */
  14909. toString(): string;
  14910. /**
  14911. * Returns the string "Color4"
  14912. * @returns "Color4"
  14913. */
  14914. getClassName(): string;
  14915. /**
  14916. * Compute the Color4 hash code
  14917. * @returns an unique number that can be used to hash Color4 objects
  14918. */
  14919. getHashCode(): number;
  14920. /**
  14921. * Creates a new Color4 copied from the current one
  14922. * @returns a new Color4 object
  14923. */
  14924. clone(): Color4;
  14925. /**
  14926. * Copies the passed Color4 values into the current one
  14927. * @param source defines the source Color4 object
  14928. * @returns the current updated Color4 object
  14929. */
  14930. copyFrom(source: Color4): Color4;
  14931. /**
  14932. * Copies the passed float values into the current one
  14933. * @param r defines the red component to read from
  14934. * @param g defines the green component to read from
  14935. * @param b defines the blue component to read from
  14936. * @param a defines the alpha component to read from
  14937. * @returns the current updated Color4 object
  14938. */
  14939. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  14940. /**
  14941. * Copies the passed float values into the current one
  14942. * @param r defines the red component to read from
  14943. * @param g defines the green component to read from
  14944. * @param b defines the blue component to read from
  14945. * @param a defines the alpha component to read from
  14946. * @returns the current updated Color4 object
  14947. */
  14948. set(r: number, g: number, b: number, a: number): Color4;
  14949. /**
  14950. * Compute the Color4 hexadecimal code as a string
  14951. * @returns a string containing the hexadecimal representation of the Color4 object
  14952. */
  14953. toHexString(): string;
  14954. /**
  14955. * Computes a new Color4 converted from the current one to linear space
  14956. * @returns a new Color4 object
  14957. */
  14958. toLinearSpace(): Color4;
  14959. /**
  14960. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  14961. * @param convertedColor defines the Color4 object where to store the linear space version
  14962. * @returns the unmodified Color4
  14963. */
  14964. toLinearSpaceToRef(convertedColor: Color4): Color4;
  14965. /**
  14966. * Computes a new Color4 converted from the current one to gamma space
  14967. * @returns a new Color4 object
  14968. */
  14969. toGammaSpace(): Color4;
  14970. /**
  14971. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  14972. * @param convertedColor defines the Color4 object where to store the gamma space version
  14973. * @returns the unmodified Color4
  14974. */
  14975. toGammaSpaceToRef(convertedColor: Color4): Color4;
  14976. /**
  14977. * Creates a new Color4 from the string containing valid hexadecimal values
  14978. * @param hex defines a string containing valid hexadecimal values
  14979. * @returns a new Color4 object
  14980. */
  14981. static FromHexString(hex: string): Color4;
  14982. /**
  14983. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  14984. * @param left defines the start value
  14985. * @param right defines the end value
  14986. * @param amount defines the gradient factor
  14987. * @returns a new Color4 object
  14988. */
  14989. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  14990. /**
  14991. * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  14992. * @param left defines the start value
  14993. * @param right defines the end value
  14994. * @param amount defines the gradient factor
  14995. * @param result defines the Color4 object where to store data
  14996. */
  14997. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  14998. /**
  14999. * Creates a new Color4 from the starting index element of the passed array
  15000. * @param array defines the source array to read from
  15001. * @param offset defines the offset in the source array
  15002. * @returns a new Color4 object
  15003. */
  15004. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  15005. /**
  15006. * Creates a new Color3 from integer values (< 256)
  15007. * @param r defines the red component to read from (value between 0 and 255)
  15008. * @param g defines the green component to read from (value between 0 and 255)
  15009. * @param b defines the blue component to read from (value between 0 and 255)
  15010. * @param a defines the alpha component to read from (value between 0 and 255)
  15011. * @returns a new Color3 object
  15012. */
  15013. static FromInts(r: number, g: number, b: number, a: number): Color4;
  15014. /**
  15015. * Check the content of a given array and convert it to an array containing RGBA data
  15016. * If the original array was already containing count * 4 values then it is returned directly
  15017. * @param colors defines the array to check
  15018. * @param count defines the number of RGBA data to expect
  15019. * @returns an array containing count * 4 values (RGBA)
  15020. */
  15021. static CheckColors4(colors: number[], count: number): number[];
  15022. }
  15023. class Vector2 {
  15024. x: number;
  15025. y: number;
  15026. /**
  15027. * Creates a new Vector2 from the passed x and y coordinates.
  15028. */
  15029. constructor(x: number, y: number);
  15030. /**
  15031. * Returns a string with the Vector2 coordinates.
  15032. */
  15033. toString(): string;
  15034. /**
  15035. * Returns the string "Vector2"
  15036. */
  15037. getClassName(): string;
  15038. /**
  15039. * Returns the Vector2 hash code as a number.
  15040. */
  15041. getHashCode(): number;
  15042. /**
  15043. * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index.
  15044. * Returns the Vector2.
  15045. */
  15046. toArray(array: FloatArray, index?: number): Vector2;
  15047. /**
  15048. * Returns a new array with 2 elements : the Vector2 coordinates.
  15049. */
  15050. asArray(): number[];
  15051. /**
  15052. * Sets the Vector2 coordinates with the passed Vector2 coordinates.
  15053. * Returns the updated Vector2.
  15054. */
  15055. copyFrom(source: Vector2): Vector2;
  15056. /**
  15057. * Sets the Vector2 coordinates with the passed floats.
  15058. * Returns the updated Vector2.
  15059. */
  15060. copyFromFloats(x: number, y: number): Vector2;
  15061. /**
  15062. * Sets the Vector2 coordinates with the passed floats.
  15063. * Returns the updated Vector2.
  15064. */
  15065. set(x: number, y: number): Vector2;
  15066. /**
  15067. * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates.
  15068. */
  15069. add(otherVector: Vector2): Vector2;
  15070. /**
  15071. * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates.
  15072. * Returns the Vector2.
  15073. */
  15074. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  15075. /**
  15076. * Set the Vector2 coordinates by adding the passed Vector2 coordinates.
  15077. * Returns the updated Vector2.
  15078. */
  15079. addInPlace(otherVector: Vector2): Vector2;
  15080. /**
  15081. * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates.
  15082. */
  15083. addVector3(otherVector: Vector3): Vector2;
  15084. /**
  15085. * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2.
  15086. */
  15087. subtract(otherVector: Vector2): Vector2;
  15088. /**
  15089. * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates.
  15090. * Returns the Vector2.
  15091. */
  15092. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  15093. /**
  15094. * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates.
  15095. * Returns the updated Vector2.
  15096. */
  15097. subtractInPlace(otherVector: Vector2): Vector2;
  15098. /**
  15099. * Multiplies in place the current Vector2 coordinates by the passed ones.
  15100. * Returns the updated Vector2.
  15101. */
  15102. multiplyInPlace(otherVector: Vector2): Vector2;
  15103. /**
  15104. * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates.
  15105. */
  15106. multiply(otherVector: Vector2): Vector2;
  15107. /**
  15108. * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates.
  15109. * Returns the Vector2.
  15110. */
  15111. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  15112. /**
  15113. * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats.
  15114. */
  15115. multiplyByFloats(x: number, y: number): Vector2;
  15116. /**
  15117. * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates.
  15118. */
  15119. divide(otherVector: Vector2): Vector2;
  15120. /**
  15121. * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates.
  15122. * Returns the Vector2.
  15123. */
  15124. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  15125. /**
  15126. * Divides the current Vector3 coordinates by the passed ones.
  15127. * Returns the updated Vector3.
  15128. */
  15129. divideInPlace(otherVector: Vector2): Vector2;
  15130. /**
  15131. * Returns a new Vector2 with current Vector2 negated coordinates.
  15132. */
  15133. negate(): Vector2;
  15134. /**
  15135. * Multiply the Vector2 coordinates by scale.
  15136. * Returns the updated Vector2.
  15137. */
  15138. scaleInPlace(scale: number): Vector2;
  15139. /**
  15140. * Returns a new Vector2 scaled by "scale" from the current Vector2.
  15141. */
  15142. scale(scale: number): Vector2;
  15143. /**
  15144. * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones.
  15145. */
  15146. equals(otherVector: Vector2): boolean;
  15147. /**
  15148. * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon.
  15149. */
  15150. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  15151. /**
  15152. * Returns the vector length (float).
  15153. */
  15154. length(): number;
  15155. /**
  15156. * Returns the vector squared length (float);
  15157. */
  15158. lengthSquared(): number;
  15159. /**
  15160. * Normalize the vector.
  15161. * Returns the updated Vector2.
  15162. */
  15163. normalize(): Vector2;
  15164. /**
  15165. * Returns a new Vector2 copied from the Vector2.
  15166. */
  15167. clone(): Vector2;
  15168. /**
  15169. * Returns a new Vector2(0, 0)
  15170. */
  15171. static Zero(): Vector2;
  15172. /**
  15173. * Returns a new Vector2(1, 1)
  15174. */
  15175. static One(): Vector2;
  15176. /**
  15177. * Returns a new Vector2 set from the passed index element of the passed array.
  15178. */
  15179. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  15180. /**
  15181. * Sets "result" from the passed index element of the passed array.
  15182. */
  15183. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  15184. /**
  15185. * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2.
  15186. */
  15187. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  15188. /**
  15189. * 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".
  15190. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  15191. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate.
  15192. */
  15193. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  15194. /**
  15195. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2".
  15196. */
  15197. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  15198. /**
  15199. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  15200. */
  15201. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  15202. /**
  15203. * Returns the dot product (float) of the vector "left" and the vector "right".
  15204. */
  15205. static Dot(left: Vector2, right: Vector2): number;
  15206. /**
  15207. * Returns a new Vector2 equal to the normalized passed vector.
  15208. */
  15209. static Normalize(vector: Vector2): Vector2;
  15210. /**
  15211. * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors.
  15212. */
  15213. static Minimize(left: Vector2, right: Vector2): Vector2;
  15214. /**
  15215. * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors.
  15216. */
  15217. static Maximize(left: Vector2, right: Vector2): Vector2;
  15218. /**
  15219. * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix.
  15220. */
  15221. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  15222. /**
  15223. * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates.
  15224. */
  15225. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  15226. /**
  15227. * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  15228. */
  15229. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  15230. /**
  15231. * Returns the distance (float) between the vectors "value1" and "value2".
  15232. */
  15233. static Distance(value1: Vector2, value2: Vector2): number;
  15234. /**
  15235. * Returns the squared distance (float) between the vectors "value1" and "value2".
  15236. */
  15237. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  15238. /**
  15239. * Returns a new Vecto2 located at the center of the vectors "value1" and "value2".
  15240. */
  15241. static Center(value1: Vector2, value2: Vector2): Vector2;
  15242. /**
  15243. * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  15244. */
  15245. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  15246. }
  15247. /**
  15248. * Classed used to store (x,y,z) vector representation
  15249. * A Vector3 is the main object used in 3D geometry
  15250. * It can represent etiher the coordinates of a point the space, either a direction
  15251. * Reminder: Babylon.js uses a left handed forward facing system
  15252. */
  15253. class Vector3 {
  15254. /**
  15255. * Defines the first coordinates (on X axis)
  15256. */
  15257. x: number;
  15258. /**
  15259. * Defines the second coordinates (on Y axis)
  15260. */
  15261. y: number;
  15262. /**
  15263. * Defines the third coordinates (on Z axis)
  15264. */
  15265. z: number;
  15266. /**
  15267. * Creates a new Vector3 object from the passed x, y, z (floats) coordinates.
  15268. * @param x defines the first coordinates (on X axis)
  15269. * @param y defines the second coordinates (on Y axis)
  15270. * @param z defines the third coordinates (on Z axis)
  15271. */
  15272. constructor(
  15273. /**
  15274. * Defines the first coordinates (on X axis)
  15275. */
  15276. x: number,
  15277. /**
  15278. * Defines the second coordinates (on Y axis)
  15279. */
  15280. y: number,
  15281. /**
  15282. * Defines the third coordinates (on Z axis)
  15283. */
  15284. z: number);
  15285. /**
  15286. * Creates a string representation of the Vector3
  15287. * @returns a string with the Vector3 coordinates.
  15288. */
  15289. toString(): string;
  15290. /**
  15291. * Gets the class name
  15292. * @returns the string "Vector3"
  15293. */
  15294. getClassName(): string;
  15295. /**
  15296. * Creates the Vector3 hash code
  15297. * @returns a number which tends to be unique between Vector3 instances
  15298. */
  15299. getHashCode(): number;
  15300. /**
  15301. * Creates an array containing three elements : the coordinates of the Vector3
  15302. * @returns a new array of numbers
  15303. */
  15304. asArray(): number[];
  15305. /**
  15306. * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3
  15307. * @param array defines the destination array
  15308. * @param index defines the offset in the destination array
  15309. * @returns the current Vector3
  15310. */
  15311. toArray(array: FloatArray, index?: number): Vector3;
  15312. /**
  15313. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  15314. * @returns a new Quaternion object, computed from the Vector3 coordinates
  15315. */
  15316. toQuaternion(): Quaternion;
  15317. /**
  15318. * Adds the passed vector to the current Vector3
  15319. * @param otherVector defines the second operand
  15320. * @returns the current updated Vector3
  15321. */
  15322. addInPlace(otherVector: Vector3): Vector3;
  15323. /**
  15324. * Gets a new Vector3, result of the addition the current Vector3 and the passed vector
  15325. * @param otherVector defines the second operand
  15326. * @returns the resulting Vector3
  15327. */
  15328. add(otherVector: Vector3): Vector3;
  15329. /**
  15330. * Adds the current Vector3 to the passed one and stores the result in the vector "result"
  15331. * @param otherVector defines the second operand
  15332. * @param result defines the Vector3 object where to store the result
  15333. * @returns the current Vector3
  15334. */
  15335. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  15336. /**
  15337. * Subtract the passed vector from the current Vector3
  15338. * @param otherVector defines the second operand
  15339. * @returns the current updated Vector3
  15340. */
  15341. subtractInPlace(otherVector: Vector3): Vector3;
  15342. /**
  15343. * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3
  15344. * @param otherVector defines the second operand
  15345. * @returns the resulting Vector3
  15346. */
  15347. subtract(otherVector: Vector3): Vector3;
  15348. /**
  15349. * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result".
  15350. * @param otherVector defines the second operand
  15351. * @param result defines the Vector3 object where to store the result
  15352. * @returns the current Vector3
  15353. */
  15354. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  15355. /**
  15356. * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates
  15357. * @param x defines the x coordinate of the operand
  15358. * @param y defines the y coordinate of the operand
  15359. * @param z defines the z coordinate of the operand
  15360. * @returns the resulting Vector3
  15361. */
  15362. subtractFromFloats(x: number, y: number, z: number): Vector3;
  15363. /**
  15364. * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result
  15365. * @param x defines the x coordinate of the operand
  15366. * @param y defines the y coordinate of the operand
  15367. * @param z defines the z coordinate of the operand
  15368. * @param result defines the Vector3 object where to store the result
  15369. * @returns the current Vector3
  15370. */
  15371. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  15372. /**
  15373. * Gets a new Vector3 set with the current Vector3 negated coordinates
  15374. * @returns a new Vector3
  15375. */
  15376. negate(): Vector3;
  15377. /**
  15378. * Multiplies the Vector3 coordinates by the float "scale"
  15379. * @param scale defines the multiplier factor
  15380. * @returns the current updated Vector3
  15381. */
  15382. scaleInPlace(scale: number): Vector3;
  15383. /**
  15384. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  15385. * @param scale defines the multiplier factor
  15386. * @returns a new Vector3
  15387. */
  15388. scale(scale: number): Vector3;
  15389. /**
  15390. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates
  15391. * @param scale defines the multiplier factor
  15392. * @param result defines the Vector3 object where to store the result
  15393. * @returns the current Vector3
  15394. */
  15395. scaleToRef(scale: number, result: Vector3): Vector3;
  15396. /**
  15397. * Returns true if the current Vector3 and the passed vector coordinates are strictly equal
  15398. * @param otherVector defines the second operand
  15399. * @returns true if both vectors are equals
  15400. */
  15401. equals(otherVector: Vector3): boolean;
  15402. /**
  15403. * Returns true if the current Vector3 and the passed vector coordinates are distant less than epsilon
  15404. * @param otherVector defines the second operand
  15405. * @param epsilon defines the minimal distance to define values as equals
  15406. * @returns true if both vectors are distant less than epsilon
  15407. */
  15408. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  15409. /**
  15410. * Returns true if the current Vector3 coordinates equals the passed floats
  15411. * @param x defines the x coordinate of the operand
  15412. * @param y defines the y coordinate of the operand
  15413. * @param z defines the z coordinate of the operand
  15414. * @returns true if both vectors are equals
  15415. */
  15416. equalsToFloats(x: number, y: number, z: number): boolean;
  15417. /**
  15418. * Multiplies the current Vector3 coordinates by the passed ones
  15419. * @param otherVector defines the second operand
  15420. * @returns the current updated Vector3
  15421. */
  15422. multiplyInPlace(otherVector: Vector3): Vector3;
  15423. /**
  15424. * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector
  15425. * @param otherVector defines the second operand
  15426. * @returns the new Vector3
  15427. */
  15428. multiply(otherVector: Vector3): Vector3;
  15429. /**
  15430. * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result"
  15431. * @param otherVector defines the second operand
  15432. * @param result defines the Vector3 object where to store the result
  15433. * @returns the current Vector3
  15434. */
  15435. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  15436. /**
  15437. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the passed floats
  15438. * @param x defines the x coordinate of the operand
  15439. * @param y defines the y coordinate of the operand
  15440. * @param z defines the z coordinate of the operand
  15441. * @returns the new Vector3
  15442. */
  15443. multiplyByFloats(x: number, y: number, z: number): Vector3;
  15444. /**
  15445. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the passed ones
  15446. * @param otherVector defines the second operand
  15447. * @returns the new Vector3
  15448. */
  15449. divide(otherVector: Vector3): Vector3;
  15450. /**
  15451. * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result"
  15452. * @param otherVector defines the second operand
  15453. * @param result defines the Vector3 object where to store the result
  15454. * @returns the current Vector3
  15455. */
  15456. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  15457. /**
  15458. * Divides the current Vector3 coordinates by the passed ones.
  15459. * @param otherVector defines the second operand
  15460. * @returns the current updated Vector3
  15461. */
  15462. divideInPlace(otherVector: Vector3): Vector3;
  15463. /**
  15464. * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones
  15465. * @param other defines the second operand
  15466. * @returns the current updated Vector3
  15467. */
  15468. minimizeInPlace(other: Vector3): Vector3;
  15469. /**
  15470. * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones.
  15471. * @param other defines the second operand
  15472. * @returns the current updated Vector3
  15473. */
  15474. maximizeInPlace(other: Vector3): Vector3;
  15475. /**
  15476. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  15477. */
  15478. readonly isNonUniform: boolean;
  15479. /**
  15480. * Gets the length of the Vector3
  15481. * @returns the length of the Vecto3
  15482. */
  15483. length(): number;
  15484. /**
  15485. * Gets the squared length of the Vector3
  15486. * @returns squared length of the Vector3
  15487. */
  15488. lengthSquared(): number;
  15489. /**
  15490. * Normalize the current Vector3.
  15491. * Please note that this is an in place operation.
  15492. * @returns the current updated Vector3
  15493. */
  15494. normalize(): Vector3;
  15495. /**
  15496. * Normalize the current Vector3 to a new vector
  15497. * @returns the new Vector3
  15498. */
  15499. normalizeToNew(): Vector3;
  15500. /**
  15501. * Normalize the current Vector3 to the reference
  15502. * @param reference define the Vector3 to update
  15503. * @returns the updated Vector3
  15504. */
  15505. normalizeToRef(reference: Vector3): Vector3;
  15506. /**
  15507. * Creates a new Vector3 copied from the current Vector3
  15508. * @returns the new Vector3
  15509. */
  15510. clone(): Vector3;
  15511. /**
  15512. * Copies the passed vector coordinates to the current Vector3 ones
  15513. * @param source defines the source Vector3
  15514. * @returns the current updated Vector3
  15515. */
  15516. copyFrom(source: Vector3): Vector3;
  15517. /**
  15518. * Copies the passed floats to the current Vector3 coordinates
  15519. * @param x defines the x coordinate of the operand
  15520. * @param y defines the y coordinate of the operand
  15521. * @param z defines the z coordinate of the operand
  15522. * @returns the current updated Vector3
  15523. */
  15524. copyFromFloats(x: number, y: number, z: number): Vector3;
  15525. /**
  15526. * Copies the passed floats to the current Vector3 coordinates
  15527. * @param x defines the x coordinate of the operand
  15528. * @param y defines the y coordinate of the operand
  15529. * @param z defines the z coordinate of the operand
  15530. * @returns the current updated Vector3
  15531. */
  15532. set(x: number, y: number, z: number): Vector3;
  15533. /**
  15534. * Get the clip factor between two vectors
  15535. * @param vector0 defines the first operand
  15536. * @param vector1 defines the second operand
  15537. * @param axis defines the axis to use
  15538. * @param size defines the size along the axis
  15539. * @returns the clip factor
  15540. */
  15541. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  15542. /**
  15543. * Get angle between two vectors
  15544. * @param vector0 angle between vector0 and vector1
  15545. * @param vector1 angle between vector0 and vector1
  15546. * @param normal direction of the normal
  15547. * @return the angle between vector0 and vector1
  15548. */
  15549. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  15550. /**
  15551. * Returns a new Vector3 set from the index "offset" of the passed array
  15552. * @param array defines the source array
  15553. * @param offset defines the offset in the source array
  15554. * @returns the new Vector3
  15555. */
  15556. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  15557. /**
  15558. * Returns a new Vector3 set from the index "offset" of the passed Float32Array
  15559. * This function is deprecated. Use FromArray instead
  15560. * @param array defines the source array
  15561. * @param offset defines the offset in the source array
  15562. * @returns the new Vector3
  15563. */
  15564. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  15565. /**
  15566. * Sets the passed vector "result" with the element values from the index "offset" of the passed array
  15567. * @param array defines the source array
  15568. * @param offset defines the offset in the source array
  15569. * @param result defines the Vector3 where to store the result
  15570. */
  15571. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  15572. /**
  15573. * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array
  15574. * This function is deprecated. Use FromArrayToRef instead.
  15575. * @param array defines the source array
  15576. * @param offset defines the offset in the source array
  15577. * @param result defines the Vector3 where to store the result
  15578. */
  15579. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  15580. /**
  15581. * Sets the passed vector "result" with the passed floats.
  15582. * @param x defines the x coordinate of the source
  15583. * @param y defines the y coordinate of the source
  15584. * @param z defines the z coordinate of the source
  15585. * @param result defines the Vector3 where to store the result
  15586. */
  15587. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  15588. /**
  15589. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  15590. * @returns a new empty Vector3
  15591. */
  15592. static Zero(): Vector3;
  15593. /**
  15594. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  15595. * @returns a new unit Vector3
  15596. */
  15597. static One(): Vector3;
  15598. /**
  15599. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  15600. * @returns a new up Vector3
  15601. */
  15602. static Up(): Vector3;
  15603. /**
  15604. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  15605. * @returns a new forward Vector3
  15606. */
  15607. static Forward(): Vector3;
  15608. /**
  15609. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  15610. * @returns a new right Vector3
  15611. */
  15612. static Right(): Vector3;
  15613. /**
  15614. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  15615. * @returns a new left Vector3
  15616. */
  15617. static Left(): Vector3;
  15618. /**
  15619. * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector.
  15620. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  15621. * @param vector defines the Vector3 to transform
  15622. * @param transformation defines the transformation matrix
  15623. * @returns the transformed Vector3
  15624. */
  15625. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  15626. /**
  15627. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector
  15628. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  15629. * @param vector defines the Vector3 to transform
  15630. * @param transformation defines the transformation matrix
  15631. * @param result defines the Vector3 where to store the result
  15632. */
  15633. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  15634. /**
  15635. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z)
  15636. * This method computes tranformed coordinates only, not transformed direction vectors
  15637. * @param x define the x coordinate of the source vector
  15638. * @param y define the y coordinate of the source vector
  15639. * @param z define the z coordinate of the source vector
  15640. * @param transformation defines the transformation matrix
  15641. * @param result defines the Vector3 where to store the result
  15642. */
  15643. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  15644. /**
  15645. * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector
  15646. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  15647. * @param vector defines the Vector3 to transform
  15648. * @param transformation defines the transformation matrix
  15649. * @returns the new Vector3
  15650. */
  15651. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  15652. /**
  15653. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector
  15654. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  15655. * @param vector defines the Vector3 to transform
  15656. * @param transformation defines the transformation matrix
  15657. * @param result defines the Vector3 where to store the result
  15658. */
  15659. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  15660. /**
  15661. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z)
  15662. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  15663. * @param x define the x coordinate of the source vector
  15664. * @param y define the y coordinate of the source vector
  15665. * @param z define the z coordinate of the source vector
  15666. * @param transformation defines the transformation matrix
  15667. * @param result defines the Vector3 where to store the result
  15668. */
  15669. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  15670. /**
  15671. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  15672. * @param value1 defines the first control point
  15673. * @param value2 defines the second control point
  15674. * @param value3 defines the third control point
  15675. * @param value4 defines the fourth control point
  15676. * @param amount defines the amount on the spline to use
  15677. * @returns the new Vector3
  15678. */
  15679. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  15680. /**
  15681. * 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"
  15682. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  15683. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  15684. * @param value defines the current value
  15685. * @param min defines the lower range value
  15686. * @param max defines the upper range value
  15687. * @returns the new Vector3
  15688. */
  15689. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  15690. /**
  15691. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  15692. * @param value1 defines the first control point
  15693. * @param tangent1 defines the first tangent vector
  15694. * @param value2 defines the second control point
  15695. * @param tangent2 defines the second tangent vector
  15696. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  15697. * @returns the new Vector3
  15698. */
  15699. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  15700. /**
  15701. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  15702. * @param start defines the start value
  15703. * @param end defines the end value
  15704. * @param amount max defines amount between both (between 0 and 1)
  15705. * @returns the new Vector3
  15706. */
  15707. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  15708. /**
  15709. * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  15710. * @param start defines the start value
  15711. * @param end defines the end value
  15712. * @param amount max defines amount between both (between 0 and 1)
  15713. * @param result defines the Vector3 where to store the result
  15714. */
  15715. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  15716. /**
  15717. * Returns the dot product (float) between the vectors "left" and "right"
  15718. * @param left defines the left operand
  15719. * @param right defines the right operand
  15720. * @returns the dot product
  15721. */
  15722. static Dot(left: Vector3, right: Vector3): number;
  15723. /**
  15724. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  15725. * The cross product is then orthogonal to both "left" and "right"
  15726. * @param left defines the left operand
  15727. * @param right defines the right operand
  15728. * @returns the cross product
  15729. */
  15730. static Cross(left: Vector3, right: Vector3): Vector3;
  15731. /**
  15732. * Sets the passed vector "result" with the cross product of "left" and "right"
  15733. * The cross product is then orthogonal to both "left" and "right"
  15734. * @param left defines the left operand
  15735. * @param right defines the right operand
  15736. * @param result defines the Vector3 where to store the result
  15737. */
  15738. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  15739. /**
  15740. * Returns a new Vector3 as the normalization of the passed vector
  15741. * @param vector defines the Vector3 to normalize
  15742. * @returns the new Vector3
  15743. */
  15744. static Normalize(vector: Vector3): Vector3;
  15745. /**
  15746. * Sets the passed vector "result" with the normalization of the passed first vector
  15747. * @param vector defines the Vector3 to normalize
  15748. * @param result defines the Vector3 where to store the result
  15749. */
  15750. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  15751. private static _viewportMatrixCache;
  15752. /**
  15753. * Project a Vector3 onto screen space
  15754. * @param vector defines the Vector3 to project
  15755. * @param world defines the world matrix to use
  15756. * @param transform defines the transform (view x projection) matrix to use
  15757. * @param viewport defines the screen viewport to use
  15758. * @returns the new Vector3
  15759. */
  15760. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  15761. /**
  15762. * Unproject from screen space to object space
  15763. * @param source defines the screen space Vector3 to use
  15764. * @param viewportWidth defines the current width of the viewport
  15765. * @param viewportHeight defines the current height of the viewport
  15766. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15767. * @param transform defines the transform (view x projection) matrix to use
  15768. * @returns the new Vector3
  15769. */
  15770. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  15771. /**
  15772. * Unproject from screen space to object space
  15773. * @param source defines the screen space Vector3 to use
  15774. * @param viewportWidth defines the current width of the viewport
  15775. * @param viewportHeight defines the current height of the viewport
  15776. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15777. * @param view defines the view matrix to use
  15778. * @param projection defines the projection matrix to use
  15779. * @returns the new Vector3
  15780. */
  15781. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  15782. /**
  15783. * Unproject from screen space to object space
  15784. * @param source defines the screen space Vector3 to use
  15785. * @param viewportWidth defines the current width of the viewport
  15786. * @param viewportHeight defines the current height of the viewport
  15787. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15788. * @param view defines the view matrix to use
  15789. * @param projection defines the projection matrix to use
  15790. * @param result defines the Vector3 where to store the result
  15791. */
  15792. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  15793. /**
  15794. * Unproject from screen space to object space
  15795. * @param sourceX defines the screen space x coordinate to use
  15796. * @param sourceY defines the screen space y coordinate to use
  15797. * @param sourceZ defines the screen space z coordinate to use
  15798. * @param viewportWidth defines the current width of the viewport
  15799. * @param viewportHeight defines the current height of the viewport
  15800. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15801. * @param view defines the view matrix to use
  15802. * @param projection defines the projection matrix to use
  15803. * @param result defines the Vector3 where to store the result
  15804. */
  15805. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  15806. /**
  15807. * Gets the minimal coordinate values between two Vector3
  15808. * @param left defines the first operand
  15809. * @param right defines the second operand
  15810. * @returns the new Vector3
  15811. */
  15812. static Minimize(left: Vector3, right: Vector3): Vector3;
  15813. /**
  15814. * Gets the maximal coordinate values between two Vector3
  15815. * @param left defines the first operand
  15816. * @param right defines the second operand
  15817. * @returns the new Vector3
  15818. */
  15819. static Maximize(left: Vector3, right: Vector3): Vector3;
  15820. /**
  15821. * Returns the distance between the vectors "value1" and "value2"
  15822. * @param value1 defines the first operand
  15823. * @param value2 defines the second operand
  15824. * @returns the distance
  15825. */
  15826. static Distance(value1: Vector3, value2: Vector3): number;
  15827. /**
  15828. * Returns the squared distance between the vectors "value1" and "value2"
  15829. * @param value1 defines the first operand
  15830. * @param value2 defines the second operand
  15831. * @returns the squared distance
  15832. */
  15833. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  15834. /**
  15835. * Returns a new Vector3 located at the center between "value1" and "value2"
  15836. * @param value1 defines the first operand
  15837. * @param value2 defines the second operand
  15838. * @returns the new Vector3
  15839. */
  15840. static Center(value1: Vector3, value2: Vector3): Vector3;
  15841. /**
  15842. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  15843. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  15844. * to something in order to rotate it from its local system to the given target system
  15845. * Note: axis1, axis2 and axis3 are normalized during this operation
  15846. * @param axis1 defines the first axis
  15847. * @param axis2 defines the second axis
  15848. * @param axis3 defines the third axis
  15849. * @returns a new Vector3
  15850. */
  15851. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  15852. /**
  15853. * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3
  15854. * @param axis1 defines the first axis
  15855. * @param axis2 defines the second axis
  15856. * @param axis3 defines the third axis
  15857. * @param ref defines the Vector3 where to store the result
  15858. */
  15859. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  15860. }
  15861. class Vector4 {
  15862. x: number;
  15863. y: number;
  15864. z: number;
  15865. w: number;
  15866. /**
  15867. * Creates a Vector4 object from the passed floats.
  15868. */
  15869. constructor(x: number, y: number, z: number, w: number);
  15870. /**
  15871. * Returns the string with the Vector4 coordinates.
  15872. */
  15873. toString(): string;
  15874. /**
  15875. * Returns the string "Vector4".
  15876. */
  15877. getClassName(): string;
  15878. /**
  15879. * Returns the Vector4 hash code.
  15880. */
  15881. getHashCode(): number;
  15882. /**
  15883. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  15884. */
  15885. asArray(): number[];
  15886. /**
  15887. * Populates the passed array from the passed index with the Vector4 coordinates.
  15888. * Returns the Vector4.
  15889. */
  15890. toArray(array: FloatArray, index?: number): Vector4;
  15891. /**
  15892. * Adds the passed vector to the current Vector4.
  15893. * Returns the updated Vector4.
  15894. */
  15895. addInPlace(otherVector: Vector4): Vector4;
  15896. /**
  15897. * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one.
  15898. */
  15899. add(otherVector: Vector4): Vector4;
  15900. /**
  15901. * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one.
  15902. * Returns the current Vector4.
  15903. */
  15904. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  15905. /**
  15906. * Subtract in place the passed vector from the current Vector4.
  15907. * Returns the updated Vector4.
  15908. */
  15909. subtractInPlace(otherVector: Vector4): Vector4;
  15910. /**
  15911. * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4.
  15912. */
  15913. subtract(otherVector: Vector4): Vector4;
  15914. /**
  15915. * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4.
  15916. * Returns the current Vector4.
  15917. */
  15918. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  15919. /**
  15920. * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  15921. */
  15922. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  15923. /**
  15924. * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  15925. * Returns the current Vector4.
  15926. */
  15927. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  15928. /**
  15929. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  15930. */
  15931. negate(): Vector4;
  15932. /**
  15933. * Multiplies the current Vector4 coordinates by scale (float).
  15934. * Returns the updated Vector4.
  15935. */
  15936. scaleInPlace(scale: number): Vector4;
  15937. /**
  15938. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  15939. */
  15940. scale(scale: number): Vector4;
  15941. /**
  15942. * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float).
  15943. * Returns the current Vector4.
  15944. */
  15945. scaleToRef(scale: number, result: Vector4): Vector4;
  15946. /**
  15947. * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones.
  15948. */
  15949. equals(otherVector: Vector4): boolean;
  15950. /**
  15951. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones.
  15952. */
  15953. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  15954. /**
  15955. * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates.
  15956. */
  15957. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  15958. /**
  15959. * Multiplies in place the current Vector4 by the passed one.
  15960. * Returns the updated Vector4.
  15961. */
  15962. multiplyInPlace(otherVector: Vector4): Vector4;
  15963. /**
  15964. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one.
  15965. */
  15966. multiply(otherVector: Vector4): Vector4;
  15967. /**
  15968. * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one.
  15969. * Returns the current Vector4.
  15970. */
  15971. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  15972. /**
  15973. * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates.
  15974. */
  15975. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  15976. /**
  15977. * Returns a new Vector4 set with the division result of the current Vector4 by the passed one.
  15978. */
  15979. divide(otherVector: Vector4): Vector4;
  15980. /**
  15981. * Updates the passed vector "result" with the division result of the current Vector4 by the passed one.
  15982. * Returns the current Vector4.
  15983. */
  15984. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  15985. /**
  15986. * Divides the current Vector3 coordinates by the passed ones.
  15987. * @returns the updated Vector3.
  15988. */
  15989. divideInPlace(otherVector: Vector4): Vector4;
  15990. /**
  15991. * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones
  15992. * @param other defines the second operand
  15993. * @returns the current updated Vector4
  15994. */
  15995. minimizeInPlace(other: Vector4): Vector4;
  15996. /**
  15997. * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones
  15998. * @param other defines the second operand
  15999. * @returns the current updated Vector4
  16000. */
  16001. maximizeInPlace(other: Vector4): Vector4;
  16002. /**
  16003. * Returns the Vector4 length (float).
  16004. */
  16005. length(): number;
  16006. /**
  16007. * Returns the Vector4 squared length (float).
  16008. */
  16009. lengthSquared(): number;
  16010. /**
  16011. * Normalizes in place the Vector4.
  16012. * Returns the updated Vector4.
  16013. */
  16014. normalize(): Vector4;
  16015. /**
  16016. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  16017. */
  16018. toVector3(): Vector3;
  16019. /**
  16020. * Returns a new Vector4 copied from the current one.
  16021. */
  16022. clone(): Vector4;
  16023. /**
  16024. * Updates the current Vector4 with the passed one coordinates.
  16025. * Returns the updated Vector4.
  16026. */
  16027. copyFrom(source: Vector4): Vector4;
  16028. /**
  16029. * Updates the current Vector4 coordinates with the passed floats.
  16030. * Returns the updated Vector4.
  16031. */
  16032. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16033. /**
  16034. * Updates the current Vector4 coordinates with the passed floats.
  16035. * Returns the updated Vector4.
  16036. */
  16037. set(x: number, y: number, z: number, w: number): Vector4;
  16038. /**
  16039. * Returns a new Vector4 set from the starting index of the passed array.
  16040. */
  16041. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  16042. /**
  16043. * Updates the passed vector "result" from the starting index of the passed array.
  16044. */
  16045. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  16046. /**
  16047. * Updates the passed vector "result" from the starting index of the passed Float32Array.
  16048. */
  16049. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  16050. /**
  16051. * Updates the passed vector "result" coordinates from the passed floats.
  16052. */
  16053. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  16054. /**
  16055. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  16056. */
  16057. static Zero(): Vector4;
  16058. /**
  16059. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  16060. */
  16061. static One(): Vector4;
  16062. /**
  16063. * Returns a new normalized Vector4 from the passed one.
  16064. */
  16065. static Normalize(vector: Vector4): Vector4;
  16066. /**
  16067. * Updates the passed vector "result" from the normalization of the passed one.
  16068. */
  16069. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  16070. static Minimize(left: Vector4, right: Vector4): Vector4;
  16071. static Maximize(left: Vector4, right: Vector4): Vector4;
  16072. /**
  16073. * Returns the distance (float) between the vectors "value1" and "value2".
  16074. */
  16075. static Distance(value1: Vector4, value2: Vector4): number;
  16076. /**
  16077. * Returns the squared distance (float) between the vectors "value1" and "value2".
  16078. */
  16079. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  16080. /**
  16081. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  16082. */
  16083. static Center(value1: Vector4, value2: Vector4): Vector4;
  16084. /**
  16085. * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector.
  16086. * This methods computes transformed normalized direction vectors only.
  16087. */
  16088. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  16089. /**
  16090. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector.
  16091. * This methods computes transformed normalized direction vectors only.
  16092. */
  16093. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  16094. /**
  16095. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w).
  16096. * This methods computes transformed normalized direction vectors only.
  16097. */
  16098. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  16099. }
  16100. interface ISize {
  16101. width: number;
  16102. height: number;
  16103. }
  16104. class Size implements ISize {
  16105. width: number;
  16106. height: number;
  16107. /**
  16108. * Creates a Size object from the passed width and height (floats).
  16109. */
  16110. constructor(width: number, height: number);
  16111. toString(): string;
  16112. /**
  16113. * Returns the string "Size"
  16114. */
  16115. getClassName(): string;
  16116. /**
  16117. * Returns the Size hash code.
  16118. */
  16119. getHashCode(): number;
  16120. /**
  16121. * Updates the current size from the passed one.
  16122. * Returns the updated Size.
  16123. */
  16124. copyFrom(src: Size): void;
  16125. /**
  16126. * Updates in place the current Size from the passed floats.
  16127. * Returns the updated Size.
  16128. */
  16129. copyFromFloats(width: number, height: number): Size;
  16130. /**
  16131. * Updates in place the current Size from the passed floats.
  16132. * Returns the updated Size.
  16133. */
  16134. set(width: number, height: number): Size;
  16135. /**
  16136. * Returns a new Size set with the multiplication result of the current Size and the passed floats.
  16137. */
  16138. multiplyByFloats(w: number, h: number): Size;
  16139. /**
  16140. * Returns a new Size copied from the passed one.
  16141. */
  16142. clone(): Size;
  16143. /**
  16144. * Boolean : True if the current Size and the passed one width and height are strictly equal.
  16145. */
  16146. equals(other: Size): boolean;
  16147. /**
  16148. * Returns the surface of the Size : width * height (float).
  16149. */
  16150. readonly surface: number;
  16151. /**
  16152. * Returns a new Size set to (0.0, 0.0)
  16153. */
  16154. static Zero(): Size;
  16155. /**
  16156. * Returns a new Size set as the addition result of the current Size and the passed one.
  16157. */
  16158. add(otherSize: Size): Size;
  16159. /**
  16160. * Returns a new Size set as the subtraction result of the passed one from the current Size.
  16161. */
  16162. subtract(otherSize: Size): Size;
  16163. /**
  16164. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  16165. */
  16166. static Lerp(start: Size, end: Size, amount: number): Size;
  16167. }
  16168. class Quaternion {
  16169. x: number;
  16170. y: number;
  16171. z: number;
  16172. w: number;
  16173. /**
  16174. * Creates a new Quaternion from the passed floats.
  16175. */
  16176. constructor(x?: number, y?: number, z?: number, w?: number);
  16177. /**
  16178. * Returns a string with the Quaternion coordinates.
  16179. */
  16180. toString(): string;
  16181. /**
  16182. * Returns the string "Quaternion".
  16183. */
  16184. getClassName(): string;
  16185. /**
  16186. * Returns the Quaternion hash code.
  16187. */
  16188. getHashCode(): number;
  16189. /**
  16190. * Returns a new array populated with 4 elements : the Quaternion coordinates.
  16191. */
  16192. asArray(): number[];
  16193. /**
  16194. * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal.
  16195. */
  16196. equals(otherQuaternion: Quaternion): boolean;
  16197. /**
  16198. * Returns a new Quaternion copied from the current one.
  16199. */
  16200. clone(): Quaternion;
  16201. /**
  16202. * Updates the current Quaternion from the passed one coordinates.
  16203. * Returns the updated Quaterion.
  16204. */
  16205. copyFrom(other: Quaternion): Quaternion;
  16206. /**
  16207. * Updates the current Quaternion from the passed float coordinates.
  16208. * Returns the updated Quaterion.
  16209. */
  16210. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  16211. /**
  16212. * Updates the current Quaternion from the passed float coordinates.
  16213. * Returns the updated Quaterion.
  16214. */
  16215. set(x: number, y: number, z: number, w: number): Quaternion;
  16216. /**
  16217. * Returns a new Quaternion as the addition result of the passed one and the current Quaternion.
  16218. */
  16219. add(other: Quaternion): Quaternion;
  16220. /**
  16221. * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion.
  16222. */
  16223. subtract(other: Quaternion): Quaternion;
  16224. /**
  16225. * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale".
  16226. */
  16227. scale(value: number): Quaternion;
  16228. /**
  16229. * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1".
  16230. */
  16231. multiply(q1: Quaternion): Quaternion;
  16232. /**
  16233. * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1".
  16234. * Returns the current Quaternion.
  16235. */
  16236. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  16237. /**
  16238. * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1".
  16239. * Returns the updated Quaternion.
  16240. */
  16241. multiplyInPlace(q1: Quaternion): Quaternion;
  16242. /**
  16243. * Sets the passed "ref" with the conjugation of the current Quaternion.
  16244. * Returns the current Quaternion.
  16245. */
  16246. conjugateToRef(ref: Quaternion): Quaternion;
  16247. /**
  16248. * Conjugates in place the current Quaternion.
  16249. * Returns the updated Quaternion.
  16250. */
  16251. conjugateInPlace(): Quaternion;
  16252. /**
  16253. * Returns a new Quaternion as the conjugate of the current Quaternion.
  16254. */
  16255. conjugate(): Quaternion;
  16256. /**
  16257. * Returns the Quaternion length (float).
  16258. */
  16259. length(): number;
  16260. /**
  16261. * Normalize in place the current Quaternion.
  16262. * Returns the updated Quaternion.
  16263. */
  16264. normalize(): Quaternion;
  16265. /**
  16266. * Returns a new Vector3 set with the Euler angles translated from the current Quaternion.
  16267. */
  16268. toEulerAngles(order?: string): Vector3;
  16269. /**
  16270. * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion.
  16271. * Returns the current Quaternion.
  16272. */
  16273. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  16274. /**
  16275. * Updates the passed rotation matrix with the current Quaternion values.
  16276. * Returns the current Quaternion.
  16277. */
  16278. toRotationMatrix(result: Matrix): Quaternion;
  16279. /**
  16280. * Updates the current Quaternion from the passed rotation matrix values.
  16281. * Returns the updated Quaternion.
  16282. */
  16283. fromRotationMatrix(matrix: Matrix): Quaternion;
  16284. /**
  16285. * Returns a new Quaternion set from the passed rotation matrix values.
  16286. */
  16287. static FromRotationMatrix(matrix: Matrix): Quaternion;
  16288. /**
  16289. * Updates the passed quaternion "result" with the passed rotation matrix values.
  16290. */
  16291. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  16292. /**
  16293. * Returns a new Quaternion set to (0.0, 0.0, 0.0).
  16294. */
  16295. static Zero(): Quaternion;
  16296. /**
  16297. * Returns a new Quaternion as the inverted current Quaternion.
  16298. */
  16299. static Inverse(q: Quaternion): Quaternion;
  16300. /**
  16301. * Returns the identity Quaternion.
  16302. */
  16303. static Identity(): Quaternion;
  16304. static IsIdentity(quaternion: Quaternion): boolean;
  16305. /**
  16306. * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float).
  16307. */
  16308. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  16309. /**
  16310. * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float).
  16311. */
  16312. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  16313. /**
  16314. * Retuns a new Quaternion set from the starting index of the passed array.
  16315. */
  16316. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  16317. /**
  16318. * Returns a new Quaternion set from the passed Euler float angles (y, x, z).
  16319. */
  16320. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  16321. /**
  16322. * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z).
  16323. */
  16324. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  16325. /**
  16326. * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation
  16327. */
  16328. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  16329. /**
  16330. * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation
  16331. */
  16332. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  16333. /**
  16334. * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  16335. * cf to Vector3.RotationFromAxis() documentation.
  16336. * Note : axis1, axis2 and axis3 are normalized during this operation.
  16337. */
  16338. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion;
  16339. /**
  16340. * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  16341. * cf to Vector3.RotationFromAxis() documentation.
  16342. * Note : axis1, axis2 and axis3 are normalized during this operation.
  16343. */
  16344. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  16345. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  16346. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  16347. /**
  16348. * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2".
  16349. */
  16350. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  16351. }
  16352. class Matrix {
  16353. private static _tempQuaternion;
  16354. private static _xAxis;
  16355. private static _yAxis;
  16356. private static _zAxis;
  16357. private static _updateFlagSeed;
  16358. private static _identityReadOnly;
  16359. private _isIdentity;
  16360. private _isIdentityDirty;
  16361. updateFlag: number;
  16362. m: Float32Array;
  16363. _markAsUpdated(): void;
  16364. constructor();
  16365. /**
  16366. * Boolean : True is the matrix is the identity matrix
  16367. */
  16368. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  16369. /**
  16370. * Returns the matrix determinant (float).
  16371. */
  16372. determinant(): number;
  16373. /**
  16374. * Returns the matrix underlying array.
  16375. */
  16376. toArray(): Float32Array;
  16377. /**
  16378. * Returns the matrix underlying array.
  16379. */
  16380. asArray(): Float32Array;
  16381. /**
  16382. * Inverts in place the Matrix.
  16383. * Returns the Matrix inverted.
  16384. */
  16385. invert(): Matrix;
  16386. /**
  16387. * Sets all the matrix elements to zero.
  16388. * Returns the Matrix.
  16389. */
  16390. reset(): Matrix;
  16391. /**
  16392. * Returns a new Matrix as the addition result of the current Matrix and the passed one.
  16393. */
  16394. add(other: Matrix): Matrix;
  16395. /**
  16396. * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one.
  16397. * Returns the Matrix.
  16398. */
  16399. addToRef(other: Matrix, result: Matrix): Matrix;
  16400. /**
  16401. * Adds in place the passed matrix to the current Matrix.
  16402. * Returns the updated Matrix.
  16403. */
  16404. addToSelf(other: Matrix): Matrix;
  16405. /**
  16406. * Sets the passed matrix with the current inverted Matrix.
  16407. * Returns the unmodified current Matrix.
  16408. */
  16409. invertToRef(other: Matrix): Matrix;
  16410. /**
  16411. * Inserts the translation vector (using 3 x floats) in the current Matrix.
  16412. * Returns the updated Matrix.
  16413. */
  16414. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  16415. /**
  16416. * Inserts the translation vector in the current Matrix.
  16417. * Returns the updated Matrix.
  16418. */
  16419. setTranslation(vector3: Vector3): Matrix;
  16420. /**
  16421. * Returns a new Vector3 as the extracted translation from the Matrix.
  16422. */
  16423. getTranslation(): Vector3;
  16424. /**
  16425. * Fill a Vector3 with the extracted translation from the Matrix.
  16426. */
  16427. getTranslationToRef(result: Vector3): Matrix;
  16428. /**
  16429. * Remove rotation and scaling part from the Matrix.
  16430. * Returns the updated Matrix.
  16431. */
  16432. removeRotationAndScaling(): Matrix;
  16433. /**
  16434. * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one.
  16435. */
  16436. multiply(other: Matrix): Matrix;
  16437. /**
  16438. * Updates the current Matrix from the passed one values.
  16439. * Returns the updated Matrix.
  16440. */
  16441. copyFrom(other: Matrix): Matrix;
  16442. /**
  16443. * Populates the passed array from the starting index with the Matrix values.
  16444. * Returns the Matrix.
  16445. */
  16446. copyToArray(array: Float32Array, offset?: number): Matrix;
  16447. /**
  16448. * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one.
  16449. */
  16450. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  16451. /**
  16452. * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one.
  16453. */
  16454. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  16455. /**
  16456. * Boolean : True is the current Matrix and the passed one values are strictly equal.
  16457. */
  16458. equals(value: Matrix): boolean;
  16459. /**
  16460. * Returns a new Matrix from the current Matrix.
  16461. */
  16462. clone(): Matrix;
  16463. /**
  16464. * Returns the string "Matrix"
  16465. */
  16466. getClassName(): string;
  16467. /**
  16468. * Returns the Matrix hash code.
  16469. */
  16470. getHashCode(): number;
  16471. /**
  16472. * Decomposes the current Matrix into :
  16473. * - a scale vector3 passed as a reference to update,
  16474. * - a rotation quaternion passed as a reference to update,
  16475. * - a translation vector3 passed as a reference to update.
  16476. * Returns the true if operation was successful.
  16477. */
  16478. decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean;
  16479. /**
  16480. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  16481. * @param ref matrix to store the result
  16482. */
  16483. toNormalMatrix(ref: Matrix): void;
  16484. /**
  16485. * Returns a new Matrix as the extracted rotation matrix from the current one.
  16486. */
  16487. getRotationMatrix(): Matrix;
  16488. /**
  16489. * Extracts the rotation matrix from the current one and sets it as the passed "result".
  16490. * Returns the current Matrix.
  16491. */
  16492. getRotationMatrixToRef(result: Matrix): Matrix;
  16493. /**
  16494. * Returns a new Matrix set from the starting index of the passed array.
  16495. */
  16496. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  16497. /**
  16498. * Sets the passed "result" matrix from the starting index of the passed array.
  16499. */
  16500. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  16501. /**
  16502. * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale".
  16503. */
  16504. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  16505. /**
  16506. * Sets the passed matrix "result" with the 16 passed floats.
  16507. */
  16508. 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;
  16509. /**
  16510. * Returns the index-th row of the current matrix as a new Vector4.
  16511. */
  16512. getRow(index: number): Nullable<Vector4>;
  16513. /**
  16514. * Sets the index-th row of the current matrix with the passed Vector4 values.
  16515. * Returns the updated Matrix.
  16516. */
  16517. setRow(index: number, row: Vector4): Matrix;
  16518. /**
  16519. * Compute the transpose of the matrix.
  16520. * Returns a new Matrix.
  16521. */
  16522. transpose(): Matrix;
  16523. /**
  16524. * Compute the transpose of the matrix.
  16525. * Returns the current matrix.
  16526. */
  16527. transposeToRef(result: Matrix): Matrix;
  16528. /**
  16529. * Sets the index-th row of the current matrix with the passed 4 x float values.
  16530. * Returns the updated Matrix.
  16531. */
  16532. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  16533. /**
  16534. * Static identity matrix to be used as readonly matrix
  16535. * Must not be updated.
  16536. */
  16537. static readonly IdentityReadOnly: Matrix;
  16538. /**
  16539. * Returns a new Matrix set from the 16 passed floats.
  16540. */
  16541. 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;
  16542. /**
  16543. * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  16544. */
  16545. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  16546. /**
  16547. * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  16548. */
  16549. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  16550. /**
  16551. * Returns a new indentity Matrix.
  16552. */
  16553. static Identity(): Matrix;
  16554. /**
  16555. * Sets the passed "result" as an identity matrix.
  16556. */
  16557. static IdentityToRef(result: Matrix): void;
  16558. /**
  16559. * Returns a new zero Matrix.
  16560. */
  16561. static Zero(): Matrix;
  16562. /**
  16563. * Returns a new rotation matrix for "angle" radians around the X axis.
  16564. */
  16565. static RotationX(angle: number): Matrix;
  16566. /**
  16567. * Returns a new Matrix as the passed inverted one.
  16568. */
  16569. static Invert(source: Matrix): Matrix;
  16570. /**
  16571. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis.
  16572. */
  16573. static RotationXToRef(angle: number, result: Matrix): void;
  16574. /**
  16575. * Returns a new rotation matrix for "angle" radians around the Y axis.
  16576. */
  16577. static RotationY(angle: number): Matrix;
  16578. /**
  16579. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis.
  16580. */
  16581. static RotationYToRef(angle: number, result: Matrix): void;
  16582. /**
  16583. * Returns a new rotation matrix for "angle" radians around the Z axis.
  16584. */
  16585. static RotationZ(angle: number): Matrix;
  16586. /**
  16587. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis.
  16588. */
  16589. static RotationZToRef(angle: number, result: Matrix): void;
  16590. /**
  16591. * Returns a new rotation matrix for "angle" radians around the passed axis.
  16592. */
  16593. static RotationAxis(axis: Vector3, angle: number): Matrix;
  16594. /**
  16595. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis.
  16596. */
  16597. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  16598. /**
  16599. * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z).
  16600. */
  16601. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  16602. /**
  16603. * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z).
  16604. */
  16605. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  16606. /**
  16607. * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z).
  16608. */
  16609. static Scaling(x: number, y: number, z: number): Matrix;
  16610. /**
  16611. * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z).
  16612. */
  16613. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  16614. /**
  16615. * Returns a new Matrix as a translation matrix from the passed floats (x, y, z).
  16616. */
  16617. static Translation(x: number, y: number, z: number): Matrix;
  16618. /**
  16619. * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z).
  16620. */
  16621. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  16622. /**
  16623. * Returns a new Matrix whose values are the interpolated values for "gradien" (float) between the ones of the matrices "startValue" and "endValue".
  16624. */
  16625. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  16626. /**
  16627. * Returns a new Matrix whose values are computed by :
  16628. * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices,
  16629. * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end,
  16630. * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices.
  16631. */
  16632. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  16633. /**
  16634. * 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".
  16635. * This methods works for a Left-Handed system.
  16636. */
  16637. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  16638. /**
  16639. * 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".
  16640. * This methods works for a Left-Handed system.
  16641. */
  16642. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  16643. /**
  16644. * 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".
  16645. * This methods works for a Right-Handed system.
  16646. */
  16647. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  16648. /**
  16649. * 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".
  16650. * This methods works for a Left-Handed system.
  16651. */
  16652. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  16653. /**
  16654. * 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.
  16655. */
  16656. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  16657. /**
  16658. * 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.
  16659. */
  16660. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  16661. /**
  16662. * 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.
  16663. */
  16664. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  16665. /**
  16666. * 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.
  16667. */
  16668. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  16669. /**
  16670. * 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.
  16671. */
  16672. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  16673. /**
  16674. * 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.
  16675. */
  16676. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  16677. /**
  16678. * 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.
  16679. */
  16680. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  16681. /**
  16682. * 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.
  16683. */
  16684. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  16685. /**
  16686. * 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.
  16687. */
  16688. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  16689. /**
  16690. * 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.
  16691. */
  16692. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  16693. /**
  16694. * 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.
  16695. */
  16696. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  16697. /**
  16698. * 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.
  16699. */
  16700. static PerspectiveFovWebVRToRef(fov: {
  16701. upDegrees: number;
  16702. downDegrees: number;
  16703. leftDegrees: number;
  16704. rightDegrees: number;
  16705. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  16706. /**
  16707. * Returns the final transformation matrix : world * view * projection * viewport
  16708. */
  16709. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  16710. /**
  16711. * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix.
  16712. */
  16713. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  16714. /**
  16715. * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix.
  16716. */
  16717. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  16718. /**
  16719. * Compute the transpose of the passed Matrix.
  16720. * Returns a new Matrix.
  16721. */
  16722. static Transpose(matrix: Matrix): Matrix;
  16723. /**
  16724. * Compute the transpose of the passed Matrix and store it in the result matrix.
  16725. */
  16726. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  16727. /**
  16728. * Returns a new Matrix as the reflection matrix across the passed plane.
  16729. */
  16730. static Reflection(plane: Plane): Matrix;
  16731. /**
  16732. * Sets the passed matrix "result" as the reflection matrix across the passed plane.
  16733. */
  16734. static ReflectionToRef(plane: Plane, result: Matrix): void;
  16735. /**
  16736. * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis.
  16737. */
  16738. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  16739. /**
  16740. * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion.
  16741. */
  16742. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  16743. }
  16744. class Plane {
  16745. normal: Vector3;
  16746. d: number;
  16747. /**
  16748. * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  16749. */
  16750. constructor(a: number, b: number, c: number, d: number);
  16751. /**
  16752. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  16753. */
  16754. asArray(): number[];
  16755. /**
  16756. * Returns a new plane copied from the current Plane.
  16757. */
  16758. clone(): Plane;
  16759. /**
  16760. * Returns the string "Plane".
  16761. */
  16762. getClassName(): string;
  16763. /**
  16764. * Returns the Plane hash code.
  16765. */
  16766. getHashCode(): number;
  16767. /**
  16768. * Normalize the current Plane in place.
  16769. * Returns the updated Plane.
  16770. */
  16771. normalize(): Plane;
  16772. /**
  16773. * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix.
  16774. */
  16775. transform(transformation: Matrix): Plane;
  16776. /**
  16777. * Returns the dot product (float) of the point coordinates and the plane normal.
  16778. */
  16779. dotCoordinate(point: Vector3): number;
  16780. /**
  16781. * Updates the current Plane from the plane defined by the three passed points.
  16782. * Returns the updated Plane.
  16783. */
  16784. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  16785. /**
  16786. * Boolean : True is the vector "direction" is the same side than the plane normal.
  16787. */
  16788. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  16789. /**
  16790. * Returns the signed distance (float) from the passed point to the Plane.
  16791. */
  16792. signedDistanceTo(point: Vector3): number;
  16793. /**
  16794. * Returns a new Plane from the passed array.
  16795. */
  16796. static FromArray(array: ArrayLike<number>): Plane;
  16797. /**
  16798. * Returns a new Plane defined by the three passed points.
  16799. */
  16800. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  16801. /**
  16802. * Returns a new Plane the normal vector to this plane at the passed origin point.
  16803. * Note : the vector "normal" is updated because normalized.
  16804. */
  16805. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  16806. /**
  16807. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point.
  16808. */
  16809. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  16810. }
  16811. class Viewport {
  16812. x: number;
  16813. y: number;
  16814. width: number;
  16815. height: number;
  16816. /**
  16817. * Creates a Viewport object located at (x, y) and sized (width, height).
  16818. */
  16819. constructor(x: number, y: number, width: number, height: number);
  16820. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  16821. /**
  16822. * Returns a new Viewport copied from the current one.
  16823. */
  16824. clone(): Viewport;
  16825. }
  16826. class Frustum {
  16827. /**
  16828. * Returns a new array of 6 Frustum planes computed by the passed transformation matrix.
  16829. */
  16830. static GetPlanes(transform: Matrix): Plane[];
  16831. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16832. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16833. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16834. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16835. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16836. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  16837. /**
  16838. * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix.
  16839. */
  16840. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  16841. }
  16842. enum Space {
  16843. LOCAL = 0,
  16844. WORLD = 1,
  16845. BONE = 2,
  16846. }
  16847. class Axis {
  16848. static X: Vector3;
  16849. static Y: Vector3;
  16850. static Z: Vector3;
  16851. }
  16852. class BezierCurve {
  16853. /**
  16854. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats.
  16855. */
  16856. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  16857. }
  16858. enum Orientation {
  16859. CW = 0,
  16860. CCW = 1,
  16861. }
  16862. class Angle {
  16863. private _radians;
  16864. /**
  16865. * Creates an Angle object of "radians" radians (float).
  16866. */
  16867. constructor(radians: number);
  16868. /**
  16869. * Returns the Angle value in degrees (float).
  16870. */
  16871. degrees: () => number;
  16872. /**
  16873. * Returns the Angle value in radians (float).
  16874. */
  16875. radians: () => number;
  16876. /**
  16877. * Returns a new Angle object valued with the angle value in radians between the two passed vectors.
  16878. */
  16879. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  16880. /**
  16881. * Returns a new Angle object from the passed float in radians.
  16882. */
  16883. static FromRadians(radians: number): Angle;
  16884. /**
  16885. * Returns a new Angle object from the passed float in degrees.
  16886. */
  16887. static FromDegrees(degrees: number): Angle;
  16888. }
  16889. class Arc2 {
  16890. startPoint: Vector2;
  16891. midPoint: Vector2;
  16892. endPoint: Vector2;
  16893. centerPoint: Vector2;
  16894. radius: number;
  16895. angle: Angle;
  16896. startAngle: Angle;
  16897. orientation: Orientation;
  16898. /**
  16899. * Creates an Arc object from the three passed points : start, middle and end.
  16900. */
  16901. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  16902. }
  16903. class Path2 {
  16904. private _points;
  16905. private _length;
  16906. closed: boolean;
  16907. /**
  16908. * Creates a Path2 object from the starting 2D coordinates x and y.
  16909. */
  16910. constructor(x: number, y: number);
  16911. /**
  16912. * Adds a new segment until the passed coordinates (x, y) to the current Path2.
  16913. * Returns the updated Path2.
  16914. */
  16915. addLineTo(x: number, y: number): Path2;
  16916. /**
  16917. * 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.
  16918. * Returns the updated Path2.
  16919. */
  16920. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  16921. /**
  16922. * Closes the Path2.
  16923. * Returns the Path2.
  16924. */
  16925. close(): Path2;
  16926. /**
  16927. * Returns the Path2 total length (float).
  16928. */
  16929. length(): number;
  16930. /**
  16931. * Returns the Path2 internal array of points.
  16932. */
  16933. getPoints(): Vector2[];
  16934. /**
  16935. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  16936. */
  16937. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  16938. /**
  16939. * Returns a new Path2 starting at the coordinates (x, y).
  16940. */
  16941. static StartingAt(x: number, y: number): Path2;
  16942. }
  16943. class Path3D {
  16944. path: Vector3[];
  16945. private _curve;
  16946. private _distances;
  16947. private _tangents;
  16948. private _normals;
  16949. private _binormals;
  16950. private _raw;
  16951. /**
  16952. * new Path3D(path, normal, raw)
  16953. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  16954. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  16955. * path : an array of Vector3, the curve axis of the Path3D
  16956. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  16957. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  16958. */
  16959. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  16960. /**
  16961. * Returns the Path3D array of successive Vector3 designing its curve.
  16962. */
  16963. getCurve(): Vector3[];
  16964. /**
  16965. * Returns an array populated with tangent vectors on each Path3D curve point.
  16966. */
  16967. getTangents(): Vector3[];
  16968. /**
  16969. * Returns an array populated with normal vectors on each Path3D curve point.
  16970. */
  16971. getNormals(): Vector3[];
  16972. /**
  16973. * Returns an array populated with binormal vectors on each Path3D curve point.
  16974. */
  16975. getBinormals(): Vector3[];
  16976. /**
  16977. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  16978. */
  16979. getDistances(): number[];
  16980. /**
  16981. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  16982. * Returns the same object updated.
  16983. */
  16984. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  16985. private _compute(firstNormal);
  16986. private _getFirstNonNullVector(index);
  16987. private _getLastNonNullVector(index);
  16988. private _normalVector(v0, vt, va);
  16989. }
  16990. class Curve3 {
  16991. private _points;
  16992. private _length;
  16993. /**
  16994. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  16995. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  16996. * @param v1 (Vector3) the control point
  16997. * @param v2 (Vector3) the end point of the Quadratic Bezier
  16998. * @param nbPoints (integer) the wanted number of points in the curve
  16999. */
  17000. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  17001. /**
  17002. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  17003. * @param v0 (Vector3) the origin point of the Cubic Bezier
  17004. * @param v1 (Vector3) the first control point
  17005. * @param v2 (Vector3) the second control point
  17006. * @param v3 (Vector3) the end point of the Cubic Bezier
  17007. * @param nbPoints (integer) the wanted number of points in the curve
  17008. */
  17009. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  17010. /**
  17011. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  17012. * @param p1 (Vector3) the origin point of the Hermite Spline
  17013. * @param t1 (Vector3) the tangent vector at the origin point
  17014. * @param p2 (Vector3) the end point of the Hermite Spline
  17015. * @param t2 (Vector3) the tangent vector at the end point
  17016. * @param nbPoints (integer) the wanted number of points in the curve
  17017. */
  17018. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  17019. /**
  17020. * Returns a Curve3 object along a CatmullRom Spline curve :
  17021. * @param points (array of Vector3) the points the spline must pass through. At least, four points required.
  17022. * @param nbPoints (integer) the wanted number of points between each curve control points.
  17023. */
  17024. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3;
  17025. /**
  17026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  17027. * A Curve3 is designed from a series of successive Vector3.
  17028. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  17029. */
  17030. constructor(points: Vector3[]);
  17031. /**
  17032. * Returns the Curve3 stored array of successive Vector3
  17033. */
  17034. getPoints(): Vector3[];
  17035. /**
  17036. * Returns the computed length (float) of the curve.
  17037. */
  17038. length(): number;
  17039. /**
  17040. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  17041. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  17042. * curveA and curveB keep unchanged.
  17043. */
  17044. continue(curve: Curve3): Curve3;
  17045. private _computeLength(path);
  17046. }
  17047. class PositionNormalVertex {
  17048. position: Vector3;
  17049. normal: Vector3;
  17050. constructor(position?: Vector3, normal?: Vector3);
  17051. clone(): PositionNormalVertex;
  17052. }
  17053. class PositionNormalTextureVertex {
  17054. position: Vector3;
  17055. normal: Vector3;
  17056. uv: Vector2;
  17057. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  17058. clone(): PositionNormalTextureVertex;
  17059. }
  17060. class Tmp {
  17061. static Color3: Color3[];
  17062. static Vector2: Vector2[];
  17063. static Vector3: Vector3[];
  17064. static Vector4: Vector4[];
  17065. static Quaternion: Quaternion[];
  17066. static Matrix: Matrix[];
  17067. }
  17068. }
  17069. declare module BABYLON {
  17070. class SphericalPolynomial {
  17071. x: Vector3;
  17072. y: Vector3;
  17073. z: Vector3;
  17074. xx: Vector3;
  17075. yy: Vector3;
  17076. zz: Vector3;
  17077. xy: Vector3;
  17078. yz: Vector3;
  17079. zx: Vector3;
  17080. addAmbient(color: Color3): void;
  17081. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  17082. scale(scale: number): void;
  17083. }
  17084. class SphericalHarmonics {
  17085. L00: Vector3;
  17086. L1_1: Vector3;
  17087. L10: Vector3;
  17088. L11: Vector3;
  17089. L2_2: Vector3;
  17090. L2_1: Vector3;
  17091. L20: Vector3;
  17092. L21: Vector3;
  17093. L22: Vector3;
  17094. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  17095. scale(scale: number): void;
  17096. convertIncidentRadianceToIrradiance(): void;
  17097. convertIrradianceToLambertianRadiance(): void;
  17098. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  17099. }
  17100. }
  17101. declare module BABYLON {
  17102. class MorphTarget {
  17103. name: string;
  17104. animations: Animation[];
  17105. private _positions;
  17106. private _normals;
  17107. private _tangents;
  17108. private _influence;
  17109. onInfluenceChanged: Observable<boolean>;
  17110. influence: number;
  17111. constructor(name: string, influence?: number);
  17112. readonly hasPositions: boolean;
  17113. readonly hasNormals: boolean;
  17114. readonly hasTangents: boolean;
  17115. setPositions(data: Nullable<FloatArray>): void;
  17116. getPositions(): Nullable<FloatArray>;
  17117. setNormals(data: Nullable<FloatArray>): void;
  17118. getNormals(): Nullable<FloatArray>;
  17119. setTangents(data: Nullable<FloatArray>): void;
  17120. getTangents(): Nullable<FloatArray>;
  17121. /**
  17122. * Serializes the current target into a Serialization object.
  17123. * Returns the serialized object.
  17124. */
  17125. serialize(): any;
  17126. static Parse(serializationObject: any): MorphTarget;
  17127. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  17128. }
  17129. }
  17130. declare module BABYLON {
  17131. class MorphTargetManager {
  17132. private _targets;
  17133. private _targetObservable;
  17134. private _activeTargets;
  17135. private _scene;
  17136. private _influences;
  17137. private _supportsNormals;
  17138. private _supportsTangents;
  17139. private _vertexCount;
  17140. private _uniqueId;
  17141. private _tempInfluences;
  17142. constructor(scene?: Nullable<Scene>);
  17143. readonly uniqueId: number;
  17144. readonly vertexCount: number;
  17145. readonly supportsNormals: boolean;
  17146. readonly supportsTangents: boolean;
  17147. readonly numTargets: number;
  17148. readonly numInfluencers: number;
  17149. readonly influences: Float32Array;
  17150. getActiveTarget(index: number): MorphTarget;
  17151. getTarget(index: number): MorphTarget;
  17152. addTarget(target: MorphTarget): void;
  17153. removeTarget(target: MorphTarget): void;
  17154. /**
  17155. * Serializes the current manager into a Serialization object.
  17156. * Returns the serialized object.
  17157. */
  17158. serialize(): any;
  17159. private _syncActiveTargets(needUpdate);
  17160. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  17161. }
  17162. }
  17163. declare module BABYLON {
  17164. /**
  17165. * Particle emitter emitting particles from the inside of a box.
  17166. * It emits the particles randomly between 2 given directions.
  17167. */
  17168. class BoxParticleEmitter implements IParticleEmitterType {
  17169. private _particleSystem;
  17170. /**
  17171. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17172. */
  17173. /**
  17174. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17175. */
  17176. direction1: Vector3;
  17177. /**
  17178. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17179. */
  17180. /**
  17181. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17182. */
  17183. direction2: Vector3;
  17184. /**
  17185. * 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.
  17186. */
  17187. /**
  17188. * 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.
  17189. */
  17190. minEmitBox: Vector3;
  17191. /**
  17192. * 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.
  17193. */
  17194. /**
  17195. * 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.
  17196. */
  17197. maxEmitBox: Vector3;
  17198. /**
  17199. * Creates a new instance of @see BoxParticleEmitter
  17200. * @param _particleSystem the particle system associated with the emitter
  17201. */
  17202. constructor(_particleSystem: ParticleSystem);
  17203. /**
  17204. * Called by the particle System when the direction is computed for the created particle.
  17205. * @param emitPower is the power of the particle (speed)
  17206. * @param worldMatrix is the world matrix of the particle system
  17207. * @param directionToUpdate is the direction vector to update with the result
  17208. * @param particle is the particle we are computed the direction for
  17209. */
  17210. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17211. /**
  17212. * Called by the particle System when the position is computed for the created particle.
  17213. * @param worldMatrix is the world matrix of the particle system
  17214. * @param positionToUpdate is the position vector to update with the result
  17215. * @param particle is the particle we are computed the position for
  17216. */
  17217. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17218. /**
  17219. * Clones the current emitter and returns a copy of it
  17220. * @returns the new emitter
  17221. */
  17222. clone(): BoxParticleEmitter;
  17223. }
  17224. }
  17225. declare module BABYLON {
  17226. /**
  17227. * Particle emitter emitting particles from the inside of a cone.
  17228. * It emits the particles alongside the cone volume from the base to the particle.
  17229. * The emission direction might be randomized.
  17230. */
  17231. class ConeParticleEmitter implements IParticleEmitterType {
  17232. /**
  17233. * The radius of the emission cone.
  17234. */
  17235. angle: number;
  17236. /**
  17237. * The cone base angle.
  17238. */
  17239. directionRandomizer: number;
  17240. private _radius;
  17241. private _height;
  17242. /**
  17243. * Gets the radius of the emission cone.
  17244. */
  17245. /**
  17246. * Sets the radius of the emission cone.
  17247. */
  17248. radius: number;
  17249. /**
  17250. * Creates a new instance of @see ConeParticleEmitter
  17251. * @param radius the radius of the emission cone
  17252. * @param angles the cone base angle
  17253. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17254. */
  17255. constructor(radius: number,
  17256. /**
  17257. * The radius of the emission cone.
  17258. */
  17259. angle: number,
  17260. /**
  17261. * The cone base angle.
  17262. */
  17263. directionRandomizer?: number);
  17264. /**
  17265. * Called by the particle System when the direction is computed for the created particle.
  17266. * @param emitPower is the power of the particle (speed)
  17267. * @param worldMatrix is the world matrix of the particle system
  17268. * @param directionToUpdate is the direction vector to update with the result
  17269. * @param particle is the particle we are computed the direction for
  17270. */
  17271. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17272. /**
  17273. * Called by the particle System when the position is computed for the created particle.
  17274. * @param worldMatrix is the world matrix of the particle system
  17275. * @param positionToUpdate is the position vector to update with the result
  17276. * @param particle is the particle we are computed the position for
  17277. */
  17278. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17279. /**
  17280. * Clones the current emitter and returns a copy of it
  17281. * @returns the new emitter
  17282. */
  17283. clone(): ConeParticleEmitter;
  17284. }
  17285. }
  17286. declare module BABYLON {
  17287. /**
  17288. * This represents a GPU particle system in Babylon.
  17289. * This os the fastest particle system in Babylon as it uses the GPU to update the individual particle data.
  17290. */
  17291. class GPUParticleSystem implements IDisposable, IParticleSystem {
  17292. /**
  17293. * The id of the Particle system.
  17294. */
  17295. id: string;
  17296. /**
  17297. * The friendly name of the Particle system.
  17298. */
  17299. name: string;
  17300. /**
  17301. * The emitter represents the Mesh or position we are attaching the particle system to.
  17302. */
  17303. emitter: Nullable<AbstractMesh | Vector3>;
  17304. /**
  17305. * The rendering group used by the Particle system to chose when to render.
  17306. */
  17307. renderingGroupId: number;
  17308. /**
  17309. * The layer mask we are rendering the particles through.
  17310. */
  17311. layerMask: number;
  17312. private _capacity;
  17313. private _renderEffect;
  17314. private _updateEffect;
  17315. private _updateBuffer;
  17316. private _updateVAO;
  17317. private _updateVertexBuffers;
  17318. private _renderBuffer;
  17319. private _renderVAO;
  17320. private _renderVertexBuffers;
  17321. private _sourceVAO;
  17322. private _targetVAO;
  17323. private _sourceBuffer;
  17324. private _targetBuffer;
  17325. private _scene;
  17326. private _engine;
  17327. private _currentRenderId;
  17328. private _started;
  17329. /**
  17330. * An event triggered when the system is disposed.
  17331. */
  17332. onDisposeObservable: Observable<GPUParticleSystem>;
  17333. /**
  17334. * Gets Wether the system has been started.
  17335. * @returns True if it has been started, otherwise false.
  17336. */
  17337. isStarted(): boolean;
  17338. /**
  17339. * Starts the particle system and begins to emit.
  17340. */
  17341. start(): void;
  17342. /**
  17343. * Stops the particle system.
  17344. */
  17345. stop(): void;
  17346. /**
  17347. * Instantiates a GPU particle system.
  17348. * 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.
  17349. * @param name The name of the particle system
  17350. * @param capacity The max number of particles alive at the same time
  17351. * @param scene The scene the particle system belongs to
  17352. */
  17353. constructor(name: string, capacity: number, scene: Scene);
  17354. /**
  17355. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17356. */
  17357. animate(): void;
  17358. private _initialize();
  17359. /**
  17360. * Renders the particle system in its current state.
  17361. * @returns the current number of particles.
  17362. */
  17363. render(): number;
  17364. /**
  17365. * Rebuilds the particle system
  17366. */
  17367. rebuild(): void;
  17368. /**
  17369. * Disposes the particle system and free the associated resources.
  17370. */
  17371. dispose(): void;
  17372. /**
  17373. * Clones the particle system.
  17374. * @param name The name of the cloned object
  17375. * @param newEmitter The new emitter to use
  17376. * @returns the cloned particle system
  17377. */
  17378. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  17379. /**
  17380. * Serializes the particle system to a JSON object.
  17381. * @returns the JSON object
  17382. */
  17383. serialize(): any;
  17384. }
  17385. }
  17386. declare module BABYLON {
  17387. /**
  17388. * Particle emitter represents a volume emitting particles.
  17389. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17390. */
  17391. interface IParticleEmitterType {
  17392. /**
  17393. * Called by the particle System when the direction is computed for the created particle.
  17394. * @param emitPower is the power of the particle (speed)
  17395. * @param worldMatrix is the world matrix of the particle system
  17396. * @param directionToUpdate is the direction vector to update with the result
  17397. * @param particle is the particle we are computed the direction for
  17398. */
  17399. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17400. /**
  17401. * Called by the particle System when the position is computed for the created particle.
  17402. * @param worldMatrix is the world matrix of the particle system
  17403. * @param positionToUpdate is the position vector to update with the result
  17404. * @param particle is the particle we are computed the position for
  17405. */
  17406. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17407. /**
  17408. * Clones the current emitter and returns a copy of it
  17409. * @returns the new emitter
  17410. */
  17411. clone(): IParticleEmitterType;
  17412. }
  17413. }
  17414. declare module BABYLON {
  17415. /**
  17416. * A particle represents one of the element emitted by a particle system.
  17417. * This is mainly define by its coordinates, direction, velocity and age.
  17418. */
  17419. class Particle {
  17420. private particleSystem;
  17421. /**
  17422. * The world position of the particle in the scene.
  17423. */
  17424. position: Vector3;
  17425. /**
  17426. * The world direction of the particle in the scene.
  17427. */
  17428. direction: Vector3;
  17429. /**
  17430. * The color of the particle.
  17431. */
  17432. color: Color4;
  17433. /**
  17434. * The color change of the particle per step.
  17435. */
  17436. colorStep: Color4;
  17437. /**
  17438. * Defines how long will the life of the particle be.
  17439. */
  17440. lifeTime: number;
  17441. /**
  17442. * The current age of the particle.
  17443. */
  17444. age: number;
  17445. /**
  17446. * The current size of the particle.
  17447. */
  17448. size: number;
  17449. /**
  17450. * The current angle of the particle.
  17451. */
  17452. angle: number;
  17453. /**
  17454. * Defines how fast is the angle changing.
  17455. */
  17456. angularSpeed: number;
  17457. /**
  17458. * Defines the cell index used by the particle to be rendered from a sprite.
  17459. */
  17460. cellIndex: number;
  17461. private _currentFrameCounter;
  17462. /**
  17463. * Creates a new instance of @see Particle
  17464. * @param particleSystem the particle system the particle belongs to
  17465. */
  17466. constructor(particleSystem: ParticleSystem);
  17467. /**
  17468. * Defines how the sprite cell index is updated for the particle. This is
  17469. * defined as a callback.
  17470. */
  17471. updateCellIndex: (scaledUpdateSpeed: number) => void;
  17472. private updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  17473. private updateCellIndexWithCustomSpeed();
  17474. /**
  17475. * Copy the properties of particle to another one.
  17476. * @param other the particle to copy the information to.
  17477. */
  17478. copyTo(other: Particle): void;
  17479. }
  17480. }
  17481. declare module BABYLON {
  17482. /**
  17483. * Interface representing a particle system in Babylon.
  17484. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17485. * A particle system represents a way to manage particles (@see Particle) from their emission to their animation and rendering.
  17486. */
  17487. interface IParticleSystem {
  17488. /**
  17489. * The id of the Particle system.
  17490. */
  17491. id: string;
  17492. /**
  17493. * The name of the Particle system.
  17494. */
  17495. name: string;
  17496. /**
  17497. * The emitter represents the Mesh or position we are attaching the particle system to.
  17498. */
  17499. emitter: Nullable<AbstractMesh | Vector3>;
  17500. /**
  17501. * The rendering group used by the Particle system to chose when to render.
  17502. */
  17503. renderingGroupId: number;
  17504. /**
  17505. * The layer mask we are rendering the particles through.
  17506. */
  17507. layerMask: number;
  17508. /**
  17509. * Gets if the particle system has been started.
  17510. * @return true if the system has been started, otherwise false.
  17511. */
  17512. isStarted(): boolean;
  17513. /**
  17514. * Animates the particle system for this frame.
  17515. */
  17516. animate(): void;
  17517. /**
  17518. * Renders the particle system in its current state.
  17519. * @returns the current number of particles.
  17520. */
  17521. render(): number;
  17522. /**
  17523. * Dispose the particle system and frees its associated resources.
  17524. */
  17525. dispose(): void;
  17526. /**
  17527. * Clones the particle system.
  17528. * @param name The name of the cloned object
  17529. * @param newEmitter The new emitter to use
  17530. * @returns the cloned particle system
  17531. */
  17532. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17533. /**
  17534. * Serializes the particle system to a JSON object.
  17535. * @returns the JSON object
  17536. */
  17537. serialize(): any;
  17538. /**
  17539. * Rebuild the particle system
  17540. */
  17541. rebuild(): void;
  17542. }
  17543. /**
  17544. * This represents a particle system in Babylon.
  17545. * 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.
  17546. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17547. * @example https://doc.babylonjs.com/babylon101/particles
  17548. */
  17549. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17550. /**
  17551. * Source color is added to the destination color without alpha affecting the result.
  17552. */
  17553. static BLENDMODE_ONEONE: number;
  17554. /**
  17555. * Blend current color and particle color using particle’s alpha.
  17556. */
  17557. static BLENDMODE_STANDARD: number;
  17558. /**
  17559. * List of animations used by the particle system.
  17560. */
  17561. animations: Animation[];
  17562. /**
  17563. * The id of the Particle system.
  17564. */
  17565. id: string;
  17566. /**
  17567. * The friendly name of the Particle system.
  17568. */
  17569. name: string;
  17570. /**
  17571. * The rendering group used by the Particle system to chose when to render.
  17572. */
  17573. renderingGroupId: number;
  17574. /**
  17575. * The emitter represents the Mesh or position we are attaching the particle system to.
  17576. */
  17577. emitter: Nullable<AbstractMesh | Vector3>;
  17578. /**
  17579. * The density of particles, the rate of particle flow
  17580. */
  17581. emitRate: number;
  17582. /**
  17583. * If you want to launch only a few particles at once, that can be done, as well.
  17584. */
  17585. manualEmitCount: number;
  17586. /**
  17587. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17588. */
  17589. updateSpeed: number;
  17590. /**
  17591. * The amount of time the particle system is running (depends of the overall speed above).
  17592. */
  17593. targetStopDuration: number;
  17594. /**
  17595. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17596. */
  17597. disposeOnStop: boolean;
  17598. /**
  17599. * Minimum power of emitting particles.
  17600. */
  17601. minEmitPower: number;
  17602. /**
  17603. * Maximum power of emitting particles.
  17604. */
  17605. maxEmitPower: number;
  17606. /**
  17607. * Minimum life time of emitting particles.
  17608. */
  17609. minLifeTime: number;
  17610. /**
  17611. * Maximum life time of emitting particles.
  17612. */
  17613. maxLifeTime: number;
  17614. /**
  17615. * Minimum Size of emitting particles.
  17616. */
  17617. minSize: number;
  17618. /**
  17619. * Maximum Size of emitting particles.
  17620. */
  17621. maxSize: number;
  17622. /**
  17623. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17624. */
  17625. minAngularSpeed: number;
  17626. /**
  17627. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17628. */
  17629. maxAngularSpeed: number;
  17630. /**
  17631. * The texture used to render each particle. (this can be a spritesheet)
  17632. */
  17633. particleTexture: Nullable<Texture>;
  17634. /**
  17635. * The layer mask we are rendering the particles through.
  17636. */
  17637. layerMask: number;
  17638. /**
  17639. * This can help using your own shader to render the particle system.
  17640. * The according effect will be created
  17641. */
  17642. customShader: any;
  17643. /**
  17644. * By default particle system starts as soon as they are created. This prevents the
  17645. * automatic start to happen and let you decide when to start emitting particles.
  17646. */
  17647. preventAutoStart: boolean;
  17648. /**
  17649. * This function can be defined to provide custom update for active particles.
  17650. * This function will be called instead of regular update (age, position, color, etc.).
  17651. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17652. */
  17653. updateFunction: (particles: Particle[]) => void;
  17654. /**
  17655. * Callback triggered when the particle animation is ending.
  17656. */
  17657. onAnimationEnd: Nullable<() => void>;
  17658. /**
  17659. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17660. */
  17661. blendMode: number;
  17662. /**
  17663. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17664. * to override the particles.
  17665. */
  17666. forceDepthWrite: boolean;
  17667. /**
  17668. * You can use gravity if you want to give an orientation to your particles.
  17669. */
  17670. gravity: Vector3;
  17671. /**
  17672. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17673. */
  17674. direction1: Vector3;
  17675. /**
  17676. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17677. */
  17678. direction2: Vector3;
  17679. /**
  17680. * 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.
  17681. */
  17682. minEmitBox: Vector3;
  17683. /**
  17684. * 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.
  17685. */
  17686. maxEmitBox: Vector3;
  17687. /**
  17688. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17689. */
  17690. color1: Color4;
  17691. /**
  17692. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17693. */
  17694. color2: Color4;
  17695. /**
  17696. * Color the particle will have at the end of its lifetime.
  17697. */
  17698. colorDead: Color4;
  17699. /**
  17700. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  17701. */
  17702. textureMask: Color4;
  17703. /**
  17704. * The particle emitter type defines the emitter used by the particle system.
  17705. * It can be for example box, sphere, or cone...
  17706. */
  17707. particleEmitterType: IParticleEmitterType;
  17708. /**
  17709. * This function can be defined to specify initial direction for every new particle.
  17710. * It by default use the emitterType defined function.
  17711. */
  17712. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17713. /**
  17714. * This function can be defined to specify initial position for every new particle.
  17715. * It by default use the emitterType defined function.
  17716. */
  17717. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17718. /**
  17719. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  17720. */
  17721. spriteCellLoop: boolean;
  17722. /**
  17723. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  17724. */
  17725. spriteCellChangeSpeed: number;
  17726. /**
  17727. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  17728. */
  17729. startSpriteCellID: number;
  17730. /**
  17731. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  17732. */
  17733. endSpriteCellID: number;
  17734. /**
  17735. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  17736. */
  17737. spriteCellWidth: number;
  17738. /**
  17739. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  17740. */
  17741. spriteCellHeight: number;
  17742. /**
  17743. * An event triggered when the system is disposed.
  17744. */
  17745. onDisposeObservable: Observable<ParticleSystem>;
  17746. private _onDisposeObserver;
  17747. /**
  17748. * Sets a callback that will be triggered when the system is disposed.
  17749. */
  17750. onDispose: () => void;
  17751. /**
  17752. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  17753. */
  17754. readonly isAnimationSheetEnabled: Boolean;
  17755. private _particles;
  17756. private _epsilon;
  17757. private _capacity;
  17758. private _scene;
  17759. private _stockParticles;
  17760. private _newPartsExcess;
  17761. private _vertexData;
  17762. private _vertexBuffer;
  17763. private _vertexBuffers;
  17764. private _indexBuffer;
  17765. private _effect;
  17766. private _customEffect;
  17767. private _cachedDefines;
  17768. private _scaledColorStep;
  17769. private _colorDiff;
  17770. private _scaledDirection;
  17771. private _scaledGravity;
  17772. private _currentRenderId;
  17773. private _alive;
  17774. private _started;
  17775. private _stopped;
  17776. private _actualFrame;
  17777. private _scaledUpdateSpeed;
  17778. private _vertexBufferSize;
  17779. private _isAnimationSheetEnabled;
  17780. /**
  17781. * Instantiates a particle system.
  17782. * 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.
  17783. * @param name The name of the particle system
  17784. * @param capacity The max number of particles alive at the same time
  17785. * @param scene The scene the particle system belongs to
  17786. * @param customEffect a custom effect used to change the way particles are rendered by default
  17787. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17788. * @param epsilon Offset used to render the particles
  17789. */
  17790. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17791. private _createIndexBuffer();
  17792. /**
  17793. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17794. * Its lifetime will start back at 0.
  17795. * @param particle The particle to recycle
  17796. */
  17797. recycleParticle(particle: Particle): void;
  17798. /**
  17799. * Gets the maximum number of particles active at the same time.
  17800. * @returns The max number of active particles.
  17801. */
  17802. getCapacity(): number;
  17803. /**
  17804. * Gets Wether there are still active particles in the system.
  17805. * @returns True if it is alive, otherwise false.
  17806. */
  17807. isAlive(): boolean;
  17808. /**
  17809. * Gets Wether the system has been started.
  17810. * @returns True if it has been started, otherwise false.
  17811. */
  17812. isStarted(): boolean;
  17813. /**
  17814. * Starts the particle system and begins to emit.
  17815. */
  17816. start(): void;
  17817. /**
  17818. * Stops the particle system.
  17819. */
  17820. stop(): void;
  17821. /**
  17822. * Remove all active particles
  17823. */
  17824. reset(): void;
  17825. /**
  17826. * @ignore (for internal use only)
  17827. */
  17828. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17829. /**
  17830. * @ignore (for internal use only)
  17831. */
  17832. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17833. private _update(newParticles);
  17834. private _getEffect();
  17835. /**
  17836. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17837. */
  17838. animate(): void;
  17839. private _appendParticleVertexes;
  17840. private _appenedParticleVertexesWithSheet(offset, particle);
  17841. private _appenedParticleVertexesNoSheet(offset, particle);
  17842. /**
  17843. * Rebuilds the particle system.
  17844. */
  17845. rebuild(): void;
  17846. /**
  17847. * Renders the particle system in its current state.
  17848. * @returns the current number of particles.
  17849. */
  17850. render(): number;
  17851. /**
  17852. * Disposes the particle system and free the associated resources.
  17853. */
  17854. dispose(): void;
  17855. /**
  17856. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  17857. * @param radius The radius of the sphere to emit from
  17858. * @returns the emitter
  17859. */
  17860. createSphereEmitter(radius?: number): SphereParticleEmitter;
  17861. /**
  17862. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  17863. * @param radius The radius of the sphere to emit from
  17864. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17865. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17866. * @returns the emitter
  17867. */
  17868. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17869. /**
  17870. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  17871. * @param radius The radius of the cone to emit from
  17872. * @param angle The base angle of the cone
  17873. * @returns the emitter
  17874. */
  17875. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17876. /**
  17877. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17878. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17879. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17880. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17881. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17882. * @returns the emitter
  17883. */
  17884. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17885. /**
  17886. * Clones the particle system.
  17887. * @param name The name of the cloned object
  17888. * @param newEmitter The new emitter to use
  17889. * @returns the cloned particle system
  17890. */
  17891. clone(name: string, newEmitter: any): ParticleSystem;
  17892. /**
  17893. * Serializes the particle system to a JSON object.
  17894. * @returns the JSON object
  17895. */
  17896. serialize(): any;
  17897. /**
  17898. * Parses a JSON object to create a particle system.
  17899. * @param parsedParticleSystem The JSON object to parse
  17900. * @param scene The scene to create the particle system in
  17901. * @param rootUrl The root url to use to load external dependencies like texture
  17902. * @returns the Parsed particle system
  17903. */
  17904. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  17905. }
  17906. }
  17907. declare module BABYLON {
  17908. /**
  17909. * Represents one particle of a solid particle system.
  17910. * @see SolidParticleSystem
  17911. */
  17912. class SolidParticle {
  17913. /**
  17914. * particle global index
  17915. */
  17916. idx: number;
  17917. /**
  17918. * The color of the particle
  17919. */
  17920. color: Nullable<Color4>;
  17921. /**
  17922. * The world space position of the particle.
  17923. */
  17924. position: Vector3;
  17925. /**
  17926. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  17927. */
  17928. rotation: Vector3;
  17929. /**
  17930. * The world space rotation quaternion of the particle.
  17931. */
  17932. rotationQuaternion: Nullable<Quaternion>;
  17933. /**
  17934. * The scaling of the particle.
  17935. */
  17936. scaling: Vector3;
  17937. /**
  17938. * The uvs of the particle.
  17939. */
  17940. uvs: Vector4;
  17941. /**
  17942. * The current speed of the particle.
  17943. */
  17944. velocity: Vector3;
  17945. /**
  17946. * The pivot point in the particle local space.
  17947. */
  17948. pivot: Vector3;
  17949. /**
  17950. * Must the particle be translated from its pivot point in its local space ?
  17951. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  17952. * Default : false
  17953. */
  17954. translateFromPivot: boolean;
  17955. /**
  17956. * Is the particle active or not ?
  17957. */
  17958. alive: boolean;
  17959. /**
  17960. * Is the particle visible or not ?
  17961. */
  17962. isVisible: boolean;
  17963. /**
  17964. * Index of this particle in the global "positions" array (Internal use)
  17965. */
  17966. _pos: number;
  17967. /**
  17968. * Index of this particle in the global "indices" array (Internal use)
  17969. */
  17970. _ind: number;
  17971. /**
  17972. * ModelShape of this particle (Internal use)
  17973. */
  17974. _model: ModelShape;
  17975. /**
  17976. * ModelShape id of this particle
  17977. */
  17978. shapeId: number;
  17979. /**
  17980. * Index of the particle in its shape id (Internal use)
  17981. */
  17982. idxInShape: number;
  17983. /**
  17984. * Reference to the shape model BoundingInfo object (Internal use)
  17985. */
  17986. _modelBoundingInfo: BoundingInfo;
  17987. /**
  17988. * Particle BoundingInfo object (Internal use)
  17989. */
  17990. _boundingInfo: BoundingInfo;
  17991. /**
  17992. * Reference to the SPS what the particle belongs to (Internal use)
  17993. */
  17994. _sps: SolidParticleSystem;
  17995. /**
  17996. * Still set as invisible in order to skip useless computations (Internal use)
  17997. */
  17998. _stillInvisible: boolean;
  17999. /**
  18000. * Last computed particle rotation matrix
  18001. */
  18002. _rotationMatrix: number[];
  18003. /**
  18004. * Parent particle Id, if any.
  18005. * Default null.
  18006. */
  18007. parentId: Nullable<number>;
  18008. /**
  18009. * Internal global position in the SPS.
  18010. */
  18011. _globalPosition: Vector3;
  18012. /**
  18013. * Creates a Solid Particle object.
  18014. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  18015. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  18016. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  18017. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  18018. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  18019. * @param shapeId (integer) is the model shape identifier in the SPS.
  18020. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  18021. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  18022. */
  18023. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  18024. /**
  18025. * Legacy support, changed scale to scaling
  18026. */
  18027. /**
  18028. * Legacy support, changed scale to scaling
  18029. */
  18030. scale: Vector3;
  18031. /**
  18032. * Legacy support, changed quaternion to rotationQuaternion
  18033. */
  18034. /**
  18035. * Legacy support, changed quaternion to rotationQuaternion
  18036. */
  18037. quaternion: Nullable<Quaternion>;
  18038. /**
  18039. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  18040. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  18041. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  18042. * @returns true if it intersects
  18043. */
  18044. intersectsMesh(target: Mesh | SolidParticle): boolean;
  18045. }
  18046. /**
  18047. * Represents the shape of the model used by one particle of a solid particle system.
  18048. * SPS internal tool, don't use it manually.
  18049. * @see SolidParticleSystem
  18050. */
  18051. class ModelShape {
  18052. /**
  18053. * The shape id.
  18054. */
  18055. shapeID: number;
  18056. /**
  18057. * flat array of model positions (internal use)
  18058. */
  18059. _shape: Vector3[];
  18060. /**
  18061. * flat array of model UVs (internal use)
  18062. */
  18063. _shapeUV: number[];
  18064. /**
  18065. * length of the shape in the model indices array (internal use)
  18066. */
  18067. _indicesLength: number;
  18068. /**
  18069. * Custom position function (internal use)
  18070. */
  18071. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  18072. /**
  18073. * Custom vertex function (internal use)
  18074. */
  18075. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  18076. /**
  18077. * 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.
  18078. * SPS internal tool, don't use it manually.
  18079. * @ignore
  18080. */
  18081. 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>);
  18082. }
  18083. /**
  18084. * Represents a Depth Sorted Particle in the solid particle system.
  18085. * @see SolidParticleSystem
  18086. */
  18087. class DepthSortedParticle {
  18088. /**
  18089. * Index of the particle in the "indices" array
  18090. */
  18091. ind: number;
  18092. /**
  18093. * Length of the particle shape in the "indices" array
  18094. */
  18095. indicesLength: number;
  18096. /**
  18097. * Squared distance from the particle to the camera
  18098. */
  18099. sqDistance: number;
  18100. }
  18101. }
  18102. declare module BABYLON {
  18103. /**
  18104. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  18105. *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.
  18106. * The SPS is also a particle system. It provides some methods to manage the particles.
  18107. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  18108. *
  18109. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  18110. */
  18111. class SolidParticleSystem implements IDisposable {
  18112. /**
  18113. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  18114. * Example : var p = SPS.particles[i];
  18115. */
  18116. particles: SolidParticle[];
  18117. /**
  18118. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  18119. */
  18120. nbParticles: number;
  18121. /**
  18122. * If the particles must ever face the camera (default false). Useful for planar particles.
  18123. */
  18124. billboard: boolean;
  18125. /**
  18126. * Recompute normals when adding a shape
  18127. */
  18128. recomputeNormals: boolean;
  18129. /**
  18130. * This a counter ofr your own usage. It's not set by any SPS functions.
  18131. */
  18132. counter: number;
  18133. /**
  18134. * The SPS name. This name is also given to the underlying mesh.
  18135. */
  18136. name: string;
  18137. /**
  18138. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  18139. */
  18140. mesh: Mesh;
  18141. /**
  18142. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  18143. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  18144. */
  18145. vars: any;
  18146. /**
  18147. * This array is populated when the SPS is set as 'pickable'.
  18148. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  18149. * Each element of this array is an object `{idx: int, faceId: int}`.
  18150. * `idx` is the picked particle index in the `SPS.particles` array
  18151. * `faceId` is the picked face index counted within this particle.
  18152. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  18153. */
  18154. pickedParticles: {
  18155. idx: number;
  18156. faceId: number;
  18157. }[];
  18158. /**
  18159. * This array is populated when `enableDepthSort` is set to true.
  18160. * Each element of this array is an instance of the class DepthSortedParticle.
  18161. */
  18162. depthSortedParticles: DepthSortedParticle[];
  18163. /**
  18164. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  18165. */
  18166. _bSphereOnly: boolean;
  18167. /**
  18168. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  18169. */
  18170. _bSphereRadiusFactor: number;
  18171. private _scene;
  18172. private _positions;
  18173. private _indices;
  18174. private _normals;
  18175. private _colors;
  18176. private _uvs;
  18177. private _indices32;
  18178. private _positions32;
  18179. private _normals32;
  18180. private _fixedNormal32;
  18181. private _colors32;
  18182. private _uvs32;
  18183. private _index;
  18184. private _updatable;
  18185. private _pickable;
  18186. private _isVisibilityBoxLocked;
  18187. private _alwaysVisible;
  18188. private _depthSort;
  18189. private _shapeCounter;
  18190. private _copy;
  18191. private _shape;
  18192. private _shapeUV;
  18193. private _color;
  18194. private _computeParticleColor;
  18195. private _computeParticleTexture;
  18196. private _computeParticleRotation;
  18197. private _computeParticleVertex;
  18198. private _computeBoundingBox;
  18199. private _depthSortParticles;
  18200. private _cam_axisZ;
  18201. private _cam_axisY;
  18202. private _cam_axisX;
  18203. private _axisZ;
  18204. private _camera;
  18205. private _particle;
  18206. private _camDir;
  18207. private _camInvertedPosition;
  18208. private _rotMatrix;
  18209. private _invertMatrix;
  18210. private _rotated;
  18211. private _quaternion;
  18212. private _vertex;
  18213. private _normal;
  18214. private _yaw;
  18215. private _pitch;
  18216. private _roll;
  18217. private _halfroll;
  18218. private _halfpitch;
  18219. private _halfyaw;
  18220. private _sinRoll;
  18221. private _cosRoll;
  18222. private _sinPitch;
  18223. private _cosPitch;
  18224. private _sinYaw;
  18225. private _cosYaw;
  18226. private _mustUnrotateFixedNormals;
  18227. private _minimum;
  18228. private _maximum;
  18229. private _minBbox;
  18230. private _maxBbox;
  18231. private _particlesIntersect;
  18232. private _depthSortFunction;
  18233. private _needs32Bits;
  18234. private _pivotBackTranslation;
  18235. private _scaledPivot;
  18236. private _particleHasParent;
  18237. private _parent;
  18238. /**
  18239. * Creates a SPS (Solid Particle System) object.
  18240. * @param name (String) is the SPS name, this will be the underlying mesh name.
  18241. * @param scene (Scene) is the scene in which the SPS is added.
  18242. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  18243. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  18244. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  18245. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  18246. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  18247. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  18248. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  18249. */
  18250. constructor(name: string, scene: Scene, options?: {
  18251. updatable?: boolean;
  18252. isPickable?: boolean;
  18253. enableDepthSort?: boolean;
  18254. particleIntersection?: boolean;
  18255. boundingSphereOnly?: boolean;
  18256. bSphereRadiusFactor?: number;
  18257. });
  18258. /**
  18259. * Builds the SPS underlying mesh. Returns a standard Mesh.
  18260. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  18261. * @returns the created mesh
  18262. */
  18263. buildMesh(): Mesh;
  18264. /**
  18265. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  18266. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  18267. * Thus the particles generated from `digest()` have their property `position` set yet.
  18268. * @param mesh ( Mesh ) is the mesh to be digested
  18269. * @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
  18270. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  18271. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  18272. * @returns the current SPS
  18273. */
  18274. digest(mesh: Mesh, options?: {
  18275. facetNb?: number;
  18276. number?: number;
  18277. delta?: number;
  18278. }): SolidParticleSystem;
  18279. private _unrotateFixedNormals();
  18280. private _resetCopy();
  18281. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  18282. private _posToShape(positions);
  18283. private _uvsToShapeUV(uvs);
  18284. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  18285. /**
  18286. * Adds some particles to the SPS from the model shape. Returns the shape id.
  18287. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  18288. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  18289. * @param nb (positive integer) the number of particles to be created from this model
  18290. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  18291. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  18292. * @returns the number of shapes in the system
  18293. */
  18294. addShape(mesh: Mesh, nb: number, options?: {
  18295. positionFunction?: any;
  18296. vertexFunction?: any;
  18297. }): number;
  18298. private _rebuildParticle(particle);
  18299. /**
  18300. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  18301. * @returns the SPS.
  18302. */
  18303. rebuildMesh(): SolidParticleSystem;
  18304. /**
  18305. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  18306. * This method calls `updateParticle()` for each particle of the SPS.
  18307. * For an animated SPS, it is usually called within the render loop.
  18308. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  18309. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  18310. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  18311. * @returns the SPS.
  18312. */
  18313. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  18314. private _quaternionRotationYPR();
  18315. private _quaternionToRotationMatrix();
  18316. /**
  18317. * Disposes the SPS.
  18318. */
  18319. dispose(): void;
  18320. /**
  18321. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  18322. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18323. * @returns the SPS.
  18324. */
  18325. refreshVisibleSize(): SolidParticleSystem;
  18326. /**
  18327. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  18328. * @param size the size (float) of the visibility box
  18329. * note : this doesn't lock the SPS mesh bounding box.
  18330. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18331. */
  18332. setVisibilityBox(size: number): void;
  18333. /**
  18334. * Gets whether the SPS as always visible or not
  18335. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18336. */
  18337. /**
  18338. * Sets the SPS as always visible or not
  18339. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18340. */
  18341. isAlwaysVisible: boolean;
  18342. /**
  18343. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  18344. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18345. */
  18346. /**
  18347. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  18348. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18349. */
  18350. isVisibilityBoxLocked: boolean;
  18351. /**
  18352. * Gets if `setParticles()` computes the particle rotations or not.
  18353. * Default value : true. The SPS is faster when it's set to false.
  18354. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  18355. */
  18356. /**
  18357. * Tells to `setParticles()` to compute the particle rotations or not.
  18358. * Default value : true. The SPS is faster when it's set to false.
  18359. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  18360. */
  18361. computeParticleRotation: boolean;
  18362. /**
  18363. * Gets if `setParticles()` computes the particle colors or not.
  18364. * Default value : true. The SPS is faster when it's set to false.
  18365. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  18366. */
  18367. /**
  18368. * Tells to `setParticles()` to compute the particle colors or not.
  18369. * Default value : true. The SPS is faster when it's set to false.
  18370. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  18371. */
  18372. computeParticleColor: boolean;
  18373. /**
  18374. * Gets if `setParticles()` computes the particle textures or not.
  18375. * Default value : true. The SPS is faster when it's set to false.
  18376. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  18377. */
  18378. computeParticleTexture: boolean;
  18379. /**
  18380. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  18381. * Default value : false. The SPS is faster when it's set to false.
  18382. * Note : the particle custom vertex positions aren't stored values.
  18383. */
  18384. /**
  18385. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  18386. * Default value : false. The SPS is faster when it's set to false.
  18387. * Note : the particle custom vertex positions aren't stored values.
  18388. */
  18389. computeParticleVertex: boolean;
  18390. /**
  18391. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  18392. */
  18393. /**
  18394. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  18395. */
  18396. computeBoundingBox: boolean;
  18397. /**
  18398. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  18399. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  18400. * Default : `true`
  18401. */
  18402. /**
  18403. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  18404. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  18405. * Default : `true`
  18406. */
  18407. depthSortParticles: boolean;
  18408. /**
  18409. * This function does nothing. It may be overwritten to set all the particle first values.
  18410. * The SPS doesn't call this function, you may have to call it by your own.
  18411. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  18412. */
  18413. initParticles(): void;
  18414. /**
  18415. * This function does nothing. It may be overwritten to recycle a particle.
  18416. * The SPS doesn't call this function, you may have to call it by your own.
  18417. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  18418. * @param particle The particle to recycle
  18419. * @returns the recycled particle
  18420. */
  18421. recycleParticle(particle: SolidParticle): SolidParticle;
  18422. /**
  18423. * Updates a particle : this function should be overwritten by the user.
  18424. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  18425. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  18426. * @example : just set a particle position or velocity and recycle conditions
  18427. * @param particle The particle to update
  18428. * @returns the updated particle
  18429. */
  18430. updateParticle(particle: SolidParticle): SolidParticle;
  18431. /**
  18432. * Updates a vertex of a particle : it can be overwritten by the user.
  18433. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  18434. * @param particle the current particle
  18435. * @param vertex the current index of the current particle
  18436. * @param pt the index of the current vertex in the particle shape
  18437. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  18438. * @example : just set a vertex particle position
  18439. * @returns the updated vertex
  18440. */
  18441. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  18442. /**
  18443. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  18444. * This does nothing and may be overwritten by the user.
  18445. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  18446. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  18447. * @param update the boolean update value actually passed to setParticles()
  18448. */
  18449. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  18450. /**
  18451. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  18452. * This will be passed three parameters.
  18453. * This does nothing and may be overwritten by the user.
  18454. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  18455. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  18456. * @param update the boolean update value actually passed to setParticles()
  18457. */
  18458. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  18459. }
  18460. }
  18461. declare module BABYLON {
  18462. /**
  18463. * Particle emitter emitting particles from the inside of a sphere.
  18464. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18465. */
  18466. class SphereParticleEmitter implements IParticleEmitterType {
  18467. /**
  18468. * The radius of the emission sphere.
  18469. */
  18470. radius: number;
  18471. /**
  18472. * How much to randomize the particle direction [0-1].
  18473. */
  18474. directionRandomizer: number;
  18475. /**
  18476. * Creates a new instance of @see SphereParticleEmitter
  18477. * @param radius the radius of the emission sphere
  18478. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18479. */
  18480. constructor(
  18481. /**
  18482. * The radius of the emission sphere.
  18483. */
  18484. radius: number,
  18485. /**
  18486. * How much to randomize the particle direction [0-1].
  18487. */
  18488. directionRandomizer?: number);
  18489. /**
  18490. * Called by the particle System when the direction is computed for the created particle.
  18491. * @param emitPower is the power of the particle (speed)
  18492. * @param worldMatrix is the world matrix of the particle system
  18493. * @param directionToUpdate is the direction vector to update with the result
  18494. * @param particle is the particle we are computed the direction for
  18495. */
  18496. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18497. /**
  18498. * Called by the particle System when the position is computed for the created particle.
  18499. * @param worldMatrix is the world matrix of the particle system
  18500. * @param positionToUpdate is the position vector to update with the result
  18501. * @param particle is the particle we are computed the position for
  18502. */
  18503. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18504. /**
  18505. * Clones the current emitter and returns a copy of it
  18506. * @returns the new emitter
  18507. */
  18508. clone(): SphereParticleEmitter;
  18509. }
  18510. /**
  18511. * Particle emitter emitting particles from the inside of a sphere.
  18512. * It emits the particles randomly between two vectors.
  18513. */
  18514. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18515. /**
  18516. * The min limit of the emission direction.
  18517. */
  18518. direction1: Vector3;
  18519. /**
  18520. * The max limit of the emission direction.
  18521. */
  18522. direction2: Vector3;
  18523. /**
  18524. * Creates a new instance of @see SphereDirectedParticleEmitter
  18525. * @param radius the radius of the emission sphere
  18526. * @param direction1 the min limit of the emission direction
  18527. * @param direction2 the max limit of the emission direction
  18528. */
  18529. constructor(radius: number,
  18530. /**
  18531. * The min limit of the emission direction.
  18532. */
  18533. direction1: Vector3,
  18534. /**
  18535. * The max limit of the emission direction.
  18536. */
  18537. direction2: Vector3);
  18538. /**
  18539. * Called by the particle System when the direction is computed for the created particle.
  18540. * @param emitPower is the power of the particle (speed)
  18541. * @param worldMatrix is the world matrix of the particle system
  18542. * @param directionToUpdate is the direction vector to update with the result
  18543. * @param particle is the particle we are computed the direction for
  18544. */
  18545. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18546. /**
  18547. * Clones the current emitter and returns a copy of it
  18548. * @returns the new emitter
  18549. */
  18550. clone(): SphereDirectedParticleEmitter;
  18551. }
  18552. }
  18553. declare module BABYLON {
  18554. interface PhysicsImpostorJoint {
  18555. mainImpostor: PhysicsImpostor;
  18556. connectedImpostor: PhysicsImpostor;
  18557. joint: PhysicsJoint;
  18558. }
  18559. class PhysicsEngine {
  18560. private _physicsPlugin;
  18561. gravity: Vector3;
  18562. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  18563. setGravity(gravity: Vector3): void;
  18564. /**
  18565. * Set the time step of the physics engine.
  18566. * default is 1/60.
  18567. * To slow it down, enter 1/600 for example.
  18568. * To speed it up, 1/30
  18569. * @param {number} newTimeStep the new timestep to apply to this world.
  18570. */
  18571. setTimeStep(newTimeStep?: number): void;
  18572. /**
  18573. * Get the time step of the physics engine.
  18574. */
  18575. getTimeStep(): number;
  18576. dispose(): void;
  18577. getPhysicsPluginName(): string;
  18578. static Epsilon: number;
  18579. private _impostors;
  18580. private _joints;
  18581. /**
  18582. * Adding a new impostor for the impostor tracking.
  18583. * This will be done by the impostor itself.
  18584. * @param {PhysicsImpostor} impostor the impostor to add
  18585. */
  18586. addImpostor(impostor: PhysicsImpostor): void;
  18587. /**
  18588. * Remove an impostor from the engine.
  18589. * This impostor and its mesh will not longer be updated by the physics engine.
  18590. * @param {PhysicsImpostor} impostor the impostor to remove
  18591. */
  18592. removeImpostor(impostor: PhysicsImpostor): void;
  18593. /**
  18594. * Add a joint to the physics engine
  18595. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  18596. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  18597. * @param {PhysicsJoint} the joint that will connect both impostors.
  18598. */
  18599. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18600. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18601. /**
  18602. * Called by the scene. no need to call it.
  18603. */
  18604. _step(delta: number): void;
  18605. getPhysicsPlugin(): IPhysicsEnginePlugin;
  18606. getImpostors(): Array<PhysicsImpostor>;
  18607. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18608. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  18609. }
  18610. interface IPhysicsEnginePlugin {
  18611. world: any;
  18612. name: string;
  18613. setGravity(gravity: Vector3): void;
  18614. setTimeStep(timeStep: number): void;
  18615. getTimeStep(): number;
  18616. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18617. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18618. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18619. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18620. removePhysicsBody(impostor: PhysicsImpostor): void;
  18621. generateJoint(joint: PhysicsImpostorJoint): void;
  18622. removeJoint(joint: PhysicsImpostorJoint): void;
  18623. isSupported(): boolean;
  18624. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18625. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18626. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18627. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18628. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18629. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18630. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18631. getBodyMass(impostor: PhysicsImpostor): number;
  18632. getBodyFriction(impostor: PhysicsImpostor): number;
  18633. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18634. getBodyRestitution(impostor: PhysicsImpostor): number;
  18635. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18636. sleepBody(impostor: PhysicsImpostor): void;
  18637. wakeUpBody(impostor: PhysicsImpostor): void;
  18638. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18639. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18640. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18641. getRadius(impostor: PhysicsImpostor): number;
  18642. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18643. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18644. dispose(): void;
  18645. }
  18646. }
  18647. declare module BABYLON {
  18648. class PhysicsHelper {
  18649. private _scene;
  18650. private _physicsEngine;
  18651. constructor(scene: Scene);
  18652. /**
  18653. * @param {Vector3} origin the origin of the explosion
  18654. * @param {number} radius the explosion radius
  18655. * @param {number} strength the explosion strength
  18656. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  18657. */
  18658. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  18659. /**
  18660. * @param {Vector3} origin the origin of the explosion
  18661. * @param {number} radius the explosion radius
  18662. * @param {number} strength the explosion strength
  18663. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  18664. */
  18665. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  18666. /**
  18667. * @param {Vector3} origin the origin of the explosion
  18668. * @param {number} radius the explosion radius
  18669. * @param {number} strength the explosion strength
  18670. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  18671. */
  18672. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  18673. /**
  18674. * @param {Vector3} origin the origin of the updraft
  18675. * @param {number} radius the radius of the updraft
  18676. * @param {number} strength the strength of the updraft
  18677. * @param {number} height the height of the updraft
  18678. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  18679. */
  18680. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  18681. /**
  18682. * @param {Vector3} origin the of the vortex
  18683. * @param {number} radius the radius of the vortex
  18684. * @param {number} strength the strength of the vortex
  18685. * @param {number} height the height of the vortex
  18686. */
  18687. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  18688. }
  18689. /***** Radial explosion *****/
  18690. class PhysicsRadialExplosionEvent {
  18691. private _scene;
  18692. private _sphere;
  18693. private _sphereOptions;
  18694. private _rays;
  18695. private _dataFetched;
  18696. constructor(scene: Scene);
  18697. /**
  18698. * Returns the data related to the radial explosion event (sphere & rays).
  18699. * @returns {PhysicsRadialExplosionEventData}
  18700. */
  18701. getData(): PhysicsRadialExplosionEventData;
  18702. /**
  18703. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  18704. * @param impostor
  18705. * @param {Vector3} origin the origin of the explosion
  18706. * @param {number} radius the explosion radius
  18707. * @param {number} strength the explosion strength
  18708. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  18709. * @returns {Nullable<PhysicsForceAndContactPoint>}
  18710. */
  18711. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  18712. /**
  18713. * Disposes the sphere.
  18714. * @param {bolean} force
  18715. */
  18716. dispose(force?: boolean): void;
  18717. /*** Helpers ***/
  18718. private _prepareSphere();
  18719. private _intersectsWithSphere(impostor, origin, radius);
  18720. }
  18721. /***** Gravitational Field *****/
  18722. class PhysicsGravitationalFieldEvent {
  18723. private _physicsHelper;
  18724. private _scene;
  18725. private _origin;
  18726. private _radius;
  18727. private _strength;
  18728. private _falloff;
  18729. private _tickCallback;
  18730. private _sphere;
  18731. private _dataFetched;
  18732. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  18733. /**
  18734. * Returns the data related to the gravitational field event (sphere).
  18735. * @returns {PhysicsGravitationalFieldEventData}
  18736. */
  18737. getData(): PhysicsGravitationalFieldEventData;
  18738. /**
  18739. * Enables the gravitational field.
  18740. */
  18741. enable(): void;
  18742. /**
  18743. * Disables the gravitational field.
  18744. */
  18745. disable(): void;
  18746. /**
  18747. * Disposes the sphere.
  18748. * @param {bolean} force
  18749. */
  18750. dispose(force?: boolean): void;
  18751. private _tick();
  18752. }
  18753. /***** Updraft *****/
  18754. class PhysicsUpdraftEvent {
  18755. private _scene;
  18756. private _origin;
  18757. private _radius;
  18758. private _strength;
  18759. private _height;
  18760. private _updraftMode;
  18761. private _physicsEngine;
  18762. private _originTop;
  18763. private _originDirection;
  18764. private _tickCallback;
  18765. private _cylinder;
  18766. private _cylinderPosition;
  18767. private _dataFetched;
  18768. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  18769. /**
  18770. * Returns the data related to the updraft event (cylinder).
  18771. * @returns {PhysicsUpdraftEventData}
  18772. */
  18773. getData(): PhysicsUpdraftEventData;
  18774. /**
  18775. * Enables the updraft.
  18776. */
  18777. enable(): void;
  18778. /**
  18779. * Disables the cortex.
  18780. */
  18781. disable(): void;
  18782. /**
  18783. * Disposes the sphere.
  18784. * @param {bolean} force
  18785. */
  18786. dispose(force?: boolean): void;
  18787. private getImpostorForceAndContactPoint(impostor);
  18788. private _tick();
  18789. /*** Helpers ***/
  18790. private _prepareCylinder();
  18791. private _intersectsWithCylinder(impostor);
  18792. }
  18793. /***** Vortex *****/
  18794. class PhysicsVortexEvent {
  18795. private _scene;
  18796. private _origin;
  18797. private _radius;
  18798. private _strength;
  18799. private _height;
  18800. private _physicsEngine;
  18801. private _originTop;
  18802. private _centripetalForceThreshold;
  18803. private _updraftMultiplier;
  18804. private _tickCallback;
  18805. private _cylinder;
  18806. private _cylinderPosition;
  18807. private _dataFetched;
  18808. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  18809. /**
  18810. * Returns the data related to the vortex event (cylinder).
  18811. * @returns {PhysicsVortexEventData}
  18812. */
  18813. getData(): PhysicsVortexEventData;
  18814. /**
  18815. * Enables the vortex.
  18816. */
  18817. enable(): void;
  18818. /**
  18819. * Disables the cortex.
  18820. */
  18821. disable(): void;
  18822. /**
  18823. * Disposes the sphere.
  18824. * @param {bolean} force
  18825. */
  18826. dispose(force?: boolean): void;
  18827. private getImpostorForceAndContactPoint(impostor);
  18828. private _tick();
  18829. /*** Helpers ***/
  18830. private _prepareCylinder();
  18831. private _intersectsWithCylinder(impostor);
  18832. }
  18833. /***** Enums *****/
  18834. /**
  18835. * The strenght of the force in correspondence to the distance of the affected object
  18836. */
  18837. enum PhysicsRadialImpulseFalloff {
  18838. Constant = 0,
  18839. Linear = 1,
  18840. }
  18841. /**
  18842. * The strenght of the force in correspondence to the distance of the affected object
  18843. */
  18844. enum PhysicsUpdraftMode {
  18845. Center = 0,
  18846. Perpendicular = 1,
  18847. }
  18848. /***** Data interfaces *****/
  18849. interface PhysicsForceAndContactPoint {
  18850. force: Vector3;
  18851. contactPoint: Vector3;
  18852. }
  18853. interface PhysicsRadialExplosionEventData {
  18854. sphere: Mesh;
  18855. rays: Array<Ray>;
  18856. }
  18857. interface PhysicsGravitationalFieldEventData {
  18858. sphere: Mesh;
  18859. }
  18860. interface PhysicsUpdraftEventData {
  18861. cylinder: Mesh;
  18862. }
  18863. interface PhysicsVortexEventData {
  18864. cylinder: Mesh;
  18865. }
  18866. }
  18867. declare module BABYLON {
  18868. interface PhysicsImpostorParameters {
  18869. mass: number;
  18870. friction?: number;
  18871. restitution?: number;
  18872. nativeOptions?: any;
  18873. ignoreParent?: boolean;
  18874. disableBidirectionalTransformation?: boolean;
  18875. }
  18876. interface IPhysicsEnabledObject {
  18877. position: Vector3;
  18878. rotationQuaternion: Nullable<Quaternion>;
  18879. scaling: Vector3;
  18880. rotation?: Vector3;
  18881. parent?: any;
  18882. getBoundingInfo(): BoundingInfo;
  18883. computeWorldMatrix(force: boolean): Matrix;
  18884. getWorldMatrix?(): Matrix;
  18885. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  18886. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  18887. getIndices?(): Nullable<IndicesArray>;
  18888. getScene?(): Scene;
  18889. getAbsolutePosition(): Vector3;
  18890. getAbsolutePivotPoint(): Vector3;
  18891. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  18892. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  18893. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  18894. getClassName(): string;
  18895. }
  18896. class PhysicsImpostor {
  18897. object: IPhysicsEnabledObject;
  18898. type: number;
  18899. private _options;
  18900. private _scene;
  18901. static DEFAULT_OBJECT_SIZE: Vector3;
  18902. static IDENTITY_QUATERNION: Quaternion;
  18903. private _physicsEngine;
  18904. private _physicsBody;
  18905. private _bodyUpdateRequired;
  18906. private _onBeforePhysicsStepCallbacks;
  18907. private _onAfterPhysicsStepCallbacks;
  18908. private _onPhysicsCollideCallbacks;
  18909. private _deltaPosition;
  18910. private _deltaRotation;
  18911. private _deltaRotationConjugated;
  18912. private _parent;
  18913. private _isDisposed;
  18914. private static _tmpVecs;
  18915. private static _tmpQuat;
  18916. readonly isDisposed: boolean;
  18917. mass: number;
  18918. friction: number;
  18919. restitution: number;
  18920. uniqueId: number;
  18921. private _joints;
  18922. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  18923. /**
  18924. * This function will completly initialize this impostor.
  18925. * It will create a new body - but only if this mesh has no parent.
  18926. * If it has, this impostor will not be used other than to define the impostor
  18927. * of the child mesh.
  18928. */
  18929. _init(): void;
  18930. private _getPhysicsParent();
  18931. /**
  18932. * Should a new body be generated.
  18933. */
  18934. isBodyInitRequired(): boolean;
  18935. setScalingUpdated(updated: boolean): void;
  18936. /**
  18937. * Force a regeneration of this or the parent's impostor's body.
  18938. * Use under cautious - This will remove all joints already implemented.
  18939. */
  18940. forceUpdate(): void;
  18941. /**
  18942. * Gets the body that holds this impostor. Either its own, or its parent.
  18943. */
  18944. /**
  18945. * Set the physics body. Used mainly by the physics engine/plugin
  18946. */
  18947. physicsBody: any;
  18948. parent: Nullable<PhysicsImpostor>;
  18949. resetUpdateFlags(): void;
  18950. getObjectExtendSize(): Vector3;
  18951. getObjectCenter(): Vector3;
  18952. /**
  18953. * Get a specific parametes from the options parameter.
  18954. */
  18955. getParam(paramName: string): any;
  18956. /**
  18957. * Sets a specific parameter in the options given to the physics plugin
  18958. */
  18959. setParam(paramName: string, value: number): void;
  18960. /**
  18961. * Specifically change the body's mass option. Won't recreate the physics body object
  18962. */
  18963. setMass(mass: number): void;
  18964. getLinearVelocity(): Nullable<Vector3>;
  18965. setLinearVelocity(velocity: Nullable<Vector3>): void;
  18966. getAngularVelocity(): Nullable<Vector3>;
  18967. setAngularVelocity(velocity: Nullable<Vector3>): void;
  18968. /**
  18969. * Execute a function with the physics plugin native code.
  18970. * Provide a function the will have two variables - the world object and the physics body object.
  18971. */
  18972. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  18973. /**
  18974. * Register a function that will be executed before the physics world is stepping forward.
  18975. */
  18976. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18977. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18978. /**
  18979. * Register a function that will be executed after the physics step
  18980. */
  18981. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18982. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18983. /**
  18984. * register a function that will be executed when this impostor collides against a different body.
  18985. */
  18986. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  18987. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  18988. private _tmpQuat;
  18989. private _tmpQuat2;
  18990. getParentsRotation(): Quaternion;
  18991. /**
  18992. * this function is executed by the physics engine.
  18993. */
  18994. beforeStep: () => void;
  18995. /**
  18996. * this function is executed by the physics engine.
  18997. */
  18998. afterStep: () => void;
  18999. /**
  19000. * Legacy collision detection event support
  19001. */
  19002. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19003. onCollide: (e: {
  19004. body: any;
  19005. }) => void;
  19006. /**
  19007. * Apply a force
  19008. */
  19009. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19010. /**
  19011. * Apply an impulse
  19012. */
  19013. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19014. /**
  19015. * A help function to create a joint.
  19016. */
  19017. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19018. /**
  19019. * Add a joint to this impostor with a different impostor.
  19020. */
  19021. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19022. /**
  19023. * Will keep this body still, in a sleep mode.
  19024. */
  19025. sleep(): PhysicsImpostor;
  19026. /**
  19027. * Wake the body up.
  19028. */
  19029. wakeUp(): PhysicsImpostor;
  19030. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19031. dispose(): void;
  19032. setDeltaPosition(position: Vector3): void;
  19033. setDeltaRotation(rotation: Quaternion): void;
  19034. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19035. getRadius(): number;
  19036. /**
  19037. * Sync a bone with this impostor
  19038. * @param bone The bone to sync to the impostor.
  19039. * @param boneMesh The mesh that the bone is influencing.
  19040. * @param jointPivot The pivot of the joint / bone in local space.
  19041. * @param distToJoint Optional distance from the impostor to the joint.
  19042. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19043. */
  19044. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19045. /**
  19046. * Sync impostor to a bone
  19047. * @param bone The bone that the impostor will be synced to.
  19048. * @param boneMesh The mesh that the bone is influencing.
  19049. * @param jointPivot The pivot of the joint / bone in local space.
  19050. * @param distToJoint Optional distance from the impostor to the joint.
  19051. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19052. * @param boneAxis Optional vector3 axis the bone is aligned with
  19053. */
  19054. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19055. static NoImpostor: number;
  19056. static SphereImpostor: number;
  19057. static BoxImpostor: number;
  19058. static PlaneImpostor: number;
  19059. static MeshImpostor: number;
  19060. static CylinderImpostor: number;
  19061. static ParticleImpostor: number;
  19062. static HeightmapImpostor: number;
  19063. }
  19064. }
  19065. declare module BABYLON {
  19066. interface PhysicsJointData {
  19067. mainPivot?: Vector3;
  19068. connectedPivot?: Vector3;
  19069. mainAxis?: Vector3;
  19070. connectedAxis?: Vector3;
  19071. collision?: boolean;
  19072. nativeParams?: any;
  19073. }
  19074. /**
  19075. * This is a holder class for the physics joint created by the physics plugin.
  19076. * It holds a set of functions to control the underlying joint.
  19077. */
  19078. class PhysicsJoint {
  19079. type: number;
  19080. jointData: PhysicsJointData;
  19081. private _physicsJoint;
  19082. protected _physicsPlugin: IPhysicsEnginePlugin;
  19083. constructor(type: number, jointData: PhysicsJointData);
  19084. physicsJoint: any;
  19085. physicsPlugin: IPhysicsEnginePlugin;
  19086. /**
  19087. * Execute a function that is physics-plugin specific.
  19088. * @param {Function} func the function that will be executed.
  19089. * It accepts two parameters: the physics world and the physics joint.
  19090. */
  19091. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19092. static DistanceJoint: number;
  19093. static HingeJoint: number;
  19094. static BallAndSocketJoint: number;
  19095. static WheelJoint: number;
  19096. static SliderJoint: number;
  19097. static PrismaticJoint: number;
  19098. static UniversalJoint: number;
  19099. static Hinge2Joint: number;
  19100. static PointToPointJoint: number;
  19101. static SpringJoint: number;
  19102. static LockJoint: number;
  19103. }
  19104. /**
  19105. * A class representing a physics distance joint.
  19106. */
  19107. class DistanceJoint extends PhysicsJoint {
  19108. constructor(jointData: DistanceJointData);
  19109. /**
  19110. * Update the predefined distance.
  19111. */
  19112. updateDistance(maxDistance: number, minDistance?: number): void;
  19113. }
  19114. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19115. constructor(type: number, jointData: PhysicsJointData);
  19116. /**
  19117. * Set the motor values.
  19118. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19119. * @param {number} force the force to apply
  19120. * @param {number} maxForce max force for this motor.
  19121. */
  19122. setMotor(force?: number, maxForce?: number): void;
  19123. /**
  19124. * Set the motor's limits.
  19125. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19126. */
  19127. setLimit(upperLimit: number, lowerLimit?: number): void;
  19128. }
  19129. /**
  19130. * This class represents a single hinge physics joint
  19131. */
  19132. class HingeJoint extends MotorEnabledJoint {
  19133. constructor(jointData: PhysicsJointData);
  19134. /**
  19135. * Set the motor values.
  19136. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19137. * @param {number} force the force to apply
  19138. * @param {number} maxForce max force for this motor.
  19139. */
  19140. setMotor(force?: number, maxForce?: number): void;
  19141. /**
  19142. * Set the motor's limits.
  19143. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19144. */
  19145. setLimit(upperLimit: number, lowerLimit?: number): void;
  19146. }
  19147. /**
  19148. * This class represents a dual hinge physics joint (same as wheel joint)
  19149. */
  19150. class Hinge2Joint extends MotorEnabledJoint {
  19151. constructor(jointData: PhysicsJointData);
  19152. /**
  19153. * Set the motor values.
  19154. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19155. * @param {number} force the force to apply
  19156. * @param {number} maxForce max force for this motor.
  19157. * @param {motorIndex} the motor's index, 0 or 1.
  19158. */
  19159. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19160. /**
  19161. * Set the motor limits.
  19162. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19163. * @param {number} upperLimit the upper limit
  19164. * @param {number} lowerLimit lower limit
  19165. * @param {motorIndex} the motor's index, 0 or 1.
  19166. */
  19167. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19168. }
  19169. interface IMotorEnabledJoint {
  19170. physicsJoint: any;
  19171. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19172. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19173. }
  19174. interface DistanceJointData extends PhysicsJointData {
  19175. maxDistance: number;
  19176. }
  19177. interface SpringJointData extends PhysicsJointData {
  19178. length: number;
  19179. stiffness: number;
  19180. damping: number;
  19181. }
  19182. }
  19183. declare module BABYLON {
  19184. class ReflectionProbe {
  19185. name: string;
  19186. private _scene;
  19187. private _renderTargetTexture;
  19188. private _projectionMatrix;
  19189. private _viewMatrix;
  19190. private _target;
  19191. private _add;
  19192. private _attachedMesh;
  19193. invertYAxis: boolean;
  19194. position: Vector3;
  19195. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  19196. samples: number;
  19197. refreshRate: number;
  19198. getScene(): Scene;
  19199. readonly cubeTexture: RenderTargetTexture;
  19200. readonly renderList: Nullable<AbstractMesh[]>;
  19201. attachToMesh(mesh: AbstractMesh): void;
  19202. /**
  19203. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19204. *
  19205. * @param renderingGroupId The rendering group id corresponding to its index
  19206. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19207. */
  19208. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19209. dispose(): void;
  19210. }
  19211. }
  19212. declare module BABYLON {
  19213. class BoundingBoxRenderer {
  19214. frontColor: Color3;
  19215. backColor: Color3;
  19216. showBackLines: boolean;
  19217. renderList: SmartArray<BoundingBox>;
  19218. private _scene;
  19219. private _colorShader;
  19220. private _vertexBuffers;
  19221. private _indexBuffer;
  19222. constructor(scene: Scene);
  19223. private _prepareRessources();
  19224. private _createIndexBuffer();
  19225. _rebuild(): void;
  19226. reset(): void;
  19227. render(): void;
  19228. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  19229. dispose(): void;
  19230. }
  19231. }
  19232. declare module BABYLON {
  19233. class DepthRenderer {
  19234. private _scene;
  19235. private _depthMap;
  19236. private _effect;
  19237. private _cachedDefines;
  19238. constructor(scene: Scene, type?: number);
  19239. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  19240. getDepthMap(): RenderTargetTexture;
  19241. dispose(): void;
  19242. }
  19243. }
  19244. declare module BABYLON {
  19245. class EdgesRenderer {
  19246. edgesWidthScalerForOrthographic: number;
  19247. edgesWidthScalerForPerspective: number;
  19248. private _source;
  19249. private _linesPositions;
  19250. private _linesNormals;
  19251. private _linesIndices;
  19252. private _epsilon;
  19253. private _indicesCount;
  19254. private _lineShader;
  19255. private _ib;
  19256. private _buffers;
  19257. private _checkVerticesInsteadOfIndices;
  19258. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19259. private _prepareRessources();
  19260. _rebuild(): void;
  19261. dispose(): void;
  19262. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  19263. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  19264. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  19265. _generateEdgesLines(): void;
  19266. render(): void;
  19267. }
  19268. }
  19269. declare module BABYLON {
  19270. /**
  19271. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  19272. */
  19273. class GeometryBufferRenderer {
  19274. private _scene;
  19275. private _multiRenderTarget;
  19276. private _ratio;
  19277. private _enablePosition;
  19278. protected _effect: Effect;
  19279. protected _cachedDefines: string;
  19280. /**
  19281. * Set the render list (meshes to be rendered) used in the G buffer.
  19282. */
  19283. renderList: Mesh[];
  19284. /**
  19285. * Gets wether or not G buffer are supported by the running hardware.
  19286. * This requires draw buffer supports
  19287. */
  19288. readonly isSupported: boolean;
  19289. /**
  19290. * Gets wether or not position are enabled for the G buffer.
  19291. */
  19292. /**
  19293. * Sets wether or not position are enabled for the G buffer.
  19294. */
  19295. enablePosition: boolean;
  19296. /**
  19297. * Gets the scene associated with the buffer.
  19298. */
  19299. readonly scene: Scene;
  19300. /**
  19301. * Gets the ratio used by the buffer during its creation.
  19302. * How big is the buffer related to the main canvas.
  19303. */
  19304. readonly ratio: number;
  19305. /**
  19306. * Creates a new G Buffer for the scene. @see GeometryBufferRenderer
  19307. * @param scene The scene the buffer belongs to
  19308. * @param ratio How big is the buffer related to the main canvas.
  19309. */
  19310. constructor(scene: Scene, ratio?: number);
  19311. /**
  19312. * Checks wether everything is ready to render a submesh to the G buffer.
  19313. * @param subMesh the submesh to check readiness for
  19314. * @param useInstances is the mesh drawn using instance or not
  19315. * @returns true if ready otherwise false
  19316. */
  19317. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  19318. /**
  19319. * Gets the current underlying G Buffer.
  19320. * @returns the buffer
  19321. */
  19322. getGBuffer(): MultiRenderTarget;
  19323. /**
  19324. * Gets the number of samples used to render the buffer (anti aliasing).
  19325. */
  19326. /**
  19327. * Sets the number of samples used to render the buffer (anti aliasing).
  19328. */
  19329. samples: number;
  19330. /**
  19331. * Disposes the renderer and frees up associated resources.
  19332. */
  19333. dispose(): void;
  19334. protected _createRenderTargets(): void;
  19335. }
  19336. }
  19337. declare module BABYLON {
  19338. class OutlineRenderer {
  19339. private _scene;
  19340. private _effect;
  19341. private _cachedDefines;
  19342. zOffset: number;
  19343. constructor(scene: Scene);
  19344. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  19345. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  19346. }
  19347. }
  19348. declare module BABYLON {
  19349. class RenderingGroup {
  19350. index: number;
  19351. private _scene;
  19352. private _opaqueSubMeshes;
  19353. private _transparentSubMeshes;
  19354. private _alphaTestSubMeshes;
  19355. private _depthOnlySubMeshes;
  19356. private _particleSystems;
  19357. private _spriteManagers;
  19358. private _opaqueSortCompareFn;
  19359. private _alphaTestSortCompareFn;
  19360. private _transparentSortCompareFn;
  19361. private _renderOpaque;
  19362. private _renderAlphaTest;
  19363. private _renderTransparent;
  19364. private _edgesRenderers;
  19365. onBeforeTransparentRendering: () => void;
  19366. /**
  19367. * Set the opaque sort comparison function.
  19368. * If null the sub meshes will be render in the order they were created
  19369. */
  19370. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19371. /**
  19372. * Set the alpha test sort comparison function.
  19373. * If null the sub meshes will be render in the order they were created
  19374. */
  19375. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19376. /**
  19377. * Set the transparent sort comparison function.
  19378. * If null the sub meshes will be render in the order they were created
  19379. */
  19380. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19381. /**
  19382. * Creates a new rendering group.
  19383. * @param index The rendering group index
  19384. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19385. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19386. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19387. */
  19388. 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>);
  19389. /**
  19390. * Render all the sub meshes contained in the group.
  19391. * @param customRenderFunction Used to override the default render behaviour of the group.
  19392. * @returns true if rendered some submeshes.
  19393. */
  19394. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19395. /**
  19396. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19397. * @param subMeshes The submeshes to render
  19398. */
  19399. private renderOpaqueSorted(subMeshes);
  19400. /**
  19401. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19402. * @param subMeshes The submeshes to render
  19403. */
  19404. private renderAlphaTestSorted(subMeshes);
  19405. /**
  19406. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19407. * @param subMeshes The submeshes to render
  19408. */
  19409. private renderTransparentSorted(subMeshes);
  19410. /**
  19411. * Renders the submeshes in a specified order.
  19412. * @param subMeshes The submeshes to sort before render
  19413. * @param sortCompareFn The comparison function use to sort
  19414. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19415. * @param transparent Specifies to activate blending if true
  19416. */
  19417. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  19418. /**
  19419. * Renders the submeshes in the order they were dispatched (no sort applied).
  19420. * @param subMeshes The submeshes to render
  19421. */
  19422. private static renderUnsorted(subMeshes);
  19423. /**
  19424. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19425. * are rendered back to front if in the same alpha index.
  19426. *
  19427. * @param a The first submesh
  19428. * @param b The second submesh
  19429. * @returns The result of the comparison
  19430. */
  19431. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19432. /**
  19433. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19434. * are rendered back to front.
  19435. *
  19436. * @param a The first submesh
  19437. * @param b The second submesh
  19438. * @returns The result of the comparison
  19439. */
  19440. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19441. /**
  19442. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19443. * are rendered front to back (prevent overdraw).
  19444. *
  19445. * @param a The first submesh
  19446. * @param b The second submesh
  19447. * @returns The result of the comparison
  19448. */
  19449. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19450. /**
  19451. * Resets the different lists of submeshes to prepare a new frame.
  19452. */
  19453. prepare(): void;
  19454. dispose(): void;
  19455. /**
  19456. * Inserts the submesh in its correct queue depending on its material.
  19457. * @param subMesh The submesh to dispatch
  19458. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19459. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19460. */
  19461. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19462. dispatchSprites(spriteManager: SpriteManager): void;
  19463. dispatchParticles(particleSystem: IParticleSystem): void;
  19464. private _renderParticles(activeMeshes);
  19465. private _renderSprites();
  19466. }
  19467. }
  19468. declare module BABYLON {
  19469. class RenderingManager {
  19470. /**
  19471. * The max id used for rendering groups (not included)
  19472. */
  19473. static MAX_RENDERINGGROUPS: number;
  19474. /**
  19475. * The min id used for rendering groups (included)
  19476. */
  19477. static MIN_RENDERINGGROUPS: number;
  19478. /**
  19479. * Used to globally prevent autoclearing scenes.
  19480. */
  19481. static AUTOCLEAR: boolean;
  19482. private _scene;
  19483. private _renderingGroups;
  19484. private _depthStencilBufferAlreadyCleaned;
  19485. private _autoClearDepthStencil;
  19486. private _customOpaqueSortCompareFn;
  19487. private _customAlphaTestSortCompareFn;
  19488. private _customTransparentSortCompareFn;
  19489. private _renderinGroupInfo;
  19490. constructor(scene: Scene);
  19491. private _clearDepthStencilBuffer(depth?, stencil?);
  19492. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19493. reset(): void;
  19494. dispose(): void;
  19495. private _prepareRenderingGroup(renderingGroupId);
  19496. dispatchSprites(spriteManager: SpriteManager): void;
  19497. dispatchParticles(particleSystem: IParticleSystem): void;
  19498. /**
  19499. * @param subMesh The submesh to dispatch
  19500. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19501. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19502. */
  19503. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19504. /**
  19505. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19506. * This allowed control for front to back rendering or reversly depending of the special needs.
  19507. *
  19508. * @param renderingGroupId The rendering group id corresponding to its index
  19509. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19510. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19511. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19512. */
  19513. 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;
  19514. /**
  19515. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19516. *
  19517. * @param renderingGroupId The rendering group id corresponding to its index
  19518. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19519. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19520. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19521. */
  19522. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19523. }
  19524. }
  19525. declare module BABYLON {
  19526. class Sprite {
  19527. name: string;
  19528. position: Vector3;
  19529. color: Color4;
  19530. width: number;
  19531. height: number;
  19532. angle: number;
  19533. cellIndex: number;
  19534. invertU: number;
  19535. invertV: number;
  19536. disposeWhenFinishedAnimating: boolean;
  19537. animations: Animation[];
  19538. isPickable: boolean;
  19539. actionManager: ActionManager;
  19540. private _animationStarted;
  19541. private _loopAnimation;
  19542. private _fromIndex;
  19543. private _toIndex;
  19544. private _delay;
  19545. private _direction;
  19546. private _manager;
  19547. private _time;
  19548. private _onAnimationEnd;
  19549. size: number;
  19550. constructor(name: string, manager: SpriteManager);
  19551. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  19552. stopAnimation(): void;
  19553. _animate(deltaTime: number): void;
  19554. dispose(): void;
  19555. }
  19556. }
  19557. declare module BABYLON {
  19558. class SpriteManager {
  19559. name: string;
  19560. sprites: Sprite[];
  19561. renderingGroupId: number;
  19562. layerMask: number;
  19563. fogEnabled: boolean;
  19564. isPickable: boolean;
  19565. cellWidth: number;
  19566. cellHeight: number;
  19567. /**
  19568. * An event triggered when the manager is disposed.
  19569. * @type {BABYLON.Observable}
  19570. */
  19571. onDisposeObservable: Observable<SpriteManager>;
  19572. private _onDisposeObserver;
  19573. onDispose: () => void;
  19574. private _capacity;
  19575. private _spriteTexture;
  19576. private _epsilon;
  19577. private _scene;
  19578. private _vertexData;
  19579. private _buffer;
  19580. private _vertexBuffers;
  19581. private _indexBuffer;
  19582. private _effectBase;
  19583. private _effectFog;
  19584. texture: Texture;
  19585. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  19586. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  19587. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  19588. render(): void;
  19589. dispose(): void;
  19590. }
  19591. }
  19592. declare module BABYLON {
  19593. class AnaglyphPostProcess extends PostProcess {
  19594. private _passedProcess;
  19595. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  19596. }
  19597. }
  19598. declare module BABYLON {
  19599. class BlackAndWhitePostProcess extends PostProcess {
  19600. degree: number;
  19601. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  19602. }
  19603. }
  19604. declare module BABYLON {
  19605. /**
  19606. * The Blur Post Process which blurs an image based on a kernel and direction.
  19607. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19608. */
  19609. class BlurPostProcess extends PostProcess {
  19610. /** The direction in which to blur the image. */ direction: Vector2;
  19611. protected _kernel: number;
  19612. protected _idealKernel: number;
  19613. protected _packedFloat: boolean;
  19614. private _staticDefines;
  19615. /**
  19616. * Gets the length in pixels of the blur sample region
  19617. */
  19618. /**
  19619. * Sets the length in pixels of the blur sample region
  19620. */
  19621. kernel: number;
  19622. /**
  19623. * Gets wether or not the blur is unpacking/repacking floats
  19624. */
  19625. /**
  19626. * Sets wether or not the blur needs to unpack/repack floats
  19627. */
  19628. packedFloat: boolean;
  19629. /**
  19630. * Creates a new instance of @see BlurPostProcess
  19631. * @param name The name of the effect.
  19632. * @param direction The direction in which to blur the image.
  19633. * @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.
  19634. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19635. * @param camera The camera to apply the render pass to.
  19636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19637. * @param engine The engine which the post process will be applied. (default: current engine)
  19638. * @param reusable If the post process can be reused on the same frame. (default: false)
  19639. * @param textureType Type of textures used when performing the post process. (default: 0)
  19640. */
  19641. 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);
  19642. protected _updateParameters(): void;
  19643. /**
  19644. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  19645. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  19646. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  19647. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  19648. * The gaps between physical kernels are compensated for in the weighting of the samples
  19649. * @param idealKernel Ideal blur kernel.
  19650. * @return Nearest best kernel.
  19651. */
  19652. protected _nearestBestKernel(idealKernel: number): number;
  19653. /**
  19654. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  19655. * @param x The point on the Gaussian distribution to sample.
  19656. * @return the value of the Gaussian function at x.
  19657. */
  19658. protected _gaussianWeight(x: number): number;
  19659. /**
  19660. * Generates a string that can be used as a floating point number in GLSL.
  19661. * @param x Value to print.
  19662. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  19663. * @return GLSL float string.
  19664. */
  19665. protected _glslFloat(x: number, decimalFigures?: number): string;
  19666. }
  19667. }
  19668. declare module BABYLON {
  19669. /**
  19670. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  19671. */
  19672. class CircleOfConfusionPostProcess extends PostProcess {
  19673. /**
  19674. * 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.
  19675. */
  19676. lensSize: number;
  19677. /**
  19678. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  19679. */
  19680. fStop: number;
  19681. /**
  19682. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  19683. */
  19684. focusDistance: number;
  19685. /**
  19686. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  19687. */
  19688. focalLength: number;
  19689. /**
  19690. * Creates a new instance of @see CircleOfConfusionPostProcess
  19691. * @param name The name of the effect.
  19692. * @param scene The scene the effect belongs to.
  19693. * @param depthTexture The depth texture of the scene to compute the circle of confusion.
  19694. * @param options The required width/height ratio to downsize to before computing the render pass.
  19695. * @param camera The camera to apply the render pass to.
  19696. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19697. * @param engine The engine which the post process will be applied. (default: current engine)
  19698. * @param reusable If the post process can be reused on the same frame. (default: false)
  19699. * @param textureType Type of textures used when performing the post process. (default: 0)
  19700. */
  19701. constructor(name: string, scene: Scene, depthTexture: RenderTargetTexture, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  19702. }
  19703. }
  19704. declare module BABYLON {
  19705. class ColorCorrectionPostProcess extends PostProcess {
  19706. private _colorTableTexture;
  19707. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  19708. }
  19709. }
  19710. declare module BABYLON {
  19711. class ConvolutionPostProcess extends PostProcess {
  19712. kernel: number[];
  19713. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  19714. static EdgeDetect0Kernel: number[];
  19715. static EdgeDetect1Kernel: number[];
  19716. static EdgeDetect2Kernel: number[];
  19717. static SharpenKernel: number[];
  19718. static EmbossKernel: number[];
  19719. static GaussianKernel: number[];
  19720. }
  19721. }
  19722. declare module BABYLON {
  19723. /**
  19724. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  19725. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  19726. * based on samples that have a large difference in distance than the center pixel.
  19727. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  19728. */
  19729. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  19730. direction: Vector2;
  19731. /**
  19732. * Creates a new instance of @see CircleOfConfusionPostProcess
  19733. * @param name The name of the effect.
  19734. * @param scene The scene the effect belongs to.
  19735. * @param direction The direction the blur should be applied.
  19736. * @param kernel The size of the kernel used to blur.
  19737. * @param options The required width/height ratio to downsize to before computing the render pass.
  19738. * @param camera The camera to apply the render pass to.
  19739. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  19740. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  19741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19742. * @param engine The engine which the post process will be applied. (default: current engine)
  19743. * @param reusable If the post process can be reused on the same frame. (default: false)
  19744. * @param textureType Type of textures used when performing the post process. (default: 0)
  19745. */
  19746. 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);
  19747. }
  19748. }
  19749. declare module BABYLON {
  19750. /**
  19751. * Specifies the level of max blur that should be applied when using the depth of field effect
  19752. */
  19753. enum DepthOfFieldEffectBlurLevel {
  19754. /**
  19755. * Subtle blur
  19756. */
  19757. Low = 0,
  19758. /**
  19759. * Medium blur
  19760. */
  19761. Medium = 1,
  19762. /**
  19763. * Large blur
  19764. */
  19765. High = 2,
  19766. }
  19767. /**
  19768. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  19769. */
  19770. class DepthOfFieldEffect extends PostProcessRenderEffect {
  19771. private _depthOfFieldPass;
  19772. private _circleOfConfusion;
  19773. private _depthOfFieldBlurX;
  19774. private _depthOfFieldBlurY;
  19775. private _depthOfFieldMerge;
  19776. /**
  19777. * The focal the length of the camera used in the effect
  19778. */
  19779. focalLength: number;
  19780. /**
  19781. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  19782. */
  19783. fStop: number;
  19784. /**
  19785. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  19786. */
  19787. focusDistance: number;
  19788. /**
  19789. * 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.
  19790. */
  19791. lensSize: number;
  19792. /**
  19793. * Creates a new instance of @see DepthOfFieldEffect
  19794. * @param scene The scene the effect belongs to.
  19795. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  19796. */
  19797. constructor(scene: Scene, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number);
  19798. /**
  19799. * Disposes each of the internal effects for a given camera.
  19800. * @param camera The camera to dispose the effect on.
  19801. */
  19802. disposeEffects(camera: Camera): void;
  19803. }
  19804. }
  19805. declare module BABYLON {
  19806. /**
  19807. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  19808. */
  19809. class DepthOfFieldMergePostProcess extends PostProcess {
  19810. /**
  19811. * Creates a new instance of @see CircleOfConfusionPostProcess
  19812. * @param name The name of the effect.
  19813. * @param original The non-blurred image to be modified
  19814. * @param circleOfConfusion The circle of confusion post process that will determine how blurred each pixel should become.
  19815. * @param blurSteps Incrimental bluring post processes.
  19816. * @param options The required width/height ratio to downsize to before computing the render pass.
  19817. * @param camera The camera to apply the render pass to.
  19818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19819. * @param engine The engine which the post process will be applied. (default: current engine)
  19820. * @param reusable If the post process can be reused on the same frame. (default: false)
  19821. * @param textureType Type of textures used when performing the post process. (default: 0)
  19822. */
  19823. constructor(name: string, original: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  19824. }
  19825. }
  19826. declare module BABYLON {
  19827. class DisplayPassPostProcess extends PostProcess {
  19828. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  19829. }
  19830. }
  19831. declare module BABYLON {
  19832. class FilterPostProcess extends PostProcess {
  19833. kernelMatrix: Matrix;
  19834. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  19835. }
  19836. }
  19837. declare module BABYLON {
  19838. class FxaaPostProcess extends PostProcess {
  19839. texelWidth: number;
  19840. texelHeight: number;
  19841. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  19842. }
  19843. }
  19844. declare module BABYLON {
  19845. class HighlightsPostProcess extends PostProcess {
  19846. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  19847. }
  19848. }
  19849. declare module BABYLON {
  19850. class ImageProcessingPostProcess extends PostProcess {
  19851. /**
  19852. * Default configuration related to image processing available in the PBR Material.
  19853. */
  19854. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19855. /**
  19856. * Gets the image processing configuration used either in this material.
  19857. */
  19858. /**
  19859. * Sets the Default image processing configuration used either in the this material.
  19860. *
  19861. * If sets to null, the scene one is in use.
  19862. */
  19863. imageProcessingConfiguration: ImageProcessingConfiguration;
  19864. /**
  19865. * Keep track of the image processing observer to allow dispose and replace.
  19866. */
  19867. private _imageProcessingObserver;
  19868. /**
  19869. * Attaches a new image processing configuration to the PBR Material.
  19870. * @param configuration
  19871. */
  19872. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  19873. /**
  19874. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  19875. */
  19876. /**
  19877. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  19878. */
  19879. colorCurves: Nullable<ColorCurves>;
  19880. /**
  19881. * Gets wether the color curves effect is enabled.
  19882. */
  19883. /**
  19884. * Sets wether the color curves effect is enabled.
  19885. */
  19886. colorCurvesEnabled: boolean;
  19887. /**
  19888. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  19889. */
  19890. /**
  19891. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  19892. */
  19893. colorGradingTexture: Nullable<BaseTexture>;
  19894. /**
  19895. * Gets wether the color grading effect is enabled.
  19896. */
  19897. /**
  19898. * Gets wether the color grading effect is enabled.
  19899. */
  19900. colorGradingEnabled: boolean;
  19901. /**
  19902. * Gets exposure used in the effect.
  19903. */
  19904. /**
  19905. * Sets exposure used in the effect.
  19906. */
  19907. exposure: number;
  19908. /**
  19909. * Gets wether tonemapping is enabled or not.
  19910. */
  19911. /**
  19912. * Sets wether tonemapping is enabled or not
  19913. */
  19914. toneMappingEnabled: boolean;
  19915. /**
  19916. * Gets contrast used in the effect.
  19917. */
  19918. /**
  19919. * Sets contrast used in the effect.
  19920. */
  19921. contrast: number;
  19922. /**
  19923. * Gets Vignette stretch size.
  19924. */
  19925. /**
  19926. * Sets Vignette stretch size.
  19927. */
  19928. vignetteStretch: number;
  19929. /**
  19930. * Gets Vignette centre X Offset.
  19931. */
  19932. /**
  19933. * Sets Vignette centre X Offset.
  19934. */
  19935. vignetteCentreX: number;
  19936. /**
  19937. * Gets Vignette centre Y Offset.
  19938. */
  19939. /**
  19940. * Sets Vignette centre Y Offset.
  19941. */
  19942. vignetteCentreY: number;
  19943. /**
  19944. * Gets Vignette weight or intensity of the vignette effect.
  19945. */
  19946. /**
  19947. * Sets Vignette weight or intensity of the vignette effect.
  19948. */
  19949. vignetteWeight: number;
  19950. /**
  19951. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  19952. * if vignetteEnabled is set to true.
  19953. */
  19954. /**
  19955. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  19956. * if vignetteEnabled is set to true.
  19957. */
  19958. vignetteColor: Color4;
  19959. /**
  19960. * Gets Camera field of view used by the Vignette effect.
  19961. */
  19962. /**
  19963. * Sets Camera field of view used by the Vignette effect.
  19964. */
  19965. vignetteCameraFov: number;
  19966. /**
  19967. * Gets the vignette blend mode allowing different kind of effect.
  19968. */
  19969. /**
  19970. * Sets the vignette blend mode allowing different kind of effect.
  19971. */
  19972. vignetteBlendMode: number;
  19973. /**
  19974. * Gets wether the vignette effect is enabled.
  19975. */
  19976. /**
  19977. * Sets wether the vignette effect is enabled.
  19978. */
  19979. vignetteEnabled: boolean;
  19980. private _fromLinearSpace;
  19981. /**
  19982. * Gets wether the input of the processing is in Gamma or Linear Space.
  19983. */
  19984. /**
  19985. * Sets wether the input of the processing is in Gamma or Linear Space.
  19986. */
  19987. fromLinearSpace: boolean;
  19988. /**
  19989. * Defines cache preventing GC.
  19990. */
  19991. private _defines;
  19992. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  19993. getClassName(): string;
  19994. protected _updateParameters(): void;
  19995. dispose(camera?: Camera): void;
  19996. }
  19997. }
  19998. declare module BABYLON {
  19999. class PassPostProcess extends PostProcess {
  20000. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  20001. }
  20002. }
  20003. declare module BABYLON {
  20004. type PostProcessOptions = {
  20005. width: number;
  20006. height: number;
  20007. };
  20008. /**
  20009. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20010. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20011. */
  20012. class PostProcess {
  20013. /** Name of the PostProcess. */ name: string;
  20014. /**
  20015. * Width of the texture to apply the post process on
  20016. */
  20017. width: number;
  20018. /**
  20019. * Height of the texture to apply the post process on
  20020. */
  20021. height: number;
  20022. /**
  20023. * Sampling mode used by the shader
  20024. * See https://doc.babylonjs.com/classes/3.1/texture
  20025. */
  20026. renderTargetSamplingMode: number;
  20027. /**
  20028. * Clear color to use when screen clearing
  20029. */
  20030. clearColor: Color4;
  20031. /**
  20032. * If the buffer needs to be cleared before applying the post process. (default: true)
  20033. * Should be set to false if shader will overwrite all previous pixels.
  20034. */
  20035. autoClear: boolean;
  20036. /**
  20037. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20038. */
  20039. alphaMode: number;
  20040. /**
  20041. * Sets the setAlphaBlendConstants of the babylon engine
  20042. */
  20043. alphaConstants: Color4;
  20044. /**
  20045. * Animations to be used for the post processing
  20046. */
  20047. animations: Animation[];
  20048. /**
  20049. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20050. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20051. */
  20052. enablePixelPerfectMode: boolean;
  20053. /**
  20054. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20055. */
  20056. scaleMode: number;
  20057. /**
  20058. * Force textures to be a power of two (default: false)
  20059. */
  20060. alwaysForcePOT: boolean;
  20061. /**
  20062. * Number of sample textures (default: 1)
  20063. */
  20064. samples: number;
  20065. /**
  20066. * Modify the scale of the post process to be the same as the viewport (default: false)
  20067. */
  20068. adaptScaleToCurrentViewport: boolean;
  20069. private _camera;
  20070. private _scene;
  20071. private _engine;
  20072. private _options;
  20073. private _reusable;
  20074. private _textureType;
  20075. /**
  20076. * Smart array of input and output textures for the post process.
  20077. */
  20078. _textures: SmartArray<InternalTexture>;
  20079. /**
  20080. * The index in _textures that corresponds to the output texture.
  20081. */
  20082. _currentRenderTextureInd: number;
  20083. private _effect;
  20084. private _samplers;
  20085. private _fragmentUrl;
  20086. private _vertexUrl;
  20087. private _parameters;
  20088. private _scaleRatio;
  20089. protected _indexParameters: any;
  20090. private _shareOutputWithPostProcess;
  20091. private _texelSize;
  20092. private _forcedOutputTexture;
  20093. /**
  20094. * An event triggered when the postprocess is activated.
  20095. * @type {BABYLON.Observable}
  20096. */
  20097. onActivateObservable: Observable<Camera>;
  20098. private _onActivateObserver;
  20099. /**
  20100. * A function that is added to the onActivateObservable
  20101. */
  20102. onActivate: Nullable<(camera: Camera) => void>;
  20103. /**
  20104. * An event triggered when the postprocess changes its size.
  20105. * @type {BABYLON.Observable}
  20106. */
  20107. onSizeChangedObservable: Observable<PostProcess>;
  20108. private _onSizeChangedObserver;
  20109. /**
  20110. * A function that is added to the onSizeChangedObservable
  20111. */
  20112. onSizeChanged: (postProcess: PostProcess) => void;
  20113. /**
  20114. * An event triggered when the postprocess applies its effect.
  20115. * @type {BABYLON.Observable}
  20116. */
  20117. onApplyObservable: Observable<Effect>;
  20118. private _onApplyObserver;
  20119. /**
  20120. * A function that is added to the onApplyObservable
  20121. */
  20122. onApply: (effect: Effect) => void;
  20123. /**
  20124. * An event triggered before rendering the postprocess
  20125. * @type {BABYLON.Observable}
  20126. */
  20127. onBeforeRenderObservable: Observable<Effect>;
  20128. private _onBeforeRenderObserver;
  20129. /**
  20130. * A function that is added to the onBeforeRenderObservable
  20131. */
  20132. onBeforeRender: (effect: Effect) => void;
  20133. /**
  20134. * An event triggered after rendering the postprocess
  20135. * @type {BABYLON.Observable}
  20136. */
  20137. onAfterRenderObservable: Observable<Effect>;
  20138. private _onAfterRenderObserver;
  20139. /**
  20140. * A function that is added to the onAfterRenderObservable
  20141. */
  20142. onAfterRender: (efect: Effect) => void;
  20143. /**
  20144. * 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
  20145. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20146. */
  20147. inputTexture: InternalTexture;
  20148. /**
  20149. * Gets the camera which post process is applied to.
  20150. * @returns The camera the post process is applied to.
  20151. */
  20152. getCamera(): Camera;
  20153. /**
  20154. * Gets the texel size of the postprocess.
  20155. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20156. */
  20157. readonly texelSize: Vector2;
  20158. /**
  20159. * Creates a new instance of @see PostProcess
  20160. * @param name The name of the PostProcess.
  20161. * @param fragmentUrl The url of the fragment shader to be used.
  20162. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20163. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20164. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20165. * @param camera The camera to apply the render pass to.
  20166. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20167. * @param engine The engine which the post process will be applied. (default: current engine)
  20168. * @param reusable If the post process can be reused on the same frame. (default: false)
  20169. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20170. * @param textureType Type of textures used when performing the post process. (default: 0)
  20171. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20172. * @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
  20173. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20174. */
  20175. 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);
  20176. /**
  20177. * Gets the engine which this post process belongs to.
  20178. * @returns The engine the post process was enabled with.
  20179. */
  20180. getEngine(): Engine;
  20181. /**
  20182. * The effect that is created when initializing the post process.
  20183. * @returns The created effect corrisponding the the postprocess.
  20184. */
  20185. getEffect(): Effect;
  20186. /**
  20187. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20188. * @param postProcess The post process to share the output with.
  20189. * @returns This post process.
  20190. */
  20191. shareOutputWith(postProcess: PostProcess): PostProcess;
  20192. /**
  20193. * Updates the effect with the current post process compile time values and recompiles the shader.
  20194. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20195. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20196. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20197. * @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
  20198. * @param onCompiled Called when the shader has been compiled.
  20199. * @param onError Called if there is an error when compiling a shader.
  20200. */
  20201. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20202. /**
  20203. * The post process is reusable if it can be used multiple times within one frame.
  20204. * @returns If the post process is reusable
  20205. */
  20206. isReusable(): boolean;
  20207. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20208. markTextureDirty(): void;
  20209. /**
  20210. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20211. * 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.
  20212. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20213. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20214. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20215. */
  20216. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): void;
  20217. /**
  20218. * If the post process is supported.
  20219. */
  20220. readonly isSupported: boolean;
  20221. /**
  20222. * The aspect ratio of the output texture.
  20223. */
  20224. readonly aspectRatio: number;
  20225. /**
  20226. * Get a value indicating if the post-process is ready to be used
  20227. * @returns true if the post-process is ready (shader is compiled)
  20228. */
  20229. isReady(): boolean;
  20230. /**
  20231. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20232. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  20233. */
  20234. apply(): Nullable<Effect>;
  20235. private _disposeTextures();
  20236. /**
  20237. * Disposes the post process.
  20238. * @param camera The camera to dispose the post process on.
  20239. */
  20240. dispose(camera?: Camera): void;
  20241. }
  20242. }
  20243. declare module BABYLON {
  20244. /**
  20245. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20246. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20247. */
  20248. class PostProcessManager {
  20249. private _scene;
  20250. private _indexBuffer;
  20251. private _vertexBuffers;
  20252. /**
  20253. * Creates a new instance of @see PostProcess
  20254. * @param scene The scene that the post process is associated with.
  20255. */
  20256. constructor(scene: Scene);
  20257. private _prepareBuffers();
  20258. private _buildIndexBuffer();
  20259. /**
  20260. * Rebuilds the vertex buffers of the manager.
  20261. */
  20262. _rebuild(): void;
  20263. /**
  20264. * Prepares a frame to be run through a post process.
  20265. * @param sourceTexture The input texture to the post procesess. (default: null)
  20266. * @param postProcesses An array of post processes to be run. (default: null)
  20267. * @returns True if the post processes were able to be run.
  20268. */
  20269. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20270. /**
  20271. * Manually render a set of post processes to a texture.
  20272. * @param postProcesses An array of post processes to be run.
  20273. * @param targetTexture The target texture to render to.
  20274. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20275. */
  20276. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  20277. /**
  20278. * Finalize the result of the output of the postprocesses.
  20279. * @param doNotPresent If true the result will not be displayed to the screen.
  20280. * @param targetTexture The target texture to render to.
  20281. * @param faceIndex The index of the face to bind the target texture to.
  20282. * @param postProcesses The array of post processes to render.
  20283. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20284. */
  20285. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: PostProcess[], forceFullscreenViewport?: boolean): void;
  20286. /**
  20287. * Disposes of the post process manager.
  20288. */
  20289. dispose(): void;
  20290. }
  20291. }
  20292. declare module BABYLON {
  20293. class RefractionPostProcess extends PostProcess {
  20294. color: Color3;
  20295. depth: number;
  20296. colorLevel: number;
  20297. private _refRexture;
  20298. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  20299. dispose(camera: Camera): void;
  20300. }
  20301. }
  20302. declare module BABYLON {
  20303. class StereoscopicInterlacePostProcess extends PostProcess {
  20304. private _stepSize;
  20305. private _passedProcess;
  20306. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  20307. }
  20308. }
  20309. declare module BABYLON {
  20310. enum TonemappingOperator {
  20311. Hable = 0,
  20312. Reinhard = 1,
  20313. HejiDawson = 2,
  20314. Photographic = 3,
  20315. }
  20316. class TonemapPostProcess extends PostProcess {
  20317. private _operator;
  20318. exposureAdjustment: number;
  20319. constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  20320. }
  20321. }
  20322. declare module BABYLON {
  20323. class VolumetricLightScatteringPostProcess extends PostProcess {
  20324. private _volumetricLightScatteringPass;
  20325. private _volumetricLightScatteringRTT;
  20326. private _viewPort;
  20327. private _screenCoordinates;
  20328. private _cachedDefines;
  20329. /**
  20330. * If not undefined, the mesh position is computed from the attached node position
  20331. * @type {{position: Vector3}}
  20332. */
  20333. attachedNode: {
  20334. position: Vector3;
  20335. };
  20336. /**
  20337. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  20338. * @type {Vector3}
  20339. */
  20340. customMeshPosition: Vector3;
  20341. /**
  20342. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  20343. * @type {boolean}
  20344. */
  20345. useCustomMeshPosition: boolean;
  20346. /**
  20347. * If the post-process should inverse the light scattering direction
  20348. * @type {boolean}
  20349. */
  20350. invert: boolean;
  20351. /**
  20352. * The internal mesh used by the post-process
  20353. * @type {boolean}
  20354. */
  20355. mesh: Mesh;
  20356. useDiffuseColor: boolean;
  20357. /**
  20358. * Array containing the excluded meshes not rendered in the internal pass
  20359. */
  20360. excludedMeshes: AbstractMesh[];
  20361. /**
  20362. * Controls the overall intensity of the post-process
  20363. * @type {number}
  20364. */
  20365. exposure: number;
  20366. /**
  20367. * Dissipates each sample's contribution in range [0, 1]
  20368. * @type {number}
  20369. */
  20370. decay: number;
  20371. /**
  20372. * Controls the overall intensity of each sample
  20373. * @type {number}
  20374. */
  20375. weight: number;
  20376. /**
  20377. * Controls the density of each sample
  20378. * @type {number}
  20379. */
  20380. density: number;
  20381. /**
  20382. * @constructor
  20383. * @param {string} name - The post-process name
  20384. * @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)
  20385. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  20386. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  20387. * @param {number} samples - The post-process quality, default 100
  20388. * @param {number} samplingMode - The post-process filtering mode
  20389. * @param {BABYLON.Engine} engine - The babylon engine
  20390. * @param {boolean} reusable - If the post-process is reusable
  20391. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  20392. */
  20393. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  20394. getClassName(): string;
  20395. private _isReady(subMesh, useInstances);
  20396. /**
  20397. * Sets the new light position for light scattering effect
  20398. * @param {BABYLON.Vector3} The new custom light position
  20399. */
  20400. setCustomMeshPosition(position: Vector3): void;
  20401. /**
  20402. * Returns the light position for light scattering effect
  20403. * @return {BABYLON.Vector3} The custom light position
  20404. */
  20405. getCustomMeshPosition(): Vector3;
  20406. /**
  20407. * Disposes the internal assets and detaches the post-process from the camera
  20408. */
  20409. dispose(camera: Camera): void;
  20410. /**
  20411. * Returns the render target texture used by the post-process
  20412. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  20413. */
  20414. getPass(): RenderTargetTexture;
  20415. private _meshExcluded(mesh);
  20416. private _createPass(scene, ratio);
  20417. private _updateMeshScreenCoordinates(scene);
  20418. /**
  20419. * Creates a default mesh for the Volumeric Light Scattering post-process
  20420. * @param {string} The mesh name
  20421. * @param {BABYLON.Scene} The scene where to create the mesh
  20422. * @return {BABYLON.Mesh} the default mesh
  20423. */
  20424. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  20425. }
  20426. }
  20427. declare module BABYLON {
  20428. class VRDistortionCorrectionPostProcess extends PostProcess {
  20429. aspectRatio: number;
  20430. private _isRightEye;
  20431. private _distortionFactors;
  20432. private _postProcessScaleFactor;
  20433. private _lensCenterOffset;
  20434. private _scaleIn;
  20435. private _scaleFactor;
  20436. private _lensCenter;
  20437. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  20438. }
  20439. }
  20440. declare module BABYLON {
  20441. class _AlphaState {
  20442. private _isAlphaBlendDirty;
  20443. private _isBlendFunctionParametersDirty;
  20444. private _isBlendEquationParametersDirty;
  20445. private _isBlendConstantsDirty;
  20446. private _alphaBlend;
  20447. private _blendFunctionParameters;
  20448. private _blendEquationParameters;
  20449. private _blendConstants;
  20450. /**
  20451. * Initializes the state.
  20452. */
  20453. constructor();
  20454. readonly isDirty: boolean;
  20455. alphaBlend: boolean;
  20456. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  20457. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  20458. setAlphaEquationParameters(rgb: number, alpha: number): void;
  20459. reset(): void;
  20460. apply(gl: WebGLRenderingContext): void;
  20461. }
  20462. }
  20463. declare module BABYLON {
  20464. class _DepthCullingState {
  20465. private _isDepthTestDirty;
  20466. private _isDepthMaskDirty;
  20467. private _isDepthFuncDirty;
  20468. private _isCullFaceDirty;
  20469. private _isCullDirty;
  20470. private _isZOffsetDirty;
  20471. private _isFrontFaceDirty;
  20472. private _depthTest;
  20473. private _depthMask;
  20474. private _depthFunc;
  20475. private _cull;
  20476. private _cullFace;
  20477. private _zOffset;
  20478. private _frontFace;
  20479. /**
  20480. * Initializes the state.
  20481. */
  20482. constructor();
  20483. readonly isDirty: boolean;
  20484. zOffset: number;
  20485. cullFace: Nullable<number>;
  20486. cull: Nullable<boolean>;
  20487. depthFunc: Nullable<number>;
  20488. depthMask: boolean;
  20489. depthTest: boolean;
  20490. frontFace: Nullable<number>;
  20491. reset(): void;
  20492. apply(gl: WebGLRenderingContext): void;
  20493. }
  20494. }
  20495. declare module BABYLON {
  20496. class _StencilState {
  20497. private _isStencilTestDirty;
  20498. private _isStencilMaskDirty;
  20499. private _isStencilFuncDirty;
  20500. private _isStencilOpDirty;
  20501. private _stencilTest;
  20502. private _stencilMask;
  20503. private _stencilFunc;
  20504. private _stencilFuncRef;
  20505. private _stencilFuncMask;
  20506. private _stencilOpStencilFail;
  20507. private _stencilOpDepthFail;
  20508. private _stencilOpStencilDepthPass;
  20509. readonly isDirty: boolean;
  20510. stencilFunc: number;
  20511. stencilFuncRef: number;
  20512. stencilFuncMask: number;
  20513. stencilOpStencilFail: number;
  20514. stencilOpDepthFail: number;
  20515. stencilOpStencilDepthPass: number;
  20516. stencilMask: number;
  20517. stencilTest: boolean;
  20518. constructor();
  20519. reset(): void;
  20520. apply(gl: WebGLRenderingContext): void;
  20521. }
  20522. }
  20523. declare module BABYLON {
  20524. class AndOrNotEvaluator {
  20525. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  20526. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  20527. private static _SimplifyNegation(booleanString);
  20528. }
  20529. }
  20530. declare module BABYLON {
  20531. /**
  20532. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  20533. */
  20534. enum AssetTaskState {
  20535. /**
  20536. * Initialization
  20537. */
  20538. INIT = 0,
  20539. /**
  20540. * Running
  20541. */
  20542. RUNNING = 1,
  20543. /**
  20544. * Done
  20545. */
  20546. DONE = 2,
  20547. /**
  20548. * Error
  20549. */
  20550. ERROR = 3,
  20551. }
  20552. /**
  20553. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  20554. */
  20555. abstract class AbstractAssetTask {
  20556. /**
  20557. * Task name
  20558. */ name: string;
  20559. /**
  20560. * Callback called when the task is successful
  20561. */
  20562. onSuccess: (task: any) => void;
  20563. /**
  20564. * Callback called when the task is successful
  20565. */
  20566. onError: (task: any, message?: string, exception?: any) => void;
  20567. /**
  20568. * Creates a new {BABYLON.AssetsManager}
  20569. * @param name defines the name of the task
  20570. */
  20571. constructor(
  20572. /**
  20573. * Task name
  20574. */ name: string);
  20575. private _isCompleted;
  20576. private _taskState;
  20577. private _errorObject;
  20578. /**
  20579. * Get if the task is completed
  20580. */
  20581. readonly isCompleted: boolean;
  20582. /**
  20583. * Gets the current state of the task
  20584. */
  20585. readonly taskState: AssetTaskState;
  20586. /**
  20587. * Gets the current error object (if task is in error)
  20588. */
  20589. readonly errorObject: {
  20590. message?: string;
  20591. exception?: any;
  20592. };
  20593. /**
  20594. * Internal only
  20595. * @ignore
  20596. */
  20597. _setErrorObject(message?: string, exception?: any): void;
  20598. /**
  20599. * Execute the current task
  20600. * @param scene defines the scene where you want your assets to be loaded
  20601. * @param onSuccess is a callback called when the task is successfully executed
  20602. * @param onError is a callback called if an error occurs
  20603. */
  20604. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  20605. /**
  20606. * Execute the current task
  20607. * @param scene defines the scene where you want your assets to be loaded
  20608. * @param onSuccess is a callback called when the task is successfully executed
  20609. * @param onError is a callback called if an error occurs
  20610. */
  20611. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  20612. private onErrorCallback(onError, message?, exception?);
  20613. private onDoneCallback(onSuccess, onError);
  20614. }
  20615. /**
  20616. * Define the interface used by progress events raised during assets loading
  20617. */
  20618. interface IAssetsProgressEvent {
  20619. /**
  20620. * Defines the number of remaining tasks to process
  20621. */
  20622. remainingCount: number;
  20623. /**
  20624. * Defines the total number of tasks
  20625. */
  20626. totalCount: number;
  20627. /**
  20628. * Defines the task that was just processed
  20629. */
  20630. task: AbstractAssetTask;
  20631. }
  20632. /**
  20633. * Class used to share progress information about assets loading
  20634. */
  20635. class AssetsProgressEvent implements IAssetsProgressEvent {
  20636. /**
  20637. * Defines the number of remaining tasks to process
  20638. */
  20639. remainingCount: number;
  20640. /**
  20641. * Defines the total number of tasks
  20642. */
  20643. totalCount: number;
  20644. /**
  20645. * Defines the task that was just processed
  20646. */
  20647. task: AbstractAssetTask;
  20648. /**
  20649. * Creates a {BABYLON.AssetsProgressEvent}
  20650. * @param remainingCount defines the number of remaining tasks to process
  20651. * @param totalCount defines the total number of tasks
  20652. * @param task defines the task that was just processed
  20653. */
  20654. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  20655. }
  20656. /**
  20657. * Define a task used by {BABYLON.AssetsManager} to load meshes
  20658. */
  20659. class MeshAssetTask extends AbstractAssetTask {
  20660. /**
  20661. * Defines the name of the task
  20662. */
  20663. name: string;
  20664. /**
  20665. * Defines the list of mesh's names you want to load
  20666. */
  20667. meshesNames: any;
  20668. /**
  20669. * Defines the root url to use as a base to load your meshes and associated resources
  20670. */
  20671. rootUrl: string;
  20672. /**
  20673. * Defines the filename of the scene to load from
  20674. */
  20675. sceneFilename: string;
  20676. /**
  20677. * Gets the list of loaded meshes
  20678. */
  20679. loadedMeshes: Array<AbstractMesh>;
  20680. /**
  20681. * Gets the list of loaded particle systems
  20682. */
  20683. loadedParticleSystems: Array<ParticleSystem>;
  20684. /**
  20685. * Gets the list of loaded skeletons
  20686. */
  20687. loadedSkeletons: Array<Skeleton>;
  20688. /**
  20689. * Callback called when the task is successful
  20690. */
  20691. onSuccess: (task: MeshAssetTask) => void;
  20692. /**
  20693. * Callback called when the task is successful
  20694. */
  20695. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  20696. /**
  20697. * Creates a new {BABYLON.MeshAssetTask}
  20698. * @param name defines the name of the task
  20699. * @param meshesNames defines the list of mesh's names you want to load
  20700. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  20701. * @param sceneFilename defines the filename of the scene to load from
  20702. */
  20703. constructor(
  20704. /**
  20705. * Defines the name of the task
  20706. */
  20707. name: string,
  20708. /**
  20709. * Defines the list of mesh's names you want to load
  20710. */
  20711. meshesNames: any,
  20712. /**
  20713. * Defines the root url to use as a base to load your meshes and associated resources
  20714. */
  20715. rootUrl: string,
  20716. /**
  20717. * Defines the filename of the scene to load from
  20718. */
  20719. sceneFilename: string);
  20720. /**
  20721. * Execute the current task
  20722. * @param scene defines the scene where you want your assets to be loaded
  20723. * @param onSuccess is a callback called when the task is successfully executed
  20724. * @param onError is a callback called if an error occurs
  20725. */
  20726. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  20727. }
  20728. /**
  20729. * Define a task used by {BABYLON.AssetsManager} to load text content
  20730. */
  20731. class TextFileAssetTask extends AbstractAssetTask {
  20732. /**
  20733. * Defines the name of the task
  20734. */
  20735. name: string;
  20736. /**
  20737. * Defines the location of the file to load
  20738. */
  20739. url: string;
  20740. /**
  20741. * Gets the loaded text string
  20742. */
  20743. text: string;
  20744. /**
  20745. * Callback called when the task is successful
  20746. */
  20747. onSuccess: (task: TextFileAssetTask) => void;
  20748. /**
  20749. * Callback called when the task is successful
  20750. */
  20751. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  20752. /**
  20753. * Creates a new TextFileAssetTask object
  20754. * @param name defines the name of the task
  20755. * @param url defines the location of the file to load
  20756. */
  20757. constructor(
  20758. /**
  20759. * Defines the name of the task
  20760. */
  20761. name: string,
  20762. /**
  20763. * Defines the location of the file to load
  20764. */
  20765. url: string);
  20766. /**
  20767. * Execute the current task
  20768. * @param scene defines the scene where you want your assets to be loaded
  20769. * @param onSuccess is a callback called when the task is successfully executed
  20770. * @param onError is a callback called if an error occurs
  20771. */
  20772. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  20773. }
  20774. /**
  20775. * Define a task used by {BABYLON.AssetsManager} to load binary data
  20776. */
  20777. class BinaryFileAssetTask extends AbstractAssetTask {
  20778. /**
  20779. * Defines the name of the task
  20780. */
  20781. name: string;
  20782. /**
  20783. * Defines the location of the file to load
  20784. */
  20785. url: string;
  20786. /**
  20787. * Gets the lodaded data (as an array buffer)
  20788. */
  20789. data: ArrayBuffer;
  20790. /**
  20791. * Callback called when the task is successful
  20792. */
  20793. onSuccess: (task: BinaryFileAssetTask) => void;
  20794. /**
  20795. * Callback called when the task is successful
  20796. */
  20797. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  20798. /**
  20799. * Creates a new BinaryFileAssetTask object
  20800. * @param name defines the name of the new task
  20801. * @param url defines the location of the file to load
  20802. */
  20803. constructor(
  20804. /**
  20805. * Defines the name of the task
  20806. */
  20807. name: string,
  20808. /**
  20809. * Defines the location of the file to load
  20810. */
  20811. url: string);
  20812. /**
  20813. * Execute the current task
  20814. * @param scene defines the scene where you want your assets to be loaded
  20815. * @param onSuccess is a callback called when the task is successfully executed
  20816. * @param onError is a callback called if an error occurs
  20817. */
  20818. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  20819. }
  20820. /**
  20821. * Define a task used by {BABYLON.AssetsManager} to load images
  20822. */
  20823. class ImageAssetTask extends AbstractAssetTask {
  20824. /**
  20825. * Defines the name of the task
  20826. */
  20827. name: string;
  20828. /**
  20829. * Defines the location of the image to load
  20830. */
  20831. url: string;
  20832. /**
  20833. * Gets the loaded images
  20834. */
  20835. image: HTMLImageElement;
  20836. /**
  20837. * Callback called when the task is successful
  20838. */
  20839. onSuccess: (task: ImageAssetTask) => void;
  20840. /**
  20841. * Callback called when the task is successful
  20842. */
  20843. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  20844. /**
  20845. * Creates a new ImageAssetTask
  20846. * @param name defines the name of the task
  20847. * @param url defines the location of the image to load
  20848. */
  20849. constructor(
  20850. /**
  20851. * Defines the name of the task
  20852. */
  20853. name: string,
  20854. /**
  20855. * Defines the location of the image to load
  20856. */
  20857. url: string);
  20858. /**
  20859. * Execute the current task
  20860. * @param scene defines the scene where you want your assets to be loaded
  20861. * @param onSuccess is a callback called when the task is successfully executed
  20862. * @param onError is a callback called if an error occurs
  20863. */
  20864. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  20865. }
  20866. /**
  20867. * Defines the interface used by texture loading tasks
  20868. */
  20869. interface ITextureAssetTask<TEX extends BaseTexture> {
  20870. /**
  20871. * Gets the loaded texture
  20872. */
  20873. texture: TEX;
  20874. }
  20875. /**
  20876. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  20877. */
  20878. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  20879. /**
  20880. * Defines the name of the task
  20881. */
  20882. name: string;
  20883. /**
  20884. * Defines the location of the file to load
  20885. */
  20886. url: string;
  20887. /**
  20888. * Defines if mipmap should not be generated (default is false)
  20889. */
  20890. noMipmap: boolean | undefined;
  20891. /**
  20892. * Defines if texture must be inverted on Y axis (default is false)
  20893. */
  20894. invertY: boolean | undefined;
  20895. /**
  20896. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  20897. */
  20898. samplingMode: number;
  20899. /**
  20900. * Gets the loaded texture
  20901. */
  20902. texture: Texture;
  20903. /**
  20904. * Callback called when the task is successful
  20905. */
  20906. onSuccess: (task: TextureAssetTask) => void;
  20907. /**
  20908. * Callback called when the task is successful
  20909. */
  20910. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  20911. /**
  20912. * Creates a new TextureAssetTask object
  20913. * @param name defines the name of the task
  20914. * @param url defines the location of the file to load
  20915. * @param noMipmap defines if mipmap should not be generated (default is false)
  20916. * @param invertY defines if texture must be inverted on Y axis (default is false)
  20917. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  20918. */
  20919. constructor(
  20920. /**
  20921. * Defines the name of the task
  20922. */
  20923. name: string,
  20924. /**
  20925. * Defines the location of the file to load
  20926. */
  20927. url: string,
  20928. /**
  20929. * Defines if mipmap should not be generated (default is false)
  20930. */
  20931. noMipmap?: boolean | undefined,
  20932. /**
  20933. * Defines if texture must be inverted on Y axis (default is false)
  20934. */
  20935. invertY?: boolean | undefined,
  20936. /**
  20937. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  20938. */
  20939. samplingMode?: number);
  20940. /**
  20941. * Execute the current task
  20942. * @param scene defines the scene where you want your assets to be loaded
  20943. * @param onSuccess is a callback called when the task is successfully executed
  20944. * @param onError is a callback called if an error occurs
  20945. */
  20946. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  20947. }
  20948. /**
  20949. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  20950. */
  20951. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  20952. /**
  20953. * Defines the name of the task
  20954. */
  20955. name: string;
  20956. /**
  20957. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  20958. */
  20959. url: string;
  20960. /**
  20961. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  20962. */
  20963. extensions: string[] | undefined;
  20964. /**
  20965. * Defines if mipmaps should not be generated (default is false)
  20966. */
  20967. noMipmap: boolean | undefined;
  20968. /**
  20969. * Defines the explicit list of files (undefined by default)
  20970. */
  20971. files: string[] | undefined;
  20972. /**
  20973. * Gets the loaded texture
  20974. */
  20975. texture: CubeTexture;
  20976. /**
  20977. * Callback called when the task is successful
  20978. */
  20979. onSuccess: (task: CubeTextureAssetTask) => void;
  20980. /**
  20981. * Callback called when the task is successful
  20982. */
  20983. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  20984. /**
  20985. * Creates a new CubeTextureAssetTask
  20986. * @param name defines the name of the task
  20987. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  20988. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  20989. * @param noMipmap defines if mipmaps should not be generated (default is false)
  20990. * @param files defines the explicit list of files (undefined by default)
  20991. */
  20992. constructor(
  20993. /**
  20994. * Defines the name of the task
  20995. */
  20996. name: string,
  20997. /**
  20998. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  20999. */
  21000. url: string,
  21001. /**
  21002. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  21003. */
  21004. extensions?: string[] | undefined,
  21005. /**
  21006. * Defines if mipmaps should not be generated (default is false)
  21007. */
  21008. noMipmap?: boolean | undefined,
  21009. /**
  21010. * Defines the explicit list of files (undefined by default)
  21011. */
  21012. files?: string[] | undefined);
  21013. /**
  21014. * Execute the current task
  21015. * @param scene defines the scene where you want your assets to be loaded
  21016. * @param onSuccess is a callback called when the task is successfully executed
  21017. * @param onError is a callback called if an error occurs
  21018. */
  21019. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21020. }
  21021. /**
  21022. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  21023. */
  21024. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  21025. /**
  21026. * Defines the name of the task
  21027. */
  21028. name: string;
  21029. /**
  21030. * Defines the location of the file to load
  21031. */
  21032. url: string;
  21033. /**
  21034. * 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.
  21035. */
  21036. size: number | undefined;
  21037. /**
  21038. * Defines if mipmaps should not be generated (default is false)
  21039. */
  21040. noMipmap: boolean;
  21041. /**
  21042. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  21043. */
  21044. generateHarmonics: boolean;
  21045. /**
  21046. * 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)
  21047. */
  21048. useInGammaSpace: boolean;
  21049. /**
  21050. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  21051. */
  21052. usePMREMGenerator: boolean;
  21053. /**
  21054. * Gets the loaded texture
  21055. */
  21056. texture: HDRCubeTexture;
  21057. /**
  21058. * Callback called when the task is successful
  21059. */
  21060. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  21061. /**
  21062. * Callback called when the task is successful
  21063. */
  21064. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  21065. /**
  21066. * Creates a new HDRCubeTextureAssetTask object
  21067. * @param name defines the name of the task
  21068. * @param url defines the location of the file to load
  21069. * @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.
  21070. * @param noMipmap defines if mipmaps should not be generated (default is false)
  21071. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  21072. * @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)
  21073. * @param usePMREMGenerator specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  21074. */
  21075. constructor(
  21076. /**
  21077. * Defines the name of the task
  21078. */
  21079. name: string,
  21080. /**
  21081. * Defines the location of the file to load
  21082. */
  21083. url: string,
  21084. /**
  21085. * 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.
  21086. */
  21087. size?: number | undefined,
  21088. /**
  21089. * Defines if mipmaps should not be generated (default is false)
  21090. */
  21091. noMipmap?: boolean,
  21092. /**
  21093. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  21094. */
  21095. generateHarmonics?: boolean,
  21096. /**
  21097. * 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)
  21098. */
  21099. useInGammaSpace?: boolean,
  21100. /**
  21101. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  21102. */
  21103. usePMREMGenerator?: boolean);
  21104. /**
  21105. * Execute the current task
  21106. * @param scene defines the scene where you want your assets to be loaded
  21107. * @param onSuccess is a callback called when the task is successfully executed
  21108. * @param onError is a callback called if an error occurs
  21109. */
  21110. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21111. }
  21112. /**
  21113. * This class can be used to easily import assets into a scene
  21114. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  21115. */
  21116. class AssetsManager {
  21117. private _scene;
  21118. private _isLoading;
  21119. protected _tasks: AbstractAssetTask[];
  21120. protected _waitingTasksCount: number;
  21121. protected _totalTasksCount: number;
  21122. /**
  21123. * Callback called when all tasks are processed
  21124. */
  21125. onFinish: (tasks: AbstractAssetTask[]) => void;
  21126. /**
  21127. * Callback called when a task is successful
  21128. */
  21129. onTaskSuccess: (task: AbstractAssetTask) => void;
  21130. /**
  21131. * Callback called when a task had an error
  21132. */
  21133. onTaskError: (task: AbstractAssetTask) => void;
  21134. /**
  21135. * Callback called when a task is done (whatever the result is)
  21136. */
  21137. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  21138. /**
  21139. * Observable called when all tasks are processed
  21140. */
  21141. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  21142. /**
  21143. * Observable called when a task had an error
  21144. */
  21145. onTaskErrorObservable: Observable<AbstractAssetTask>;
  21146. /**
  21147. * Observable called when a task is successful
  21148. */
  21149. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  21150. /**
  21151. * Observable called when a task is done (whatever the result is)
  21152. */
  21153. onProgressObservable: Observable<IAssetsProgressEvent>;
  21154. /**
  21155. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  21156. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  21157. */
  21158. useDefaultLoadingScreen: boolean;
  21159. /**
  21160. * Creates a new AssetsManager
  21161. * @param scene defines the scene to work on
  21162. */
  21163. constructor(scene: Scene);
  21164. /**
  21165. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  21166. * @param taskName defines the name of the new task
  21167. * @param meshesNames defines the name of meshes to load
  21168. * @param rootUrl defines the root url to use to locate files
  21169. * @param sceneFilename defines the filename of the scene file
  21170. * @returns a new {BABYLON.MeshAssetTask} object
  21171. */
  21172. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  21173. /**
  21174. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  21175. * @param taskName defines the name of the new task
  21176. * @param url defines the url of the file to load
  21177. * @returns a new {BABYLON.TextFileAssetTask} object
  21178. */
  21179. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  21180. /**
  21181. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  21182. * @param taskName defines the name of the new task
  21183. * @param url defines the url of the file to load
  21184. * @returns a new {BABYLON.BinaryFileAssetTask} object
  21185. */
  21186. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  21187. /**
  21188. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  21189. * @param taskName defines the name of the new task
  21190. * @param url defines the url of the file to load
  21191. * @returns a new {BABYLON.ImageAssetTask} object
  21192. */
  21193. addImageTask(taskName: string, url: string): ImageAssetTask;
  21194. /**
  21195. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  21196. * @param taskName defines the name of the new task
  21197. * @param url defines the url of the file to load
  21198. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  21199. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  21200. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  21201. * @returns a new {BABYLON.TextureAssetTask} object
  21202. */
  21203. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  21204. /**
  21205. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  21206. * @param taskName defines the name of the new task
  21207. * @param url defines the url of the file to load
  21208. * @param extensions defines the extension to use to load the cube map (can be null)
  21209. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  21210. * @param files defines the list of files to load (can be null)
  21211. * @returns a new {BABYLON.CubeTextureAssetTask} object
  21212. */
  21213. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  21214. /**
  21215. *
  21216. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  21217. * @param taskName defines the name of the new task
  21218. * @param url defines the url of the file to load
  21219. * @param size defines the size you want for the cubemap (can be null)
  21220. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  21221. * @param generateHarmonics defines if you want to automatically generate (true by default)
  21222. * @param useInGammaSpace defines if the texture must be considered in gamma space (false by default)
  21223. * @param usePMREMGenerator is a reserved parameter and must be set to false or ignored
  21224. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  21225. */
  21226. addHDRCubeTextureTask(taskName: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean): HDRCubeTextureAssetTask;
  21227. private _decreaseWaitingTasksCount(task);
  21228. private _runTask(task);
  21229. /**
  21230. * Reset the {BABYLON.AssetsManager} and remove all tasks
  21231. * @return the current instance of the {BABYLON.AssetsManager}
  21232. */
  21233. reset(): AssetsManager;
  21234. /**
  21235. * Start the loading process
  21236. * @return the current instance of the {BABYLON.AssetsManager}
  21237. */
  21238. load(): AssetsManager;
  21239. }
  21240. }
  21241. declare module BABYLON {
  21242. class Database {
  21243. private callbackManifestChecked;
  21244. private currentSceneUrl;
  21245. private db;
  21246. private _enableSceneOffline;
  21247. private _enableTexturesOffline;
  21248. private manifestVersionFound;
  21249. private mustUpdateRessources;
  21250. private hasReachedQuota;
  21251. private isSupported;
  21252. private idbFactory;
  21253. static IsUASupportingBlobStorage: boolean;
  21254. static IDBStorageEnabled: boolean;
  21255. readonly enableSceneOffline: boolean;
  21256. readonly enableTexturesOffline: boolean;
  21257. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any);
  21258. static parseURL: (url: string) => string;
  21259. static ReturnFullUrlLocation: (url: string) => string;
  21260. checkManifestFile(): void;
  21261. openAsync(successCallback: () => void, errorCallback: () => void): void;
  21262. loadImageFromDB(url: string, image: HTMLImageElement): void;
  21263. private _loadImageFromDBAsync(url, image, notInDBCallback);
  21264. private _saveImageIntoDBAsync(url, image);
  21265. private _checkVersionFromDB(url, versionLoaded);
  21266. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  21267. private _saveVersionIntoDBAsync(url, callback);
  21268. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  21269. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  21270. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  21271. }
  21272. }
  21273. declare module BABYLON {
  21274. interface DDSInfo {
  21275. width: number;
  21276. height: number;
  21277. mipmapCount: number;
  21278. isFourCC: boolean;
  21279. isRGB: boolean;
  21280. isLuminance: boolean;
  21281. isCube: boolean;
  21282. isCompressed: boolean;
  21283. dxgiFormat: number;
  21284. textureType: number;
  21285. }
  21286. class DDSTools {
  21287. static StoreLODInAlphaChannel: boolean;
  21288. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  21289. private static _FloatView;
  21290. private static _Int32View;
  21291. private static _ToHalfFloat(value);
  21292. private static _FromHalfFloat(value);
  21293. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  21294. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  21295. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  21296. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  21297. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  21298. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  21299. private static _ExtractLongWordOrder(value);
  21300. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  21301. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  21302. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  21303. }
  21304. }
  21305. declare module BABYLON {
  21306. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  21307. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21308. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21309. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21310. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21311. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21312. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21313. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21314. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21315. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21316. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21317. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21318. class SerializationHelper {
  21319. static Serialize<T>(entity: T, serializationObject?: any): any;
  21320. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  21321. static Clone<T>(creationFunction: () => T, source: T): T;
  21322. static Instanciate<T>(creationFunction: () => T, source: T): T;
  21323. }
  21324. }
  21325. declare module BABYLON {
  21326. /**
  21327. * Wrapper class for promise with external resolve and reject.
  21328. */
  21329. class Deferred<T> {
  21330. /**
  21331. * The promise associated with this deferred object.
  21332. */
  21333. readonly promise: Promise<T>;
  21334. private _resolve;
  21335. private _reject;
  21336. /**
  21337. * The resolve method of the promise associated with this deferred object.
  21338. */
  21339. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  21340. /**
  21341. * The reject method of the promise associated with this deferred object.
  21342. */
  21343. readonly reject: (reason?: any) => void;
  21344. /**
  21345. * Constructor for this deferred object.
  21346. */
  21347. constructor();
  21348. }
  21349. }
  21350. declare module Earcut {
  21351. /**
  21352. * The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
  21353. * @param data is a flat array of vertice coordinates like [x0, y0, x1, y1, x2, y2, ...].
  21354. * @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).
  21355. * @param dim is the number of coordinates per vertice in the input array (2 by default).
  21356. */
  21357. function earcut(data: number[], holeIndices: number[], dim: number): Array<number>;
  21358. /**
  21359. * return a percentage difference between the polygon area and its triangulation area;
  21360. * used to verify correctness of triangulation
  21361. */
  21362. function deviation(data: number[], holeIndices: number[], dim: number, triangles: number[]): number;
  21363. /**
  21364. * turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
  21365. */
  21366. function flatten(data: number[][][]): {
  21367. vertices: number[];
  21368. holes: number[];
  21369. dimensions: number;
  21370. };
  21371. }
  21372. declare module BABYLON {
  21373. class FilesInput {
  21374. static FilesToLoad: {
  21375. [key: string]: File;
  21376. };
  21377. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  21378. private _engine;
  21379. private _currentScene;
  21380. private _sceneLoadedCallback;
  21381. private _progressCallback;
  21382. private _additionalRenderLoopLogicCallback;
  21383. private _textureLoadingCallback;
  21384. private _startingProcessingFilesCallback;
  21385. private _onReloadCallback;
  21386. private _errorCallback;
  21387. private _elementToMonitor;
  21388. private _sceneFileToLoad;
  21389. private _filesToLoad;
  21390. 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);
  21391. private _dragEnterHandler;
  21392. private _dragOverHandler;
  21393. private _dropHandler;
  21394. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  21395. dispose(): void;
  21396. private renderFunction();
  21397. private drag(e);
  21398. private drop(eventDrop);
  21399. private _traverseFolder(folder, files, remaining, callback);
  21400. private _processFiles(files);
  21401. loadFiles(event: any): void;
  21402. private _processReload();
  21403. reload(): void;
  21404. }
  21405. }
  21406. declare module BABYLON {
  21407. /**
  21408. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  21409. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  21410. */
  21411. class KhronosTextureContainer {
  21412. arrayBuffer: any;
  21413. static HEADER_LEN: number;
  21414. static COMPRESSED_2D: number;
  21415. static COMPRESSED_3D: number;
  21416. static TEX_2D: number;
  21417. static TEX_3D: number;
  21418. glType: number;
  21419. glTypeSize: number;
  21420. glFormat: number;
  21421. glInternalFormat: number;
  21422. glBaseInternalFormat: number;
  21423. pixelWidth: number;
  21424. pixelHeight: number;
  21425. pixelDepth: number;
  21426. numberOfArrayElements: number;
  21427. numberOfFaces: number;
  21428. numberOfMipmapLevels: number;
  21429. bytesOfKeyValueData: number;
  21430. loadType: number;
  21431. /**
  21432. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  21433. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  21434. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  21435. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  21436. */
  21437. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  21438. switchEndainness(val: number): number;
  21439. /**
  21440. * It is assumed that the texture has already been created & is currently bound
  21441. */
  21442. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  21443. private _upload2DCompressedLevels(gl, loadMipmaps);
  21444. }
  21445. }
  21446. declare module BABYLON {
  21447. /**
  21448. * A class serves as a medium between the observable and its observers
  21449. */
  21450. class EventState {
  21451. /**
  21452. * Create a new EventState
  21453. * @param mask defines the mask associated with this state
  21454. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  21455. * @param target defines the original target of the state
  21456. * @param currentTarget defines the current target of the state
  21457. */
  21458. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  21459. /**
  21460. * Initialize the current event state
  21461. * @param mask defines the mask associated with this state
  21462. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  21463. * @param target defines the original target of the state
  21464. * @param currentTarget defines the current target of the state
  21465. * @returns the current event state
  21466. */
  21467. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  21468. /**
  21469. * An Observer can set this property to true to prevent subsequent observers of being notified
  21470. */
  21471. skipNextObservers: boolean;
  21472. /**
  21473. * Get the mask value that were used to trigger the event corresponding to this EventState object
  21474. */
  21475. mask: number;
  21476. /**
  21477. * The object that originally notified the event
  21478. */
  21479. target?: any;
  21480. /**
  21481. * The current object in the bubbling phase
  21482. */
  21483. currentTarget?: any;
  21484. /**
  21485. * This will be populated with the return value of the last function that was executed.
  21486. * If it is the first function in the callback chain it will be the event data.
  21487. */
  21488. lastReturnValue?: any;
  21489. }
  21490. /**
  21491. * Represent an Observer registered to a given Observable object.
  21492. */
  21493. class Observer<T> {
  21494. /**
  21495. * Defines the callback to call when the observer is notified
  21496. */
  21497. callback: (eventData: T, eventState: EventState) => void;
  21498. /**
  21499. * Defines the mask of the observer (used to filter notifications)
  21500. */
  21501. mask: number;
  21502. /**
  21503. * Defines the current scope used to restore the JS context
  21504. */
  21505. scope: any;
  21506. /** @ignore */
  21507. _willBeUnregistered: boolean;
  21508. /**
  21509. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  21510. */
  21511. unregisterOnNextCall: boolean;
  21512. /**
  21513. * Creates a new observer
  21514. * @param callback defines the callback to call when the observer is notified
  21515. * @param mask defines the mask of the observer (used to filter notifications)
  21516. * @param scope defines the current scope used to restore the JS context
  21517. */
  21518. constructor(
  21519. /**
  21520. * Defines the callback to call when the observer is notified
  21521. */
  21522. callback: (eventData: T, eventState: EventState) => void,
  21523. /**
  21524. * Defines the mask of the observer (used to filter notifications)
  21525. */
  21526. mask: number,
  21527. /**
  21528. * Defines the current scope used to restore the JS context
  21529. */
  21530. scope?: any);
  21531. }
  21532. /**
  21533. * Represent a list of observers registered to multiple Observables object.
  21534. */
  21535. class MultiObserver<T> {
  21536. private _observers;
  21537. private _observables;
  21538. /**
  21539. * Release associated resources
  21540. */
  21541. dispose(): void;
  21542. /**
  21543. * Raise a callback when one of the observable will notify
  21544. * @param observables defines a list of observables to watch
  21545. * @param callback defines the callback to call on notification
  21546. * @param mask defines the mask used to filter notifications
  21547. * @param scope defines the current scope used to restore the JS context
  21548. * @returns the new MultiObserver
  21549. */
  21550. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  21551. }
  21552. /**
  21553. * The Observable class is a simple implementation of the Observable pattern.
  21554. * 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.
  21555. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  21556. * 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).
  21557. * 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.
  21558. */
  21559. class Observable<T> {
  21560. private _observers;
  21561. private _eventState;
  21562. private _onObserverAdded;
  21563. /**
  21564. * Creates a new observable
  21565. * @param onObserverAdded defines a callback to call when a new observer is added
  21566. */
  21567. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  21568. /**
  21569. * Create a new Observer with the specified callback
  21570. * @param callback the callback that will be executed for that Observer
  21571. * @param mask the mask used to filter observers
  21572. * @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.
  21573. * @param scope optional scope for the callback to be called from
  21574. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  21575. * @returns the new observer created for the callback
  21576. */
  21577. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  21578. /**
  21579. * Remove an Observer from the Observable object
  21580. * @param observer the instance of the Observer to remove
  21581. * @returns false if it doesn't belong to this Observable
  21582. */
  21583. remove(observer: Nullable<Observer<T>>): boolean;
  21584. /**
  21585. * Remove a callback from the Observable object
  21586. * @param callback the callback to remove
  21587. * @param scope optional scope. If used only the callbacks with this scope will be removed
  21588. * @returns false if it doesn't belong to this Observable
  21589. */
  21590. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  21591. private _deferUnregister(observer);
  21592. /**
  21593. * Notify all Observers by calling their respective callback with the given data
  21594. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  21595. * @param eventData defines the data to send to all observers
  21596. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  21597. * @param target defines the original target of the state
  21598. * @param currentTarget defines the current target of the state
  21599. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  21600. */
  21601. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  21602. /**
  21603. * Calling this will execute each callback, expecting it to be a promise or return a value.
  21604. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  21605. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  21606. * and it is crucial that all callbacks will be executed.
  21607. * The order of the callbacks is kept, callbacks are not executed parallel.
  21608. *
  21609. * @param eventData The data to be sent to each callback
  21610. * @param mask is used to filter observers defaults to -1
  21611. * @param target defines the callback target (see EventState)
  21612. * @param currentTarget defines he current object in the bubbling phase
  21613. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  21614. */
  21615. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  21616. /**
  21617. * Notify a specific observer
  21618. * @param observer defines the observer to notify
  21619. * @param eventData defines the data to be sent to each callback
  21620. * @param mask is used to filter observers defaults to -1
  21621. */
  21622. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  21623. /**
  21624. * Gets a boolean indicating if the observable has at least one observer
  21625. * @returns true is the Observable has at least one Observer registered
  21626. */
  21627. hasObservers(): boolean;
  21628. /**
  21629. * Clear the list of observers
  21630. */
  21631. clear(): void;
  21632. /**
  21633. * Clone the current observable
  21634. * @returns a new observable
  21635. */
  21636. clone(): Observable<T>;
  21637. /**
  21638. * Does this observable handles observer registered with a given mask
  21639. * @param mask defines the mask to be tested
  21640. * @return whether or not one observer registered with the given mask is handeled
  21641. **/
  21642. hasSpecificMask(mask?: number): boolean;
  21643. }
  21644. }
  21645. declare module BABYLON {
  21646. /**
  21647. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  21648. */
  21649. class PerformanceMonitor {
  21650. private _enabled;
  21651. private _rollingFrameTime;
  21652. private _lastFrameTimeMs;
  21653. /**
  21654. * constructor
  21655. * @param frameSampleSize The number of samples required to saturate the sliding window
  21656. */
  21657. constructor(frameSampleSize?: number);
  21658. /**
  21659. * Samples current frame
  21660. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  21661. */
  21662. sampleFrame(timeMs?: number): void;
  21663. /**
  21664. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  21665. * @return Average frame time in milliseconds
  21666. */
  21667. readonly averageFrameTime: number;
  21668. /**
  21669. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  21670. * @return Frame time variance in milliseconds squared
  21671. */
  21672. readonly averageFrameTimeVariance: number;
  21673. /**
  21674. * Returns the frame time of the most recent frame
  21675. * @return Frame time in milliseconds
  21676. */
  21677. readonly instantaneousFrameTime: number;
  21678. /**
  21679. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  21680. * @return Framerate in frames per second
  21681. */
  21682. readonly averageFPS: number;
  21683. /**
  21684. * Returns the average framerate in frames per second using the most recent frame time
  21685. * @return Framerate in frames per second
  21686. */
  21687. readonly instantaneousFPS: number;
  21688. /**
  21689. * Returns true if enough samples have been taken to completely fill the sliding window
  21690. * @return true if saturated
  21691. */
  21692. readonly isSaturated: boolean;
  21693. /**
  21694. * Enables contributions to the sliding window sample set
  21695. */
  21696. enable(): void;
  21697. /**
  21698. * Disables contributions to the sliding window sample set
  21699. * Samples will not be interpolated over the disabled period
  21700. */
  21701. disable(): void;
  21702. /**
  21703. * Returns true if sampling is enabled
  21704. * @return true if enabled
  21705. */
  21706. readonly isEnabled: boolean;
  21707. /**
  21708. * Resets performance monitor
  21709. */
  21710. reset(): void;
  21711. }
  21712. /**
  21713. * RollingAverage
  21714. *
  21715. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  21716. */
  21717. class RollingAverage {
  21718. /**
  21719. * Current average
  21720. */
  21721. average: number;
  21722. /**
  21723. * Current variance
  21724. */
  21725. variance: number;
  21726. protected _samples: Array<number>;
  21727. protected _sampleCount: number;
  21728. protected _pos: number;
  21729. protected _m2: number;
  21730. /**
  21731. * constructor
  21732. * @param length The number of samples required to saturate the sliding window
  21733. */
  21734. constructor(length: number);
  21735. /**
  21736. * Adds a sample to the sample set
  21737. * @param v The sample value
  21738. */
  21739. add(v: number): void;
  21740. /**
  21741. * Returns previously added values or null if outside of history or outside the sliding window domain
  21742. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  21743. * @return Value previously recorded with add() or null if outside of range
  21744. */
  21745. history(i: number): number;
  21746. /**
  21747. * Returns true if enough samples have been taken to completely fill the sliding window
  21748. * @return true if sample-set saturated
  21749. */
  21750. isSaturated(): boolean;
  21751. /**
  21752. * Resets the rolling average (equivalent to 0 samples taken so far)
  21753. */
  21754. reset(): void;
  21755. /**
  21756. * Wraps a value around the sample range boundaries
  21757. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  21758. * @return Wrapped position in sample range
  21759. */
  21760. protected _wrapPosition(i: number): number;
  21761. }
  21762. }
  21763. declare module BABYLON {
  21764. /**
  21765. * Helper class that provides a small promise polyfill
  21766. */
  21767. class PromisePolyfill {
  21768. /**
  21769. * Static function used to check if the polyfill is required
  21770. * If this is the case then the function will inject the polyfill to window.Promise
  21771. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  21772. */
  21773. static Apply(force?: boolean): void;
  21774. }
  21775. }
  21776. declare module BABYLON {
  21777. /**
  21778. * Defines the root class used to create scene optimization to use with SceneOptimizer
  21779. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  21780. */
  21781. class SceneOptimization {
  21782. /**
  21783. * Defines the priority of this optimization (0 by default which means first in the list)
  21784. */
  21785. priority: number;
  21786. /**
  21787. * Gets a string describing the action executed by the current optimization
  21788. * @returns description string
  21789. */
  21790. getDescription(): string;
  21791. /**
  21792. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  21793. * @param scene defines the current scene where to apply this optimization
  21794. * @param optimizer defines the current optimizer
  21795. * @returns true if everything that can be done was applied
  21796. */
  21797. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  21798. /**
  21799. * Creates the SceneOptimization object
  21800. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  21801. * @param desc defines the description associated with the optimization
  21802. */
  21803. constructor(
  21804. /**
  21805. * Defines the priority of this optimization (0 by default which means first in the list)
  21806. */
  21807. priority?: number);
  21808. }
  21809. /**
  21810. * Defines an optimization used to reduce the size of render target textures
  21811. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  21812. */
  21813. class TextureOptimization extends SceneOptimization {
  21814. /**
  21815. * Defines the priority of this optimization (0 by default which means first in the list)
  21816. */
  21817. priority: number;
  21818. /**
  21819. * 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
  21820. */
  21821. maximumSize: number;
  21822. /**
  21823. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  21824. */
  21825. step: number;
  21826. /**
  21827. * Gets a string describing the action executed by the current optimization
  21828. * @returns description string
  21829. */
  21830. getDescription(): string;
  21831. /**
  21832. * Creates the TextureOptimization object
  21833. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  21834. * @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
  21835. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  21836. */
  21837. constructor(
  21838. /**
  21839. * Defines the priority of this optimization (0 by default which means first in the list)
  21840. */
  21841. priority?: number,
  21842. /**
  21843. * 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
  21844. */
  21845. maximumSize?: number,
  21846. /**
  21847. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  21848. */
  21849. step?: number);
  21850. /**
  21851. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  21852. * @param scene defines the current scene where to apply this optimization
  21853. * @param optimizer defines the current optimizer
  21854. * @returns true if everything that can be done was applied
  21855. */
  21856. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  21857. }
  21858. /**
  21859. * Defines an optimization used to increase or decrease the rendering resolution
  21860. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  21861. */
  21862. class HardwareScalingOptimization extends SceneOptimization {
  21863. /**
  21864. * Defines the priority of this optimization (0 by default which means first in the list)
  21865. */
  21866. priority: number;
  21867. /**
  21868. * Defines the maximum scale to use (2 by default)
  21869. */
  21870. maximumScale: number;
  21871. /**
  21872. * Defines the step to use between two passes (0.5 by default)
  21873. */
  21874. step: number;
  21875. private _currentScale;
  21876. private _directionOffset;
  21877. /**
  21878. * Gets a string describing the action executed by the current optimization
  21879. * @return description string
  21880. */
  21881. getDescription(): string;
  21882. /**
  21883. * Creates the HardwareScalingOptimization object
  21884. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  21885. * @param maximumScale defines the maximum scale to use (2 by default)
  21886. * @param step defines the step to use between two passes (0.5 by default)
  21887. */
  21888. constructor(
  21889. /**
  21890. * Defines the priority of this optimization (0 by default which means first in the list)
  21891. */
  21892. priority?: number,
  21893. /**
  21894. * Defines the maximum scale to use (2 by default)
  21895. */
  21896. maximumScale?: number,
  21897. /**
  21898. * Defines the step to use between two passes (0.5 by default)
  21899. */
  21900. step?: number);
  21901. /**
  21902. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  21903. * @param scene defines the current scene where to apply this optimization
  21904. * @param optimizer defines the current optimizer
  21905. * @returns true if everything that can be done was applied
  21906. */
  21907. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  21908. }
  21909. /**
  21910. * Defines an optimization used to remove shadows
  21911. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  21912. */
  21913. class ShadowsOptimization extends SceneOptimization {
  21914. /**
  21915. * Gets a string describing the action executed by the current optimization
  21916. * @return description string
  21917. */
  21918. getDescription(): string;
  21919. /**
  21920. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  21921. * @param scene defines the current scene where to apply this optimization
  21922. * @param optimizer defines the current optimizer
  21923. * @returns true if everything that can be done was applied
  21924. */
  21925. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  21926. }
  21927. /**
  21928. * Defines an optimization used to turn post-processes off
  21929. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  21930. */
  21931. class PostProcessesOptimization extends SceneOptimization {
  21932. /**
  21933. * Gets a string describing the action executed by the current optimization
  21934. * @return description string
  21935. */
  21936. getDescription(): string;
  21937. /**
  21938. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  21939. * @param scene defines the current scene where to apply this optimization
  21940. * @param optimizer defines the current optimizer
  21941. * @returns true if everything that can be done was applied
  21942. */
  21943. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  21944. }
  21945. /**
  21946. * Defines an optimization used to turn lens flares off
  21947. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  21948. */
  21949. class LensFlaresOptimization extends SceneOptimization {
  21950. /**
  21951. * Gets a string describing the action executed by the current optimization
  21952. * @return description string
  21953. */
  21954. getDescription(): string;
  21955. /**
  21956. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  21957. * @param scene defines the current scene where to apply this optimization
  21958. * @param optimizer defines the current optimizer
  21959. * @returns true if everything that can be done was applied
  21960. */
  21961. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  21962. }
  21963. /**
  21964. * Defines an optimization based on user defined callback.
  21965. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  21966. */
  21967. class CustomOptimization extends SceneOptimization {
  21968. /**
  21969. * Callback called to apply the custom optimization.
  21970. */
  21971. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  21972. /**
  21973. * Callback called to get custom description
  21974. */
  21975. onGetDescription: () => string;
  21976. /**
  21977. * Gets a string describing the action executed by the current optimization
  21978. * @returns description string
  21979. */
  21980. getDescription(): string;
  21981. /**
  21982. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  21983. * @param scene defines the current scene where to apply this optimization
  21984. * @param optimizer defines the current optimizer
  21985. * @returns true if everything that can be done was applied
  21986. */
  21987. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  21988. }
  21989. /**
  21990. * Defines an optimization used to turn particles off
  21991. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  21992. */
  21993. class ParticlesOptimization extends SceneOptimization {
  21994. /**
  21995. * Gets a string describing the action executed by the current optimization
  21996. * @return description string
  21997. */
  21998. getDescription(): string;
  21999. /**
  22000. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22001. * @param scene defines the current scene where to apply this optimization
  22002. * @param optimizer defines the current optimizer
  22003. * @returns true if everything that can be done was applied
  22004. */
  22005. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22006. }
  22007. /**
  22008. * Defines an optimization used to turn render targets off
  22009. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22010. */
  22011. class RenderTargetsOptimization extends SceneOptimization {
  22012. /**
  22013. * Gets a string describing the action executed by the current optimization
  22014. * @return description string
  22015. */
  22016. getDescription(): string;
  22017. /**
  22018. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22019. * @param scene defines the current scene where to apply this optimization
  22020. * @param optimizer defines the current optimizer
  22021. * @returns true if everything that can be done was applied
  22022. */
  22023. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22024. }
  22025. /**
  22026. * Defines an optimization used to merge meshes with compatible materials
  22027. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22028. */
  22029. class MergeMeshesOptimization extends SceneOptimization {
  22030. private static _UpdateSelectionTree;
  22031. /**
  22032. * Gets or sets a boolean which defines if optimization octree has to be updated
  22033. */
  22034. /**
  22035. * Gets or sets a boolean which defines if optimization octree has to be updated
  22036. */
  22037. static UpdateSelectionTree: boolean;
  22038. /**
  22039. * Gets a string describing the action executed by the current optimization
  22040. * @return description string
  22041. */
  22042. getDescription(): string;
  22043. private _canBeMerged;
  22044. /**
  22045. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22046. * @param scene defines the current scene where to apply this optimization
  22047. * @param optimizer defines the current optimizer
  22048. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  22049. * @returns true if everything that can be done was applied
  22050. */
  22051. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  22052. }
  22053. /**
  22054. * Defines a list of options used by SceneOptimizer
  22055. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22056. */
  22057. class SceneOptimizerOptions {
  22058. /**
  22059. * Defines the target frame rate to reach (60 by default)
  22060. */
  22061. targetFrameRate: number;
  22062. /**
  22063. * Defines the interval between two checkes (2000ms by default)
  22064. */
  22065. trackerDuration: number;
  22066. /**
  22067. * Gets the list of optimizations to apply
  22068. */
  22069. optimizations: SceneOptimization[];
  22070. /**
  22071. * Creates a new list of options used by SceneOptimizer
  22072. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  22073. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  22074. */
  22075. constructor(
  22076. /**
  22077. * Defines the target frame rate to reach (60 by default)
  22078. */
  22079. targetFrameRate?: number,
  22080. /**
  22081. * Defines the interval between two checkes (2000ms by default)
  22082. */
  22083. trackerDuration?: number);
  22084. /**
  22085. * Add a new optimization
  22086. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  22087. * @returns the current SceneOptimizerOptions
  22088. */
  22089. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  22090. /**
  22091. * Add a new custom optimization
  22092. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  22093. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  22094. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  22095. * @returns the current SceneOptimizerOptions
  22096. */
  22097. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  22098. /**
  22099. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  22100. * @param targetFrameRate defines the target frame rate (60 by default)
  22101. * @returns a SceneOptimizerOptions object
  22102. */
  22103. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  22104. /**
  22105. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  22106. * @param targetFrameRate defines the target frame rate (60 by default)
  22107. * @returns a SceneOptimizerOptions object
  22108. */
  22109. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  22110. /**
  22111. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  22112. * @param targetFrameRate defines the target frame rate (60 by default)
  22113. * @returns a SceneOptimizerOptions object
  22114. */
  22115. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  22116. }
  22117. /**
  22118. * Class used to run optimizations in order to reach a target frame rate
  22119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22120. */
  22121. class SceneOptimizer implements IDisposable {
  22122. private _isRunning;
  22123. private _options;
  22124. private _scene;
  22125. private _currentPriorityLevel;
  22126. private _targetFrameRate;
  22127. private _trackerDuration;
  22128. private _currentFrameRate;
  22129. private _sceneDisposeObserver;
  22130. private _improvementMode;
  22131. /**
  22132. * Defines an observable called when the optimizer reaches the target frame rate
  22133. */
  22134. onSuccessObservable: Observable<SceneOptimizer>;
  22135. /**
  22136. * Defines an observable called when the optimizer enables an optimization
  22137. */
  22138. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  22139. /**
  22140. * Defines an observable called when the optimizer is not able to reach the target frame rate
  22141. */
  22142. onFailureObservable: Observable<SceneOptimizer>;
  22143. /**
  22144. * Gets a boolean indicating if the optimizer is in improvement mode
  22145. */
  22146. readonly isInImprovementMode: boolean;
  22147. /**
  22148. * Gets the current priority level (0 at start)
  22149. */
  22150. readonly currentPriorityLevel: number;
  22151. /**
  22152. * Gets the current frame rate checked by the SceneOptimizer
  22153. */
  22154. readonly currentFrameRate: number;
  22155. /**
  22156. * Gets or sets the current target frame rate (60 by default)
  22157. */
  22158. /**
  22159. * Gets or sets the current target frame rate (60 by default)
  22160. */
  22161. targetFrameRate: number;
  22162. /**
  22163. * Gets or sets the current interval between two checks (every 2000ms by default)
  22164. */
  22165. /**
  22166. * Gets or sets the current interval between two checks (every 2000ms by default)
  22167. */
  22168. trackerDuration: number;
  22169. /**
  22170. * Gets the list of active optimizations
  22171. */
  22172. readonly optimizations: SceneOptimization[];
  22173. /**
  22174. * Creates a new SceneOptimizer
  22175. * @param scene defines the scene to work on
  22176. * @param options defines the options to use with the SceneOptimizer
  22177. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  22178. * @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)
  22179. */
  22180. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  22181. /**
  22182. * Stops the current optimizer
  22183. */
  22184. stop(): void;
  22185. /**
  22186. * Reset the optimizer to initial step (current priority level = 0)
  22187. */
  22188. reset(): void;
  22189. /**
  22190. * Start the optimizer. By default it will try to reach a specific framerate
  22191. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  22192. */
  22193. start(): void;
  22194. private _checkCurrentState();
  22195. /**
  22196. * Release all resources
  22197. */
  22198. dispose(): void;
  22199. /**
  22200. * Helper function to create a SceneOptimizer with one single line of code
  22201. * @param scene defines the scene to work on
  22202. * @param options defines the options to use with the SceneOptimizer
  22203. * @param onSuccess defines a callback to call on success
  22204. * @param onFailure defines a callback to call on failure
  22205. * @returns the new SceneOptimizer object
  22206. */
  22207. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  22208. }
  22209. }
  22210. declare module BABYLON {
  22211. class SceneSerializer {
  22212. static ClearCache(): void;
  22213. static Serialize(scene: Scene): any;
  22214. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  22215. }
  22216. }
  22217. declare module BABYLON {
  22218. class SmartArray<T> {
  22219. data: Array<T>;
  22220. length: number;
  22221. protected _id: number;
  22222. [index: number]: T;
  22223. constructor(capacity: number);
  22224. push(value: T): void;
  22225. forEach(func: (content: T) => void): void;
  22226. sort(compareFn: (a: T, b: T) => number): void;
  22227. reset(): void;
  22228. dispose(): void;
  22229. concat(array: any): void;
  22230. indexOf(value: T): number;
  22231. contains(value: T): boolean;
  22232. private static _GlobalId;
  22233. }
  22234. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  22235. private _duplicateId;
  22236. [index: number]: T;
  22237. push(value: T): void;
  22238. pushNoDuplicate(value: T): boolean;
  22239. reset(): void;
  22240. concatWithNoDuplicate(array: any): void;
  22241. }
  22242. }
  22243. declare module BABYLON {
  22244. /**
  22245. * This class implement a typical dictionary using a string as key and the generic type T as value.
  22246. * The underlying implementation relies on an associative array to ensure the best performances.
  22247. * The value can be anything including 'null' but except 'undefined'
  22248. */
  22249. class StringDictionary<T> {
  22250. /**
  22251. * This will clear this dictionary and copy the content from the 'source' one.
  22252. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  22253. * @param source the dictionary to take the content from and copy to this dictionary
  22254. */
  22255. copyFrom(source: StringDictionary<T>): void;
  22256. /**
  22257. * Get a value based from its key
  22258. * @param key the given key to get the matching value from
  22259. * @return the value if found, otherwise undefined is returned
  22260. */
  22261. get(key: string): T | undefined;
  22262. /**
  22263. * Get a value from its key or add it if it doesn't exist.
  22264. * This method will ensure you that a given key/data will be present in the dictionary.
  22265. * @param key the given key to get the matching value from
  22266. * @param factory the factory that will create the value if the key is not present in the dictionary.
  22267. * The factory will only be invoked if there's no data for the given key.
  22268. * @return the value corresponding to the key.
  22269. */
  22270. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  22271. /**
  22272. * Get a value from its key if present in the dictionary otherwise add it
  22273. * @param key the key to get the value from
  22274. * @param val if there's no such key/value pair in the dictionary add it with this value
  22275. * @return the value corresponding to the key
  22276. */
  22277. getOrAdd(key: string, val: T): T;
  22278. /**
  22279. * Check if there's a given key in the dictionary
  22280. * @param key the key to check for
  22281. * @return true if the key is present, false otherwise
  22282. */
  22283. contains(key: string): boolean;
  22284. /**
  22285. * Add a new key and its corresponding value
  22286. * @param key the key to add
  22287. * @param value the value corresponding to the key
  22288. * @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
  22289. */
  22290. add(key: string, value: T): boolean;
  22291. set(key: string, value: T): boolean;
  22292. /**
  22293. * Get the element of the given key and remove it from the dictionary
  22294. * @param key
  22295. */
  22296. getAndRemove(key: string): Nullable<T>;
  22297. /**
  22298. * Remove a key/value from the dictionary.
  22299. * @param key the key to remove
  22300. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  22301. */
  22302. remove(key: string): boolean;
  22303. /**
  22304. * Clear the whole content of the dictionary
  22305. */
  22306. clear(): void;
  22307. readonly count: number;
  22308. /**
  22309. * Execute a callback on each key/val of the dictionary.
  22310. * Note that you can remove any element in this dictionary in the callback implementation
  22311. * @param callback the callback to execute on a given key/value pair
  22312. */
  22313. forEach(callback: (key: string, val: T) => void): void;
  22314. /**
  22315. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  22316. * If the callback returns null or undefined the method will iterate to the next key/value pair
  22317. * Note that you can remove any element in this dictionary in the callback implementation
  22318. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  22319. */
  22320. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  22321. private _count;
  22322. private _data;
  22323. }
  22324. }
  22325. declare module BABYLON {
  22326. class Tags {
  22327. static EnableFor(obj: any): void;
  22328. static DisableFor(obj: any): void;
  22329. static HasTags(obj: any): boolean;
  22330. static GetTags(obj: any, asString?: boolean): any;
  22331. static AddTagsTo(obj: any, tagsString: string): void;
  22332. static _AddTagTo(obj: any, tag: string): void;
  22333. static RemoveTagsFrom(obj: any, tagsString: string): void;
  22334. static _RemoveTagFrom(obj: any, tag: string): void;
  22335. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  22336. }
  22337. }
  22338. declare module BABYLON {
  22339. class TextureTools {
  22340. /**
  22341. * Uses the GPU to create a copy texture rescaled at a given size
  22342. * @param texture Texture to copy from
  22343. * @param width Desired width
  22344. * @param height Desired height
  22345. * @return Generated texture
  22346. */
  22347. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  22348. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  22349. private static _environmentBRDFBase64Texture;
  22350. }
  22351. }
  22352. declare module BABYLON {
  22353. class TGATools {
  22354. private static _TYPE_INDEXED;
  22355. private static _TYPE_RGB;
  22356. private static _TYPE_GREY;
  22357. private static _TYPE_RLE_INDEXED;
  22358. private static _TYPE_RLE_RGB;
  22359. private static _TYPE_RLE_GREY;
  22360. private static _ORIGIN_MASK;
  22361. private static _ORIGIN_SHIFT;
  22362. private static _ORIGIN_BL;
  22363. private static _ORIGIN_BR;
  22364. private static _ORIGIN_UL;
  22365. private static _ORIGIN_UR;
  22366. static GetTGAHeader(data: Uint8Array): any;
  22367. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  22368. 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;
  22369. 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;
  22370. 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;
  22371. 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;
  22372. 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;
  22373. 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;
  22374. }
  22375. }
  22376. declare module BABYLON {
  22377. interface IAnimatable {
  22378. animations: Array<Animation>;
  22379. }
  22380. class LoadFileError extends Error {
  22381. request: XMLHttpRequest | undefined;
  22382. private static _setPrototypeOf;
  22383. constructor(message: string, request?: XMLHttpRequest | undefined);
  22384. }
  22385. class RetryStrategy {
  22386. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  22387. }
  22388. interface IFileRequest {
  22389. /**
  22390. * Raised when the request is complete (success or error).
  22391. */
  22392. onCompleteObservable: Observable<IFileRequest>;
  22393. /**
  22394. * Aborts the request for a file.
  22395. */
  22396. abort: () => void;
  22397. }
  22398. class Tools {
  22399. static BaseUrl: string;
  22400. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  22401. /**
  22402. * Default behaviour for cors in the application.
  22403. * It can be a string if the expected behavior is identical in the entire app.
  22404. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  22405. */
  22406. static CorsBehavior: string | ((url: string | string[]) => string);
  22407. static UseFallbackTexture: boolean;
  22408. /**
  22409. * Use this object to register external classes like custom textures or material
  22410. * to allow the laoders to instantiate them
  22411. */
  22412. static RegisteredExternalClasses: {
  22413. [key: string]: Object;
  22414. };
  22415. static fallbackTexture: string;
  22416. /**
  22417. * Interpolates between a and b via alpha
  22418. * @param a The lower value (returned when alpha = 0)
  22419. * @param b The upper value (returned when alpha = 1)
  22420. * @param alpha The interpolation-factor
  22421. * @return The mixed value
  22422. */
  22423. static Mix(a: number, b: number, alpha: number): number;
  22424. static Instantiate(className: string): any;
  22425. /**
  22426. * Provides a slice function that will work even on IE
  22427. * @param data defines the array to slice
  22428. * @returns the new sliced array
  22429. */
  22430. static Slice(data: FloatArray): FloatArray;
  22431. static SetImmediate(action: () => void): void;
  22432. static IsExponentOfTwo(value: number): boolean;
  22433. /**
  22434. * Find the next highest power of two.
  22435. * @param x Number to start search from.
  22436. * @return Next highest power of two.
  22437. */
  22438. static CeilingPOT(x: number): number;
  22439. /**
  22440. * Find the next lowest power of two.
  22441. * @param x Number to start search from.
  22442. * @return Next lowest power of two.
  22443. */
  22444. static FloorPOT(x: number): number;
  22445. /**
  22446. * Find the nearest power of two.
  22447. * @param x Number to start search from.
  22448. * @return Next nearest power of two.
  22449. */
  22450. static NearestPOT(x: number): number;
  22451. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  22452. static GetFilename(path: string): string;
  22453. /**
  22454. * Extracts the "folder" part of a path (everything before the filename).
  22455. * @param uri The URI to extract the info from
  22456. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  22457. * @returns The "folder" part of the path
  22458. */
  22459. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  22460. static GetDOMTextContent(element: HTMLElement): string;
  22461. static ToDegrees(angle: number): number;
  22462. static ToRadians(angle: number): number;
  22463. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  22464. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  22465. minimum: Vector3;
  22466. maximum: Vector3;
  22467. };
  22468. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  22469. minimum: Vector3;
  22470. maximum: Vector3;
  22471. };
  22472. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  22473. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  22474. minimum: Vector2;
  22475. maximum: Vector2;
  22476. };
  22477. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  22478. static GetPointerPrefix(): string;
  22479. /**
  22480. * @param func - the function to be called
  22481. * @param requester - the object that will request the next frame. Falls back to window.
  22482. */
  22483. static QueueNewFrame(func: () => void, requester?: any): number;
  22484. static RequestFullscreen(element: HTMLElement): void;
  22485. static ExitFullscreen(): void;
  22486. static SetCorsBehavior(url: string | string[], element: {
  22487. crossOrigin: string | null;
  22488. }): void;
  22489. static CleanUrl(url: string): string;
  22490. static PreprocessUrl: (url: string) => string;
  22491. static LoadImage(url: any, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  22492. 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;
  22493. /**
  22494. * Load a script (identified by an url). When the url returns, the
  22495. * content of this file is added into a new script element, attached to the DOM (body element)
  22496. */
  22497. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  22498. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (this: MSBaseReader, ev: ProgressEvent) => any): IFileRequest;
  22499. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (this: MSBaseReader, ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  22500. static FileAsURL(content: string): string;
  22501. static Format(value: number, decimals?: number): string;
  22502. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  22503. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  22504. static IsEmpty(obj: any): boolean;
  22505. static RegisterTopRootEvents(events: {
  22506. name: string;
  22507. handler: Nullable<(e: FocusEvent) => any>;
  22508. }[]): void;
  22509. static UnregisterTopRootEvents(events: {
  22510. name: string;
  22511. handler: Nullable<(e: FocusEvent) => any>;
  22512. }[]): void;
  22513. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  22514. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  22515. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  22516. /**
  22517. * Generates an image screenshot from the specified camera.
  22518. *
  22519. * @param engine The engine to use for rendering
  22520. * @param camera The camera to use for rendering
  22521. * @param size This parameter can be set to a single number or to an object with the
  22522. * following (optional) properties: precision, width, height. If a single number is passed,
  22523. * it will be used for both width and height. If an object is passed, the screenshot size
  22524. * will be derived from the parameters. The precision property is a multiplier allowing
  22525. * rendering at a higher or lower resolution.
  22526. * @param successCallback The callback receives a single parameter which contains the
  22527. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  22528. * src parameter of an <img> to display it.
  22529. * @param mimeType The MIME type of the screenshot image (default: image/png).
  22530. * Check your browser for supported MIME types.
  22531. * @param samples Texture samples (default: 1)
  22532. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  22533. * @param fileName A name for for the downloaded file.
  22534. * @constructor
  22535. */
  22536. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  22537. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  22538. /**
  22539. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22540. * Be aware Math.random() could cause collisions, but:
  22541. * "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"
  22542. */
  22543. static RandomId(): string;
  22544. /**
  22545. * Test if the given uri is a base64 string.
  22546. * @param uri The uri to test
  22547. * @return True if the uri is a base64 string or false otherwise.
  22548. */
  22549. static IsBase64(uri: string): boolean;
  22550. /**
  22551. * Decode the given base64 uri.
  22552. * @param uri The uri to decode
  22553. * @return The decoded base64 data.
  22554. */
  22555. static DecodeBase64(uri: string): ArrayBuffer;
  22556. private static _NoneLogLevel;
  22557. private static _MessageLogLevel;
  22558. private static _WarningLogLevel;
  22559. private static _ErrorLogLevel;
  22560. private static _LogCache;
  22561. static errorsCount: number;
  22562. static OnNewCacheEntry: (entry: string) => void;
  22563. static readonly NoneLogLevel: number;
  22564. static readonly MessageLogLevel: number;
  22565. static readonly WarningLogLevel: number;
  22566. static readonly ErrorLogLevel: number;
  22567. static readonly AllLogLevel: number;
  22568. private static _AddLogEntry(entry);
  22569. private static _FormatMessage(message);
  22570. private static _LogDisabled(message);
  22571. private static _LogEnabled(message);
  22572. private static _WarnDisabled(message);
  22573. private static _WarnEnabled(message);
  22574. private static _ErrorDisabled(message);
  22575. private static _ErrorEnabled(message);
  22576. static Log: (message: string) => void;
  22577. static Warn: (message: string) => void;
  22578. static Error: (message: string) => void;
  22579. static readonly LogCache: string;
  22580. static ClearLogCache(): void;
  22581. static LogLevels: number;
  22582. static IsWindowObjectExist(): boolean;
  22583. private static _PerformanceNoneLogLevel;
  22584. private static _PerformanceUserMarkLogLevel;
  22585. private static _PerformanceConsoleLogLevel;
  22586. private static _performance;
  22587. static readonly PerformanceNoneLogLevel: number;
  22588. static readonly PerformanceUserMarkLogLevel: number;
  22589. static readonly PerformanceConsoleLogLevel: number;
  22590. static PerformanceLogLevel: number;
  22591. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  22592. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  22593. static _StartUserMark(counterName: string, condition?: boolean): void;
  22594. static _EndUserMark(counterName: string, condition?: boolean): void;
  22595. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  22596. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  22597. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  22598. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  22599. static readonly Now: number;
  22600. /**
  22601. * This method will return the name of the class used to create the instance of the given object.
  22602. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  22603. * @param object the object to get the class name from
  22604. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  22605. */
  22606. static GetClassName(object: any, isType?: boolean): string;
  22607. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  22608. /**
  22609. * This method will return the name of the full name of the class, including its owning module (if any).
  22610. * 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).
  22611. * @param object the object to get the class name from
  22612. * @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.
  22613. */
  22614. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  22615. /**
  22616. * 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.
  22617. * @param array
  22618. */
  22619. static arrayOrStringFeeder(array: any): (i: number) => number;
  22620. /**
  22621. * Compute the hashCode of a stream of number
  22622. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  22623. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  22624. * @return the hash code computed
  22625. */
  22626. static hashCodeFromStream(feeder: (index: number) => number): number;
  22627. /**
  22628. * Returns a promise that resolves after the given amount of time.
  22629. * @param delay Number of milliseconds to delay
  22630. * @returns Promise that resolves after the given amount of time
  22631. */
  22632. static DelayAsync(delay: number): Promise<void>;
  22633. }
  22634. /**
  22635. * This class is used to track a performance counter which is number based.
  22636. * The user has access to many properties which give statistics of different nature
  22637. *
  22638. * The implementer can track two kinds of Performance Counter: time and count
  22639. * 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.
  22640. * 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.
  22641. */
  22642. class PerfCounter {
  22643. static Enabled: boolean;
  22644. /**
  22645. * Returns the smallest value ever
  22646. */
  22647. readonly min: number;
  22648. /**
  22649. * Returns the biggest value ever
  22650. */
  22651. readonly max: number;
  22652. /**
  22653. * Returns the average value since the performance counter is running
  22654. */
  22655. readonly average: number;
  22656. /**
  22657. * Returns the average value of the last second the counter was monitored
  22658. */
  22659. readonly lastSecAverage: number;
  22660. /**
  22661. * Returns the current value
  22662. */
  22663. readonly current: number;
  22664. readonly total: number;
  22665. readonly count: number;
  22666. constructor();
  22667. /**
  22668. * Call this method to start monitoring a new frame.
  22669. * 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.
  22670. */
  22671. fetchNewFrame(): void;
  22672. /**
  22673. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  22674. * @param newCount the count value to add to the monitored count
  22675. * @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.
  22676. */
  22677. addCount(newCount: number, fetchResult: boolean): void;
  22678. /**
  22679. * Start monitoring this performance counter
  22680. */
  22681. beginMonitoring(): void;
  22682. /**
  22683. * Compute the time lapsed since the previous beginMonitoring() call.
  22684. * @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
  22685. */
  22686. endMonitoring(newFrame?: boolean): void;
  22687. private _fetchResult();
  22688. private _startMonitoringTime;
  22689. private _min;
  22690. private _max;
  22691. private _average;
  22692. private _current;
  22693. private _totalValueCount;
  22694. private _totalAccumulated;
  22695. private _lastSecAverage;
  22696. private _lastSecAccumulated;
  22697. private _lastSecTime;
  22698. private _lastSecValueCount;
  22699. }
  22700. /**
  22701. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  22702. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  22703. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  22704. * @param name The name of the class, case should be preserved
  22705. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  22706. */
  22707. function className(name: string, module?: string): (target: Object) => void;
  22708. /**
  22709. * An implementation of a loop for asynchronous functions.
  22710. */
  22711. class AsyncLoop {
  22712. iterations: number;
  22713. private _fn;
  22714. private _successCallback;
  22715. index: number;
  22716. private _done;
  22717. /**
  22718. * Constroctor.
  22719. * @param iterations the number of iterations.
  22720. * @param _fn the function to run each iteration
  22721. * @param _successCallback the callback that will be called upon succesful execution
  22722. * @param offset starting offset.
  22723. */
  22724. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  22725. /**
  22726. * Execute the next iteration. Must be called after the last iteration was finished.
  22727. */
  22728. executeNext(): void;
  22729. /**
  22730. * Break the loop and run the success callback.
  22731. */
  22732. breakLoop(): void;
  22733. /**
  22734. * Helper function
  22735. */
  22736. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  22737. /**
  22738. * A for-loop that will run a given number of iterations synchronous and the rest async.
  22739. * @param iterations total number of iterations
  22740. * @param syncedIterations number of synchronous iterations in each async iteration.
  22741. * @param fn the function to call each iteration.
  22742. * @param callback a success call back that will be called when iterating stops.
  22743. * @param breakFunction a break condition (optional)
  22744. * @param timeout timeout settings for the setTimeout function. default - 0.
  22745. * @constructor
  22746. */
  22747. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  22748. }
  22749. }
  22750. declare module BABYLON {
  22751. enum JoystickAxis {
  22752. X = 0,
  22753. Y = 1,
  22754. Z = 2,
  22755. }
  22756. class VirtualJoystick {
  22757. reverseLeftRight: boolean;
  22758. reverseUpDown: boolean;
  22759. deltaPosition: Vector3;
  22760. pressed: boolean;
  22761. private static _globalJoystickIndex;
  22762. private static vjCanvas;
  22763. private static vjCanvasContext;
  22764. private static vjCanvasWidth;
  22765. private static vjCanvasHeight;
  22766. private static halfWidth;
  22767. private _action;
  22768. private _axisTargetedByLeftAndRight;
  22769. private _axisTargetedByUpAndDown;
  22770. private _joystickSensibility;
  22771. private _inversedSensibility;
  22772. private _joystickPointerID;
  22773. private _joystickColor;
  22774. private _joystickPointerPos;
  22775. private _joystickPreviousPointerPos;
  22776. private _joystickPointerStartPos;
  22777. private _deltaJoystickVector;
  22778. private _leftJoystick;
  22779. private _touches;
  22780. private _onPointerDownHandlerRef;
  22781. private _onPointerMoveHandlerRef;
  22782. private _onPointerUpHandlerRef;
  22783. private _onResize;
  22784. constructor(leftJoystick?: boolean);
  22785. setJoystickSensibility(newJoystickSensibility: number): void;
  22786. private _onPointerDown(e);
  22787. private _onPointerMove(e);
  22788. private _onPointerUp(e);
  22789. /**
  22790. * Change the color of the virtual joystick
  22791. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  22792. */
  22793. setJoystickColor(newColor: string): void;
  22794. setActionOnTouch(action: () => any): void;
  22795. setAxisForLeftRight(axis: JoystickAxis): void;
  22796. setAxisForUpDown(axis: JoystickAxis): void;
  22797. private _drawVirtualJoystick();
  22798. releaseCanvas(): void;
  22799. }
  22800. }
  22801. declare module BABYLON {
  22802. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  22803. readonly name: string;
  22804. private _zoomStopsAnimation;
  22805. private _idleRotationSpeed;
  22806. private _idleRotationWaitTime;
  22807. private _idleRotationSpinupTime;
  22808. /**
  22809. * Gets the flag that indicates if user zooming should stop animation.
  22810. */
  22811. /**
  22812. * Sets the flag that indicates if user zooming should stop animation.
  22813. */
  22814. zoomStopsAnimation: boolean;
  22815. /**
  22816. * Gets the default speed at which the camera rotates around the model.
  22817. */
  22818. /**
  22819. * Sets the default speed at which the camera rotates around the model.
  22820. */
  22821. idleRotationSpeed: number;
  22822. /**
  22823. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  22824. */
  22825. /**
  22826. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  22827. */
  22828. idleRotationWaitTime: number;
  22829. /**
  22830. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  22831. */
  22832. /**
  22833. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  22834. */
  22835. idleRotationSpinupTime: number;
  22836. /**
  22837. * Gets a value indicating if the camera is currently rotating because of this behavior
  22838. */
  22839. readonly rotationInProgress: boolean;
  22840. private _onPrePointerObservableObserver;
  22841. private _onAfterCheckInputsObserver;
  22842. private _attachedCamera;
  22843. private _isPointerDown;
  22844. private _lastFrameTime;
  22845. private _lastInteractionTime;
  22846. private _cameraRotationSpeed;
  22847. init(): void;
  22848. attach(camera: ArcRotateCamera): void;
  22849. detach(): void;
  22850. /**
  22851. * Returns true if user is scrolling.
  22852. * @return true if user is scrolling.
  22853. */
  22854. private _userIsZooming();
  22855. private _lastFrameRadius;
  22856. private _shouldAnimationStopForInteraction();
  22857. /**
  22858. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  22859. */
  22860. private _applyUserInteraction();
  22861. private _userIsMoving();
  22862. }
  22863. }
  22864. declare module BABYLON {
  22865. /**
  22866. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  22867. */
  22868. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  22869. readonly name: string;
  22870. /**
  22871. * The easing function used by animations
  22872. */
  22873. static EasingFunction: BackEase;
  22874. /**
  22875. * The easing mode used by animations
  22876. */
  22877. static EasingMode: number;
  22878. /**
  22879. * The duration of the animation, in milliseconds
  22880. */
  22881. transitionDuration: number;
  22882. /**
  22883. * Length of the distance animated by the transition when lower radius is reached
  22884. */
  22885. lowerRadiusTransitionRange: number;
  22886. /**
  22887. * Length of the distance animated by the transition when upper radius is reached
  22888. */
  22889. upperRadiusTransitionRange: number;
  22890. private _autoTransitionRange;
  22891. /**
  22892. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  22893. */
  22894. /**
  22895. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  22896. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  22897. */
  22898. autoTransitionRange: boolean;
  22899. private _attachedCamera;
  22900. private _onAfterCheckInputsObserver;
  22901. private _onMeshTargetChangedObserver;
  22902. init(): void;
  22903. attach(camera: ArcRotateCamera): void;
  22904. detach(): void;
  22905. private _radiusIsAnimating;
  22906. private _radiusBounceTransition;
  22907. private _animatables;
  22908. private _cachedWheelPrecision;
  22909. /**
  22910. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  22911. * @param radiusLimit The limit to check against.
  22912. * @return Bool to indicate if at limit.
  22913. */
  22914. private _isRadiusAtLimit(radiusLimit);
  22915. /**
  22916. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  22917. * @param radiusDelta The delta by which to animate to. Can be negative.
  22918. */
  22919. private _applyBoundRadiusAnimation(radiusDelta);
  22920. /**
  22921. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  22922. */
  22923. protected _clearAnimationLocks(): void;
  22924. /**
  22925. * Stops and removes all animations that have been applied to the camera
  22926. */
  22927. stopAllAnimations(): void;
  22928. }
  22929. }
  22930. declare module BABYLON {
  22931. class FramingBehavior implements Behavior<ArcRotateCamera> {
  22932. readonly name: string;
  22933. private _mode;
  22934. private _radiusScale;
  22935. private _positionScale;
  22936. private _defaultElevation;
  22937. private _elevationReturnTime;
  22938. private _elevationReturnWaitTime;
  22939. private _zoomStopsAnimation;
  22940. private _framingTime;
  22941. /**
  22942. * The easing function used by animations
  22943. */
  22944. static EasingFunction: ExponentialEase;
  22945. /**
  22946. * The easing mode used by animations
  22947. */
  22948. static EasingMode: number;
  22949. /**
  22950. * Gets current mode used by the behavior.
  22951. */
  22952. /**
  22953. * Sets the current mode used by the behavior
  22954. */
  22955. mode: number;
  22956. /**
  22957. * Gets the scale applied to the radius
  22958. */
  22959. /**
  22960. * Sets the scale applied to the radius (1 by default)
  22961. */
  22962. radiusScale: number;
  22963. /**
  22964. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  22965. */
  22966. /**
  22967. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  22968. */
  22969. positionScale: number;
  22970. /**
  22971. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  22972. * behaviour is triggered, in radians.
  22973. */
  22974. /**
  22975. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  22976. * behaviour is triggered, in radians.
  22977. */
  22978. defaultElevation: number;
  22979. /**
  22980. * Gets the time (in milliseconds) taken to return to the default beta position.
  22981. * Negative value indicates camera should not return to default.
  22982. */
  22983. /**
  22984. * Sets the time (in milliseconds) taken to return to the default beta position.
  22985. * Negative value indicates camera should not return to default.
  22986. */
  22987. elevationReturnTime: number;
  22988. /**
  22989. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  22990. */
  22991. /**
  22992. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  22993. */
  22994. elevationReturnWaitTime: number;
  22995. /**
  22996. * Gets the flag that indicates if user zooming should stop animation.
  22997. */
  22998. /**
  22999. * Sets the flag that indicates if user zooming should stop animation.
  23000. */
  23001. zoomStopsAnimation: boolean;
  23002. /**
  23003. * Gets the transition time when framing the mesh, in milliseconds
  23004. */
  23005. /**
  23006. * Sets the transition time when framing the mesh, in milliseconds
  23007. */
  23008. framingTime: number;
  23009. private _onPrePointerObservableObserver;
  23010. private _onAfterCheckInputsObserver;
  23011. private _onMeshTargetChangedObserver;
  23012. private _attachedCamera;
  23013. private _isPointerDown;
  23014. private _lastInteractionTime;
  23015. init(): void;
  23016. attach(camera: ArcRotateCamera): void;
  23017. detach(): void;
  23018. private _animatables;
  23019. private _betaIsAnimating;
  23020. private _betaTransition;
  23021. private _radiusTransition;
  23022. private _vectorTransition;
  23023. /**
  23024. * Targets the given mesh and updates zoom level accordingly.
  23025. * @param mesh The mesh to target.
  23026. * @param radius Optional. If a cached radius position already exists, overrides default.
  23027. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23028. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23029. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23030. */
  23031. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23032. /**
  23033. * Targets the given mesh with its children and updates zoom level accordingly.
  23034. * @param mesh The mesh to target.
  23035. * @param radius Optional. If a cached radius position already exists, overrides default.
  23036. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23037. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23038. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23039. */
  23040. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23041. /**
  23042. * Targets the given meshes with their children and updates zoom level accordingly.
  23043. * @param meshes The mesh to target.
  23044. * @param radius Optional. If a cached radius position already exists, overrides default.
  23045. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23046. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23047. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23048. */
  23049. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23050. /**
  23051. * Targets the given mesh and updates zoom level accordingly.
  23052. * @param mesh The mesh to target.
  23053. * @param radius Optional. If a cached radius position already exists, overrides default.
  23054. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23055. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23056. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23057. */
  23058. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23059. /**
  23060. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  23061. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  23062. * frustum width.
  23063. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  23064. * to fully enclose the mesh in the viewing frustum.
  23065. */
  23066. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  23067. /**
  23068. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  23069. * is automatically returned to its default position (expected to be above ground plane).
  23070. */
  23071. private _maintainCameraAboveGround();
  23072. /**
  23073. * Returns the frustum slope based on the canvas ratio and camera FOV
  23074. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  23075. */
  23076. private _getFrustumSlope();
  23077. /**
  23078. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  23079. */
  23080. private _clearAnimationLocks();
  23081. /**
  23082. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  23083. */
  23084. private _applyUserInteraction();
  23085. /**
  23086. * Stops and removes all animations that have been applied to the camera
  23087. */
  23088. stopAllAnimations(): void;
  23089. /**
  23090. * Gets a value indicating if the user is moving the camera
  23091. */
  23092. readonly isUserIsMoving: boolean;
  23093. /**
  23094. * The camera can move all the way towards the mesh.
  23095. */
  23096. static IgnoreBoundsSizeMode: number;
  23097. /**
  23098. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  23099. */
  23100. static FitFrustumSidesMode: number;
  23101. }
  23102. }
  23103. declare module BABYLON {
  23104. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  23105. camera: ArcRotateCamera;
  23106. gamepad: Nullable<Gamepad>;
  23107. private _onGamepadConnectedObserver;
  23108. private _onGamepadDisconnectedObserver;
  23109. gamepadRotationSensibility: number;
  23110. gamepadMoveSensibility: number;
  23111. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23112. detachControl(element: Nullable<HTMLElement>): void;
  23113. checkInputs(): void;
  23114. getClassName(): string;
  23115. getSimpleName(): string;
  23116. }
  23117. }
  23118. declare module BABYLON {
  23119. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  23120. camera: ArcRotateCamera;
  23121. private _keys;
  23122. keysUp: number[];
  23123. keysDown: number[];
  23124. keysLeft: number[];
  23125. keysRight: number[];
  23126. keysReset: number[];
  23127. panningSensibility: number;
  23128. zoomingSensibility: number;
  23129. useAltToZoom: boolean;
  23130. private _ctrlPressed;
  23131. private _altPressed;
  23132. private _onCanvasBlurObserver;
  23133. private _onKeyboardObserver;
  23134. private _engine;
  23135. private _scene;
  23136. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23137. detachControl(element: Nullable<HTMLElement>): void;
  23138. checkInputs(): void;
  23139. getClassName(): string;
  23140. getSimpleName(): string;
  23141. }
  23142. }
  23143. declare module BABYLON {
  23144. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  23145. camera: ArcRotateCamera;
  23146. private _wheel;
  23147. private _observer;
  23148. wheelPrecision: number;
  23149. /**
  23150. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  23151. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  23152. */
  23153. wheelDeltaPercentage: number;
  23154. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23155. detachControl(element: Nullable<HTMLElement>): void;
  23156. getClassName(): string;
  23157. getSimpleName(): string;
  23158. }
  23159. }
  23160. declare module BABYLON {
  23161. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  23162. camera: ArcRotateCamera;
  23163. buttons: number[];
  23164. angularSensibilityX: number;
  23165. angularSensibilityY: number;
  23166. pinchPrecision: number;
  23167. /**
  23168. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  23169. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  23170. */
  23171. pinchDeltaPercentage: number;
  23172. panningSensibility: number;
  23173. multiTouchPanning: boolean;
  23174. multiTouchPanAndZoom: boolean;
  23175. private _isPanClick;
  23176. pinchInwards: boolean;
  23177. private _pointerInput;
  23178. private _observer;
  23179. private _onMouseMove;
  23180. private _onGestureStart;
  23181. private _onGesture;
  23182. private _MSGestureHandler;
  23183. private _onLostFocus;
  23184. private _onContextMenu;
  23185. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23186. detachControl(element: Nullable<HTMLElement>): void;
  23187. getClassName(): string;
  23188. getSimpleName(): string;
  23189. }
  23190. }
  23191. declare module BABYLON {
  23192. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  23193. camera: ArcRotateCamera;
  23194. alphaCorrection: number;
  23195. betaCorrection: number;
  23196. gammaCorrection: number;
  23197. private _alpha;
  23198. private _gamma;
  23199. private _dirty;
  23200. private _deviceOrientationHandler;
  23201. constructor();
  23202. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23203. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  23204. checkInputs(): void;
  23205. detachControl(element: Nullable<HTMLElement>): void;
  23206. getClassName(): string;
  23207. getSimpleName(): string;
  23208. }
  23209. }
  23210. declare module BABYLON {
  23211. /**
  23212. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  23213. * Screen rotation is taken into account.
  23214. */
  23215. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  23216. private _camera;
  23217. private _screenOrientationAngle;
  23218. private _constantTranform;
  23219. private _screenQuaternion;
  23220. private _alpha;
  23221. private _beta;
  23222. private _gamma;
  23223. constructor();
  23224. camera: FreeCamera;
  23225. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23226. private _orientationChanged;
  23227. private _deviceOrientation;
  23228. detachControl(element: Nullable<HTMLElement>): void;
  23229. checkInputs(): void;
  23230. getClassName(): string;
  23231. getSimpleName(): string;
  23232. }
  23233. }
  23234. declare module BABYLON {
  23235. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  23236. camera: FreeCamera;
  23237. gamepad: Nullable<Gamepad>;
  23238. private _onGamepadConnectedObserver;
  23239. private _onGamepadDisconnectedObserver;
  23240. gamepadAngularSensibility: number;
  23241. gamepadMoveSensibility: number;
  23242. private _cameraTransform;
  23243. private _deltaTransform;
  23244. private _vector3;
  23245. private _vector2;
  23246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23247. detachControl(element: Nullable<HTMLElement>): void;
  23248. checkInputs(): void;
  23249. getClassName(): string;
  23250. getSimpleName(): string;
  23251. }
  23252. }
  23253. declare module BABYLON {
  23254. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  23255. camera: FreeCamera;
  23256. private _keys;
  23257. private _onCanvasBlurObserver;
  23258. private _onKeyboardObserver;
  23259. private _engine;
  23260. private _scene;
  23261. keysUp: number[];
  23262. keysDown: number[];
  23263. keysLeft: number[];
  23264. keysRight: number[];
  23265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23266. detachControl(element: Nullable<HTMLElement>): void;
  23267. checkInputs(): void;
  23268. getClassName(): string;
  23269. _onLostFocus(e: FocusEvent): void;
  23270. getSimpleName(): string;
  23271. }
  23272. }
  23273. declare module BABYLON {
  23274. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  23275. touchEnabled: boolean;
  23276. camera: FreeCamera;
  23277. buttons: number[];
  23278. angularSensibility: number;
  23279. private _pointerInput;
  23280. private _onMouseMove;
  23281. private _observer;
  23282. private previousPosition;
  23283. constructor(touchEnabled?: boolean);
  23284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23285. detachControl(element: Nullable<HTMLElement>): void;
  23286. getClassName(): string;
  23287. getSimpleName(): string;
  23288. }
  23289. }
  23290. declare module BABYLON {
  23291. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  23292. camera: FreeCamera;
  23293. private _offsetX;
  23294. private _offsetY;
  23295. private _pointerPressed;
  23296. private _pointerInput;
  23297. private _observer;
  23298. private _onLostFocus;
  23299. touchAngularSensibility: number;
  23300. touchMoveSensibility: number;
  23301. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23302. detachControl(element: Nullable<HTMLElement>): void;
  23303. checkInputs(): void;
  23304. getClassName(): string;
  23305. getSimpleName(): string;
  23306. }
  23307. }
  23308. declare module BABYLON {
  23309. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  23310. camera: FreeCamera;
  23311. private _leftjoystick;
  23312. private _rightjoystick;
  23313. getLeftJoystick(): VirtualJoystick;
  23314. getRightJoystick(): VirtualJoystick;
  23315. checkInputs(): void;
  23316. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23317. detachControl(element: Nullable<HTMLElement>): void;
  23318. getClassName(): string;
  23319. getSimpleName(): string;
  23320. }
  23321. }
  23322. declare module BABYLON {
  23323. class VRCameraMetrics {
  23324. hResolution: number;
  23325. vResolution: number;
  23326. hScreenSize: number;
  23327. vScreenSize: number;
  23328. vScreenCenter: number;
  23329. eyeToScreenDistance: number;
  23330. lensSeparationDistance: number;
  23331. interpupillaryDistance: number;
  23332. distortionK: number[];
  23333. chromaAbCorrection: number[];
  23334. postProcessScaleFactor: number;
  23335. lensCenterOffset: number;
  23336. compensateDistortion: boolean;
  23337. readonly aspectRatio: number;
  23338. readonly aspectRatioFov: number;
  23339. readonly leftHMatrix: Matrix;
  23340. readonly rightHMatrix: Matrix;
  23341. readonly leftPreViewMatrix: Matrix;
  23342. readonly rightPreViewMatrix: Matrix;
  23343. static GetDefault(): VRCameraMetrics;
  23344. }
  23345. }
  23346. declare module BABYLON {
  23347. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  23348. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  23349. getClassName(): string;
  23350. }
  23351. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  23352. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  23353. getClassName(): string;
  23354. }
  23355. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  23356. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  23357. getClassName(): string;
  23358. }
  23359. }
  23360. declare module BABYLON {
  23361. /**
  23362. * Options to modify the vr teleportation behavior.
  23363. */
  23364. interface VRTeleportationOptions {
  23365. /**
  23366. * The name of the mesh which should be used as the teleportation floor. (default: null)
  23367. */
  23368. floorMeshName?: string;
  23369. /**
  23370. * A list of meshes to be used as the teleportation floor. (default: empty)
  23371. */
  23372. floorMeshes?: Mesh[];
  23373. }
  23374. /**
  23375. * Options to modify the vr experience helper's behavior.
  23376. */
  23377. interface VRExperienceHelperOptions extends WebVROptions {
  23378. /**
  23379. * Create a DeviceOrientationCamera to be used as your out of vr camera.
  23380. */
  23381. createDeviceOrientationCamera?: boolean;
  23382. /**
  23383. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found.
  23384. */
  23385. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  23386. }
  23387. /**
  23388. * Helps to quickly add VR support to an existing scene.
  23389. * See http://doc.babylonjs.com/how_to/webvr_helper
  23390. */
  23391. class VRExperienceHelper {
  23392. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  23393. private _scene;
  23394. private _position;
  23395. private _btnVR;
  23396. private _btnVRDisplayed;
  23397. private _webVRsupported;
  23398. private _webVRready;
  23399. private _webVRrequesting;
  23400. private _webVRpresenting;
  23401. private _fullscreenVRpresenting;
  23402. private _canvas;
  23403. private _webVRCamera;
  23404. private _vrDeviceOrientationCamera;
  23405. private _deviceOrientationCamera;
  23406. private _existingCamera;
  23407. private _onKeyDown;
  23408. private _onVrDisplayPresentChange;
  23409. private _onVRDisplayChanged;
  23410. private _onVRRequestPresentStart;
  23411. private _onVRRequestPresentComplete;
  23412. /**
  23413. * Observable raised when entering VR.
  23414. */
  23415. onEnteringVRObservable: Observable<VRExperienceHelper>;
  23416. /**
  23417. * Observable raised when exiting VR.
  23418. */
  23419. onExitingVRObservable: Observable<VRExperienceHelper>;
  23420. /**
  23421. * Observable raised when controller mesh is loaded.
  23422. */
  23423. onControllerMeshLoadedObservable: Observable<WebVRController>;
  23424. /** Return this.onEnteringVRObservable
  23425. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  23426. */
  23427. readonly onEnteringVR: Observable<VRExperienceHelper>;
  23428. /** Return this.onExitingVRObservable
  23429. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  23430. */
  23431. readonly onExitingVR: Observable<VRExperienceHelper>;
  23432. /** Return this.onControllerMeshLoadedObservable
  23433. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  23434. */
  23435. readonly onControllerMeshLoaded: Observable<WebVRController>;
  23436. private _rayLength;
  23437. private _useCustomVRButton;
  23438. private _teleportationRequested;
  23439. private _teleportationEnabledOnLeftController;
  23440. private _teleportationEnabledOnRightController;
  23441. private _interactionsEnabledOnLeftController;
  23442. private _interactionsEnabledOnRightController;
  23443. private _leftControllerReady;
  23444. private _rightControllerReady;
  23445. private _floorMeshName;
  23446. private _floorMeshesCollection;
  23447. private _teleportationAllowed;
  23448. private _rotationAllowed;
  23449. private _teleportationRequestInitiated;
  23450. private _teleportationBackRequestInitiated;
  23451. private teleportBackwardsVector;
  23452. private _rotationRightAsked;
  23453. private _rotationLeftAsked;
  23454. private _teleportationTarget;
  23455. private _isDefaultTeleportationTarget;
  23456. private _postProcessMove;
  23457. private _passProcessMove;
  23458. private _teleportationFillColor;
  23459. private _teleportationBorderColor;
  23460. private _rotationAngle;
  23461. private _haloCenter;
  23462. private _gazeTracker;
  23463. private _padSensibilityUp;
  23464. private _padSensibilityDown;
  23465. private _leftLaserPointer;
  23466. private _rightLaserPointer;
  23467. private _currentMeshSelected;
  23468. /**
  23469. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  23470. */
  23471. onNewMeshSelected: Observable<AbstractMesh>;
  23472. /**
  23473. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  23474. */
  23475. onNewMeshPicked: Observable<PickingInfo>;
  23476. private _circleEase;
  23477. /**
  23478. * Observable raised before camera teleportation
  23479. */
  23480. onBeforeCameraTeleport: Observable<Vector3>;
  23481. /**
  23482. * Observable raised after camera teleportation
  23483. */
  23484. onAfterCameraTeleport: Observable<Vector3>;
  23485. /**
  23486. * Observable raised when current selected mesh gets unselected
  23487. */
  23488. onSelectedMeshUnselected: Observable<AbstractMesh>;
  23489. private _raySelectionPredicate;
  23490. /**
  23491. * To be optionaly changed by user to define custom ray selection
  23492. */
  23493. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  23494. /**
  23495. * To be optionaly changed by user to define custom selection logic (after ray selection)
  23496. */
  23497. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  23498. /**
  23499. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  23500. */
  23501. teleportationEnabled: boolean;
  23502. private _currentHit;
  23503. private _pointerDownOnMeshAsked;
  23504. private _isActionableMesh;
  23505. private _defaultHeight;
  23506. private _teleportationInitialized;
  23507. private _interactionsEnabled;
  23508. private _interactionsRequested;
  23509. private _displayGaze;
  23510. private _displayLaserPointer;
  23511. private _dpadPressed;
  23512. /**
  23513. * The mesh used to display where the user is going to teleport.
  23514. */
  23515. /**
  23516. * Sets the mesh to be used to display where the user is going to teleport.
  23517. */
  23518. teleportationTarget: Mesh;
  23519. /**
  23520. * The mesh used to display where the user is selecting.
  23521. */
  23522. /**
  23523. * Sets the mesh to be used to display where the user is selecting.
  23524. */
  23525. gazeTrackerMesh: Mesh;
  23526. /**
  23527. * If the ray of the gaze should be displayed.
  23528. */
  23529. /**
  23530. * Sets if the ray of the gaze should be displayed.
  23531. */
  23532. displayGaze: boolean;
  23533. /**
  23534. * If the ray of the LaserPointer should be displayed.
  23535. */
  23536. /**
  23537. * Sets if the ray of the LaserPointer should be displayed.
  23538. */
  23539. displayLaserPointer: boolean;
  23540. /**
  23541. * The deviceOrientationCamera used as the camera when not in VR.
  23542. */
  23543. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  23544. /**
  23545. * Based on the current WebVR support, returns the current VR camera used.
  23546. */
  23547. readonly currentVRCamera: Nullable<Camera>;
  23548. /**
  23549. * The webVRCamera which is used when in VR.
  23550. */
  23551. readonly webVRCamera: WebVRFreeCamera;
  23552. /**
  23553. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  23554. */
  23555. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  23556. /**
  23557. * Instantiates a VRExperienceHelper.
  23558. * Helps to quickly add VR support to an existing scene.
  23559. * @param scene The scene the VRExperienceHelper belongs to.
  23560. * @param webVROptions Options to modify the vr experience helper's behavior.
  23561. */
  23562. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  23563. private _onDefaultMeshLoaded(webVRController);
  23564. private _onResize;
  23565. private _onFullscreenChange;
  23566. /**
  23567. * Gets a value indicating if we are currently in VR mode.
  23568. */
  23569. readonly isInVRMode: boolean;
  23570. private onVrDisplayPresentChange();
  23571. private onVRDisplayChanged(eventArgs);
  23572. private moveButtonToBottomRight();
  23573. private displayVRButton();
  23574. private updateButtonVisibility();
  23575. /**
  23576. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  23577. * Otherwise, will use the fullscreen API.
  23578. */
  23579. enterVR(): void;
  23580. /**
  23581. * Attempt to exit VR, or fullscreen.
  23582. */
  23583. exitVR(): void;
  23584. /**
  23585. * The position of the vr experience helper.
  23586. */
  23587. /**
  23588. * Sets the position of the vr experience helper.
  23589. */
  23590. position: Vector3;
  23591. /**
  23592. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  23593. */
  23594. enableInteractions(): void;
  23595. private beforeRender;
  23596. private _isTeleportationFloor(mesh);
  23597. /**
  23598. * Adds a floor mesh to be used for teleportation.
  23599. * @param floorMesh the mesh to be used for teleportation.
  23600. */
  23601. addFloorMesh(floorMesh: Mesh): void;
  23602. /**
  23603. * Removes a floor mesh from being used for teleportation.
  23604. * @param floorMesh the mesh to be removed.
  23605. */
  23606. removeFloorMesh(floorMesh: Mesh): void;
  23607. /**
  23608. * Enables interactions and teleportation using the VR controllers and gaze.
  23609. * @param vrTeleportationOptions options to modify teleportation behavior.
  23610. */
  23611. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  23612. private _onNewGamepadConnected;
  23613. private _tryEnableInteractionOnController;
  23614. private _onNewGamepadDisconnected;
  23615. private _enableInteractionOnController(webVRController);
  23616. private _checkTeleportWithRay(stateObject, webVRController?);
  23617. private _selectionPointerDown();
  23618. private _selectionPointerUp();
  23619. private _checkRotate(stateObject);
  23620. private _checkTeleportBackwards(stateObject);
  23621. private _enableTeleportationOnController(webVRController);
  23622. private _createGazeTracker();
  23623. private _createTeleportationCircles();
  23624. private _displayTeleportationTarget();
  23625. private _hideTeleportationTarget();
  23626. private _rotateCamera(right);
  23627. private _moveTeleportationSelectorTo(hit);
  23628. private _workingVector;
  23629. private _workingQuaternion;
  23630. private _workingMatrix;
  23631. private _teleportCamera(location?);
  23632. private _castRayAndSelectObject();
  23633. private _notifySelectedMeshUnselected();
  23634. /**
  23635. * Sets the color of the laser ray from the vr controllers.
  23636. * @param color new color for the ray.
  23637. */
  23638. changeLaserColor(color: Color3): void;
  23639. /**
  23640. * Sets the color of the ray from the vr headsets gaze.
  23641. * @param color new color for the ray.
  23642. */
  23643. changeGazeColor(color: Color3): void;
  23644. /**
  23645. * Exits VR and disposes of the vr experience helper
  23646. */
  23647. dispose(): void;
  23648. /**
  23649. * Gets the name of the VRExperienceHelper class
  23650. * @returns "VRExperienceHelper"
  23651. */
  23652. getClassName(): string;
  23653. }
  23654. }
  23655. declare var HMDVRDevice: any;
  23656. declare var VRDisplay: any;
  23657. declare var VRFrameData: any;
  23658. declare module BABYLON {
  23659. /**
  23660. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  23661. * IMPORTANT!! The data is right-hand data.
  23662. * @export
  23663. * @interface DevicePose
  23664. */
  23665. interface DevicePose {
  23666. /**
  23667. * The position of the device, values in array are [x,y,z].
  23668. */
  23669. readonly position?: Float32Array;
  23670. /**
  23671. * The linearVelocity of the device, values in array are [x,y,z].
  23672. */
  23673. readonly linearVelocity?: Float32Array;
  23674. /**
  23675. * The linearAcceleration of the device, values in array are [x,y,z].
  23676. */
  23677. readonly linearAcceleration?: Float32Array;
  23678. /**
  23679. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  23680. */
  23681. readonly orientation?: Float32Array;
  23682. /**
  23683. * The angularVelocity of the device, values in array are [x,y,z].
  23684. */
  23685. readonly angularVelocity?: Float32Array;
  23686. /**
  23687. * The angularAcceleration of the device, values in array are [x,y,z].
  23688. */
  23689. readonly angularAcceleration?: Float32Array;
  23690. }
  23691. /**
  23692. * Interface representing a pose controlled object in Babylon.
  23693. * A pose controlled object has both regular pose values as well as pose values
  23694. * from an external device such as a VR head mounted display
  23695. */
  23696. interface PoseControlled {
  23697. /**
  23698. * The position of the object in babylon space.
  23699. */
  23700. position: Vector3;
  23701. /**
  23702. * The rotation quaternion of the object in babylon space.
  23703. */
  23704. rotationQuaternion: Quaternion;
  23705. /**
  23706. * The position of the device in babylon space.
  23707. */
  23708. devicePosition?: Vector3;
  23709. /**
  23710. * The rotation quaternion of the device in babylon space.
  23711. */
  23712. deviceRotationQuaternion: Quaternion;
  23713. /**
  23714. * The raw pose coming from the device.
  23715. */
  23716. rawPose: Nullable<DevicePose>;
  23717. /**
  23718. * The scale of the device to be used when translating from device space to babylon space.
  23719. */
  23720. deviceScaleFactor: number;
  23721. /**
  23722. * Updates the poseControlled values based on the input device pose.
  23723. * @param poseData the pose data to update the object with
  23724. */
  23725. updateFromDevice(poseData: DevicePose): void;
  23726. }
  23727. /**
  23728. * Set of options to customize the webVRCamera
  23729. */
  23730. interface WebVROptions {
  23731. /**
  23732. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  23733. */
  23734. trackPosition?: boolean;
  23735. /**
  23736. * Sets the scale of the vrDevice in babylon space. (default: 1)
  23737. */
  23738. positionScale?: number;
  23739. /**
  23740. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  23741. */
  23742. displayName?: string;
  23743. /**
  23744. * Should the native controller meshes be initialized. (default: true)
  23745. */
  23746. controllerMeshes?: boolean;
  23747. /**
  23748. * Creating a default HemiLight only on controllers. (default: true)
  23749. */
  23750. defaultLightingOnControllers?: boolean;
  23751. /**
  23752. * If you don't want to use the default VR button of the helper. (default: false)
  23753. */
  23754. useCustomVRButton?: boolean;
  23755. /**
  23756. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  23757. */
  23758. customVRButton?: HTMLButtonElement;
  23759. /**
  23760. * To change the length of the ray for gaze/controllers. (default: 100)
  23761. */
  23762. rayLength?: number;
  23763. /**
  23764. * To change the default offset from the ground to account for user's height. (default: 1.7)
  23765. */
  23766. defaultHeight?: number;
  23767. }
  23768. /**
  23769. * This represents a WebVR camera.
  23770. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  23771. * @example http://doc.babylonjs.com/how_to/webvr_camera
  23772. */
  23773. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  23774. private webVROptions;
  23775. /**
  23776. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  23777. */
  23778. _vrDevice: any;
  23779. /**
  23780. * The rawPose of the vrDevice.
  23781. */
  23782. rawPose: Nullable<DevicePose>;
  23783. private _onVREnabled;
  23784. private _specsVersion;
  23785. private _attached;
  23786. private _frameData;
  23787. protected _descendants: Array<Node>;
  23788. private _deviceRoomPosition;
  23789. private _deviceRoomRotationQuaternion;
  23790. private _standingMatrix;
  23791. /**
  23792. * Represents device position in babylon space.
  23793. */
  23794. devicePosition: Vector3;
  23795. /**
  23796. * Represents device rotation in babylon space.
  23797. */
  23798. deviceRotationQuaternion: Quaternion;
  23799. /**
  23800. * The scale of the device to be used when translating from device space to babylon space.
  23801. */
  23802. deviceScaleFactor: number;
  23803. private _deviceToWorld;
  23804. private _worldToDevice;
  23805. /**
  23806. * References to the webVR controllers for the vrDevice.
  23807. */
  23808. controllers: Array<WebVRController>;
  23809. /**
  23810. * Emits an event when a controller is attached.
  23811. */
  23812. onControllersAttachedObservable: Observable<WebVRController[]>;
  23813. /**
  23814. * Emits an event when a controller's mesh has been loaded;
  23815. */
  23816. onControllerMeshLoadedObservable: Observable<WebVRController>;
  23817. /**
  23818. * If the rig cameras be used as parent instead of this camera.
  23819. */
  23820. rigParenting: boolean;
  23821. private _lightOnControllers;
  23822. private _defaultHeight?;
  23823. /**
  23824. * Instantiates a WebVRFreeCamera.
  23825. * @param name The name of the WebVRFreeCamera
  23826. * @param position The starting anchor position for the camera
  23827. * @param scene The scene the camera belongs to
  23828. * @param webVROptions a set of customizable options for the webVRCamera
  23829. */
  23830. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  23831. /**
  23832. * Gets the device distance from the ground.
  23833. * @returns the distance from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  23834. */
  23835. deviceDistanceToRoomGround(): number;
  23836. /**
  23837. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  23838. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  23839. */
  23840. useStandingMatrix(callback?: (bool: boolean) => void): void;
  23841. /**
  23842. * Disposes the camera
  23843. */
  23844. dispose(): void;
  23845. /**
  23846. * Gets a vrController by name.
  23847. * @param name The name of the controller to retreive
  23848. * @returns the controller matching the name specified or null if not found
  23849. */
  23850. getControllerByName(name: string): Nullable<WebVRController>;
  23851. private _leftController;
  23852. /**
  23853. * The controller corrisponding to the users left hand.
  23854. */
  23855. readonly leftController: Nullable<WebVRController>;
  23856. private _rightController;
  23857. /**
  23858. * The controller corrisponding to the users right hand.
  23859. */
  23860. readonly rightController: Nullable<WebVRController>;
  23861. /**
  23862. * Casts a ray forward from the vrCamera's gaze.
  23863. * @param length Length of the ray (default: 100)
  23864. * @returns the ray corrisponding to the gaze
  23865. */
  23866. getForwardRay(length?: number): Ray;
  23867. /**
  23868. * Updates the camera based on device's frame data
  23869. */
  23870. _checkInputs(): void;
  23871. /**
  23872. * Updates the poseControlled values based on the input device pose.
  23873. * @param poseData Pose coming from the device
  23874. */
  23875. updateFromDevice(poseData: DevicePose): void;
  23876. /**
  23877. * WebVR's attach control will start broadcasting frames to the device.
  23878. * Note that in certain browsers (chrome for example) this function must be called
  23879. * within a user-interaction callback. Example:
  23880. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  23881. *
  23882. * @param element html element to attach the vrDevice to
  23883. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  23884. */
  23885. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23886. /**
  23887. * Detaches the camera from the html element and disables VR
  23888. *
  23889. * @param element html element to detach from
  23890. */
  23891. detachControl(element: HTMLElement): void;
  23892. /**
  23893. * @returns the name of this class
  23894. */
  23895. getClassName(): string;
  23896. /**
  23897. * Calls resetPose on the vrDisplay
  23898. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  23899. */
  23900. resetToCurrentRotation(): void;
  23901. /**
  23902. * Updates the rig cameras (left and right eye)
  23903. */
  23904. _updateRigCameras(): void;
  23905. private _workingVector;
  23906. private _oneVector;
  23907. private _workingMatrix;
  23908. private updateCacheCalled;
  23909. /**
  23910. * Updates the cached values of the camera
  23911. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  23912. */
  23913. _updateCache(ignoreParentClass?: boolean): void;
  23914. /**
  23915. * Updates the current device position and rotation in the babylon world
  23916. */
  23917. update(): void;
  23918. /**
  23919. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  23920. * @returns an identity matrix
  23921. */
  23922. _getViewMatrix(): Matrix;
  23923. /**
  23924. * This function is called by the two RIG cameras.
  23925. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  23926. */
  23927. protected _getWebVRViewMatrix(): Matrix;
  23928. protected _getWebVRProjectionMatrix(): Matrix;
  23929. private _onGamepadConnectedObserver;
  23930. private _onGamepadDisconnectedObserver;
  23931. /**
  23932. * Initializes the controllers and their meshes
  23933. */
  23934. initControllers(): void;
  23935. }
  23936. }
  23937. declare module BABYLON {
  23938. interface IOctreeContainer<T> {
  23939. blocks: Array<OctreeBlock<T>>;
  23940. }
  23941. class Octree<T> {
  23942. maxDepth: number;
  23943. blocks: Array<OctreeBlock<T>>;
  23944. dynamicContent: T[];
  23945. private _maxBlockCapacity;
  23946. private _selectionContent;
  23947. private _creationFunc;
  23948. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  23949. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  23950. addMesh(entry: T): void;
  23951. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  23952. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  23953. intersectsRay(ray: Ray): SmartArray<T>;
  23954. 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;
  23955. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  23956. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  23957. }
  23958. }
  23959. declare module BABYLON {
  23960. class OctreeBlock<T> {
  23961. entries: T[];
  23962. blocks: Array<OctreeBlock<T>>;
  23963. private _depth;
  23964. private _maxDepth;
  23965. private _capacity;
  23966. private _minPoint;
  23967. private _maxPoint;
  23968. private _boundingVectors;
  23969. private _creationFunc;
  23970. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  23971. readonly capacity: number;
  23972. readonly minPoint: Vector3;
  23973. readonly maxPoint: Vector3;
  23974. addEntry(entry: T): void;
  23975. addEntries(entries: T[]): void;
  23976. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  23977. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  23978. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  23979. createInnerBlocks(): void;
  23980. }
  23981. }
  23982. declare module BABYLON {
  23983. class GearVRController extends WebVRController {
  23984. static MODEL_BASE_URL: string;
  23985. static MODEL_FILENAME: string;
  23986. static readonly GAMEPAD_ID_PREFIX: string;
  23987. private readonly _buttonIndexToObservableNameMap;
  23988. constructor(vrGamepad: any);
  23989. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  23990. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  23991. }
  23992. }
  23993. declare module BABYLON {
  23994. class GenericController extends WebVRController {
  23995. static readonly MODEL_BASE_URL: string;
  23996. static readonly MODEL_FILENAME: string;
  23997. constructor(vrGamepad: any);
  23998. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  23999. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24000. }
  24001. }
  24002. declare module BABYLON {
  24003. class OculusTouchController extends WebVRController {
  24004. static MODEL_BASE_URL: string;
  24005. static MODEL_LEFT_FILENAME: string;
  24006. static MODEL_RIGHT_FILENAME: string;
  24007. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  24008. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  24009. constructor(vrGamepad: any);
  24010. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24011. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24012. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24013. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24014. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24015. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24016. }
  24017. }
  24018. declare module BABYLON {
  24019. enum PoseEnabledControllerType {
  24020. VIVE = 0,
  24021. OCULUS = 1,
  24022. WINDOWS = 2,
  24023. GEAR_VR = 3,
  24024. GENERIC = 4,
  24025. }
  24026. interface MutableGamepadButton {
  24027. value: number;
  24028. touched: boolean;
  24029. pressed: boolean;
  24030. }
  24031. interface ExtendedGamepadButton extends GamepadButton {
  24032. readonly pressed: boolean;
  24033. readonly touched: boolean;
  24034. readonly value: number;
  24035. }
  24036. class PoseEnabledControllerHelper {
  24037. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | GenericController;
  24038. }
  24039. class PoseEnabledController extends Gamepad implements PoseControlled {
  24040. private _deviceRoomPosition;
  24041. private _deviceRoomRotationQuaternion;
  24042. devicePosition: Vector3;
  24043. deviceRotationQuaternion: Quaternion;
  24044. deviceScaleFactor: number;
  24045. position: Vector3;
  24046. rotationQuaternion: Quaternion;
  24047. controllerType: PoseEnabledControllerType;
  24048. private _calculatedPosition;
  24049. private _calculatedRotation;
  24050. rawPose: DevicePose;
  24051. _mesh: Nullable<AbstractMesh>;
  24052. private _poseControlledCamera;
  24053. private _leftHandSystemQuaternion;
  24054. _deviceToWorld: Matrix;
  24055. constructor(browserGamepad: any);
  24056. private _workingMatrix;
  24057. update(): void;
  24058. updateFromDevice(poseData: DevicePose): void;
  24059. attachToMesh(mesh: AbstractMesh): void;
  24060. attachToPoseControlledCamera(camera: TargetCamera): void;
  24061. dispose(): void;
  24062. readonly mesh: Nullable<AbstractMesh>;
  24063. getForwardRay(length?: number): Ray;
  24064. }
  24065. }
  24066. declare module BABYLON {
  24067. class ViveController extends WebVRController {
  24068. static MODEL_BASE_URL: string;
  24069. static MODEL_FILENAME: string;
  24070. constructor(vrGamepad: any);
  24071. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24072. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24073. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24074. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24075. /**
  24076. * Vive mapping:
  24077. * 0: touchpad
  24078. * 1: trigger
  24079. * 2: left AND right buttons
  24080. * 3: menu button
  24081. */
  24082. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24083. }
  24084. }
  24085. declare module BABYLON {
  24086. abstract class WebVRController extends PoseEnabledController {
  24087. protected _defaultModel: AbstractMesh;
  24088. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  24089. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24090. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24091. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  24092. onPadValuesChangedObservable: Observable<StickValues>;
  24093. protected _buttons: Array<MutableGamepadButton>;
  24094. private _onButtonStateChange;
  24095. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  24096. pad: StickValues;
  24097. hand: string;
  24098. readonly defaultModel: AbstractMesh;
  24099. constructor(vrGamepad: any);
  24100. update(): void;
  24101. protected abstract handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24102. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24103. private _setButtonValue(newState, currentState, buttonIndex);
  24104. private _changes;
  24105. private _checkChanges(newState, currentState);
  24106. dispose(): void;
  24107. }
  24108. }
  24109. declare module BABYLON {
  24110. class WindowsMotionController extends WebVRController {
  24111. static MODEL_BASE_URL: string;
  24112. static MODEL_LEFT_FILENAME: string;
  24113. static MODEL_RIGHT_FILENAME: string;
  24114. static readonly GAMEPAD_ID_PREFIX: string;
  24115. private static readonly GAMEPAD_ID_PATTERN;
  24116. private _loadedMeshInfo;
  24117. private readonly _mapping;
  24118. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  24119. onTrackpadValuesChangedObservable: Observable<StickValues>;
  24120. trackpad: StickValues;
  24121. constructor(vrGamepad: any);
  24122. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24123. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24124. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24125. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24126. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24127. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  24128. /**
  24129. * Called once per frame by the engine.
  24130. */
  24131. update(): void;
  24132. /**
  24133. * Called once for each button that changed state since the last frame
  24134. * @param buttonIdx Which button index changed
  24135. * @param state New state of the button
  24136. * @param changes Which properties on the state changed since last frame
  24137. */
  24138. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24139. protected lerpButtonTransform(buttonName: string, buttonValue: number): void;
  24140. protected lerpAxisTransform(axis: number, axisValue: number): void;
  24141. /**
  24142. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  24143. * @param scene scene in which to add meshes
  24144. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  24145. */
  24146. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  24147. /**
  24148. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  24149. * can be transformed by button presses and axes values, based on this._mapping.
  24150. *
  24151. * @param scene scene in which the meshes exist
  24152. * @param meshes list of meshes that make up the controller model to process
  24153. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  24154. */
  24155. private processModel(scene, meshes);
  24156. private createMeshInfo(rootNode);
  24157. getForwardRay(length?: number): Ray;
  24158. dispose(): void;
  24159. }
  24160. }
  24161. declare module BABYLON {
  24162. /**
  24163. * Interface to implement to create a shadow generator compatible with BJS.
  24164. */
  24165. interface IShadowGenerator {
  24166. /**
  24167. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  24168. * @returns The render target texture if present otherwise, null
  24169. */
  24170. getShadowMap(): Nullable<RenderTargetTexture>;
  24171. /**
  24172. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  24173. * @returns The render target texture if the shadow map is present otherwise, null
  24174. */
  24175. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  24176. /**
  24177. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  24178. * @param subMesh The submesh we want to render in the shadow map
  24179. * @param useInstances Defines wether will draw in the map using instances
  24180. * @returns true if ready otherwise, false
  24181. */
  24182. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24183. /**
  24184. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  24185. * @param defines Defines of the material we want to update
  24186. * @param lightIndex Index of the light in the enabled light list of the material
  24187. */
  24188. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  24189. /**
  24190. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  24191. * defined in the generator but impacting the effect).
  24192. * It implies the unifroms available on the materials are the standard BJS ones.
  24193. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  24194. * @param effect The effect we are binfing the information for
  24195. */
  24196. bindShadowLight(lightIndex: string, effect: Effect): void;
  24197. /**
  24198. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  24199. * (eq to shadow prjection matrix * light transform matrix)
  24200. * @returns The transform matrix used to create the shadow map
  24201. */
  24202. getTransformMatrix(): Matrix;
  24203. /**
  24204. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  24205. * Cube and 2D textures for instance.
  24206. */
  24207. recreateShadowMap(): void;
  24208. /**
  24209. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  24210. * @param onCompiled Callback triggered at the and of the effects compilation
  24211. * @param options Sets of optional options forcing the compilation with different modes
  24212. */
  24213. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  24214. useInstances: boolean;
  24215. }>): void;
  24216. /**
  24217. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  24218. * @param options Sets of optional options forcing the compilation with different modes
  24219. * @returns A promise that resolves when the compilation completes
  24220. */
  24221. forceCompilationAsync(options?: Partial<{
  24222. useInstances: boolean;
  24223. }>): Promise<void>;
  24224. /**
  24225. * Serializes the shadow generator setup to a json object.
  24226. * @returns The serialized JSON object
  24227. */
  24228. serialize(): any;
  24229. /**
  24230. * Disposes the Shadow map and related Textures and effects.
  24231. */
  24232. dispose(): void;
  24233. }
  24234. /**
  24235. * Default implementation of @see IShadowGenerator.
  24236. * This is the main object responsible of generating shadows in the framework.
  24237. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  24238. */
  24239. class ShadowGenerator implements IShadowGenerator {
  24240. private static _FILTER_NONE;
  24241. private static _FILTER_EXPONENTIALSHADOWMAP;
  24242. private static _FILTER_POISSONSAMPLING;
  24243. private static _FILTER_BLUREXPONENTIALSHADOWMAP;
  24244. private static _FILTER_CLOSEEXPONENTIALSHADOWMAP;
  24245. private static _FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  24246. /**
  24247. * Shadow generator mode None: no filtering applied.
  24248. */
  24249. static readonly FILTER_NONE: number;
  24250. /**
  24251. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  24252. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  24253. */
  24254. static readonly FILTER_POISSONSAMPLING: number;
  24255. /**
  24256. * Shadow generator mode ESM: Exponential Shadow Mapping.
  24257. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  24258. */
  24259. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  24260. /**
  24261. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  24262. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  24263. */
  24264. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  24265. /**
  24266. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  24267. * edge artifacts on steep falloff.
  24268. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  24269. */
  24270. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  24271. /**
  24272. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  24273. * edge artifacts on steep falloff.
  24274. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  24275. */
  24276. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  24277. private _bias;
  24278. /**
  24279. * Gets the bias: offset applied on the depth preventing acnea.
  24280. */
  24281. /**
  24282. * Sets the bias: offset applied on the depth preventing acnea.
  24283. */
  24284. bias: number;
  24285. private _blurBoxOffset;
  24286. /**
  24287. * Gets the blur box offset: offset applied during the blur pass.
  24288. * Only usefull if useKernelBlur = false
  24289. */
  24290. /**
  24291. * Sets the blur box offset: offset applied during the blur pass.
  24292. * Only usefull if useKernelBlur = false
  24293. */
  24294. blurBoxOffset: number;
  24295. private _blurScale;
  24296. /**
  24297. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  24298. * 2 means half of the size.
  24299. */
  24300. /**
  24301. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  24302. * 2 means half of the size.
  24303. */
  24304. blurScale: number;
  24305. private _blurKernel;
  24306. /**
  24307. * Gets the blur kernel: kernel size of the blur pass.
  24308. * Only usefull if useKernelBlur = true
  24309. */
  24310. /**
  24311. * Sets the blur kernel: kernel size of the blur pass.
  24312. * Only usefull if useKernelBlur = true
  24313. */
  24314. blurKernel: number;
  24315. private _useKernelBlur;
  24316. /**
  24317. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  24318. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  24319. */
  24320. /**
  24321. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  24322. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  24323. */
  24324. useKernelBlur: boolean;
  24325. private _depthScale;
  24326. /**
  24327. * Gets the depth scale used in ESM mode.
  24328. */
  24329. /**
  24330. * Sets the depth scale used in ESM mode.
  24331. * This can override the scale stored on the light.
  24332. */
  24333. depthScale: number;
  24334. private _filter;
  24335. /**
  24336. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  24337. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  24338. */
  24339. /**
  24340. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  24341. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  24342. */
  24343. filter: number;
  24344. /**
  24345. * Gets if the current filter is set to Poisson Sampling aka PCF.
  24346. */
  24347. /**
  24348. * Sets the current filter to Poisson Sampling aka PCF.
  24349. */
  24350. usePoissonSampling: boolean;
  24351. /**
  24352. * Gets if the current filter is set to VSM.
  24353. * DEPRECATED. Should use useExponentialShadowMap instead.
  24354. */
  24355. /**
  24356. * Sets the current filter is to VSM.
  24357. * DEPRECATED. Should use useExponentialShadowMap instead.
  24358. */
  24359. useVarianceShadowMap: boolean;
  24360. /**
  24361. * Gets if the current filter is set to blurred VSM.
  24362. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  24363. */
  24364. /**
  24365. * Sets the current filter is to blurred VSM.
  24366. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  24367. */
  24368. useBlurVarianceShadowMap: boolean;
  24369. /**
  24370. * Gets if the current filter is set to ESM.
  24371. */
  24372. /**
  24373. * Sets the current filter is to ESM.
  24374. */
  24375. useExponentialShadowMap: boolean;
  24376. /**
  24377. * Gets if the current filter is set to filtered ESM.
  24378. */
  24379. /**
  24380. * Gets if the current filter is set to filtered ESM.
  24381. */
  24382. useBlurExponentialShadowMap: boolean;
  24383. /**
  24384. * Gets if the current filter is set to "close ESM" (using the inverse of the
  24385. * exponential to prevent steep falloff artifacts).
  24386. */
  24387. /**
  24388. * Sets the current filter to "close ESM" (using the inverse of the
  24389. * exponential to prevent steep falloff artifacts).
  24390. */
  24391. useCloseExponentialShadowMap: boolean;
  24392. /**
  24393. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  24394. * exponential to prevent steep falloff artifacts).
  24395. */
  24396. /**
  24397. * Sets the current filter to fileterd "close ESM" (using the inverse of the
  24398. * exponential to prevent steep falloff artifacts).
  24399. */
  24400. useBlurCloseExponentialShadowMap: boolean;
  24401. private _darkness;
  24402. /**
  24403. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  24404. * 0 means strongest and 1 would means no shadow.
  24405. * @returns the darkness.
  24406. */
  24407. getDarkness(): number;
  24408. /**
  24409. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  24410. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  24411. * @returns the shadow generator allowing fluent coding.
  24412. */
  24413. setDarkness(darkness: number): ShadowGenerator;
  24414. private _transparencyShadow;
  24415. /**
  24416. * Sets the ability to have transparent shadow (boolean).
  24417. * @param transparent True if transparent else False
  24418. * @returns the shadow generator allowing fluent coding
  24419. */
  24420. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  24421. private _shadowMap;
  24422. private _shadowMap2;
  24423. /**
  24424. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  24425. * @returns The render target texture if present otherwise, null
  24426. */
  24427. getShadowMap(): Nullable<RenderTargetTexture>;
  24428. /**
  24429. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  24430. * @returns The render target texture if the shadow map is present otherwise, null
  24431. */
  24432. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  24433. /**
  24434. * Helper function to add a mesh and its descendants to the list of shadow casters.
  24435. * @param mesh Mesh to add
  24436. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  24437. * @returns the Shadow Generator itself
  24438. */
  24439. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  24440. /**
  24441. * Helper function to remove a mesh and its descendants from the list of shadow casters
  24442. * @param mesh Mesh to remove
  24443. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  24444. * @returns the Shadow Generator itself
  24445. */
  24446. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  24447. /**
  24448. * Controls the extent to which the shadows fade out at the edge of the frustum
  24449. * Used only by directionals and spots
  24450. */
  24451. frustumEdgeFalloff: number;
  24452. private _light;
  24453. /**
  24454. * Returns the associated light object.
  24455. * @returns the light generating the shadow
  24456. */
  24457. getLight(): IShadowLight;
  24458. /**
  24459. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  24460. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  24461. * It might on the other hand introduce peter panning.
  24462. */
  24463. forceBackFacesOnly: boolean;
  24464. private _scene;
  24465. private _lightDirection;
  24466. private _effect;
  24467. private _viewMatrix;
  24468. private _projectionMatrix;
  24469. private _transformMatrix;
  24470. private _cachedPosition;
  24471. private _cachedDirection;
  24472. private _cachedDefines;
  24473. private _currentRenderID;
  24474. private _boxBlurPostprocess;
  24475. private _kernelBlurXPostprocess;
  24476. private _kernelBlurYPostprocess;
  24477. private _blurPostProcesses;
  24478. private _mapSize;
  24479. private _currentFaceIndex;
  24480. private _currentFaceIndexCache;
  24481. private _textureType;
  24482. private _defaultTextureMatrix;
  24483. /**
  24484. * Creates a ShadowGenerator object.
  24485. * A ShadowGenerator is the required tool to use the shadows.
  24486. * Each light casting shadows needs to use its own ShadowGenerator.
  24487. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  24488. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  24489. * @param light The light object generating the shadows.
  24490. * @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.
  24491. */
  24492. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  24493. private _initializeGenerator();
  24494. private _initializeShadowMap();
  24495. private _initializeBlurRTTAndPostProcesses();
  24496. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  24497. private _renderSubMeshForShadowMap(subMesh);
  24498. private _applyFilterValues();
  24499. /**
  24500. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  24501. * @param onCompiled Callback triggered at the and of the effects compilation
  24502. * @param options Sets of optional options forcing the compilation with different modes
  24503. */
  24504. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  24505. useInstances: boolean;
  24506. }>): void;
  24507. /**
  24508. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  24509. * @param options Sets of optional options forcing the compilation with different modes
  24510. * @returns A promise that resolves when the compilation completes
  24511. */
  24512. forceCompilationAsync(options?: Partial<{
  24513. useInstances: boolean;
  24514. }>): Promise<void>;
  24515. /**
  24516. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  24517. * @param subMesh The submesh we want to render in the shadow map
  24518. * @param useInstances Defines wether will draw in the map using instances
  24519. * @returns true if ready otherwise, false
  24520. */
  24521. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24522. /**
  24523. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  24524. * @param defines Defines of the material we want to update
  24525. * @param lightIndex Index of the light in the enabled light list of the material
  24526. */
  24527. prepareDefines(defines: any, lightIndex: number): void;
  24528. /**
  24529. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  24530. * defined in the generator but impacting the effect).
  24531. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  24532. * @param effect The effect we are binfing the information for
  24533. */
  24534. bindShadowLight(lightIndex: string, effect: Effect): void;
  24535. /**
  24536. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  24537. * (eq to shadow prjection matrix * light transform matrix)
  24538. * @returns The transform matrix used to create the shadow map
  24539. */
  24540. getTransformMatrix(): Matrix;
  24541. /**
  24542. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  24543. * Cube and 2D textures for instance.
  24544. */
  24545. recreateShadowMap(): void;
  24546. private _disposeBlurPostProcesses();
  24547. private _disposeRTTandPostProcesses();
  24548. /**
  24549. * Disposes the ShadowGenerator.
  24550. * Returns nothing.
  24551. */
  24552. dispose(): void;
  24553. /**
  24554. * Serializes the shadow generator setup to a json object.
  24555. * @returns The serialized JSON object
  24556. */
  24557. serialize(): any;
  24558. /**
  24559. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  24560. * @param parsedShadowGenerator The JSON object to parse
  24561. * @param scene The scene to create the shadow map for
  24562. * @returns The parsed shadow generator
  24563. */
  24564. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  24565. }
  24566. }
  24567. declare module BABYLON {
  24568. }
  24569. declare module BABYLON {
  24570. /**
  24571. * Background material used to create an efficient environement around your scene.
  24572. */
  24573. class BackgroundMaterial extends PushMaterial {
  24574. /**
  24575. * Standard reflectance value at parallel view angle.
  24576. */
  24577. static StandardReflectance0: number;
  24578. /**
  24579. * Standard reflectance value at grazing angle.
  24580. */
  24581. static StandardReflectance90: number;
  24582. protected _primaryColor: Color3;
  24583. /**
  24584. * Key light Color (multiply against the R channel of the environement texture)
  24585. */
  24586. primaryColor: Color3;
  24587. protected _primaryLevel: float;
  24588. /**
  24589. * Key light Level (allowing HDR output of the background)
  24590. */
  24591. primaryLevel: float;
  24592. protected _secondaryColor: Color3;
  24593. /**
  24594. * Secondary light Color (multiply against the G channel of the environement texture)
  24595. */
  24596. secondaryColor: Color3;
  24597. protected _secondaryLevel: float;
  24598. /**
  24599. * Secondary light Level (allowing HDR output of the background)
  24600. */
  24601. secondaryLevel: float;
  24602. protected _tertiaryColor: Color3;
  24603. /**
  24604. * Tertiary light Color (multiply against the B channel of the environement texture)
  24605. */
  24606. tertiaryColor: Color3;
  24607. protected _tertiaryLevel: float;
  24608. /**
  24609. * Tertiary light Level (allowing HDR output of the background)
  24610. */
  24611. tertiaryLevel: float;
  24612. protected _reflectionTexture: Nullable<BaseTexture>;
  24613. /**
  24614. * Reflection Texture used in the material.
  24615. * Should be author in a specific way for the best result (refer to the documentation).
  24616. */
  24617. reflectionTexture: Nullable<BaseTexture>;
  24618. protected _reflectionBlur: float;
  24619. /**
  24620. * Reflection Texture level of blur.
  24621. *
  24622. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  24623. * texture twice.
  24624. */
  24625. reflectionBlur: float;
  24626. protected _diffuseTexture: Nullable<BaseTexture>;
  24627. /**
  24628. * Diffuse Texture used in the material.
  24629. * Should be author in a specific way for the best result (refer to the documentation).
  24630. */
  24631. diffuseTexture: Nullable<BaseTexture>;
  24632. protected _shadowLights: Nullable<IShadowLight[]>;
  24633. /**
  24634. * Specify the list of lights casting shadow on the material.
  24635. * All scene shadow lights will be included if null.
  24636. */
  24637. shadowLights: Nullable<IShadowLight[]>;
  24638. protected _shadowBlurScale: int;
  24639. /**
  24640. * For the lights having a blurred shadow generator, this can add a second blur pass in order to reach
  24641. * soft lighting on the background.
  24642. */
  24643. shadowBlurScale: int;
  24644. protected _shadowLevel: float;
  24645. /**
  24646. * Helps adjusting the shadow to a softer level if required.
  24647. * 0 means black shadows and 1 means no shadows.
  24648. */
  24649. shadowLevel: float;
  24650. protected _sceneCenter: Vector3;
  24651. /**
  24652. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  24653. * It is usually zero but might be interesting to modify according to your setup.
  24654. */
  24655. sceneCenter: Vector3;
  24656. protected _opacityFresnel: boolean;
  24657. /**
  24658. * This helps specifying that the material is falling off to the sky box at grazing angle.
  24659. * This helps ensuring a nice transition when the camera goes under the ground.
  24660. */
  24661. opacityFresnel: boolean;
  24662. protected _reflectionFresnel: boolean;
  24663. /**
  24664. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  24665. * This helps adding a mirror texture on the ground.
  24666. */
  24667. reflectionFresnel: boolean;
  24668. protected _reflectionFalloffDistance: number;
  24669. /**
  24670. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  24671. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  24672. */
  24673. reflectionFalloffDistance: number;
  24674. protected _reflectionAmount: number;
  24675. /**
  24676. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  24677. */
  24678. reflectionAmount: number;
  24679. protected _reflectionReflectance0: number;
  24680. /**
  24681. * This specifies the weight of the reflection at grazing angle.
  24682. */
  24683. reflectionReflectance0: number;
  24684. protected _reflectionReflectance90: number;
  24685. /**
  24686. * This specifies the weight of the reflection at a perpendicular point of view.
  24687. */
  24688. reflectionReflectance90: number;
  24689. /**
  24690. * Sets the reflection reflectance fresnel values according to the default standard
  24691. * empirically know to work well :-)
  24692. */
  24693. reflectionStandardFresnelWeight: number;
  24694. protected _useRGBColor: boolean;
  24695. /**
  24696. * Helps to directly use the maps channels instead of their level.
  24697. */
  24698. useRGBColor: boolean;
  24699. protected _enableNoise: boolean;
  24700. /**
  24701. * This helps reducing the banding effect that could occur on the background.
  24702. */
  24703. enableNoise: boolean;
  24704. /**
  24705. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  24706. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  24707. * Recommended to be keep at 1.0 except for special cases.
  24708. */
  24709. fovMultiplier: number;
  24710. private _fovMultiplier;
  24711. /**
  24712. * Enable the FOV adjustment feature controlled by fovMultiplier.
  24713. * @type {boolean}
  24714. */
  24715. useEquirectangularFOV: boolean;
  24716. private _maxSimultaneousLights;
  24717. /**
  24718. * Number of Simultaneous lights allowed on the material.
  24719. */
  24720. maxSimultaneousLights: int;
  24721. /**
  24722. * Default configuration related to image processing available in the Background Material.
  24723. */
  24724. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24725. /**
  24726. * Keep track of the image processing observer to allow dispose and replace.
  24727. */
  24728. private _imageProcessingObserver;
  24729. /**
  24730. * Attaches a new image processing configuration to the PBR Material.
  24731. * @param configuration (if null the scene configuration will be use)
  24732. */
  24733. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24734. /**
  24735. * Gets the image processing configuration used either in this material.
  24736. */
  24737. /**
  24738. * Sets the Default image processing configuration used either in the this material.
  24739. *
  24740. * If sets to null, the scene one is in use.
  24741. */
  24742. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  24743. /**
  24744. * Gets wether the color curves effect is enabled.
  24745. */
  24746. /**
  24747. * Sets wether the color curves effect is enabled.
  24748. */
  24749. cameraColorCurvesEnabled: boolean;
  24750. /**
  24751. * Gets wether the color grading effect is enabled.
  24752. */
  24753. /**
  24754. * Gets wether the color grading effect is enabled.
  24755. */
  24756. cameraColorGradingEnabled: boolean;
  24757. /**
  24758. * Gets wether tonemapping is enabled or not.
  24759. */
  24760. /**
  24761. * Sets wether tonemapping is enabled or not
  24762. */
  24763. cameraToneMappingEnabled: boolean;
  24764. /**
  24765. * The camera exposure used on this material.
  24766. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24767. * This corresponds to a photographic exposure.
  24768. */
  24769. /**
  24770. * The camera exposure used on this material.
  24771. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24772. * This corresponds to a photographic exposure.
  24773. */
  24774. cameraExposure: float;
  24775. /**
  24776. * Gets The camera contrast used on this material.
  24777. */
  24778. /**
  24779. * Sets The camera contrast used on this material.
  24780. */
  24781. cameraContrast: float;
  24782. /**
  24783. * Gets the Color Grading 2D Lookup Texture.
  24784. */
  24785. /**
  24786. * Sets the Color Grading 2D Lookup Texture.
  24787. */
  24788. cameraColorGradingTexture: Nullable<BaseTexture>;
  24789. /**
  24790. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24791. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24792. * 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;
  24793. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24794. */
  24795. /**
  24796. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24797. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24798. * 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;
  24799. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24800. */
  24801. cameraColorCurves: Nullable<ColorCurves>;
  24802. private _renderTargets;
  24803. private _reflectionControls;
  24804. /**
  24805. * Instantiates a Background Material in the given scene
  24806. * @param name The friendly name of the material
  24807. * @param scene The scene to add the material to
  24808. */
  24809. constructor(name: string, scene: Scene);
  24810. /**
  24811. * The entire material has been created in order to prevent overdraw.
  24812. * @returns false
  24813. */
  24814. needAlphaTesting(): boolean;
  24815. /**
  24816. * The entire material has been created in order to prevent overdraw.
  24817. * @returns true if blending is enable
  24818. */
  24819. needAlphaBlending(): boolean;
  24820. /**
  24821. * Checks wether the material is ready to be rendered for a given mesh.
  24822. * @param mesh The mesh to render
  24823. * @param subMesh The submesh to check against
  24824. * @param useInstances Specify wether or not the material is used with instances
  24825. * @returns true if all the dependencies are ready (Textures, Effects...)
  24826. */
  24827. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24828. /**
  24829. * Build the uniform buffer used in the material.
  24830. */
  24831. buildUniformLayout(): void;
  24832. /**
  24833. * Unbind the material.
  24834. */
  24835. unbind(): void;
  24836. /**
  24837. * Bind only the world matrix to the material.
  24838. * @param world The world matrix to bind.
  24839. */
  24840. bindOnlyWorldMatrix(world: Matrix): void;
  24841. /**
  24842. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  24843. * @param world The world matrix to bind.
  24844. * @param subMesh The submesh to bind for.
  24845. */
  24846. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24847. /**
  24848. * Dispose the material.
  24849. * @param forceDisposeEffect Force disposal of the associated effect.
  24850. * @param forceDisposeTextures Force disposal of the associated textures.
  24851. */
  24852. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  24853. /**
  24854. * Clones the material.
  24855. * @param name The cloned name.
  24856. * @returns The cloned material.
  24857. */
  24858. clone(name: string): BackgroundMaterial;
  24859. /**
  24860. * Serializes the current material to its JSON representation.
  24861. * @returns The JSON representation.
  24862. */
  24863. serialize(): any;
  24864. /**
  24865. * Gets the class name of the material
  24866. * @returns "BackgroundMaterial"
  24867. */
  24868. getClassName(): string;
  24869. /**
  24870. * Parse a JSON input to create back a background material.
  24871. * @param source The JSON data to parse
  24872. * @param scene The scene to create the parsed material in
  24873. * @param rootUrl The root url of the assets the material depends upon
  24874. * @returns the instantiated BackgroundMaterial.
  24875. */
  24876. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  24877. }
  24878. }
  24879. declare module BABYLON {
  24880. /**
  24881. * The Physically based material base class of BJS.
  24882. *
  24883. * This offers the main features of a standard PBR material.
  24884. * For more information, please refer to the documentation :
  24885. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  24886. */
  24887. abstract class PBRBaseMaterial extends PushMaterial {
  24888. /**
  24889. * Intensity of the direct lights e.g. the four lights available in your scene.
  24890. * This impacts both the direct diffuse and specular highlights.
  24891. */
  24892. protected _directIntensity: number;
  24893. /**
  24894. * Intensity of the emissive part of the material.
  24895. * This helps controlling the emissive effect without modifying the emissive color.
  24896. */
  24897. protected _emissiveIntensity: number;
  24898. /**
  24899. * Intensity of the environment e.g. how much the environment will light the object
  24900. * either through harmonics for rough material or through the refelction for shiny ones.
  24901. */
  24902. protected _environmentIntensity: number;
  24903. /**
  24904. * This is a special control allowing the reduction of the specular highlights coming from the
  24905. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  24906. */
  24907. protected _specularIntensity: number;
  24908. /**
  24909. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  24910. */
  24911. private _lightingInfos;
  24912. /**
  24913. * Debug Control allowing disabling the bump map on this material.
  24914. */
  24915. protected _disableBumpMap: boolean;
  24916. /**
  24917. * AKA Diffuse Texture in standard nomenclature.
  24918. */
  24919. protected _albedoTexture: BaseTexture;
  24920. /**
  24921. * AKA Occlusion Texture in other nomenclature.
  24922. */
  24923. protected _ambientTexture: BaseTexture;
  24924. /**
  24925. * AKA Occlusion Texture Intensity in other nomenclature.
  24926. */
  24927. protected _ambientTextureStrength: number;
  24928. /**
  24929. * Stores the alpha values in a texture.
  24930. */
  24931. protected _opacityTexture: BaseTexture;
  24932. /**
  24933. * Stores the reflection values in a texture.
  24934. */
  24935. protected _reflectionTexture: BaseTexture;
  24936. /**
  24937. * Stores the refraction values in a texture.
  24938. */
  24939. protected _refractionTexture: BaseTexture;
  24940. /**
  24941. * Stores the emissive values in a texture.
  24942. */
  24943. protected _emissiveTexture: BaseTexture;
  24944. /**
  24945. * AKA Specular texture in other nomenclature.
  24946. */
  24947. protected _reflectivityTexture: BaseTexture;
  24948. /**
  24949. * Used to switch from specular/glossiness to metallic/roughness workflow.
  24950. */
  24951. protected _metallicTexture: BaseTexture;
  24952. /**
  24953. * Specifies the metallic scalar of the metallic/roughness workflow.
  24954. * Can also be used to scale the metalness values of the metallic texture.
  24955. */
  24956. protected _metallic: number;
  24957. /**
  24958. * Specifies the roughness scalar of the metallic/roughness workflow.
  24959. * Can also be used to scale the roughness values of the metallic texture.
  24960. */
  24961. protected _roughness: number;
  24962. /**
  24963. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  24964. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  24965. */
  24966. protected _microSurfaceTexture: BaseTexture;
  24967. /**
  24968. * Stores surface normal data used to displace a mesh in a texture.
  24969. */
  24970. protected _bumpTexture: BaseTexture;
  24971. /**
  24972. * Stores the pre-calculated light information of a mesh in a texture.
  24973. */
  24974. protected _lightmapTexture: BaseTexture;
  24975. /**
  24976. * The color of a material in ambient lighting.
  24977. */
  24978. protected _ambientColor: Color3;
  24979. /**
  24980. * AKA Diffuse Color in other nomenclature.
  24981. */
  24982. protected _albedoColor: Color3;
  24983. /**
  24984. * AKA Specular Color in other nomenclature.
  24985. */
  24986. protected _reflectivityColor: Color3;
  24987. /**
  24988. * The color applied when light is reflected from a material.
  24989. */
  24990. protected _reflectionColor: Color3;
  24991. /**
  24992. * The color applied when light is emitted from a material.
  24993. */
  24994. protected _emissiveColor: Color3;
  24995. /**
  24996. * AKA Glossiness in other nomenclature.
  24997. */
  24998. protected _microSurface: number;
  24999. /**
  25000. * source material index of refraction (IOR)' / 'destination material IOR.
  25001. */
  25002. protected _indexOfRefraction: number;
  25003. /**
  25004. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  25005. */
  25006. protected _invertRefractionY: boolean;
  25007. /**
  25008. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25009. * Materials half opaque for instance using refraction could benefit from this control.
  25010. */
  25011. protected _linkRefractionWithTransparency: boolean;
  25012. /**
  25013. * Specifies that the material will use the light map as a show map.
  25014. */
  25015. protected _useLightmapAsShadowmap: boolean;
  25016. /**
  25017. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  25018. * makes the reflect vector face the model (under horizon).
  25019. */
  25020. protected _useHorizonOcclusion: boolean;
  25021. /**
  25022. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  25023. * too much the area relying on ambient texture to define their ambient occlusion.
  25024. */
  25025. protected _useRadianceOcclusion: boolean;
  25026. /**
  25027. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  25028. */
  25029. protected _useAlphaFromAlbedoTexture: boolean;
  25030. /**
  25031. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  25032. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  25033. */
  25034. protected _useSpecularOverAlpha: boolean;
  25035. /**
  25036. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  25037. */
  25038. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  25039. /**
  25040. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  25041. */
  25042. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  25043. /**
  25044. * Specifies if the metallic texture contains the roughness information in its green channel.
  25045. */
  25046. protected _useRoughnessFromMetallicTextureGreen: boolean;
  25047. /**
  25048. * Specifies if the metallic texture contains the metallness information in its blue channel.
  25049. */
  25050. protected _useMetallnessFromMetallicTextureBlue: boolean;
  25051. /**
  25052. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  25053. */
  25054. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  25055. /**
  25056. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  25057. */
  25058. protected _useAmbientInGrayScale: boolean;
  25059. /**
  25060. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  25061. * The material will try to infer what glossiness each pixel should be.
  25062. */
  25063. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  25064. /**
  25065. * BJS is using an harcoded light falloff based on a manually sets up range.
  25066. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  25067. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  25068. */
  25069. protected _usePhysicalLightFalloff: boolean;
  25070. /**
  25071. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  25072. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  25073. */
  25074. protected _useRadianceOverAlpha: boolean;
  25075. /**
  25076. * Allows using an object space normal map (instead of tangent space).
  25077. */
  25078. protected _useObjectSpaceNormalMap: boolean;
  25079. /**
  25080. * Allows using the bump map in parallax mode.
  25081. */
  25082. protected _useParallax: boolean;
  25083. /**
  25084. * Allows using the bump map in parallax occlusion mode.
  25085. */
  25086. protected _useParallaxOcclusion: boolean;
  25087. /**
  25088. * Controls the scale bias of the parallax mode.
  25089. */
  25090. protected _parallaxScaleBias: number;
  25091. /**
  25092. * If sets to true, disables all the lights affecting the material.
  25093. */
  25094. protected _disableLighting: boolean;
  25095. /**
  25096. * Number of Simultaneous lights allowed on the material.
  25097. */
  25098. protected _maxSimultaneousLights: number;
  25099. /**
  25100. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  25101. */
  25102. protected _invertNormalMapX: boolean;
  25103. /**
  25104. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  25105. */
  25106. protected _invertNormalMapY: boolean;
  25107. /**
  25108. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25109. */
  25110. protected _twoSidedLighting: boolean;
  25111. /**
  25112. * Defines the alpha limits in alpha test mode.
  25113. */
  25114. protected _alphaCutOff: number;
  25115. /**
  25116. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25117. */
  25118. protected _forceAlphaTest: boolean;
  25119. /**
  25120. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  25121. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  25122. */
  25123. protected _useAlphaFresnel: boolean;
  25124. /**
  25125. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  25126. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  25127. */
  25128. protected _useLinearAlphaFresnel: boolean;
  25129. /**
  25130. * The transparency mode of the material.
  25131. */
  25132. protected _transparencyMode: Nullable<number>;
  25133. /**
  25134. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  25135. * from cos thetav and roughness:
  25136. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  25137. */
  25138. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  25139. /**
  25140. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  25141. */
  25142. protected _forceIrradianceInFragment: boolean;
  25143. /**
  25144. * Force normal to face away from face.
  25145. */
  25146. protected _forceNormalForward: boolean;
  25147. /**
  25148. * Force metallic workflow.
  25149. */
  25150. protected _forceMetallicWorkflow: boolean;
  25151. /**
  25152. * Default configuration related to image processing available in the PBR Material.
  25153. */
  25154. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25155. /**
  25156. * Keep track of the image processing observer to allow dispose and replace.
  25157. */
  25158. private _imageProcessingObserver;
  25159. /**
  25160. * Attaches a new image processing configuration to the PBR Material.
  25161. * @param configuration
  25162. */
  25163. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25164. /**
  25165. * Stores the available render targets.
  25166. */
  25167. private _renderTargets;
  25168. /**
  25169. * Sets the global ambient color for the material used in lighting calculations.
  25170. */
  25171. private _globalAmbientColor;
  25172. /**
  25173. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  25174. */
  25175. private _useLogarithmicDepth;
  25176. /**
  25177. * Instantiates a new PBRMaterial instance.
  25178. *
  25179. * @param name The material name
  25180. * @param scene The scene the material will be use in.
  25181. */
  25182. constructor(name: string, scene: Scene);
  25183. /**
  25184. * Gets the name of the material class.
  25185. */
  25186. getClassName(): string;
  25187. /**
  25188. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  25189. */
  25190. /**
  25191. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  25192. */
  25193. useLogarithmicDepth: boolean;
  25194. /**
  25195. * Gets the current transparency mode.
  25196. */
  25197. /**
  25198. * Sets the transparency mode of the material.
  25199. */
  25200. transparencyMode: Nullable<number>;
  25201. /**
  25202. * Returns true if alpha blending should be disabled.
  25203. */
  25204. private readonly _disableAlphaBlending;
  25205. /**
  25206. * Specifies whether or not this material should be rendered in alpha blend mode.
  25207. */
  25208. needAlphaBlending(): boolean;
  25209. /**
  25210. * Specifies if the mesh will require alpha blending.
  25211. * @param mesh - BJS mesh.
  25212. */
  25213. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25214. /**
  25215. * Specifies whether or not this material should be rendered in alpha test mode.
  25216. */
  25217. needAlphaTesting(): boolean;
  25218. /**
  25219. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  25220. */
  25221. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  25222. /**
  25223. * Gets the texture used for the alpha test.
  25224. */
  25225. getAlphaTestTexture(): BaseTexture;
  25226. /**
  25227. * Stores the reflectivity values based on metallic roughness workflow.
  25228. */
  25229. private static _scaledReflectivity;
  25230. /**
  25231. * Specifies that the submesh is ready to be used.
  25232. * @param mesh - BJS mesh.
  25233. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  25234. * @param useInstances - Specifies that instances should be used.
  25235. * @returns - boolean indicating that the submesh is ready or not.
  25236. */
  25237. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25238. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  25239. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  25240. /**
  25241. * Force shader compilation
  25242. */
  25243. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  25244. clipPlane: boolean;
  25245. }>): void;
  25246. /**
  25247. * Initializes the uniform buffer layout for the shader.
  25248. */
  25249. buildUniformLayout(): void;
  25250. /**
  25251. * Unbinds the textures.
  25252. */
  25253. unbind(): void;
  25254. /**
  25255. * Binds the submesh data.
  25256. * @param world - The world matrix.
  25257. * @param mesh - The BJS mesh.
  25258. * @param subMesh - A submesh of the BJS mesh.
  25259. */
  25260. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25261. /**
  25262. * Returns the animatable textures.
  25263. * @returns - Array of animatable textures.
  25264. */
  25265. getAnimatables(): IAnimatable[];
  25266. /**
  25267. * Returns the texture used for reflections.
  25268. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  25269. */
  25270. private _getReflectionTexture();
  25271. /**
  25272. * Returns the texture used for refraction or null if none is used.
  25273. * @returns - Refection texture if present. If no refraction texture and refraction
  25274. * is linked with transparency, returns environment texture. Otherwise, returns null.
  25275. */
  25276. private _getRefractionTexture();
  25277. /**
  25278. * Disposes the resources of the material.
  25279. * @param forceDisposeEffect - Forces the disposal of effects.
  25280. * @param forceDisposeTextures - Forces the disposal of all textures.
  25281. */
  25282. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25283. }
  25284. }
  25285. declare module BABYLON {
  25286. /**
  25287. * The Physically based simple base material of BJS.
  25288. *
  25289. * This enables better naming and convention enforcements on top of the pbrMaterial.
  25290. * It is used as the base class for both the specGloss and metalRough conventions.
  25291. */
  25292. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  25293. /**
  25294. * Number of Simultaneous lights allowed on the material.
  25295. */
  25296. maxSimultaneousLights: number;
  25297. /**
  25298. * If sets to true, disables all the lights affecting the material.
  25299. */
  25300. disableLighting: boolean;
  25301. /**
  25302. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  25303. */
  25304. environmentTexture: BaseTexture;
  25305. /**
  25306. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25307. */
  25308. invertNormalMapX: boolean;
  25309. /**
  25310. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25311. */
  25312. invertNormalMapY: boolean;
  25313. /**
  25314. * Normal map used in the model.
  25315. */
  25316. normalTexture: BaseTexture;
  25317. /**
  25318. * Emissivie color used to self-illuminate the model.
  25319. */
  25320. emissiveColor: Color3;
  25321. /**
  25322. * Emissivie texture used to self-illuminate the model.
  25323. */
  25324. emissiveTexture: BaseTexture;
  25325. /**
  25326. * Occlusion Channel Strenght.
  25327. */
  25328. occlusionStrength: number;
  25329. /**
  25330. * Occlusion Texture of the material (adding extra occlusion effects).
  25331. */
  25332. occlusionTexture: BaseTexture;
  25333. /**
  25334. * Defines the alpha limits in alpha test mode.
  25335. */
  25336. alphaCutOff: number;
  25337. /**
  25338. * Gets the current double sided mode.
  25339. */
  25340. /**
  25341. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25342. */
  25343. doubleSided: boolean;
  25344. lightmapTexture: BaseTexture;
  25345. useLightmapAsShadowmap: boolean;
  25346. /**
  25347. * Return the active textures of the material.
  25348. */
  25349. getActiveTextures(): BaseTexture[];
  25350. hasTexture(texture: BaseTexture): boolean;
  25351. /**
  25352. * Instantiates a new PBRMaterial instance.
  25353. *
  25354. * @param name The material name
  25355. * @param scene The scene the material will be use in.
  25356. */
  25357. constructor(name: string, scene: Scene);
  25358. getClassName(): string;
  25359. }
  25360. }
  25361. declare module BABYLON {
  25362. /**
  25363. * The Physically based material of BJS.
  25364. *
  25365. * This offers the main features of a standard PBR material.
  25366. * For more information, please refer to the documentation :
  25367. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  25368. */
  25369. class PBRMaterial extends PBRBaseMaterial {
  25370. private static _PBRMATERIAL_OPAQUE;
  25371. /**
  25372. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25373. */
  25374. static readonly PBRMATERIAL_OPAQUE: number;
  25375. /**
  25376. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25377. */
  25378. private static _PBRMATERIAL_ALPHATEST;
  25379. /**
  25380. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25381. */
  25382. static readonly PBRMATERIAL_ALPHATEST: number;
  25383. /**
  25384. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25385. */
  25386. private static _PBRMATERIAL_ALPHABLEND;
  25387. /**
  25388. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25389. */
  25390. static readonly PBRMATERIAL_ALPHABLEND: number;
  25391. /**
  25392. * 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.
  25393. * They are also discarded below the alpha cutoff threshold to improve performances.
  25394. */
  25395. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  25396. /**
  25397. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25398. * They are also discarded below the alpha cutoff threshold to improve performances.
  25399. */
  25400. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  25401. /**
  25402. * Intensity of the direct lights e.g. the four lights available in your scene.
  25403. * This impacts both the direct diffuse and specular highlights.
  25404. */
  25405. directIntensity: number;
  25406. /**
  25407. * Intensity of the emissive part of the material.
  25408. * This helps controlling the emissive effect without modifying the emissive color.
  25409. */
  25410. emissiveIntensity: number;
  25411. /**
  25412. * Intensity of the environment e.g. how much the environment will light the object
  25413. * either through harmonics for rough material or through the refelction for shiny ones.
  25414. */
  25415. environmentIntensity: number;
  25416. /**
  25417. * This is a special control allowing the reduction of the specular highlights coming from the
  25418. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  25419. */
  25420. specularIntensity: number;
  25421. /**
  25422. * Debug Control allowing disabling the bump map on this material.
  25423. */
  25424. disableBumpMap: boolean;
  25425. /**
  25426. * AKA Diffuse Texture in standard nomenclature.
  25427. */
  25428. albedoTexture: BaseTexture;
  25429. /**
  25430. * AKA Occlusion Texture in other nomenclature.
  25431. */
  25432. ambientTexture: BaseTexture;
  25433. /**
  25434. * AKA Occlusion Texture Intensity in other nomenclature.
  25435. */
  25436. ambientTextureStrength: number;
  25437. /**
  25438. * Stores the alpha values in a texture.
  25439. */
  25440. opacityTexture: BaseTexture;
  25441. /**
  25442. * Stores the reflection values in a texture.
  25443. */
  25444. reflectionTexture: Nullable<BaseTexture>;
  25445. /**
  25446. * Stores the emissive values in a texture.
  25447. */
  25448. emissiveTexture: BaseTexture;
  25449. /**
  25450. * AKA Specular texture in other nomenclature.
  25451. */
  25452. reflectivityTexture: BaseTexture;
  25453. /**
  25454. * Used to switch from specular/glossiness to metallic/roughness workflow.
  25455. */
  25456. metallicTexture: BaseTexture;
  25457. /**
  25458. * Specifies the metallic scalar of the metallic/roughness workflow.
  25459. * Can also be used to scale the metalness values of the metallic texture.
  25460. */
  25461. metallic: number;
  25462. /**
  25463. * Specifies the roughness scalar of the metallic/roughness workflow.
  25464. * Can also be used to scale the roughness values of the metallic texture.
  25465. */
  25466. roughness: number;
  25467. /**
  25468. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  25469. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  25470. */
  25471. microSurfaceTexture: BaseTexture;
  25472. /**
  25473. * Stores surface normal data used to displace a mesh in a texture.
  25474. */
  25475. bumpTexture: BaseTexture;
  25476. /**
  25477. * Stores the pre-calculated light information of a mesh in a texture.
  25478. */
  25479. lightmapTexture: BaseTexture;
  25480. /**
  25481. * Stores the refracted light information in a texture.
  25482. */
  25483. refractionTexture: BaseTexture;
  25484. /**
  25485. * The color of a material in ambient lighting.
  25486. */
  25487. ambientColor: Color3;
  25488. /**
  25489. * AKA Diffuse Color in other nomenclature.
  25490. */
  25491. albedoColor: Color3;
  25492. /**
  25493. * AKA Specular Color in other nomenclature.
  25494. */
  25495. reflectivityColor: Color3;
  25496. /**
  25497. * The color reflected from the material.
  25498. */
  25499. reflectionColor: Color3;
  25500. /**
  25501. * The color emitted from the material.
  25502. */
  25503. emissiveColor: Color3;
  25504. /**
  25505. * AKA Glossiness in other nomenclature.
  25506. */
  25507. microSurface: number;
  25508. /**
  25509. * source material index of refraction (IOR)' / 'destination material IOR.
  25510. */
  25511. indexOfRefraction: number;
  25512. /**
  25513. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  25514. */
  25515. invertRefractionY: boolean;
  25516. /**
  25517. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25518. * Materials half opaque for instance using refraction could benefit from this control.
  25519. */
  25520. linkRefractionWithTransparency: boolean;
  25521. useLightmapAsShadowmap: boolean;
  25522. /**
  25523. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  25524. */
  25525. useAlphaFromAlbedoTexture: boolean;
  25526. /**
  25527. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25528. */
  25529. forceAlphaTest: boolean;
  25530. /**
  25531. * Defines the alpha limits in alpha test mode.
  25532. */
  25533. alphaCutOff: number;
  25534. /**
  25535. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  25536. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  25537. */
  25538. useSpecularOverAlpha: boolean;
  25539. /**
  25540. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  25541. */
  25542. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  25543. /**
  25544. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  25545. */
  25546. useRoughnessFromMetallicTextureAlpha: boolean;
  25547. /**
  25548. * Specifies if the metallic texture contains the roughness information in its green channel.
  25549. */
  25550. useRoughnessFromMetallicTextureGreen: boolean;
  25551. /**
  25552. * Specifies if the metallic texture contains the metallness information in its blue channel.
  25553. */
  25554. useMetallnessFromMetallicTextureBlue: boolean;
  25555. /**
  25556. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  25557. */
  25558. useAmbientOcclusionFromMetallicTextureRed: boolean;
  25559. /**
  25560. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  25561. */
  25562. useAmbientInGrayScale: boolean;
  25563. /**
  25564. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  25565. * The material will try to infer what glossiness each pixel should be.
  25566. */
  25567. useAutoMicroSurfaceFromReflectivityMap: boolean;
  25568. /**
  25569. * BJS is using an harcoded light falloff based on a manually sets up range.
  25570. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  25571. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  25572. */
  25573. usePhysicalLightFalloff: boolean;
  25574. /**
  25575. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  25576. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  25577. */
  25578. useRadianceOverAlpha: boolean;
  25579. /**
  25580. * Allows using an object space normal map (instead of tangent space).
  25581. */
  25582. useObjectSpaceNormalMap: boolean;
  25583. /**
  25584. * Allows using the bump map in parallax mode.
  25585. */
  25586. useParallax: boolean;
  25587. /**
  25588. * Allows using the bump map in parallax occlusion mode.
  25589. */
  25590. useParallaxOcclusion: boolean;
  25591. /**
  25592. * Controls the scale bias of the parallax mode.
  25593. */
  25594. parallaxScaleBias: number;
  25595. /**
  25596. * If sets to true, disables all the lights affecting the material.
  25597. */
  25598. disableLighting: boolean;
  25599. /**
  25600. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  25601. */
  25602. forceIrradianceInFragment: boolean;
  25603. /**
  25604. * Number of Simultaneous lights allowed on the material.
  25605. */
  25606. maxSimultaneousLights: number;
  25607. /**
  25608. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25609. */
  25610. invertNormalMapX: boolean;
  25611. /**
  25612. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25613. */
  25614. invertNormalMapY: boolean;
  25615. /**
  25616. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25617. */
  25618. twoSidedLighting: boolean;
  25619. /**
  25620. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  25621. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  25622. */
  25623. useAlphaFresnel: boolean;
  25624. /**
  25625. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  25626. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  25627. */
  25628. useLinearAlphaFresnel: boolean;
  25629. /**
  25630. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  25631. * And/Or occlude the blended part.
  25632. */
  25633. environmentBRDFTexture: Nullable<BaseTexture>;
  25634. /**
  25635. * Force normal to face away from face.
  25636. */
  25637. forceNormalForward: boolean;
  25638. /**
  25639. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  25640. * makes the reflect vector face the model (under horizon).
  25641. */
  25642. useHorizonOcclusion: boolean;
  25643. /**
  25644. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  25645. * too much the area relying on ambient texture to define their ambient occlusion.
  25646. */
  25647. useRadianceOcclusion: boolean;
  25648. /**
  25649. * Gets the image processing configuration used either in this material.
  25650. */
  25651. /**
  25652. * Sets the Default image processing configuration used either in the this material.
  25653. *
  25654. * If sets to null, the scene one is in use.
  25655. */
  25656. imageProcessingConfiguration: ImageProcessingConfiguration;
  25657. /**
  25658. * Gets wether the color curves effect is enabled.
  25659. */
  25660. /**
  25661. * Sets wether the color curves effect is enabled.
  25662. */
  25663. cameraColorCurvesEnabled: boolean;
  25664. /**
  25665. * Gets wether the color grading effect is enabled.
  25666. */
  25667. /**
  25668. * Gets wether the color grading effect is enabled.
  25669. */
  25670. cameraColorGradingEnabled: boolean;
  25671. /**
  25672. * Gets wether tonemapping is enabled or not.
  25673. */
  25674. /**
  25675. * Sets wether tonemapping is enabled or not
  25676. */
  25677. cameraToneMappingEnabled: boolean;
  25678. /**
  25679. * The camera exposure used on this material.
  25680. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25681. * This corresponds to a photographic exposure.
  25682. */
  25683. /**
  25684. * The camera exposure used on this material.
  25685. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25686. * This corresponds to a photographic exposure.
  25687. */
  25688. cameraExposure: number;
  25689. /**
  25690. * Gets The camera contrast used on this material.
  25691. */
  25692. /**
  25693. * Sets The camera contrast used on this material.
  25694. */
  25695. cameraContrast: number;
  25696. /**
  25697. * Gets the Color Grading 2D Lookup Texture.
  25698. */
  25699. /**
  25700. * Sets the Color Grading 2D Lookup Texture.
  25701. */
  25702. cameraColorGradingTexture: Nullable<BaseTexture>;
  25703. /**
  25704. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25705. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25706. * 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;
  25707. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25708. */
  25709. /**
  25710. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25711. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25712. * 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;
  25713. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25714. */
  25715. cameraColorCurves: Nullable<ColorCurves>;
  25716. /**
  25717. * Instantiates a new PBRMaterial instance.
  25718. *
  25719. * @param name The material name
  25720. * @param scene The scene the material will be use in.
  25721. */
  25722. constructor(name: string, scene: Scene);
  25723. /**
  25724. * Returns the name of this material class.
  25725. */
  25726. getClassName(): string;
  25727. /**
  25728. * Returns an array of the actively used textures.
  25729. * @returns - Array of BaseTextures
  25730. */
  25731. getActiveTextures(): BaseTexture[];
  25732. /**
  25733. * Checks to see if a texture is used in the material.
  25734. * @param texture - Base texture to use.
  25735. * @returns - Boolean specifying if a texture is used in the material.
  25736. */
  25737. hasTexture(texture: BaseTexture): boolean;
  25738. /**
  25739. * Makes a duplicate of the current material.
  25740. * @param name - name to use for the new material.
  25741. */
  25742. clone(name: string): PBRMaterial;
  25743. /**
  25744. * Serializes this PBR Material.
  25745. * @returns - An object with the serialized material.
  25746. */
  25747. serialize(): any;
  25748. /**
  25749. * Parses a PBR Material from a serialized object.
  25750. * @param source - Serialized object.
  25751. * @param scene - BJS scene instance.
  25752. * @param rootUrl - url for the scene object
  25753. * @returns - PBRMaterial
  25754. */
  25755. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  25756. }
  25757. }
  25758. declare module BABYLON {
  25759. /**
  25760. * The PBR material of BJS following the metal roughness convention.
  25761. *
  25762. * This fits to the PBR convention in the GLTF definition:
  25763. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  25764. */
  25765. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  25766. /**
  25767. * The base color has two different interpretations depending on the value of metalness.
  25768. * When the material is a metal, the base color is the specific measured reflectance value
  25769. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  25770. * of the material.
  25771. */
  25772. baseColor: Color3;
  25773. /**
  25774. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  25775. * well as opacity information in the alpha channel.
  25776. */
  25777. baseTexture: BaseTexture;
  25778. /**
  25779. * Specifies the metallic scalar value of the material.
  25780. * Can also be used to scale the metalness values of the metallic texture.
  25781. */
  25782. metallic: number;
  25783. /**
  25784. * Specifies the roughness scalar value of the material.
  25785. * Can also be used to scale the roughness values of the metallic texture.
  25786. */
  25787. roughness: number;
  25788. /**
  25789. * Texture containing both the metallic value in the B channel and the
  25790. * roughness value in the G channel to keep better precision.
  25791. */
  25792. metallicRoughnessTexture: BaseTexture;
  25793. /**
  25794. * Instantiates a new PBRMetalRoughnessMaterial instance.
  25795. *
  25796. * @param name The material name
  25797. * @param scene The scene the material will be use in.
  25798. */
  25799. constructor(name: string, scene: Scene);
  25800. /**
  25801. * Return the currrent class name of the material.
  25802. */
  25803. getClassName(): string;
  25804. /**
  25805. * Return the active textures of the material.
  25806. */
  25807. getActiveTextures(): BaseTexture[];
  25808. /**
  25809. * Checks to see if a texture is used in the material.
  25810. * @param texture - Base texture to use.
  25811. * @returns - Boolean specifying if a texture is used in the material.
  25812. */
  25813. hasTexture(texture: BaseTexture): boolean;
  25814. /**
  25815. * Makes a duplicate of the current material.
  25816. * @param name - name to use for the new material.
  25817. */
  25818. clone(name: string): PBRMetallicRoughnessMaterial;
  25819. /**
  25820. * Serialize the material to a parsable JSON object.
  25821. */
  25822. serialize(): any;
  25823. /**
  25824. * Parses a JSON object correponding to the serialize function.
  25825. */
  25826. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  25827. }
  25828. }
  25829. declare module BABYLON {
  25830. /**
  25831. * The PBR material of BJS following the specular glossiness convention.
  25832. *
  25833. * This fits to the PBR convention in the GLTF definition:
  25834. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  25835. */
  25836. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  25837. /**
  25838. * Specifies the diffuse color of the material.
  25839. */
  25840. diffuseColor: Color3;
  25841. /**
  25842. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  25843. * channel.
  25844. */
  25845. diffuseTexture: BaseTexture;
  25846. /**
  25847. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  25848. */
  25849. specularColor: Color3;
  25850. /**
  25851. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  25852. */
  25853. glossiness: number;
  25854. /**
  25855. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  25856. */
  25857. specularGlossinessTexture: BaseTexture;
  25858. /**
  25859. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  25860. *
  25861. * @param name The material name
  25862. * @param scene The scene the material will be use in.
  25863. */
  25864. constructor(name: string, scene: Scene);
  25865. /**
  25866. * Return the currrent class name of the material.
  25867. */
  25868. getClassName(): string;
  25869. /**
  25870. * Return the active textures of the material.
  25871. */
  25872. getActiveTextures(): BaseTexture[];
  25873. /**
  25874. * Checks to see if a texture is used in the material.
  25875. * @param texture - Base texture to use.
  25876. * @returns - Boolean specifying if a texture is used in the material.
  25877. */
  25878. hasTexture(texture: BaseTexture): boolean;
  25879. /**
  25880. * Makes a duplicate of the current material.
  25881. * @param name - name to use for the new material.
  25882. */
  25883. clone(name: string): PBRSpecularGlossinessMaterial;
  25884. /**
  25885. * Serialize the material to a parsable JSON object.
  25886. */
  25887. serialize(): any;
  25888. /**
  25889. * Parses a JSON object correponding to the serialize function.
  25890. */
  25891. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  25892. }
  25893. }
  25894. declare module BABYLON {
  25895. class BaseTexture {
  25896. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25897. name: string;
  25898. private _hasAlpha;
  25899. hasAlpha: boolean;
  25900. getAlphaFromRGB: boolean;
  25901. level: number;
  25902. coordinatesIndex: number;
  25903. private _coordinatesMode;
  25904. coordinatesMode: number;
  25905. wrapU: number;
  25906. wrapV: number;
  25907. wrapR: number;
  25908. anisotropicFilteringLevel: number;
  25909. isCube: boolean;
  25910. is3D: boolean;
  25911. gammaSpace: boolean;
  25912. invertZ: boolean;
  25913. lodLevelInAlpha: boolean;
  25914. lodGenerationOffset: number;
  25915. lodGenerationScale: number;
  25916. isRenderTarget: boolean;
  25917. readonly uid: string;
  25918. toString(): string;
  25919. getClassName(): string;
  25920. animations: Animation[];
  25921. /**
  25922. * An event triggered when the texture is disposed.
  25923. * @type {BABYLON.Observable}
  25924. */
  25925. onDisposeObservable: Observable<BaseTexture>;
  25926. private _onDisposeObserver;
  25927. onDispose: () => void;
  25928. delayLoadState: number;
  25929. private _scene;
  25930. _texture: Nullable<InternalTexture>;
  25931. private _uid;
  25932. readonly isBlocking: boolean;
  25933. constructor(scene: Nullable<Scene>);
  25934. getScene(): Nullable<Scene>;
  25935. getTextureMatrix(): Matrix;
  25936. getReflectionTextureMatrix(): Matrix;
  25937. getInternalTexture(): Nullable<InternalTexture>;
  25938. isReadyOrNotBlocking(): boolean;
  25939. isReady(): boolean;
  25940. getSize(): ISize;
  25941. getBaseSize(): ISize;
  25942. scale(ratio: number): void;
  25943. readonly canRescale: boolean;
  25944. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  25945. _rebuild(): void;
  25946. delayLoad(): void;
  25947. clone(): Nullable<BaseTexture>;
  25948. readonly textureType: number;
  25949. readonly textureFormat: number;
  25950. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  25951. releaseInternalTexture(): void;
  25952. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25953. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25954. readonly _lodTextureMid: Nullable<BaseTexture>;
  25955. readonly _lodTextureLow: Nullable<BaseTexture>;
  25956. dispose(): void;
  25957. serialize(): any;
  25958. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25959. }
  25960. }
  25961. declare module BABYLON {
  25962. /**
  25963. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  25964. * It can help converting any input color in a desired output one. This can then be used to create effects
  25965. * from sepia, black and white to sixties or futuristic rendering...
  25966. *
  25967. * The only supported format is currently 3dl.
  25968. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  25969. */
  25970. class ColorGradingTexture extends BaseTexture {
  25971. /**
  25972. * The current texture matrix. (will always be identity in color grading texture)
  25973. */
  25974. private _textureMatrix;
  25975. /**
  25976. * The texture URL.
  25977. */
  25978. url: string;
  25979. /**
  25980. * Empty line regex stored for GC.
  25981. */
  25982. private static _noneEmptyLineRegex;
  25983. private _engine;
  25984. /**
  25985. * Instantiates a ColorGradingTexture from the following parameters.
  25986. *
  25987. * @param url The location of the color gradind data (currently only supporting 3dl)
  25988. * @param scene The scene the texture will be used in
  25989. */
  25990. constructor(url: string, scene: Scene);
  25991. /**
  25992. * Returns the texture matrix used in most of the material.
  25993. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  25994. */
  25995. getTextureMatrix(): Matrix;
  25996. /**
  25997. * Occurs when the file being loaded is a .3dl LUT file.
  25998. */
  25999. private load3dlTexture();
  26000. /**
  26001. * Starts the loading process of the texture.
  26002. */
  26003. private loadTexture();
  26004. /**
  26005. * Clones the color gradind texture.
  26006. */
  26007. clone(): ColorGradingTexture;
  26008. /**
  26009. * Called during delayed load for textures.
  26010. */
  26011. delayLoad(): void;
  26012. /**
  26013. * Parses a color grading texture serialized by Babylon.
  26014. * @param parsedTexture The texture information being parsedTexture
  26015. * @param scene The scene to load the texture in
  26016. * @param rootUrl The root url of the data assets to load
  26017. * @return A color gradind texture
  26018. */
  26019. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  26020. /**
  26021. * Serializes the LUT texture to json format.
  26022. */
  26023. serialize(): any;
  26024. }
  26025. }
  26026. declare module BABYLON {
  26027. class CubeTexture extends BaseTexture {
  26028. url: string;
  26029. coordinatesMode: number;
  26030. /**
  26031. * Gets or sets the center of the bounding box associated with the cube texture
  26032. * It must define where the camera used to render the texture was set
  26033. */
  26034. boundingBoxPosition: Vector3;
  26035. private _boundingBoxSize;
  26036. /**
  26037. * Gets or sets the size of the bounding box associated with the cube texture
  26038. * When defined, the cubemap will switch to local mode
  26039. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  26040. * @example https://www.babylonjs-playground.com/#RNASML
  26041. */
  26042. boundingBoxSize: Vector3;
  26043. private _noMipmap;
  26044. private _files;
  26045. private _extensions;
  26046. private _textureMatrix;
  26047. private _format;
  26048. private _prefiltered;
  26049. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  26050. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture;
  26051. 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);
  26052. delayLoad(): void;
  26053. getReflectionTextureMatrix(): Matrix;
  26054. setReflectionTextureMatrix(value: Matrix): void;
  26055. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  26056. clone(): CubeTexture;
  26057. }
  26058. }
  26059. declare module BABYLON {
  26060. class DynamicTexture extends Texture {
  26061. private _generateMipMaps;
  26062. private _canvas;
  26063. private _context;
  26064. private _engine;
  26065. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  26066. readonly canRescale: boolean;
  26067. private _recreate(textureSize);
  26068. scale(ratio: number): void;
  26069. scaleTo(width: number, height: number): void;
  26070. getContext(): CanvasRenderingContext2D;
  26071. clear(): void;
  26072. update(invertY?: boolean): void;
  26073. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  26074. clone(): DynamicTexture;
  26075. _rebuild(): void;
  26076. }
  26077. }
  26078. declare module BABYLON {
  26079. /**
  26080. * This represents a texture coming from an HDR input.
  26081. *
  26082. * The only supported format is currently panorama picture stored in RGBE format.
  26083. * Example of such files can be found on HDRLib: http://hdrlib.com/
  26084. */
  26085. class HDRCubeTexture extends BaseTexture {
  26086. private static _facesMapping;
  26087. private _useInGammaSpace;
  26088. private _generateHarmonics;
  26089. private _noMipmap;
  26090. private _textureMatrix;
  26091. private _size;
  26092. private _usePMREMGenerator;
  26093. private _isBABYLONPreprocessed;
  26094. private _onLoad;
  26095. private _onError;
  26096. /**
  26097. * The texture URL.
  26098. */
  26099. url: string;
  26100. /**
  26101. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  26102. */
  26103. coordinatesMode: number;
  26104. /**
  26105. * Specifies wether the texture has been generated through the PMREMGenerator tool.
  26106. * This is usefull at run time to apply the good shader.
  26107. */
  26108. isPMREM: boolean;
  26109. protected _isBlocking: boolean;
  26110. /**
  26111. * Gets wether or not the texture is blocking during loading.
  26112. */
  26113. /**
  26114. * Sets wether or not the texture is blocking during loading.
  26115. */
  26116. isBlocking: boolean;
  26117. /**
  26118. * Instantiates an HDRTexture from the following parameters.
  26119. *
  26120. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  26121. * @param scene The scene the texture will be used in
  26122. * @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.
  26123. * @param noMipmap Forces to not generate the mipmap if true
  26124. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  26125. * @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)
  26126. * @param usePMREMGenerator Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
  26127. */
  26128. 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>);
  26129. /**
  26130. * Occurs when the file is a preprocessed .babylon.hdr file.
  26131. */
  26132. private loadBabylonTexture();
  26133. /**
  26134. * Occurs when the file is raw .hdr file.
  26135. */
  26136. private loadHDRTexture();
  26137. /**
  26138. * Starts the loading process of the texture.
  26139. */
  26140. private loadTexture();
  26141. clone(): HDRCubeTexture;
  26142. delayLoad(): void;
  26143. getReflectionTextureMatrix(): Matrix;
  26144. setReflectionTextureMatrix(value: Matrix): void;
  26145. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  26146. serialize(): any;
  26147. /**
  26148. * Saves as a file the data contained in the texture in a binary format.
  26149. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  26150. * as the spherical used in the lighting.
  26151. * @param url The HDR file url.
  26152. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  26153. * @param onError Method called if any error happens during download.
  26154. * @return The packed binary data.
  26155. */
  26156. static generateBabylonHDROnDisk(url: string, size: number, onError?: Nullable<(() => void)>): void;
  26157. /**
  26158. * Serializes the data contained in the texture in a binary format.
  26159. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  26160. * as the spherical used in the lighting.
  26161. * @param url The HDR file url.
  26162. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  26163. * @param onError Method called if any error happens during download.
  26164. * @return The packed binary data.
  26165. */
  26166. static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer: ArrayBuffer) => void), onError?: Nullable<(() => void)>): void;
  26167. }
  26168. }
  26169. declare module BABYLON {
  26170. /**
  26171. * Class used to store data associated with WebGL texture data for the engine
  26172. * This class should not be used directly
  26173. */
  26174. class InternalTexture implements IInternalTextureTracker {
  26175. /**
  26176. * The source of the texture data is unknown
  26177. */
  26178. static DATASOURCE_UNKNOWN: number;
  26179. /**
  26180. * Texture data comes from an URL
  26181. */
  26182. static DATASOURCE_URL: number;
  26183. /**
  26184. * Texture data is only used for temporary storage
  26185. */
  26186. static DATASOURCE_TEMP: number;
  26187. /**
  26188. * Texture data comes from raw data (ArrayBuffer)
  26189. */
  26190. static DATASOURCE_RAW: number;
  26191. /**
  26192. * Texture content is dynamic (video or dynamic texture)
  26193. */
  26194. static DATASOURCE_DYNAMIC: number;
  26195. /**
  26196. * Texture content is generated by rendering to it
  26197. */
  26198. static DATASOURCE_RENDERTARGET: number;
  26199. /**
  26200. * Texture content is part of a multi render target process
  26201. */
  26202. static DATASOURCE_MULTIRENDERTARGET: number;
  26203. /**
  26204. * Texture data comes from a cube data file
  26205. */
  26206. static DATASOURCE_CUBE: number;
  26207. /**
  26208. * Texture data comes from a raw cube data
  26209. */
  26210. static DATASOURCE_CUBERAW: number;
  26211. /**
  26212. * Texture data come from a prefiltered cube data file
  26213. */
  26214. static DATASOURCE_CUBEPREFILTERED: number;
  26215. /**
  26216. * Texture content is raw 3D data
  26217. */
  26218. static DATASOURCE_RAW3D: number;
  26219. /**
  26220. * Defines if the texture is ready
  26221. */
  26222. isReady: boolean;
  26223. /**
  26224. * Defines if the texture is a cube texture
  26225. */
  26226. isCube: boolean;
  26227. /**
  26228. * Defines if the texture contains 3D data
  26229. */
  26230. is3D: boolean;
  26231. /**
  26232. * Gets the URL used to load this texture
  26233. */
  26234. url: string;
  26235. /**
  26236. * Gets the sampling mode of the texture
  26237. */
  26238. samplingMode: number;
  26239. /**
  26240. * Gets a boolean indicating if the texture needs mipmaps generation
  26241. */
  26242. generateMipMaps: boolean;
  26243. /**
  26244. * Gets the number of samples used by the texture (WebGL2+ only)
  26245. */
  26246. samples: number;
  26247. /**
  26248. * Gets the type of the texture
  26249. */
  26250. type: number;
  26251. /**
  26252. * Gets the format of the texture
  26253. */
  26254. format: number;
  26255. /**
  26256. * Observable called when the texture is loaded
  26257. */
  26258. onLoadedObservable: Observable<InternalTexture>;
  26259. /**
  26260. * Gets the width of the texture
  26261. */
  26262. width: number;
  26263. /**
  26264. * Gets the height of the texture
  26265. */
  26266. height: number;
  26267. /**
  26268. * Gets the depth of the texture
  26269. */
  26270. depth: number;
  26271. /**
  26272. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  26273. */
  26274. baseWidth: number;
  26275. /**
  26276. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  26277. */
  26278. baseHeight: number;
  26279. /**
  26280. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  26281. */
  26282. baseDepth: number;
  26283. /**
  26284. * Gets a boolean indicating if the texture is inverted on Y axis
  26285. */
  26286. invertY: boolean;
  26287. /**
  26288. * Gets or set the previous tracker in the list
  26289. */
  26290. previous: Nullable<IInternalTextureTracker>;
  26291. /**
  26292. * Gets or set the next tracker in the list
  26293. */
  26294. next: Nullable<IInternalTextureTracker>;
  26295. /** @ignore */
  26296. _initialSlot: number;
  26297. /** @ignore */
  26298. _designatedSlot: number;
  26299. /** @ignore */
  26300. _dataSource: number;
  26301. /** @ignore */
  26302. _buffer: Nullable<ArrayBuffer | HTMLImageElement>;
  26303. /** @ignore */
  26304. _bufferView: Nullable<ArrayBufferView>;
  26305. /** @ignore */
  26306. _bufferViewArray: Nullable<ArrayBufferView[]>;
  26307. /** @ignore */
  26308. _size: number;
  26309. /** @ignore */
  26310. _extension: string;
  26311. /** @ignore */
  26312. _files: Nullable<string[]>;
  26313. /** @ignore */
  26314. _workingCanvas: HTMLCanvasElement;
  26315. /** @ignore */
  26316. _workingContext: CanvasRenderingContext2D;
  26317. /** @ignore */
  26318. _framebuffer: Nullable<WebGLFramebuffer>;
  26319. /** @ignore */
  26320. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  26321. /** @ignore */
  26322. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  26323. /** @ignore */
  26324. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  26325. /** @ignore */
  26326. _attachments: Nullable<number[]>;
  26327. /** @ignore */
  26328. _cachedCoordinatesMode: Nullable<number>;
  26329. /** @ignore */
  26330. _cachedWrapU: Nullable<number>;
  26331. /** @ignore */
  26332. _cachedWrapV: Nullable<number>;
  26333. /** @ignore */
  26334. _cachedWrapR: Nullable<number>;
  26335. /** @ignore */
  26336. _cachedAnisotropicFilteringLevel: Nullable<number>;
  26337. /** @ignore */
  26338. _isDisabled: boolean;
  26339. /** @ignore */
  26340. _compression: Nullable<string>;
  26341. /** @ignore */
  26342. _generateStencilBuffer: boolean;
  26343. /** @ignore */
  26344. _generateDepthBuffer: boolean;
  26345. /** @ignore */
  26346. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  26347. /** @ignore */
  26348. _lodGenerationScale: number;
  26349. /** @ignore */
  26350. _lodGenerationOffset: number;
  26351. /** @ignore */
  26352. _lodTextureHigh: BaseTexture;
  26353. /** @ignore */
  26354. _lodTextureMid: BaseTexture;
  26355. /** @ignore */
  26356. _lodTextureLow: BaseTexture;
  26357. /** @ignore */
  26358. _webGLTexture: Nullable<WebGLTexture>;
  26359. /** @ignore */
  26360. _references: number;
  26361. private _engine;
  26362. /**
  26363. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  26364. */
  26365. readonly dataSource: number;
  26366. /**
  26367. * Creates a new InternalTexture
  26368. * @param engine defines the engine to use
  26369. * @param dataSource defines the type of data that will be used
  26370. */
  26371. constructor(engine: Engine, dataSource: number);
  26372. /**
  26373. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  26374. */
  26375. incrementReferences(): void;
  26376. /**
  26377. * Change the size of the texture (not the size of the content)
  26378. * @param width defines the new width
  26379. * @param height defines the new height
  26380. * @param depth defines the new depth (1 by default)
  26381. */
  26382. updateSize(width: int, height: int, depth?: int): void;
  26383. /** @ignore */
  26384. _rebuild(): void;
  26385. private _swapAndDie(target);
  26386. /**
  26387. * Dispose the current allocated resources
  26388. */
  26389. dispose(): void;
  26390. }
  26391. }
  26392. declare module BABYLON {
  26393. /**
  26394. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  26395. */
  26396. interface IInternalTextureTracker {
  26397. /**
  26398. * Gets or set the previous tracker in the list
  26399. */
  26400. previous: Nullable<IInternalTextureTracker>;
  26401. /**
  26402. * Gets or set the next tracker in the list
  26403. */
  26404. next: Nullable<IInternalTextureTracker>;
  26405. }
  26406. /**
  26407. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  26408. */
  26409. class DummyInternalTextureTracker {
  26410. /**
  26411. * Gets or set the previous tracker in the list
  26412. */
  26413. previous: Nullable<IInternalTextureTracker>;
  26414. /**
  26415. * Gets or set the next tracker in the list
  26416. */
  26417. next: Nullable<IInternalTextureTracker>;
  26418. }
  26419. }
  26420. declare module BABYLON {
  26421. class MirrorTexture extends RenderTargetTexture {
  26422. mirrorPlane: Plane;
  26423. private _transformMatrix;
  26424. private _mirrorMatrix;
  26425. private _savedViewMatrix;
  26426. private _blurX;
  26427. private _blurY;
  26428. private _adaptiveBlurKernel;
  26429. private _blurKernelX;
  26430. private _blurKernelY;
  26431. private _blurRatio;
  26432. blurRatio: number;
  26433. adaptiveBlurKernel: number;
  26434. blurKernel: number;
  26435. blurKernelX: number;
  26436. blurKernelY: number;
  26437. private _autoComputeBlurKernel();
  26438. protected _onRatioRescale(): void;
  26439. constructor(name: string, size: number | {
  26440. width: number;
  26441. height: number;
  26442. } | {
  26443. ratio: number;
  26444. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  26445. private _preparePostProcesses();
  26446. clone(): MirrorTexture;
  26447. serialize(): any;
  26448. }
  26449. }
  26450. declare module BABYLON {
  26451. interface IMultiRenderTargetOptions {
  26452. generateMipMaps?: boolean;
  26453. types?: number[];
  26454. samplingModes?: number[];
  26455. generateDepthBuffer?: boolean;
  26456. generateStencilBuffer?: boolean;
  26457. generateDepthTexture?: boolean;
  26458. textureCount?: number;
  26459. doNotChangeAspectRatio?: boolean;
  26460. defaultType?: number;
  26461. }
  26462. class MultiRenderTarget extends RenderTargetTexture {
  26463. private _internalTextures;
  26464. private _textures;
  26465. readonly isSupported: boolean;
  26466. private _multiRenderTargetOptions;
  26467. readonly textures: Texture[];
  26468. readonly depthTexture: Texture;
  26469. wrapU: number;
  26470. wrapV: number;
  26471. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26472. _rebuild(): void;
  26473. private _createInternalTextures();
  26474. private _createTextures();
  26475. samples: number;
  26476. resize(size: any): void;
  26477. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26478. dispose(): void;
  26479. releaseInternalTextures(): void;
  26480. }
  26481. }
  26482. declare module BABYLON {
  26483. class RawTexture extends Texture {
  26484. format: number;
  26485. private _engine;
  26486. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  26487. update(data: ArrayBufferView): void;
  26488. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  26489. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  26490. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  26491. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  26492. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  26493. }
  26494. }
  26495. declare module BABYLON {
  26496. /**
  26497. * Creates a refraction texture used by refraction channel of the standard material.
  26498. * @param name the texture name
  26499. * @param size size of the underlying texture
  26500. * @param scene root scene
  26501. */
  26502. class RefractionTexture extends RenderTargetTexture {
  26503. refractionPlane: Plane;
  26504. depth: number;
  26505. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  26506. clone(): RefractionTexture;
  26507. serialize(): any;
  26508. }
  26509. }
  26510. declare module BABYLON {
  26511. class RenderTargetTexture extends Texture {
  26512. isCube: boolean;
  26513. static _REFRESHRATE_RENDER_ONCE: number;
  26514. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  26515. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  26516. static readonly REFRESHRATE_RENDER_ONCE: number;
  26517. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  26518. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  26519. /**
  26520. * Use this predicate to dynamically define the list of mesh you want to render.
  26521. * If set, the renderList property will be overwritten.
  26522. */
  26523. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  26524. /**
  26525. * Use this list to define the list of mesh you want to render.
  26526. */
  26527. renderList: Nullable<Array<AbstractMesh>>;
  26528. renderParticles: boolean;
  26529. renderSprites: boolean;
  26530. coordinatesMode: number;
  26531. activeCamera: Nullable<Camera>;
  26532. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  26533. useCameraPostProcesses: boolean;
  26534. ignoreCameraViewport: boolean;
  26535. private _postProcessManager;
  26536. private _postProcesses;
  26537. private _resizeObserver;
  26538. /**
  26539. * An event triggered when the texture is unbind.
  26540. * @type {BABYLON.Observable}
  26541. */
  26542. onBeforeBindObservable: Observable<RenderTargetTexture>;
  26543. /**
  26544. * An event triggered when the texture is unbind.
  26545. * @type {BABYLON.Observable}
  26546. */
  26547. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  26548. private _onAfterUnbindObserver;
  26549. onAfterUnbind: () => void;
  26550. /**
  26551. * An event triggered before rendering the texture
  26552. * @type {BABYLON.Observable}
  26553. */
  26554. onBeforeRenderObservable: Observable<number>;
  26555. private _onBeforeRenderObserver;
  26556. onBeforeRender: (faceIndex: number) => void;
  26557. /**
  26558. * An event triggered after rendering the texture
  26559. * @type {BABYLON.Observable}
  26560. */
  26561. onAfterRenderObservable: Observable<number>;
  26562. private _onAfterRenderObserver;
  26563. onAfterRender: (faceIndex: number) => void;
  26564. /**
  26565. * An event triggered after the texture clear
  26566. * @type {BABYLON.Observable}
  26567. */
  26568. onClearObservable: Observable<Engine>;
  26569. private _onClearObserver;
  26570. onClear: (Engine: Engine) => void;
  26571. clearColor: Color4;
  26572. protected _size: number | {
  26573. width: number;
  26574. height: number;
  26575. };
  26576. protected _initialSizeParameter: number | {
  26577. width: number;
  26578. height: number;
  26579. } | {
  26580. ratio: number;
  26581. };
  26582. protected _sizeRatio: Nullable<number>;
  26583. _generateMipMaps: boolean;
  26584. protected _renderingManager: RenderingManager;
  26585. _waitingRenderList: string[];
  26586. protected _doNotChangeAspectRatio: boolean;
  26587. protected _currentRefreshId: number;
  26588. protected _refreshRate: number;
  26589. protected _textureMatrix: Matrix;
  26590. protected _samples: number;
  26591. protected _renderTargetOptions: RenderTargetCreationOptions;
  26592. readonly renderTargetOptions: RenderTargetCreationOptions;
  26593. protected _engine: Engine;
  26594. protected _onRatioRescale(): void;
  26595. /**
  26596. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  26597. * It must define where the camera used to render the texture is set
  26598. */
  26599. boundingBoxPosition: Vector3;
  26600. private _boundingBoxSize;
  26601. /**
  26602. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  26603. * When defined, the cubemap will switch to local mode
  26604. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  26605. * @example https://www.babylonjs-playground.com/#RNASML
  26606. */
  26607. boundingBoxSize: Vector3;
  26608. constructor(name: string, size: number | {
  26609. width: number;
  26610. height: number;
  26611. } | {
  26612. ratio: number;
  26613. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  26614. private _processSizeParameter(size);
  26615. samples: number;
  26616. resetRefreshCounter(): void;
  26617. refreshRate: number;
  26618. addPostProcess(postProcess: PostProcess): void;
  26619. clearPostProcesses(dispose?: boolean): void;
  26620. removePostProcess(postProcess: PostProcess): void;
  26621. _shouldRender(): boolean;
  26622. getRenderSize(): number;
  26623. getRenderWidth(): number;
  26624. getRenderHeight(): number;
  26625. readonly canRescale: boolean;
  26626. scale(ratio: number): void;
  26627. getReflectionTextureMatrix(): Matrix;
  26628. resize(size: number | {
  26629. width: number;
  26630. height: number;
  26631. } | {
  26632. ratio: number;
  26633. }): void;
  26634. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  26635. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  26636. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26637. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  26638. /**
  26639. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  26640. * This allowed control for front to back rendering or reversly depending of the special needs.
  26641. *
  26642. * @param renderingGroupId The rendering group id corresponding to its index
  26643. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  26644. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  26645. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  26646. */
  26647. 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;
  26648. /**
  26649. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26650. *
  26651. * @param renderingGroupId The rendering group id corresponding to its index
  26652. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26653. */
  26654. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  26655. clone(): RenderTargetTexture;
  26656. serialize(): any;
  26657. disposeFramebufferObjects(): void;
  26658. dispose(): void;
  26659. _rebuild(): void;
  26660. }
  26661. }
  26662. declare module BABYLON {
  26663. class Texture extends BaseTexture {
  26664. static NEAREST_SAMPLINGMODE: number;
  26665. static NEAREST_NEAREST_MIPLINEAR: number;
  26666. static BILINEAR_SAMPLINGMODE: number;
  26667. static LINEAR_LINEAR_MIPNEAREST: number;
  26668. static TRILINEAR_SAMPLINGMODE: number;
  26669. static LINEAR_LINEAR_MIPLINEAR: number;
  26670. static NEAREST_NEAREST_MIPNEAREST: number;
  26671. static NEAREST_LINEAR_MIPNEAREST: number;
  26672. static NEAREST_LINEAR_MIPLINEAR: number;
  26673. static NEAREST_LINEAR: number;
  26674. static NEAREST_NEAREST: number;
  26675. static LINEAR_NEAREST_MIPNEAREST: number;
  26676. static LINEAR_NEAREST_MIPLINEAR: number;
  26677. static LINEAR_LINEAR: number;
  26678. static LINEAR_NEAREST: number;
  26679. static EXPLICIT_MODE: number;
  26680. static SPHERICAL_MODE: number;
  26681. static PLANAR_MODE: number;
  26682. static CUBIC_MODE: number;
  26683. static PROJECTION_MODE: number;
  26684. static SKYBOX_MODE: number;
  26685. static INVCUBIC_MODE: number;
  26686. static EQUIRECTANGULAR_MODE: number;
  26687. static FIXED_EQUIRECTANGULAR_MODE: number;
  26688. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26689. static CLAMP_ADDRESSMODE: number;
  26690. static WRAP_ADDRESSMODE: number;
  26691. static MIRROR_ADDRESSMODE: number;
  26692. url: Nullable<string>;
  26693. uOffset: number;
  26694. vOffset: number;
  26695. uScale: number;
  26696. vScale: number;
  26697. uAng: number;
  26698. vAng: number;
  26699. wAng: number;
  26700. readonly noMipmap: boolean;
  26701. private _noMipmap;
  26702. _invertY: boolean;
  26703. private _rowGenerationMatrix;
  26704. private _cachedTextureMatrix;
  26705. private _projectionModeMatrix;
  26706. private _t0;
  26707. private _t1;
  26708. private _t2;
  26709. private _cachedUOffset;
  26710. private _cachedVOffset;
  26711. private _cachedUScale;
  26712. private _cachedVScale;
  26713. private _cachedUAng;
  26714. private _cachedVAng;
  26715. private _cachedWAng;
  26716. private _cachedProjectionMatrixId;
  26717. private _cachedCoordinatesMode;
  26718. _samplingMode: number;
  26719. private _buffer;
  26720. private _deleteBuffer;
  26721. protected _format: Nullable<number>;
  26722. private _delayedOnLoad;
  26723. private _delayedOnError;
  26724. private _onLoadObservable;
  26725. protected _isBlocking: boolean;
  26726. isBlocking: boolean;
  26727. readonly samplingMode: number;
  26728. 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);
  26729. updateURL(url: string): void;
  26730. delayLoad(): void;
  26731. updateSamplingMode(samplingMode: number): void;
  26732. private _prepareRowForTextureGeneration(x, y, z, t);
  26733. getTextureMatrix(): Matrix;
  26734. getReflectionTextureMatrix(): Matrix;
  26735. clone(): Texture;
  26736. readonly onLoadObservable: Observable<Texture>;
  26737. serialize(): any;
  26738. getClassName(): string;
  26739. dispose(): void;
  26740. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  26741. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  26742. 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;
  26743. }
  26744. }
  26745. declare module BABYLON {
  26746. /**
  26747. * Settings for finer control over video usage
  26748. */
  26749. interface VideoTextureSettings {
  26750. /**
  26751. * Applies `autoplay` to video, if specified
  26752. */
  26753. autoPlay?: boolean;
  26754. /**
  26755. * Applies `loop` to video, if specified
  26756. */
  26757. loop?: boolean;
  26758. /**
  26759. * Automatically updates internal texture from video at every frame in the render loop
  26760. */
  26761. autoUpdateTexture: boolean;
  26762. }
  26763. class VideoTexture extends Texture {
  26764. /**
  26765. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26766. */
  26767. readonly autoUpdateTexture: boolean;
  26768. /**
  26769. * The video instance used by the texture internally
  26770. */
  26771. readonly video: HTMLVideoElement;
  26772. private _generateMipMaps;
  26773. private _engine;
  26774. /**
  26775. * Creates a video texture.
  26776. * Sample : https://doc.babylonjs.com/how_to/video_texture
  26777. * @param {string | null} name optional name, will detect from video source, if not defined
  26778. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  26779. * @param {BABYLON.Scene} scene is obviously the current scene.
  26780. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26781. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  26782. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26783. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  26784. */
  26785. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26786. private _getName(src);
  26787. private _getVideo(src);
  26788. private _createInternalTexture;
  26789. private reset;
  26790. /**
  26791. * Internal method to initiate `update`.
  26792. */
  26793. _rebuild(): void;
  26794. /**
  26795. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26796. */
  26797. update(): void;
  26798. /**
  26799. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26800. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26801. */
  26802. updateTexture(isVisible: boolean): void;
  26803. protected _updateInternalTexture: (e?: Event | undefined) => void;
  26804. /**
  26805. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26806. * @param url New url.
  26807. */
  26808. updateURL(url: string): void;
  26809. dispose(): void;
  26810. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26811. minWidth: number;
  26812. maxWidth: number;
  26813. minHeight: number;
  26814. maxHeight: number;
  26815. deviceId: string;
  26816. }): void;
  26817. }
  26818. }
  26819. declare module BABYLON {
  26820. class CannonJSPlugin implements IPhysicsEnginePlugin {
  26821. private _useDeltaForWorldStep;
  26822. world: any;
  26823. name: string;
  26824. private _physicsMaterials;
  26825. private _fixedTimeStep;
  26826. BJSCANNON: any;
  26827. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  26828. setGravity(gravity: Vector3): void;
  26829. setTimeStep(timeStep: number): void;
  26830. getTimeStep(): number;
  26831. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26832. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26833. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26834. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26835. private _processChildMeshes(mainImpostor);
  26836. removePhysicsBody(impostor: PhysicsImpostor): void;
  26837. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  26838. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  26839. private _addMaterial(name, friction, restitution);
  26840. private _checkWithEpsilon(value);
  26841. private _createShape(impostor);
  26842. private _createHeightmap(object, pointDepth?);
  26843. private _minus90X;
  26844. private _plus90X;
  26845. private _tmpPosition;
  26846. private _tmpDeltaPosition;
  26847. private _tmpUnityRotation;
  26848. private _updatePhysicsBodyTransformation(impostor);
  26849. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26850. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26851. isSupported(): boolean;
  26852. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  26853. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  26854. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26855. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26856. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26857. getBodyMass(impostor: PhysicsImpostor): number;
  26858. getBodyFriction(impostor: PhysicsImpostor): number;
  26859. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26860. getBodyRestitution(impostor: PhysicsImpostor): number;
  26861. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26862. sleepBody(impostor: PhysicsImpostor): void;
  26863. wakeUpBody(impostor: PhysicsImpostor): void;
  26864. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26865. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  26866. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  26867. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26868. getRadius(impostor: PhysicsImpostor): number;
  26869. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26870. dispose(): void;
  26871. private _extendNamespace();
  26872. }
  26873. }
  26874. declare module BABYLON {
  26875. class OimoJSPlugin implements IPhysicsEnginePlugin {
  26876. world: any;
  26877. name: string;
  26878. BJSOIMO: any;
  26879. constructor(iterations?: number);
  26880. setGravity(gravity: Vector3): void;
  26881. setTimeStep(timeStep: number): void;
  26882. getTimeStep(): number;
  26883. private _tmpImpostorsArray;
  26884. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26885. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26886. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26887. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26888. private _tmpPositionVector;
  26889. removePhysicsBody(impostor: PhysicsImpostor): void;
  26890. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  26891. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  26892. isSupported(): boolean;
  26893. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26894. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26895. private _getLastShape(body);
  26896. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  26897. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  26898. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26899. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26900. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26901. getBodyMass(impostor: PhysicsImpostor): number;
  26902. getBodyFriction(impostor: PhysicsImpostor): number;
  26903. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26904. getBodyRestitution(impostor: PhysicsImpostor): number;
  26905. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26906. sleepBody(impostor: PhysicsImpostor): void;
  26907. wakeUpBody(impostor: PhysicsImpostor): void;
  26908. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26909. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26910. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26911. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26912. getRadius(impostor: PhysicsImpostor): number;
  26913. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26914. dispose(): void;
  26915. }
  26916. }
  26917. declare module BABYLON {
  26918. /**
  26919. * This represents a set of one or more post processes in Babylon.
  26920. * A post process can be used to apply a shader to a texture after it is rendered.
  26921. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  26922. */
  26923. class PostProcessRenderEffect {
  26924. private _postProcesses;
  26925. private _getPostProcesses;
  26926. private _singleInstance;
  26927. private _cameras;
  26928. private _indicesForCamera;
  26929. /**
  26930. * Name of the effect
  26931. */
  26932. _name: string;
  26933. /**
  26934. * Instantiates a post process render effect.
  26935. * A post process can be used to apply a shader to a texture after it is rendered.
  26936. * @param engine The engine the effect is tied to
  26937. * @param name The name of the effect
  26938. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  26939. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  26940. */
  26941. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  26942. /**
  26943. * Checks if all the post processes in the effect are supported.
  26944. */
  26945. readonly isSupported: boolean;
  26946. /**
  26947. * Updates the current state of the effect
  26948. */
  26949. _update(): void;
  26950. /**
  26951. * Attaches the effect on cameras
  26952. * @param cameras The camera to attach to.
  26953. */
  26954. _attachCameras(cameras: Camera): void;
  26955. /**
  26956. * Attaches the effect on cameras
  26957. * @param cameras The camera to attach to.
  26958. */
  26959. _attachCameras(cameras: Camera[]): void;
  26960. /**
  26961. * Detatches the effect on cameras
  26962. * @param cameras The camera to detatch from.
  26963. */
  26964. _detachCameras(cameras: Camera): void;
  26965. /**
  26966. * Detatches the effect on cameras
  26967. * @param cameras The camera to detatch from.
  26968. */
  26969. _detachCameras(cameras: Camera[]): void;
  26970. /**
  26971. * Enables the effect on given cameras
  26972. * @param cameras The camera to enable.
  26973. */
  26974. _enable(cameras: Camera): void;
  26975. /**
  26976. * Enables the effect on given cameras
  26977. * @param cameras The camera to enable.
  26978. */
  26979. _enable(cameras: Nullable<Camera[]>): void;
  26980. /**
  26981. * Disables the effect on the given cameras
  26982. * @param cameras The camera to disable.
  26983. */
  26984. _disable(cameras: Camera): void;
  26985. /**
  26986. * Disables the effect on the given cameras
  26987. * @param cameras The camera to disable.
  26988. */
  26989. _disable(cameras: Nullable<Camera[]>): void;
  26990. /**
  26991. * Gets a list of the post processes contained in the effect.
  26992. * @param camera The camera to get the post processes on.
  26993. * @returns The list of the post processes in the effect.
  26994. */
  26995. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  26996. }
  26997. }
  26998. declare module BABYLON {
  26999. class PostProcessRenderPipeline {
  27000. private _renderEffects;
  27001. private _renderEffectsForIsolatedPass;
  27002. protected _cameras: Camera[];
  27003. _name: string;
  27004. constructor(engine: Engine, name: string);
  27005. getClassName(): string;
  27006. readonly isSupported: boolean;
  27007. addEffect(renderEffect: PostProcessRenderEffect): void;
  27008. _rebuild(): void;
  27009. _enableEffect(renderEffectName: string, cameras: Camera): void;
  27010. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  27011. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  27012. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  27013. _attachCameras(cameras: Camera, unique: boolean): void;
  27014. _attachCameras(cameras: Camera[], unique: boolean): void;
  27015. _detachCameras(cameras: Camera): void;
  27016. _detachCameras(cameras: Nullable<Camera[]>): void;
  27017. _update(): void;
  27018. _reset(): void;
  27019. dispose(): void;
  27020. }
  27021. }
  27022. declare module BABYLON {
  27023. class PostProcessRenderPipelineManager {
  27024. private _renderPipelines;
  27025. constructor();
  27026. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  27027. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  27028. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  27029. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  27030. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  27031. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  27032. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  27033. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  27034. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  27035. update(): void;
  27036. _rebuild(): void;
  27037. dispose(): void;
  27038. }
  27039. }
  27040. declare module BABYLON {
  27041. /**
  27042. * Helper class dealing with the extraction of spherical polynomial dataArray
  27043. * from a cube map.
  27044. */
  27045. class CubeMapToSphericalPolynomialTools {
  27046. private static FileFaces;
  27047. /**
  27048. * Converts a texture to the according Spherical Polynomial data.
  27049. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27050. *
  27051. * @param texture The texture to extract the information from.
  27052. * @return The Spherical Polynomial data.
  27053. */
  27054. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27055. /**
  27056. * Converts a cubemap to the according Spherical Polynomial data.
  27057. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27058. *
  27059. * @param cubeInfo The Cube map to extract the information from.
  27060. * @return The Spherical Polynomial data.
  27061. */
  27062. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27063. }
  27064. }
  27065. declare module BABYLON {
  27066. /**
  27067. * Header information of HDR texture files.
  27068. */
  27069. interface HDRInfo {
  27070. /**
  27071. * The height of the texture in pixels.
  27072. */
  27073. height: number;
  27074. /**
  27075. * The width of the texture in pixels.
  27076. */
  27077. width: number;
  27078. /**
  27079. * The index of the beginning of the data in the binary file.
  27080. */
  27081. dataPosition: number;
  27082. }
  27083. /**
  27084. * This groups tools to convert HDR texture to native colors array.
  27085. */
  27086. class HDRTools {
  27087. private static Ldexp(mantissa, exponent);
  27088. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  27089. private static readStringLine(uint8array, startIndex);
  27090. /**
  27091. * Reads header information from an RGBE texture stored in a native array.
  27092. * More information on this format are available here:
  27093. * https://en.wikipedia.org/wiki/RGBE_image_format
  27094. *
  27095. * @param uint8array The binary file stored in native array.
  27096. * @return The header information.
  27097. */
  27098. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  27099. /**
  27100. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  27101. * This RGBE texture needs to store the information as a panorama.
  27102. *
  27103. * More information on this format are available here:
  27104. * https://en.wikipedia.org/wiki/RGBE_image_format
  27105. *
  27106. * @param buffer The binary file stored in an array buffer.
  27107. * @param size The expected size of the extracted cubemap.
  27108. * @return The Cube Map information.
  27109. */
  27110. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  27111. /**
  27112. * Returns the pixels data extracted from an RGBE texture.
  27113. * This pixels will be stored left to right up to down in the R G B order in one array.
  27114. *
  27115. * More information on this format are available here:
  27116. * https://en.wikipedia.org/wiki/RGBE_image_format
  27117. *
  27118. * @param uint8array The binary file stored in an array buffer.
  27119. * @param hdrInfo The header information of the file.
  27120. * @return The pixels data in RGB right to left up to down order.
  27121. */
  27122. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  27123. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  27124. }
  27125. }
  27126. declare module BABYLON {
  27127. /**
  27128. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27129. */
  27130. interface CubeMapInfo {
  27131. /**
  27132. * The pixel array for the front face.
  27133. * This is stored in format, left to right, up to down format.
  27134. */
  27135. front: Nullable<ArrayBufferView>;
  27136. /**
  27137. * The pixel array for the back face.
  27138. * This is stored in format, left to right, up to down format.
  27139. */
  27140. back: Nullable<ArrayBufferView>;
  27141. /**
  27142. * The pixel array for the left face.
  27143. * This is stored in format, left to right, up to down format.
  27144. */
  27145. left: Nullable<ArrayBufferView>;
  27146. /**
  27147. * The pixel array for the right face.
  27148. * This is stored in format, left to right, up to down format.
  27149. */
  27150. right: Nullable<ArrayBufferView>;
  27151. /**
  27152. * The pixel array for the up face.
  27153. * This is stored in format, left to right, up to down format.
  27154. */
  27155. up: Nullable<ArrayBufferView>;
  27156. /**
  27157. * The pixel array for the down face.
  27158. * This is stored in format, left to right, up to down format.
  27159. */
  27160. down: Nullable<ArrayBufferView>;
  27161. /**
  27162. * The size of the cubemap stored.
  27163. *
  27164. * Each faces will be size * size pixels.
  27165. */
  27166. size: number;
  27167. /**
  27168. * The format of the texture.
  27169. *
  27170. * RGBA, RGB.
  27171. */
  27172. format: number;
  27173. /**
  27174. * The type of the texture data.
  27175. *
  27176. * UNSIGNED_INT, FLOAT.
  27177. */
  27178. type: number;
  27179. /**
  27180. * Specifies whether the texture is in gamma space.
  27181. */
  27182. gammaSpace: boolean;
  27183. }
  27184. /**
  27185. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  27186. */
  27187. class PanoramaToCubeMapTools {
  27188. private static FACE_FRONT;
  27189. private static FACE_BACK;
  27190. private static FACE_RIGHT;
  27191. private static FACE_LEFT;
  27192. private static FACE_DOWN;
  27193. private static FACE_UP;
  27194. /**
  27195. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27196. *
  27197. * @param float32Array The source data.
  27198. * @param inputWidth The width of the input panorama.
  27199. * @param inputhHeight The height of the input panorama.
  27200. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27201. * @return The cubemap data
  27202. */
  27203. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27204. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  27205. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  27206. }
  27207. }
  27208. declare module BABYLON {
  27209. class CustomProceduralTexture extends ProceduralTexture {
  27210. private _animate;
  27211. private _time;
  27212. private _config;
  27213. private _texturePath;
  27214. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  27215. private loadJson(jsonUrl);
  27216. isReady(): boolean;
  27217. render(useCameraPostProcess?: boolean): void;
  27218. updateTextures(): void;
  27219. updateShaderUniforms(): void;
  27220. animate: boolean;
  27221. }
  27222. }
  27223. declare module BABYLON {
  27224. class ProceduralTexture extends Texture {
  27225. isCube: boolean;
  27226. private _size;
  27227. _generateMipMaps: boolean;
  27228. isEnabled: boolean;
  27229. private _currentRefreshId;
  27230. private _refreshRate;
  27231. onGenerated: () => void;
  27232. private _vertexBuffers;
  27233. private _indexBuffer;
  27234. private _effect;
  27235. private _uniforms;
  27236. private _samplers;
  27237. private _fragment;
  27238. _textures: {
  27239. [key: string]: Texture;
  27240. };
  27241. private _floats;
  27242. private _floatsArrays;
  27243. private _colors3;
  27244. private _colors4;
  27245. private _vectors2;
  27246. private _vectors3;
  27247. private _matrices;
  27248. private _fallbackTexture;
  27249. private _fallbackTextureUsed;
  27250. private _engine;
  27251. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  27252. private _createIndexBuffer();
  27253. _rebuild(): void;
  27254. reset(): void;
  27255. isReady(): boolean;
  27256. resetRefreshCounter(): void;
  27257. setFragment(fragment: any): void;
  27258. refreshRate: number;
  27259. _shouldRender(): boolean;
  27260. getRenderSize(): number;
  27261. resize(size: number, generateMipMaps: boolean): void;
  27262. private _checkUniform(uniformName);
  27263. setTexture(name: string, texture: Texture): ProceduralTexture;
  27264. setFloat(name: string, value: number): ProceduralTexture;
  27265. setFloats(name: string, value: number[]): ProceduralTexture;
  27266. setColor3(name: string, value: Color3): ProceduralTexture;
  27267. setColor4(name: string, value: Color4): ProceduralTexture;
  27268. setVector2(name: string, value: Vector2): ProceduralTexture;
  27269. setVector3(name: string, value: Vector3): ProceduralTexture;
  27270. setMatrix(name: string, value: Matrix): ProceduralTexture;
  27271. render(useCameraPostProcess?: boolean): void;
  27272. clone(): ProceduralTexture;
  27273. dispose(): void;
  27274. }
  27275. }
  27276. declare module BABYLON {
  27277. /**
  27278. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  27279. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  27280. */
  27281. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  27282. private _scene;
  27283. /**
  27284. * ID of the pass post process used for bloom,
  27285. */
  27286. readonly PassPostProcessId: string;
  27287. /**
  27288. * ID of the highlight post process used for bloom,
  27289. */
  27290. readonly HighLightsPostProcessId: string;
  27291. /**
  27292. * ID of the blurX post process used for bloom,
  27293. */
  27294. readonly BlurXPostProcessId: string;
  27295. /**
  27296. * ID of the blurY post process used for bloom,
  27297. */
  27298. readonly BlurYPostProcessId: string;
  27299. /**
  27300. * ID of the copy back post process used for bloom,
  27301. */
  27302. readonly CopyBackPostProcessId: string;
  27303. /**
  27304. * ID of the image processing post process;
  27305. */
  27306. readonly ImageProcessingPostProcessId: string;
  27307. /**
  27308. * ID of the Fast Approximate Anti-Aliasing post process;
  27309. */
  27310. readonly FxaaPostProcessId: string;
  27311. /**
  27312. * ID of the final merge post process;
  27313. */
  27314. readonly FinalMergePostProcessId: string;
  27315. /**
  27316. * First pass of bloom to capture the original image texture for later use.
  27317. */
  27318. pass: PassPostProcess;
  27319. /**
  27320. * Second pass of bloom used to brighten bright portions of the image.
  27321. */
  27322. highlights: HighlightsPostProcess;
  27323. /**
  27324. * BlurX post process used in coordination with blurY to guassian blur the highlighted image.
  27325. */
  27326. blurX: BlurPostProcess;
  27327. /**
  27328. * BlurY post process used in coordination with blurX to guassian blur the highlighted image.
  27329. */
  27330. blurY: BlurPostProcess;
  27331. /**
  27332. * Final pass run for bloom to copy the resulting bloom texture back to screen.
  27333. */
  27334. copyBack: PassPostProcess;
  27335. /**
  27336. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  27337. */
  27338. depthOfField: DepthOfFieldEffect;
  27339. /**
  27340. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  27341. */
  27342. fxaa: FxaaPostProcess;
  27343. /**
  27344. * Image post processing pass used to perform operations such as tone mapping or color grading.
  27345. */
  27346. imageProcessing: ImageProcessingPostProcess;
  27347. /**
  27348. * Final post process to merge results of all previous passes
  27349. */
  27350. finalMerge: PassPostProcess;
  27351. /**
  27352. * Animations which can be used to tweak settings over a period of time
  27353. */
  27354. animations: Animation[];
  27355. private _bloomEnabled;
  27356. private _depthOfFieldEnabled;
  27357. private _depthOfFieldBlurLevel;
  27358. private _fxaaEnabled;
  27359. private _imageProcessingEnabled;
  27360. private _defaultPipelineTextureType;
  27361. private _bloomScale;
  27362. private _buildAllowed;
  27363. /**
  27364. * Specifies the size of the bloom blur kernel, relative to the final output size
  27365. */
  27366. bloomKernel: number;
  27367. /**
  27368. * Specifies the weight of the bloom in the final rendering
  27369. */
  27370. private _bloomWeight;
  27371. private _hdr;
  27372. /**
  27373. * The strength of the bloom.
  27374. */
  27375. bloomWeight: number;
  27376. /**
  27377. * The scale of the bloom, lower value will provide better performance.
  27378. */
  27379. bloomScale: number;
  27380. /**
  27381. * Enable or disable the bloom from the pipeline
  27382. */
  27383. bloomEnabled: boolean;
  27384. /**
  27385. * If the depth of field is enabled.
  27386. */
  27387. depthOfFieldEnabled: boolean;
  27388. /**
  27389. * Blur level of the depth of field effect. (Higher blur will effect performance)
  27390. */
  27391. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  27392. /**
  27393. * If the anti aliasing is enabled.
  27394. */
  27395. fxaaEnabled: boolean;
  27396. /**
  27397. * If image processing is enabled.
  27398. */
  27399. imageProcessingEnabled: boolean;
  27400. /**
  27401. * @constructor
  27402. * @param {string} name - The rendering pipeline name
  27403. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  27404. * @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)
  27405. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  27406. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
  27407. */
  27408. constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild?: boolean);
  27409. /**
  27410. * Force the compilation of the entire pipeline.
  27411. */
  27412. prepare(): void;
  27413. private _buildPipeline();
  27414. private _disposePostProcesses();
  27415. /**
  27416. * Dispose of the pipeline and stop all post processes
  27417. */
  27418. dispose(): void;
  27419. /**
  27420. * Serialize the rendering pipeline (Used when exporting)
  27421. * @returns the serialized object
  27422. */
  27423. serialize(): any;
  27424. /**
  27425. * Parse the serialized pipeline
  27426. * @param source Source pipeline.
  27427. * @param scene The scene to load the pipeline to.
  27428. * @param rootUrl The URL of the serialized pipeline.
  27429. * @returns An instantiated pipeline from the serialized object.
  27430. */
  27431. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  27432. }
  27433. }
  27434. declare module BABYLON {
  27435. class LensRenderingPipeline extends PostProcessRenderPipeline {
  27436. /**
  27437. * The chromatic aberration PostProcess id in the pipeline
  27438. * @type {string}
  27439. */
  27440. LensChromaticAberrationEffect: string;
  27441. /**
  27442. * The highlights enhancing PostProcess id in the pipeline
  27443. * @type {string}
  27444. */
  27445. HighlightsEnhancingEffect: string;
  27446. /**
  27447. * The depth-of-field PostProcess id in the pipeline
  27448. * @type {string}
  27449. */
  27450. LensDepthOfFieldEffect: string;
  27451. private _scene;
  27452. private _depthTexture;
  27453. private _grainTexture;
  27454. private _chromaticAberrationPostProcess;
  27455. private _highlightsPostProcess;
  27456. private _depthOfFieldPostProcess;
  27457. private _edgeBlur;
  27458. private _grainAmount;
  27459. private _chromaticAberration;
  27460. private _distortion;
  27461. private _highlightsGain;
  27462. private _highlightsThreshold;
  27463. private _dofDistance;
  27464. private _dofAperture;
  27465. private _dofDarken;
  27466. private _dofPentagon;
  27467. private _blurNoise;
  27468. /**
  27469. * @constructor
  27470. *
  27471. * Effect parameters are as follow:
  27472. * {
  27473. * chromatic_aberration: number; // from 0 to x (1 for realism)
  27474. * edge_blur: number; // from 0 to x (1 for realism)
  27475. * distortion: number; // from 0 to x (1 for realism)
  27476. * grain_amount: number; // from 0 to 1
  27477. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  27478. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  27479. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  27480. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  27481. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  27482. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  27483. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  27484. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  27485. * }
  27486. * Note: if an effect parameter is unset, effect is disabled
  27487. *
  27488. * @param {string} name - The rendering pipeline name
  27489. * @param {object} parameters - An object containing all parameters (see above)
  27490. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  27491. * @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)
  27492. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  27493. */
  27494. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  27495. setEdgeBlur(amount: number): void;
  27496. disableEdgeBlur(): void;
  27497. setGrainAmount(amount: number): void;
  27498. disableGrain(): void;
  27499. setChromaticAberration(amount: number): void;
  27500. disableChromaticAberration(): void;
  27501. setEdgeDistortion(amount: number): void;
  27502. disableEdgeDistortion(): void;
  27503. setFocusDistance(amount: number): void;
  27504. disableDepthOfField(): void;
  27505. setAperture(amount: number): void;
  27506. setDarkenOutOfFocus(amount: number): void;
  27507. enablePentagonBokeh(): void;
  27508. disablePentagonBokeh(): void;
  27509. enableNoiseBlur(): void;
  27510. disableNoiseBlur(): void;
  27511. setHighlightsGain(amount: number): void;
  27512. setHighlightsThreshold(amount: number): void;
  27513. disableHighlights(): void;
  27514. /**
  27515. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  27516. */
  27517. dispose(disableDepthRender?: boolean): void;
  27518. private _createChromaticAberrationPostProcess(ratio);
  27519. private _createHighlightsPostProcess(ratio);
  27520. private _createDepthOfFieldPostProcess(ratio);
  27521. private _createGrainTexture();
  27522. }
  27523. }
  27524. declare module BABYLON {
  27525. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  27526. /**
  27527. * The PassPostProcess id in the pipeline that contains the original scene color
  27528. * @type {string}
  27529. */
  27530. SSAOOriginalSceneColorEffect: string;
  27531. /**
  27532. * The SSAO PostProcess id in the pipeline
  27533. * @type {string}
  27534. */
  27535. SSAORenderEffect: string;
  27536. /**
  27537. * The horizontal blur PostProcess id in the pipeline
  27538. * @type {string}
  27539. */
  27540. SSAOBlurHRenderEffect: string;
  27541. /**
  27542. * The vertical blur PostProcess id in the pipeline
  27543. * @type {string}
  27544. */
  27545. SSAOBlurVRenderEffect: string;
  27546. /**
  27547. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  27548. * @type {string}
  27549. */
  27550. SSAOCombineRenderEffect: string;
  27551. /**
  27552. * The output strength of the SSAO post-process. Default value is 1.0.
  27553. * @type {number}
  27554. */
  27555. totalStrength: number;
  27556. /**
  27557. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  27558. * @type {number}
  27559. */
  27560. maxZ: number;
  27561. /**
  27562. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  27563. * @type {number}
  27564. */
  27565. minZAspect: number;
  27566. /**
  27567. * Number of samples used for the SSAO calculations. Default value is 8
  27568. * @type {number}
  27569. */
  27570. private _samples;
  27571. /**
  27572. * Dynamically generated sphere sampler.
  27573. * @type {number[]}
  27574. */
  27575. private _sampleSphere;
  27576. /**
  27577. * Blur filter offsets
  27578. * @type {number[]}
  27579. */
  27580. private _samplerOffsets;
  27581. samples: number;
  27582. /**
  27583. * Are we using bilateral blur ?
  27584. * @type {boolean}
  27585. */
  27586. private _expensiveBlur;
  27587. expensiveBlur: boolean;
  27588. /**
  27589. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  27590. * @type {number}
  27591. */
  27592. radius: number;
  27593. /**
  27594. * The base color of the SSAO post-process
  27595. * The final result is "base + ssao" between [0, 1]
  27596. * @type {number}
  27597. */
  27598. base: number;
  27599. /**
  27600. * Support test.
  27601. * @type {boolean}
  27602. */
  27603. static readonly IsSupported: boolean;
  27604. private _scene;
  27605. private _depthTexture;
  27606. private _normalTexture;
  27607. private _randomTexture;
  27608. private _originalColorPostProcess;
  27609. private _ssaoPostProcess;
  27610. private _blurHPostProcess;
  27611. private _blurVPostProcess;
  27612. private _ssaoCombinePostProcess;
  27613. private _firstUpdate;
  27614. /**
  27615. * @constructor
  27616. * @param {string} name - The rendering pipeline name
  27617. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  27618. * @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 }
  27619. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  27620. */
  27621. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  27622. /**
  27623. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  27624. */
  27625. dispose(disableGeometryBufferRenderer?: boolean): void;
  27626. private _createBlurPostProcess(ssaoRatio, blurRatio);
  27627. _rebuild(): void;
  27628. private _generateHemisphere();
  27629. private _createSSAOPostProcess(ratio);
  27630. private _createSSAOCombinePostProcess(ratio);
  27631. private _createRandomTexture();
  27632. }
  27633. }
  27634. declare module BABYLON {
  27635. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  27636. /**
  27637. * The PassPostProcess id in the pipeline that contains the original scene color
  27638. * @type {string}
  27639. */
  27640. SSAOOriginalSceneColorEffect: string;
  27641. /**
  27642. * The SSAO PostProcess id in the pipeline
  27643. * @type {string}
  27644. */
  27645. SSAORenderEffect: string;
  27646. /**
  27647. * The horizontal blur PostProcess id in the pipeline
  27648. * @type {string}
  27649. */
  27650. SSAOBlurHRenderEffect: string;
  27651. /**
  27652. * The vertical blur PostProcess id in the pipeline
  27653. * @type {string}
  27654. */
  27655. SSAOBlurVRenderEffect: string;
  27656. /**
  27657. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  27658. * @type {string}
  27659. */
  27660. SSAOCombineRenderEffect: string;
  27661. /**
  27662. * The output strength of the SSAO post-process. Default value is 1.0.
  27663. * @type {number}
  27664. */
  27665. totalStrength: number;
  27666. /**
  27667. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  27668. * @type {number}
  27669. */
  27670. radius: number;
  27671. /**
  27672. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  27673. * Must not be equal to fallOff and superior to fallOff.
  27674. * Default value is 0.975
  27675. * @type {number}
  27676. */
  27677. area: number;
  27678. /**
  27679. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  27680. * Must not be equal to area and inferior to area.
  27681. * Default value is 0.0
  27682. * @type {number}
  27683. */
  27684. fallOff: number;
  27685. /**
  27686. * The base color of the SSAO post-process
  27687. * The final result is "base + ssao" between [0, 1]
  27688. * @type {number}
  27689. */
  27690. base: number;
  27691. private _scene;
  27692. private _depthTexture;
  27693. private _randomTexture;
  27694. private _originalColorPostProcess;
  27695. private _ssaoPostProcess;
  27696. private _blurHPostProcess;
  27697. private _blurVPostProcess;
  27698. private _ssaoCombinePostProcess;
  27699. private _firstUpdate;
  27700. /**
  27701. * @constructor
  27702. * @param {string} name - The rendering pipeline name
  27703. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  27704. * @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 }
  27705. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  27706. */
  27707. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  27708. /**
  27709. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  27710. */
  27711. dispose(disableDepthRender?: boolean): void;
  27712. private _createBlurPostProcess(ratio);
  27713. _rebuild(): void;
  27714. private _createSSAOPostProcess(ratio);
  27715. private _createSSAOCombinePostProcess(ratio);
  27716. private _createRandomTexture();
  27717. }
  27718. }
  27719. declare module BABYLON {
  27720. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  27721. /**
  27722. * Public members
  27723. */
  27724. originalPostProcess: Nullable<PostProcess>;
  27725. downSampleX4PostProcess: Nullable<PostProcess>;
  27726. brightPassPostProcess: Nullable<PostProcess>;
  27727. blurHPostProcesses: PostProcess[];
  27728. blurVPostProcesses: PostProcess[];
  27729. textureAdderPostProcess: Nullable<PostProcess>;
  27730. volumetricLightPostProcess: Nullable<PostProcess>;
  27731. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  27732. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  27733. volumetricLightMergePostProces: Nullable<PostProcess>;
  27734. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  27735. luminancePostProcess: Nullable<PostProcess>;
  27736. luminanceDownSamplePostProcesses: PostProcess[];
  27737. hdrPostProcess: Nullable<PostProcess>;
  27738. textureAdderFinalPostProcess: Nullable<PostProcess>;
  27739. lensFlareFinalPostProcess: Nullable<PostProcess>;
  27740. hdrFinalPostProcess: Nullable<PostProcess>;
  27741. lensFlarePostProcess: Nullable<PostProcess>;
  27742. lensFlareComposePostProcess: Nullable<PostProcess>;
  27743. motionBlurPostProcess: Nullable<PostProcess>;
  27744. depthOfFieldPostProcess: Nullable<PostProcess>;
  27745. brightThreshold: number;
  27746. blurWidth: number;
  27747. horizontalBlur: boolean;
  27748. exposure: number;
  27749. lensTexture: Nullable<Texture>;
  27750. volumetricLightCoefficient: number;
  27751. volumetricLightPower: number;
  27752. volumetricLightBlurScale: number;
  27753. sourceLight: Nullable<SpotLight | DirectionalLight>;
  27754. hdrMinimumLuminance: number;
  27755. hdrDecreaseRate: number;
  27756. hdrIncreaseRate: number;
  27757. lensColorTexture: Nullable<Texture>;
  27758. lensFlareStrength: number;
  27759. lensFlareGhostDispersal: number;
  27760. lensFlareHaloWidth: number;
  27761. lensFlareDistortionStrength: number;
  27762. lensStarTexture: Nullable<Texture>;
  27763. lensFlareDirtTexture: Nullable<Texture>;
  27764. depthOfFieldDistance: number;
  27765. depthOfFieldBlurWidth: number;
  27766. motionStrength: number;
  27767. animations: Animation[];
  27768. /**
  27769. * Private members
  27770. */
  27771. private _scene;
  27772. private _currentDepthOfFieldSource;
  27773. private _basePostProcess;
  27774. private _hdrCurrentLuminance;
  27775. private _floatTextureType;
  27776. private _ratio;
  27777. private _bloomEnabled;
  27778. private _depthOfFieldEnabled;
  27779. private _vlsEnabled;
  27780. private _lensFlareEnabled;
  27781. private _hdrEnabled;
  27782. private _motionBlurEnabled;
  27783. private _motionBlurSamples;
  27784. private _volumetricLightStepsCount;
  27785. BloomEnabled: boolean;
  27786. DepthOfFieldEnabled: boolean;
  27787. LensFlareEnabled: boolean;
  27788. HDREnabled: boolean;
  27789. VLSEnabled: boolean;
  27790. MotionBlurEnabled: boolean;
  27791. volumetricLightStepsCount: number;
  27792. motionBlurSamples: number;
  27793. /**
  27794. * @constructor
  27795. * @param {string} name - The rendering pipeline name
  27796. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  27797. * @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)
  27798. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  27799. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  27800. */
  27801. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  27802. private _buildPipeline();
  27803. private _createDownSampleX4PostProcess(scene, ratio);
  27804. private _createBrightPassPostProcess(scene, ratio);
  27805. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  27806. private _createTextureAdderPostProcess(scene, ratio);
  27807. private _createVolumetricLightPostProcess(scene, ratio);
  27808. private _createLuminancePostProcesses(scene, textureType);
  27809. private _createHdrPostProcess(scene, ratio);
  27810. private _createLensFlarePostProcess(scene, ratio);
  27811. private _createDepthOfFieldPostProcess(scene, ratio);
  27812. private _createMotionBlurPostProcess(scene, ratio);
  27813. private _getDepthTexture();
  27814. private _disposePostProcesses();
  27815. dispose(): void;
  27816. serialize(): any;
  27817. /**
  27818. * Static members
  27819. */
  27820. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  27821. static LuminanceSteps: number;
  27822. }
  27823. }