babylon.d.ts 1.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920
  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. name: string;
  306. id: string;
  307. uniqueId: number;
  308. state: string;
  309. metadata: any;
  310. doNotSerialize: boolean;
  311. animations: Animation[];
  312. private _ranges;
  313. onReady: (node: Node) => void;
  314. private _isEnabled;
  315. private _isReady;
  316. _currentRenderId: number;
  317. private _parentRenderId;
  318. _waitingParentId: Nullable<string>;
  319. private _scene;
  320. _cache: any;
  321. private _parentNode;
  322. private _children;
  323. parent: Nullable<Node>;
  324. getClassName(): string;
  325. /**
  326. * An event triggered when the mesh is disposed.
  327. * @type {BABYLON.Observable}
  328. */
  329. onDisposeObservable: Observable<Node>;
  330. private _onDisposeObserver;
  331. onDispose: () => void;
  332. /**
  333. * @constructor
  334. * @param {string} name - the name and id to be given to this node
  335. * @param {BABYLON.Scene} the scene this node will be added to
  336. */
  337. constructor(name: string, scene?: Nullable<Scene>);
  338. getScene(): Scene;
  339. getEngine(): Engine;
  340. private _behaviors;
  341. addBehavior(behavior: Behavior<Node>): Node;
  342. removeBehavior(behavior: Behavior<Node>): Node;
  343. readonly behaviors: Behavior<Node>[];
  344. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  345. getWorldMatrix(): Matrix;
  346. _initCache(): void;
  347. updateCache(force?: boolean): void;
  348. _updateCache(ignoreParentClass?: boolean): void;
  349. _isSynchronized(): boolean;
  350. _markSyncedWithParent(): void;
  351. isSynchronizedWithParent(): boolean;
  352. isSynchronized(updateCache?: boolean): boolean;
  353. hasNewParent(update?: boolean): boolean;
  354. /**
  355. * Is this node ready to be used/rendered
  356. * @return {boolean} is it ready
  357. */
  358. isReady(): boolean;
  359. /**
  360. * Is this node enabled.
  361. * 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.
  362. * @param {boolean} [checkAncestors=true] - 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.
  363. * @return {boolean} whether this node (and its parent) is enabled.
  364. * @see setEnabled
  365. */
  366. isEnabled(checkAncestors?: boolean): boolean;
  367. /**
  368. * Set the enabled state of this node.
  369. * @param {boolean} value - the new enabled state
  370. * @see isEnabled
  371. */
  372. setEnabled(value: boolean): void;
  373. /**
  374. * Is this node a descendant of the given node.
  375. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined.
  376. * @param {BABYLON.Node} ancestor - The parent node to inspect
  377. * @see parent
  378. */
  379. isDescendantOf(ancestor: Node): boolean;
  380. /**
  381. * Evaluate the list of children and determine if they should be considered as descendants considering the given criterias
  382. * @param {BABYLON.Node[]} results the result array containing the nodes matching the given criterias
  383. * @param {boolean} directDescendantsOnly 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.
  384. * @param predicate: an optional predicate that will be called on every evaluated children, the predicate must return true for a given child to be part of the result, otherwise it will be ignored.
  385. */
  386. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  387. /**
  388. * Will return all nodes that have this node as ascendant.
  389. * @param {boolean} directDescendantsOnly 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.
  390. * @param predicate: an optional predicate that will be called on every evaluated children, the predicate must return true for a given child to be part of the result, otherwise it will be ignored.
  391. * @return {BABYLON.Node[]} all children nodes of all types.
  392. */
  393. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  394. /**
  395. * Get all child-meshes of this node.
  396. */
  397. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  398. /**
  399. * Get all child-transformNodes of this node.
  400. */
  401. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  402. /**
  403. * Get all direct children of this node.
  404. */
  405. getChildren(predicate?: (node: Node) => boolean): Node[];
  406. _setReady(state: boolean): void;
  407. getAnimationByName(name: string): Nullable<Animation>;
  408. createAnimationRange(name: string, from: number, to: number): void;
  409. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  410. getAnimationRange(name: string): Nullable<AnimationRange>;
  411. /**
  412. * Will start the animation sequence
  413. * @param name defines the range frames for animation sequence
  414. * @param loop defines if the animation should loop (false by default)
  415. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  416. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  417. * @returns the {BABYLON.Animatable} object created for this animation. If range does not exist, it will return null
  418. */
  419. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  420. serializeAnimationRanges(): any;
  421. computeWorldMatrix(force?: boolean): Matrix;
  422. dispose(): void;
  423. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  424. }
  425. }
  426. declare module BABYLON {
  427. interface IDisposable {
  428. dispose(): void;
  429. }
  430. interface IActiveMeshCandidateProvider {
  431. getMeshes(scene: Scene): AbstractMesh[];
  432. readonly checksIsEnabled: boolean;
  433. }
  434. /**
  435. * This class is used by the onRenderingGroupObservable
  436. */
  437. class RenderingGroupInfo {
  438. /**
  439. * The Scene that being rendered
  440. */
  441. scene: Scene;
  442. /**
  443. * The camera currently used for the rendering pass
  444. */
  445. camera: Nullable<Camera>;
  446. /**
  447. * The ID of the renderingGroup being processed
  448. */
  449. renderingGroupId: number;
  450. /**
  451. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  452. */
  453. renderStage: number;
  454. /**
  455. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  456. * This stage will be fired no matter what
  457. */
  458. static STAGE_PRECLEAR: number;
  459. /**
  460. * Called before opaque object are rendered.
  461. * This stage will be fired only if there's 3D Opaque content to render
  462. */
  463. static STAGE_PREOPAQUE: number;
  464. /**
  465. * Called after the opaque objects are rendered and before the transparent ones
  466. * This stage will be fired only if there's 3D transparent content to render
  467. */
  468. static STAGE_PRETRANSPARENT: number;
  469. /**
  470. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  471. * This stage will be fired no matter what
  472. */
  473. static STAGE_POSTTRANSPARENT: number;
  474. }
  475. /**
  476. * Represents a scene to be rendered by the engine.
  477. * @see http://doc.babylonjs.com/page.php?p=21911
  478. */
  479. class Scene implements IAnimatable {
  480. private static _FOGMODE_NONE;
  481. private static _FOGMODE_EXP;
  482. private static _FOGMODE_EXP2;
  483. private static _FOGMODE_LINEAR;
  484. private static _uniqueIdCounter;
  485. static MinDeltaTime: number;
  486. static MaxDeltaTime: number;
  487. /** The fog is deactivated */
  488. static readonly FOGMODE_NONE: number;
  489. /** The fog density is following an exponential function */
  490. static readonly FOGMODE_EXP: number;
  491. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  492. static readonly FOGMODE_EXP2: number;
  493. /** The fog density is following a linear function. */
  494. static readonly FOGMODE_LINEAR: number;
  495. autoClear: boolean;
  496. autoClearDepthAndStencil: boolean;
  497. clearColor: Color4;
  498. ambientColor: Color3;
  499. _environmentBRDFTexture: BaseTexture;
  500. protected _environmentTexture: BaseTexture;
  501. /**
  502. * Texture used in all pbr material as the reflection texture.
  503. * As in the majority of the scene they are the same (exception for multi room and so on),
  504. * this is easier to reference from here than from all the materials.
  505. */
  506. /**
  507. * Texture used in all pbr material as the reflection texture.
  508. * As in the majority of the scene they are the same (exception for multi room and so on),
  509. * this is easier to set here than in all the materials.
  510. */
  511. environmentTexture: BaseTexture;
  512. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  513. /**
  514. * Default image processing configuration used either in the rendering
  515. * Forward main pass or through the imageProcessingPostProcess if present.
  516. * As in the majority of the scene they are the same (exception for multi camera),
  517. * this is easier to reference from here than from all the materials and post process.
  518. *
  519. * No setter as we it is a shared configuration, you can set the values instead.
  520. */
  521. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  522. forceWireframe: boolean;
  523. private _forcePointsCloud;
  524. forcePointsCloud: boolean;
  525. forceShowBoundingBoxes: boolean;
  526. clipPlane: Nullable<Plane>;
  527. animationsEnabled: boolean;
  528. useConstantAnimationDeltaTime: boolean;
  529. constantlyUpdateMeshUnderPointer: boolean;
  530. hoverCursor: string;
  531. defaultCursor: string;
  532. /**
  533. * This is used to call preventDefault() on pointer down
  534. * in order to block unwanted artifacts like system double clicks
  535. */
  536. preventDefaultOnPointerDown: boolean;
  537. metadata: any;
  538. loadingPluginName: string;
  539. private _spritePredicate;
  540. /**
  541. * An event triggered when the scene is disposed.
  542. * @type {BABYLON.Observable}
  543. */
  544. onDisposeObservable: Observable<Scene>;
  545. private _onDisposeObserver;
  546. /** A function to be executed when this scene is disposed. */
  547. onDispose: () => void;
  548. /**
  549. * An event triggered before rendering the scene (right after animations and physics)
  550. * @type {BABYLON.Observable}
  551. */
  552. onBeforeRenderObservable: Observable<Scene>;
  553. private _onBeforeRenderObserver;
  554. /** A function to be executed before rendering this scene */
  555. beforeRender: Nullable<() => void>;
  556. /**
  557. * An event triggered after rendering the scene
  558. * @type {BABYLON.Observable}
  559. */
  560. onAfterRenderObservable: Observable<Scene>;
  561. private _onAfterRenderObserver;
  562. /** A function to be executed after rendering this scene */
  563. afterRender: Nullable<() => void>;
  564. /**
  565. * An event triggered before animating the scene
  566. * @type {BABYLON.Observable}
  567. */
  568. onBeforeAnimationsObservable: Observable<Scene>;
  569. /**
  570. * An event triggered after animations processing
  571. * @type {BABYLON.Observable}
  572. */
  573. onAfterAnimationsObservable: Observable<Scene>;
  574. /**
  575. * An event triggered before draw calls are ready to be sent
  576. * @type {BABYLON.Observable}
  577. */
  578. onBeforeDrawPhaseObservable: Observable<Scene>;
  579. /**
  580. * An event triggered after draw calls have been sent
  581. * @type {BABYLON.Observable}
  582. */
  583. onAfterDrawPhaseObservable: Observable<Scene>;
  584. /**
  585. * An event triggered when physic simulation is about to be run
  586. * @type {BABYLON.Observable}
  587. */
  588. onBeforePhysicsObservable: Observable<Scene>;
  589. /**
  590. * An event triggered when physic simulation has been done
  591. * @type {BABYLON.Observable}
  592. */
  593. onAfterPhysicsObservable: Observable<Scene>;
  594. /**
  595. * An event triggered when the scene is ready
  596. * @type {BABYLON.Observable}
  597. */
  598. onReadyObservable: Observable<Scene>;
  599. /**
  600. * An event triggered before rendering a camera
  601. * @type {BABYLON.Observable}
  602. */
  603. onBeforeCameraRenderObservable: Observable<Camera>;
  604. private _onBeforeCameraRenderObserver;
  605. beforeCameraRender: () => void;
  606. /**
  607. * An event triggered after rendering a camera
  608. * @type {BABYLON.Observable}
  609. */
  610. onAfterCameraRenderObservable: Observable<Camera>;
  611. private _onAfterCameraRenderObserver;
  612. afterCameraRender: () => void;
  613. /**
  614. * An event triggered when active meshes evaluation is about to start
  615. * @type {BABYLON.Observable}
  616. */
  617. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  618. /**
  619. * An event triggered when active meshes evaluation is done
  620. * @type {BABYLON.Observable}
  621. */
  622. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  623. /**
  624. * An event triggered when particles rendering is about to start
  625. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  626. * @type {BABYLON.Observable}
  627. */
  628. onBeforeParticlesRenderingObservable: Observable<Scene>;
  629. /**
  630. * An event triggered when particles rendering is done
  631. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  632. * @type {BABYLON.Observable}
  633. */
  634. onAfterParticlesRenderingObservable: Observable<Scene>;
  635. /**
  636. * An event triggered when sprites rendering is about to start
  637. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  638. * @type {BABYLON.Observable}
  639. */
  640. onBeforeSpritesRenderingObservable: Observable<Scene>;
  641. /**
  642. * An event triggered when sprites rendering is done
  643. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  644. * @type {BABYLON.Observable}
  645. */
  646. onAfterSpritesRenderingObservable: Observable<Scene>;
  647. /**
  648. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  649. * @type {BABYLON.Observable}
  650. */
  651. onDataLoadedObservable: Observable<Scene>;
  652. /**
  653. * An event triggered when a camera is created
  654. * @type {BABYLON.Observable}
  655. */
  656. onNewCameraAddedObservable: Observable<Camera>;
  657. /**
  658. * An event triggered when a camera is removed
  659. * @type {BABYLON.Observable}
  660. */
  661. onCameraRemovedObservable: Observable<Camera>;
  662. /**
  663. * An event triggered when a light is created
  664. * @type {BABYLON.Observable}
  665. */
  666. onNewLightAddedObservable: Observable<Light>;
  667. /**
  668. * An event triggered when a light is removed
  669. * @type {BABYLON.Observable}
  670. */
  671. onLightRemovedObservable: Observable<Light>;
  672. /**
  673. * An event triggered when a geometry is created
  674. * @type {BABYLON.Observable}
  675. */
  676. onNewGeometryAddedObservable: Observable<Geometry>;
  677. /**
  678. * An event triggered when a geometry is removed
  679. * @type {BABYLON.Observable}
  680. */
  681. onGeometryRemovedObservable: Observable<Geometry>;
  682. /**
  683. * An event triggered when a transform node is created
  684. * @type {BABYLON.Observable}
  685. */
  686. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  687. /**
  688. * An event triggered when a transform node is removed
  689. * @type {BABYLON.Observable}
  690. */
  691. onTransformNodeRemovedObservable: Observable<TransformNode>;
  692. /**
  693. * An event triggered when a mesh is created
  694. * @type {BABYLON.Observable}
  695. */
  696. onNewMeshAddedObservable: Observable<AbstractMesh>;
  697. /**
  698. * An event triggered when a mesh is removed
  699. * @type {BABYLON.Observable}
  700. */
  701. onMeshRemovedObservable: Observable<AbstractMesh>;
  702. /**
  703. * An event triggered when render targets are about to be rendered
  704. * Can happen multiple times per frame.
  705. * @type {BABYLON.Observable}
  706. */
  707. OnBeforeRenderTargetsRenderObservable: Observable<Scene>;
  708. /**
  709. * An event triggered when render targets were rendered.
  710. * Can happen multiple times per frame.
  711. * @type {BABYLON.Observable}
  712. */
  713. OnAfterRenderTargetsRenderObservable: Observable<Scene>;
  714. /**
  715. * An event triggered before calculating deterministic simulation step
  716. * @type {BABYLON.Observable}
  717. */
  718. onBeforeStepObservable: Observable<Scene>;
  719. /**
  720. * An event triggered after calculating deterministic simulation step
  721. * @type {BABYLON.Observable}
  722. */
  723. onAfterStepObservable: Observable<Scene>;
  724. /**
  725. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  726. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  727. * 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)
  728. */
  729. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  730. animations: Animation[];
  731. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  732. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  733. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  734. private _onPointerMove;
  735. private _onPointerDown;
  736. private _onPointerUp;
  737. /** Deprecated. Use onPointerObservable instead */
  738. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  739. /** Deprecated. Use onPointerObservable instead */
  740. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  741. /** Deprecated. Use onPointerObservable instead */
  742. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>) => void;
  743. /** Deprecated. Use onPointerObservable instead */
  744. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  745. private _gamepadManager;
  746. readonly gamepadManager: GamepadManager;
  747. /**
  748. * 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).
  749. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  750. */
  751. onPrePointerObservable: Observable<PointerInfoPre>;
  752. /**
  753. * Observable event triggered each time an input event is received from the rendering canvas
  754. */
  755. onPointerObservable: Observable<PointerInfo>;
  756. readonly unTranslatedPointer: Vector2;
  757. /** The distance in pixel that you have to move to prevent some events */
  758. static DragMovementThreshold: number;
  759. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  760. static LongPressDelay: number;
  761. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  762. static DoubleClickDelay: number;
  763. /** If you need to check double click without raising a single click at first click, enable this flag */
  764. static ExclusiveDoubleClickMode: boolean;
  765. private _initClickEvent;
  766. private _initActionManager;
  767. private _delayedSimpleClick;
  768. private _delayedSimpleClickTimeout;
  769. private _previousDelayedSimpleClickTimeout;
  770. private _meshPickProceed;
  771. private _previousButtonPressed;
  772. private _currentPickResult;
  773. private _previousPickResult;
  774. private _totalPointersPressed;
  775. private _doubleClickOccured;
  776. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  777. cameraToUseForPointers: Nullable<Camera>;
  778. private _pointerX;
  779. private _pointerY;
  780. private _unTranslatedPointerX;
  781. private _unTranslatedPointerY;
  782. private _startingPointerPosition;
  783. private _previousStartingPointerPosition;
  784. private _startingPointerTime;
  785. private _previousStartingPointerTime;
  786. private _timeAccumulator;
  787. private _currentStepId;
  788. private _currentInternalStep;
  789. _mirroredCameraPosition: Nullable<Vector3>;
  790. /**
  791. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  792. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  793. */
  794. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  795. /**
  796. * Observable event triggered each time an keyboard event is received from the hosting window
  797. */
  798. onKeyboardObservable: Observable<KeyboardInfo>;
  799. private _onKeyDown;
  800. private _onKeyUp;
  801. private _onCanvasFocusObserver;
  802. private _onCanvasBlurObserver;
  803. /**
  804. * use right-handed coordinate system on this scene.
  805. * @type {boolean}
  806. */
  807. private _useRightHandedSystem;
  808. useRightHandedSystem: boolean;
  809. setStepId(newStepId: number): void;
  810. getStepId(): number;
  811. getInternalStep(): number;
  812. private _fogEnabled;
  813. /**
  814. * is fog enabled on this scene.
  815. */
  816. fogEnabled: boolean;
  817. private _fogMode;
  818. fogMode: number;
  819. fogColor: Color3;
  820. fogDensity: number;
  821. fogStart: number;
  822. fogEnd: number;
  823. /**
  824. * is shadow enabled on this scene.
  825. * @type {boolean}
  826. */
  827. private _shadowsEnabled;
  828. shadowsEnabled: boolean;
  829. /**
  830. * is light enabled on this scene.
  831. * @type {boolean}
  832. */
  833. private _lightsEnabled;
  834. lightsEnabled: boolean;
  835. /**
  836. * All of the lights added to this scene.
  837. * @see BABYLON.Light
  838. * @type {BABYLON.Light[]}
  839. */
  840. lights: Light[];
  841. /** All of the cameras added to this scene. */
  842. cameras: Camera[];
  843. /** All of the active cameras added to this scene. */
  844. activeCameras: Camera[];
  845. /** The current active camera */
  846. activeCamera: Nullable<Camera>;
  847. /**
  848. * All of the tranform nodes added to this scene.
  849. * @see BABYLON.TransformNode
  850. * @type {BABYLON.TransformNode[]}
  851. */
  852. transformNodes: TransformNode[];
  853. /**
  854. * All of the (abstract) meshes added to this scene.
  855. * @see BABYLON.AbstractMesh
  856. * @type {BABYLON.AbstractMesh[]}
  857. */
  858. meshes: AbstractMesh[];
  859. /**
  860. * All of the animation groups added to this scene.
  861. * @see BABYLON.AnimationGroup
  862. * @type {BABYLON.AnimationGroup[]}
  863. */
  864. animationGroups: AnimationGroup[];
  865. private _geometries;
  866. materials: Material[];
  867. multiMaterials: MultiMaterial[];
  868. private _defaultMaterial;
  869. /** The default material used on meshes when no material is affected */
  870. /** The default material used on meshes when no material is affected */
  871. defaultMaterial: Material;
  872. private _texturesEnabled;
  873. texturesEnabled: boolean;
  874. textures: BaseTexture[];
  875. particlesEnabled: boolean;
  876. particleSystems: IParticleSystem[];
  877. spritesEnabled: boolean;
  878. spriteManagers: SpriteManager[];
  879. layers: Layer[];
  880. highlightLayers: HighlightLayer[];
  881. private _skeletonsEnabled;
  882. skeletonsEnabled: boolean;
  883. skeletons: Skeleton[];
  884. morphTargetManagers: MorphTargetManager[];
  885. lensFlaresEnabled: boolean;
  886. lensFlareSystems: LensFlareSystem[];
  887. collisionsEnabled: boolean;
  888. private _workerCollisions;
  889. collisionCoordinator: ICollisionCoordinator;
  890. /** Defines the gravity applied to this scene */
  891. gravity: Vector3;
  892. postProcesses: PostProcess[];
  893. postProcessesEnabled: boolean;
  894. postProcessManager: PostProcessManager;
  895. private _postProcessRenderPipelineManager;
  896. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  897. renderTargetsEnabled: boolean;
  898. dumpNextRenderTargets: boolean;
  899. customRenderTargets: RenderTargetTexture[];
  900. useDelayedTextureLoading: boolean;
  901. importedMeshesFiles: String[];
  902. probesEnabled: boolean;
  903. reflectionProbes: ReflectionProbe[];
  904. database: Database;
  905. /**
  906. * This scene's action manager
  907. * @type {BABYLON.ActionManager}
  908. */
  909. actionManager: ActionManager;
  910. _actionManagers: ActionManager[];
  911. private _meshesForIntersections;
  912. proceduralTexturesEnabled: boolean;
  913. _proceduralTextures: ProceduralTexture[];
  914. private _mainSoundTrack;
  915. soundTracks: SoundTrack[];
  916. private _audioEnabled;
  917. private _headphone;
  918. readonly mainSoundTrack: SoundTrack;
  919. VRHelper: VRExperienceHelper;
  920. simplificationQueue: SimplificationQueue;
  921. private _engine;
  922. private _totalVertices;
  923. _activeIndices: PerfCounter;
  924. _activeParticles: PerfCounter;
  925. _activeBones: PerfCounter;
  926. private _animationRatio;
  927. private _animationTimeLast;
  928. private _animationTime;
  929. animationTimeScale: number;
  930. _cachedMaterial: Nullable<Material>;
  931. _cachedEffect: Nullable<Effect>;
  932. _cachedVisibility: Nullable<number>;
  933. private _renderId;
  934. private _executeWhenReadyTimeoutId;
  935. private _intermediateRendering;
  936. private _viewUpdateFlag;
  937. private _projectionUpdateFlag;
  938. private _alternateViewUpdateFlag;
  939. private _alternateProjectionUpdateFlag;
  940. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  941. private _activeRequests;
  942. private _pendingData;
  943. private _isDisposed;
  944. dispatchAllSubMeshesOfActiveMeshes: boolean;
  945. private _activeMeshes;
  946. private _processedMaterials;
  947. private _renderTargets;
  948. _activeParticleSystems: SmartArray<IParticleSystem>;
  949. private _activeSkeletons;
  950. private _softwareSkinnedMeshes;
  951. private _renderingManager;
  952. private _physicsEngine;
  953. _activeAnimatables: Animatable[];
  954. private _transformMatrix;
  955. private _sceneUbo;
  956. private _alternateSceneUbo;
  957. private _pickWithRayInverseMatrix;
  958. private _boundingBoxRenderer;
  959. private _outlineRenderer;
  960. private _viewMatrix;
  961. private _projectionMatrix;
  962. private _alternateViewMatrix;
  963. private _alternateProjectionMatrix;
  964. private _alternateTransformMatrix;
  965. private _useAlternateCameraConfiguration;
  966. private _alternateRendering;
  967. _forcedViewPosition: Nullable<Vector3>;
  968. readonly _isAlternateRenderingEnabled: boolean;
  969. private _frustumPlanes;
  970. readonly frustumPlanes: Plane[];
  971. requireLightSorting: boolean;
  972. private _selectionOctree;
  973. private _pointerOverMesh;
  974. private _pointerOverSprite;
  975. private _debugLayer;
  976. private _depthRenderer;
  977. private _geometryBufferRenderer;
  978. /**
  979. * Gets the current geometry buffer associated to the scene.
  980. */
  981. /**
  982. * Sets the current geometry buffer for the scene.
  983. */
  984. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  985. private _pickedDownMesh;
  986. private _pickedUpMesh;
  987. private _pickedDownSprite;
  988. private _externalData;
  989. private _uid;
  990. /**
  991. * @constructor
  992. * @param {BABYLON.Engine} engine - the engine to be used to render this scene.
  993. */
  994. constructor(engine: Engine);
  995. readonly debugLayer: DebugLayer;
  996. workerCollisions: boolean;
  997. readonly selectionOctree: Octree<AbstractMesh>;
  998. /**
  999. * The mesh that is currently under the pointer.
  1000. * @return {BABYLON.AbstractMesh} mesh under the pointer/mouse cursor or null if none.
  1001. */
  1002. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1003. /**
  1004. * Current on-screen X position of the pointer
  1005. * @return {number} X position of the pointer
  1006. */
  1007. readonly pointerX: number;
  1008. /**
  1009. * Current on-screen Y position of the pointer
  1010. * @return {number} Y position of the pointer
  1011. */
  1012. readonly pointerY: number;
  1013. getCachedMaterial(): Nullable<Material>;
  1014. getCachedEffect(): Nullable<Effect>;
  1015. getCachedVisibility(): Nullable<number>;
  1016. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1017. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1018. getOutlineRenderer(): OutlineRenderer;
  1019. getEngine(): Engine;
  1020. getTotalVertices(): number;
  1021. readonly totalVerticesPerfCounter: PerfCounter;
  1022. getActiveIndices(): number;
  1023. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1024. getActiveParticles(): number;
  1025. readonly activeParticlesPerfCounter: PerfCounter;
  1026. getActiveBones(): number;
  1027. readonly activeBonesPerfCounter: PerfCounter;
  1028. getInterFramePerfCounter(): number;
  1029. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1030. getLastFrameDuration(): number;
  1031. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1032. getEvaluateActiveMeshesDuration(): number;
  1033. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1034. getActiveMeshes(): SmartArray<AbstractMesh>;
  1035. getRenderTargetsDuration(): number;
  1036. getRenderDuration(): number;
  1037. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1038. getParticlesDuration(): number;
  1039. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1040. getSpritesDuration(): number;
  1041. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1042. getAnimationRatio(): number;
  1043. getRenderId(): number;
  1044. incrementRenderId(): void;
  1045. private _updatePointerPosition(evt);
  1046. private _createUbo();
  1047. private _createAlternateUbo();
  1048. /**
  1049. * Use this method to simulate a pointer move on a mesh
  1050. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1051. */
  1052. simulatePointerMove(pickResult: PickingInfo): Scene;
  1053. private _processPointerMove(pickResult, evt);
  1054. /**
  1055. * Use this method to simulate a pointer down on a mesh
  1056. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1057. */
  1058. simulatePointerDown(pickResult: PickingInfo): Scene;
  1059. private _processPointerDown(pickResult, evt);
  1060. /**
  1061. * Use this method to simulate a pointer up on a mesh
  1062. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1063. */
  1064. simulatePointerUp(pickResult: PickingInfo): Scene;
  1065. private _processPointerUp(pickResult, evt, clickInfo);
  1066. /**
  1067. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1068. * @param attachUp defines if you want to attach events to pointerup
  1069. * @param attachDown defines if you want to attach events to pointerdown
  1070. * @param attachMove defines if you want to attach events to pointermove
  1071. */
  1072. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1073. detachControl(): void;
  1074. /**
  1075. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1076. * Delay loaded resources are not taking in account
  1077. * @return true if all required resources are ready
  1078. */
  1079. isReady(): boolean;
  1080. resetCachedMaterial(): void;
  1081. registerBeforeRender(func: () => void): void;
  1082. unregisterBeforeRender(func: () => void): void;
  1083. registerAfterRender(func: () => void): void;
  1084. unregisterAfterRender(func: () => void): void;
  1085. private _executeOnceBeforeRender(func);
  1086. /**
  1087. * The provided function will run before render once and will be disposed afterwards.
  1088. * A timeout delay can be provided so that the function will be executed in N ms.
  1089. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1090. * @param func The function to be executed.
  1091. * @param timeout optional delay in ms
  1092. */
  1093. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1094. _addPendingData(data: any): void;
  1095. _removePendingData(data: any): void;
  1096. getWaitingItemsCount(): number;
  1097. readonly isLoading: boolean;
  1098. /**
  1099. * Registers a function to be executed when the scene is ready.
  1100. * @param {Function} func - the function to be executed.
  1101. */
  1102. executeWhenReady(func: () => void): void;
  1103. _checkIsReady(): void;
  1104. /**
  1105. * Will start the animation sequence of a given target
  1106. * @param target - the target
  1107. * @param {number} from - from which frame should animation start
  1108. * @param {number} to - till which frame should animation run.
  1109. * @param {boolean} [loop] - should the animation loop
  1110. * @param {number} [speedRatio] - the speed in which to run the animation
  1111. * @param {Function} [onAnimationEnd] function to be executed when the animation ended.
  1112. * @param {BABYLON.Animatable} [animatable] an animatable object. If not provided a new one will be created from the given params.
  1113. * Returns {BABYLON.Animatable} the animatable object created for this animation
  1114. * See BABYLON.Animatable
  1115. */
  1116. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1117. /**
  1118. * Begin a new animation on a given node
  1119. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1120. * @param {BABYLON.Animation[]} defines the list of animations to start
  1121. * @param {number} from defines the initial value
  1122. * @param {number} to defines the final value
  1123. * @param {boolean} loop defines if you want animation to loop (off by default)
  1124. * @param {number} speedRatio defines the speed ratio to apply to all animations
  1125. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1126. * @returns the list of created animatables
  1127. */
  1128. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1129. /**
  1130. * Begin a new animation on a given node and its hierarchy
  1131. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1132. * @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.
  1133. * @param {BABYLON.Animation[]} defines the list of animations to start
  1134. * @param {number} from defines the initial value
  1135. * @param {number} to defines the final value
  1136. * @param {boolean} loop defines if you want animation to loop (off by default)
  1137. * @param {number} speedRatio defines the speed ratio to apply to all animations
  1138. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1139. * @returns the list of animatables created for all nodes
  1140. */
  1141. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1142. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1143. readonly animatables: Animatable[];
  1144. /**
  1145. * Will stop the animation of the given target
  1146. * @param target - the target
  1147. * @param animationName - the name of the animation to stop (all animations will be stopped is empty)
  1148. * @see beginAnimation
  1149. */
  1150. stopAnimation(target: any, animationName?: string): void;
  1151. /**
  1152. * Stops and removes all animations that have been applied to the scene
  1153. */
  1154. stopAllAnimations(): void;
  1155. private _animate();
  1156. _switchToAlternateCameraConfiguration(active: boolean): void;
  1157. getViewMatrix(): Matrix;
  1158. getProjectionMatrix(): Matrix;
  1159. getTransformMatrix(): Matrix;
  1160. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1161. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1162. getSceneUniformBuffer(): UniformBuffer;
  1163. getUniqueId(): number;
  1164. addMesh(newMesh: AbstractMesh): void;
  1165. removeMesh(toRemove: AbstractMesh): number;
  1166. addTransformNode(newTransformNode: TransformNode): void;
  1167. removeTransformNode(toRemove: TransformNode): number;
  1168. removeSkeleton(toRemove: Skeleton): number;
  1169. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1170. removeLight(toRemove: Light): number;
  1171. removeCamera(toRemove: Camera): number;
  1172. removeParticleSystem(toRemove: ParticleSystem): number;
  1173. removeAnimation(toRemove: Animation): number;
  1174. removeMultiMaterial(toRemove: MultiMaterial): number;
  1175. removeMaterial(toRemove: Material): number;
  1176. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1177. removeActionManager(toRemove: ActionManager): number;
  1178. addLight(newLight: Light): void;
  1179. sortLightsByPriority(): void;
  1180. addCamera(newCamera: Camera): void;
  1181. addSkeleton(newSkeleton: Skeleton): void;
  1182. addParticleSystem(newParticleSystem: ParticleSystem): void;
  1183. addAnimation(newAnimation: Animation): void;
  1184. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1185. addMaterial(newMaterial: Material): void;
  1186. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1187. addGeometry(newGeometrie: Geometry): void;
  1188. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1189. addActionManager(newActionManager: ActionManager): void;
  1190. /**
  1191. * Switch active camera
  1192. * @param {Camera} newCamera - new active camera
  1193. * @param {boolean} attachControl - call attachControl for the new active camera (default: true)
  1194. */
  1195. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1196. /**
  1197. * sets the active camera of the scene using its ID
  1198. * @param {string} id - the camera's ID
  1199. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1200. * @see activeCamera
  1201. */
  1202. setActiveCameraByID(id: string): Nullable<Camera>;
  1203. /**
  1204. * sets the active camera of the scene using its name
  1205. * @param {string} name - the camera's name
  1206. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1207. * @see activeCamera
  1208. */
  1209. setActiveCameraByName(name: string): Nullable<Camera>;
  1210. /**
  1211. * get an animation group using its name
  1212. * @param {string} the material's name
  1213. * @return {BABYLON.AnimationGroup|null} the animation group or null if none found.
  1214. */
  1215. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1216. /**
  1217. * get a material using its id
  1218. * @param {string} the material's ID
  1219. * @return {BABYLON.Material|null} the material or null if none found.
  1220. */
  1221. getMaterialByID(id: string): Nullable<Material>;
  1222. /**
  1223. * get a material using its name
  1224. * @param {string} the material's name
  1225. * @return {BABYLON.Material|null} the material or null if none found.
  1226. */
  1227. getMaterialByName(name: string): Nullable<Material>;
  1228. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  1229. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  1230. getCameraByID(id: string): Nullable<Camera>;
  1231. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1232. /**
  1233. * get a camera using its name
  1234. * @param {string} the camera's name
  1235. * @return {BABYLON.Camera|null} the camera or null if none found.
  1236. */
  1237. getCameraByName(name: string): Nullable<Camera>;
  1238. /**
  1239. * get a bone using its id
  1240. * @param {string} the bone's id
  1241. * @return {BABYLON.Bone|null} the bone or null if not found
  1242. */
  1243. getBoneByID(id: string): Nullable<Bone>;
  1244. /**
  1245. * get a bone using its id
  1246. * @param {string} the bone's name
  1247. * @return {BABYLON.Bone|null} the bone or null if not found
  1248. */
  1249. getBoneByName(name: string): Nullable<Bone>;
  1250. /**
  1251. * get a light node using its name
  1252. * @param {string} the light's name
  1253. * @return {BABYLON.Light|null} the light or null if none found.
  1254. */
  1255. getLightByName(name: string): Nullable<Light>;
  1256. /**
  1257. * get a light node using its ID
  1258. * @param {string} the light's id
  1259. * @return {BABYLON.Light|null} the light or null if none found.
  1260. */
  1261. getLightByID(id: string): Nullable<Light>;
  1262. /**
  1263. * get a light node using its scene-generated unique ID
  1264. * @param {number} the light's unique id
  1265. * @return {BABYLON.Light|null} the light or null if none found.
  1266. */
  1267. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  1268. /**
  1269. * get a particle system by id
  1270. * @param id {number} the particle system id
  1271. * @return {BABYLON.IParticleSystem|null} the corresponding system or null if none found.
  1272. */
  1273. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  1274. /**
  1275. * get a geometry using its ID
  1276. * @param {string} the geometry's id
  1277. * @return {BABYLON.Geometry|null} the geometry or null if none found.
  1278. */
  1279. getGeometryByID(id: string): Nullable<Geometry>;
  1280. /**
  1281. * add a new geometry to this scene.
  1282. * @param {BABYLON.Geometry} geometry - the geometry to be added to the scene.
  1283. * @param {boolean} [force] - force addition, even if a geometry with this ID already exists
  1284. * @return {boolean} was the geometry added or not
  1285. */
  1286. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  1287. /**
  1288. * Removes an existing geometry
  1289. * @param {BABYLON.Geometry} geometry - the geometry to be removed from the scene.
  1290. * @return {boolean} was the geometry removed or not
  1291. */
  1292. removeGeometry(geometry: Geometry): boolean;
  1293. getGeometries(): Geometry[];
  1294. /**
  1295. * Get the first added mesh found of a given ID
  1296. * @param {string} id - the id to search for
  1297. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1298. */
  1299. getMeshByID(id: string): Nullable<AbstractMesh>;
  1300. getMeshesByID(id: string): Array<AbstractMesh>;
  1301. /**
  1302. * Get the first added transform node found of a given ID
  1303. * @param {string} id - the id to search for
  1304. * @return {BABYLON.TransformNode|null} the transform node found or null if not found at all.
  1305. */
  1306. getTransformNodeByID(id: string): Nullable<TransformNode>;
  1307. getTransformNodesByID(id: string): Array<TransformNode>;
  1308. /**
  1309. * Get a mesh with its auto-generated unique id
  1310. * @param {number} uniqueId - the unique id to search for
  1311. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1312. */
  1313. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  1314. /**
  1315. * Get a the last added mesh found of a given ID
  1316. * @param {string} id - the id to search for
  1317. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1318. */
  1319. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  1320. /**
  1321. * Get a the last added node (Mesh, Camera, Light) found of a given ID
  1322. * @param {string} id - the id to search for
  1323. * @return {BABYLON.Node|null} the node found or null if not found at all.
  1324. */
  1325. getLastEntryByID(id: string): Nullable<Node>;
  1326. getNodeByID(id: string): Nullable<Node>;
  1327. getNodeByName(name: string): Nullable<Node>;
  1328. getMeshByName(name: string): Nullable<AbstractMesh>;
  1329. getTransformNodeByName(name: string): Nullable<TransformNode>;
  1330. getSoundByName(name: string): Nullable<Sound>;
  1331. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  1332. getSkeletonById(id: string): Nullable<Skeleton>;
  1333. getSkeletonByName(name: string): Nullable<Skeleton>;
  1334. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  1335. isActiveMesh(mesh: AbstractMesh): boolean;
  1336. /**
  1337. * Return a the first highlight layer of the scene with a given name.
  1338. * @param name The name of the highlight layer to look for.
  1339. * @return The highlight layer if found otherwise null.
  1340. */
  1341. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  1342. /**
  1343. * Return a unique id as a string which can serve as an identifier for the scene
  1344. */
  1345. readonly uid: string;
  1346. /**
  1347. * Add an externaly attached data from its key.
  1348. * This method call will fail and return false, if such key already exists.
  1349. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  1350. * @param key the unique key that identifies the data
  1351. * @param data the data object to associate to the key for this Engine instance
  1352. * @return true if no such key were already present and the data was added successfully, false otherwise
  1353. */
  1354. addExternalData<T>(key: string, data: T): boolean;
  1355. /**
  1356. * Get an externaly attached data from its key
  1357. * @param key the unique key that identifies the data
  1358. * @return the associated data, if present (can be null), or undefined if not present
  1359. */
  1360. getExternalData<T>(key: string): Nullable<T>;
  1361. /**
  1362. * Get an externaly attached data from its key, create it using a factory if it's not already present
  1363. * @param key the unique key that identifies the data
  1364. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  1365. * @return the associated data, can be null if the factory returned null.
  1366. */
  1367. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  1368. /**
  1369. * Remove an externaly attached data from the Engine instance
  1370. * @param key the unique key that identifies the data
  1371. * @return true if the data was successfully removed, false if it doesn't exist
  1372. */
  1373. removeExternalData(key: string): boolean;
  1374. private _evaluateSubMesh(subMesh, mesh);
  1375. _isInIntermediateRendering(): boolean;
  1376. private _activeMeshCandidateProvider;
  1377. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  1378. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  1379. private _activeMeshesFrozen;
  1380. /**
  1381. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  1382. */
  1383. freezeActiveMeshes(): Scene;
  1384. /**
  1385. * Use this function to restart evaluating active meshes on every frame
  1386. */
  1387. unfreezeActiveMeshes(): this;
  1388. private _evaluateActiveMeshes();
  1389. private _activeMesh(sourceMesh, mesh);
  1390. updateTransformMatrix(force?: boolean): void;
  1391. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  1392. private _renderForCamera(camera);
  1393. private _processSubCameras(camera);
  1394. private _checkIntersections();
  1395. render(): void;
  1396. private _updateAudioParameters();
  1397. audioEnabled: boolean;
  1398. private _disableAudio();
  1399. private _enableAudio();
  1400. headphone: boolean;
  1401. private _switchAudioModeForHeadphones();
  1402. private _switchAudioModeForNormalSpeakers();
  1403. enableDepthRenderer(): DepthRenderer;
  1404. disableDepthRenderer(): void;
  1405. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  1406. disableGeometryBufferRenderer(): void;
  1407. freezeMaterials(): void;
  1408. unfreezeMaterials(): void;
  1409. dispose(): void;
  1410. readonly isDisposed: boolean;
  1411. disposeSounds(): void;
  1412. getWorldExtends(): {
  1413. min: Vector3;
  1414. max: Vector3;
  1415. };
  1416. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  1417. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  1418. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  1419. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  1420. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  1421. private _internalPick(rayFunction, predicate?, fastCheck?);
  1422. private _internalMultiPick(rayFunction, predicate?);
  1423. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  1424. private _tempPickingRay;
  1425. /** Launch a ray to try to pick a mesh in the scene
  1426. * @param x position on screen
  1427. * @param y position on screen
  1428. * @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
  1429. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1430. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1431. */
  1432. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  1433. /** Launch a ray to try to pick a sprite in the scene
  1434. * @param x position on screen
  1435. * @param y position on screen
  1436. * @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
  1437. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1438. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1439. */
  1440. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  1441. private _cachedRayForTransform;
  1442. /** Use the given ray to pick a mesh in the scene
  1443. * @param ray The ray to use to pick meshes
  1444. * @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
  1445. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1446. */
  1447. pickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  1448. /**
  1449. * Launch a ray to try to pick a mesh in the scene
  1450. * @param x X position on screen
  1451. * @param y Y position on screen
  1452. * @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
  1453. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1454. */
  1455. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  1456. /**
  1457. * Launch a ray to try to pick a mesh in the scene
  1458. * @param ray Ray to use
  1459. * @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
  1460. */
  1461. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  1462. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  1463. getPointerOverMesh(): Nullable<AbstractMesh>;
  1464. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  1465. getPointerOverSprite(): Nullable<Sprite>;
  1466. getPhysicsEngine(): Nullable<PhysicsEngine>;
  1467. /**
  1468. * Enables physics to the current scene
  1469. * @param {BABYLON.Vector3} [gravity] - the scene's gravity for the physics engine
  1470. * @param {BABYLON.IPhysicsEnginePlugin} [plugin] - The physics engine to be used. defaults to OimoJS.
  1471. * @return {boolean} was the physics engine initialized
  1472. */
  1473. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  1474. disablePhysicsEngine(): void;
  1475. isPhysicsEnabled(): boolean;
  1476. deleteCompoundImpostor(compound: any): void;
  1477. _rebuildGeometries(): void;
  1478. _rebuildTextures(): void;
  1479. /**
  1480. * Creates a default light for the scene.
  1481. * @param replace Whether to replace the existing lights in the scene.
  1482. */
  1483. createDefaultLight(replace?: boolean): void;
  1484. /**
  1485. * Creates a default camera for the scene.
  1486. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  1487. * @param replace Whether to replace the existing active camera in the scene.
  1488. * @param attachCameraControls Whether to attach camera controls to the canvas.
  1489. */
  1490. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  1491. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  1492. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number): Nullable<Mesh>;
  1493. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  1494. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  1495. private _getByTags(list, tagsQuery, forEach?);
  1496. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  1497. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  1498. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  1499. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  1500. /**
  1501. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  1502. * This allowed control for front to back rendering or reversly depending of the special needs.
  1503. *
  1504. * @param renderingGroupId The rendering group id corresponding to its index
  1505. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  1506. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  1507. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  1508. */
  1509. 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;
  1510. /**
  1511. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  1512. *
  1513. * @param renderingGroupId The rendering group id corresponding to its index
  1514. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  1515. * @param depth Automatically clears depth between groups if true and autoClear is true.
  1516. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  1517. */
  1518. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  1519. /**
  1520. * Will flag all materials as dirty to trigger new shader compilation
  1521. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  1522. */
  1523. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  1524. _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;
  1525. /** @ignore */
  1526. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  1527. }
  1528. }
  1529. declare module BABYLON {
  1530. type Nullable<T> = T | null;
  1531. type float = number;
  1532. type double = number;
  1533. type int = number;
  1534. type FloatArray = number[] | Float32Array;
  1535. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  1536. }
  1537. declare module BABYLON {
  1538. class Action {
  1539. triggerOptions: any;
  1540. trigger: number;
  1541. _actionManager: ActionManager;
  1542. private _nextActiveAction;
  1543. private _child;
  1544. private _condition?;
  1545. private _triggerParameter;
  1546. onBeforeExecuteObservable: Observable<Action>;
  1547. constructor(triggerOptions: any, condition?: Condition);
  1548. _prepare(): void;
  1549. getTriggerParameter(): any;
  1550. _executeCurrent(evt?: ActionEvent): void;
  1551. execute(evt?: ActionEvent): void;
  1552. skipToNextActiveAction(): void;
  1553. then(action: Action): Action;
  1554. _getProperty(propertyPath: string): string;
  1555. _getEffectiveTarget(target: any, propertyPath: string): any;
  1556. serialize(parent: any): any;
  1557. protected _serialize(serializedAction: any, parent?: any): any;
  1558. static _SerializeValueAsString: (value: any) => string;
  1559. static _GetTargetProperty: (target: Scene | Node) => {
  1560. name: string;
  1561. targetType: string;
  1562. value: string;
  1563. };
  1564. }
  1565. }
  1566. declare module BABYLON {
  1567. /**
  1568. * ActionEvent is the event beint sent when an action is triggered.
  1569. */
  1570. class ActionEvent {
  1571. source: any;
  1572. pointerX: number;
  1573. pointerY: number;
  1574. meshUnderPointer: Nullable<AbstractMesh>;
  1575. sourceEvent: any;
  1576. additionalData: any;
  1577. /**
  1578. * @param source The mesh or sprite that triggered the action.
  1579. * @param pointerX The X mouse cursor position at the time of the event
  1580. * @param pointerY The Y mouse cursor position at the time of the event
  1581. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  1582. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  1583. */
  1584. constructor(source: any, pointerX: number, pointerY: number, meshUnderPointer: Nullable<AbstractMesh>, sourceEvent?: any, additionalData?: any);
  1585. /**
  1586. * Helper function to auto-create an ActionEvent from a source mesh.
  1587. * @param source The source mesh that triggered the event
  1588. * @param evt {Event} The original (browser) event
  1589. */
  1590. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  1591. /**
  1592. * Helper function to auto-create an ActionEvent from a source mesh.
  1593. * @param source The source sprite that triggered the event
  1594. * @param scene Scene associated with the sprite
  1595. * @param evt {Event} The original (browser) event
  1596. */
  1597. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  1598. /**
  1599. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  1600. * @param scene the scene where the event occurred
  1601. * @param evt {Event} The original (browser) event
  1602. */
  1603. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  1604. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  1605. }
  1606. /**
  1607. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  1608. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  1609. */
  1610. class ActionManager {
  1611. private static _NothingTrigger;
  1612. private static _OnPickTrigger;
  1613. private static _OnLeftPickTrigger;
  1614. private static _OnRightPickTrigger;
  1615. private static _OnCenterPickTrigger;
  1616. private static _OnPickDownTrigger;
  1617. private static _OnDoublePickTrigger;
  1618. private static _OnPickUpTrigger;
  1619. private static _OnLongPressTrigger;
  1620. private static _OnPointerOverTrigger;
  1621. private static _OnPointerOutTrigger;
  1622. private static _OnEveryFrameTrigger;
  1623. private static _OnIntersectionEnterTrigger;
  1624. private static _OnIntersectionExitTrigger;
  1625. private static _OnKeyDownTrigger;
  1626. private static _OnKeyUpTrigger;
  1627. private static _OnPickOutTrigger;
  1628. static readonly NothingTrigger: number;
  1629. static readonly OnPickTrigger: number;
  1630. static readonly OnLeftPickTrigger: number;
  1631. static readonly OnRightPickTrigger: number;
  1632. static readonly OnCenterPickTrigger: number;
  1633. static readonly OnPickDownTrigger: number;
  1634. static readonly OnDoublePickTrigger: number;
  1635. static readonly OnPickUpTrigger: number;
  1636. static readonly OnPickOutTrigger: number;
  1637. static readonly OnLongPressTrigger: number;
  1638. static readonly OnPointerOverTrigger: number;
  1639. static readonly OnPointerOutTrigger: number;
  1640. static readonly OnEveryFrameTrigger: number;
  1641. static readonly OnIntersectionEnterTrigger: number;
  1642. static readonly OnIntersectionExitTrigger: number;
  1643. static readonly OnKeyDownTrigger: number;
  1644. static readonly OnKeyUpTrigger: number;
  1645. static Triggers: {
  1646. [key: string]: number;
  1647. };
  1648. actions: Action[];
  1649. hoverCursor: string;
  1650. private _scene;
  1651. constructor(scene: Scene);
  1652. dispose(): void;
  1653. getScene(): Scene;
  1654. /**
  1655. * Does this action manager handles actions of any of the given triggers
  1656. * @param {number[]} triggers - the triggers to be tested
  1657. * @return {boolean} whether one (or more) of the triggers is handeled
  1658. */
  1659. hasSpecificTriggers(triggers: number[]): boolean;
  1660. /**
  1661. * Does this action manager handles actions of a given trigger
  1662. * @param {number} trigger - the trigger to be tested
  1663. * @return {boolean} whether the trigger is handeled
  1664. */
  1665. hasSpecificTrigger(trigger: number): boolean;
  1666. /**
  1667. * Does this action manager has pointer triggers
  1668. * @return {boolean} whether or not it has pointer triggers
  1669. */
  1670. readonly hasPointerTriggers: boolean;
  1671. /**
  1672. * Does this action manager has pick triggers
  1673. * @return {boolean} whether or not it has pick triggers
  1674. */
  1675. readonly hasPickTriggers: boolean;
  1676. /**
  1677. * Does exist one action manager with at least one trigger
  1678. * @return {boolean} whether or not it exists one action manager with one trigger
  1679. **/
  1680. static readonly HasTriggers: boolean;
  1681. /**
  1682. * Does exist one action manager with at least one pick trigger
  1683. * @return {boolean} whether or not it exists one action manager with one pick trigger
  1684. **/
  1685. static readonly HasPickTriggers: boolean;
  1686. /**
  1687. * Does exist one action manager that handles actions of a given trigger
  1688. * @param {number} trigger - the trigger to be tested
  1689. * @return {boolean} whether the trigger is handeled by at least one action manager
  1690. **/
  1691. static HasSpecificTrigger(trigger: number): boolean;
  1692. /**
  1693. * Registers an action to this action manager
  1694. * @param {BABYLON.Action} action - the action to be registered
  1695. * @return {BABYLON.Action} the action amended (prepared) after registration
  1696. */
  1697. registerAction(action: Action): Nullable<Action>;
  1698. /**
  1699. * Unregisters an action to this action manager
  1700. * @param action The action to be unregistered
  1701. * @return whether the action has been unregistered
  1702. */
  1703. unregisterAction(action: Action): Boolean;
  1704. /**
  1705. * Process a specific trigger
  1706. * @param {number} trigger - the trigger to process
  1707. * @param evt {BABYLON.ActionEvent} the event details to be processed
  1708. */
  1709. processTrigger(trigger: number, evt?: ActionEvent): void;
  1710. _getEffectiveTarget(target: any, propertyPath: string): any;
  1711. _getProperty(propertyPath: string): string;
  1712. serialize(name: string): any;
  1713. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  1714. static GetTriggerName(trigger: number): string;
  1715. }
  1716. }
  1717. declare module BABYLON {
  1718. class Condition {
  1719. _actionManager: ActionManager;
  1720. _evaluationId: number;
  1721. _currentResult: boolean;
  1722. constructor(actionManager: ActionManager);
  1723. isValid(): boolean;
  1724. _getProperty(propertyPath: string): string;
  1725. _getEffectiveTarget(target: any, propertyPath: string): any;
  1726. serialize(): any;
  1727. protected _serialize(serializedCondition: any): any;
  1728. }
  1729. class ValueCondition extends Condition {
  1730. propertyPath: string;
  1731. value: any;
  1732. operator: number;
  1733. private static _IsEqual;
  1734. private static _IsDifferent;
  1735. private static _IsGreater;
  1736. private static _IsLesser;
  1737. static readonly IsEqual: number;
  1738. static readonly IsDifferent: number;
  1739. static readonly IsGreater: number;
  1740. static readonly IsLesser: number;
  1741. _actionManager: ActionManager;
  1742. private _target;
  1743. private _effectiveTarget;
  1744. private _property;
  1745. constructor(actionManager: ActionManager, target: any, propertyPath: string, value: any, operator?: number);
  1746. isValid(): boolean;
  1747. serialize(): any;
  1748. static GetOperatorName(operator: number): string;
  1749. }
  1750. class PredicateCondition extends Condition {
  1751. predicate: () => boolean;
  1752. _actionManager: ActionManager;
  1753. constructor(actionManager: ActionManager, predicate: () => boolean);
  1754. isValid(): boolean;
  1755. }
  1756. class StateCondition extends Condition {
  1757. value: string;
  1758. _actionManager: ActionManager;
  1759. private _target;
  1760. constructor(actionManager: ActionManager, target: any, value: string);
  1761. isValid(): boolean;
  1762. serialize(): any;
  1763. }
  1764. }
  1765. declare module BABYLON {
  1766. class SwitchBooleanAction extends Action {
  1767. propertyPath: string;
  1768. private _target;
  1769. private _effectiveTarget;
  1770. private _property;
  1771. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  1772. _prepare(): void;
  1773. execute(): void;
  1774. serialize(parent: any): any;
  1775. }
  1776. class SetStateAction extends Action {
  1777. value: string;
  1778. private _target;
  1779. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  1780. execute(): void;
  1781. serialize(parent: any): any;
  1782. }
  1783. class SetValueAction extends Action {
  1784. propertyPath: string;
  1785. value: any;
  1786. private _target;
  1787. private _effectiveTarget;
  1788. private _property;
  1789. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1790. _prepare(): void;
  1791. execute(): void;
  1792. serialize(parent: any): any;
  1793. }
  1794. class IncrementValueAction extends Action {
  1795. propertyPath: string;
  1796. value: any;
  1797. private _target;
  1798. private _effectiveTarget;
  1799. private _property;
  1800. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1801. _prepare(): void;
  1802. execute(): void;
  1803. serialize(parent: any): any;
  1804. }
  1805. class PlayAnimationAction extends Action {
  1806. from: number;
  1807. to: number;
  1808. loop: boolean | undefined;
  1809. private _target;
  1810. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  1811. _prepare(): void;
  1812. execute(): void;
  1813. serialize(parent: any): any;
  1814. }
  1815. class StopAnimationAction extends Action {
  1816. private _target;
  1817. constructor(triggerOptions: any, target: any, condition?: Condition);
  1818. _prepare(): void;
  1819. execute(): void;
  1820. serialize(parent: any): any;
  1821. }
  1822. class DoNothingAction extends Action {
  1823. constructor(triggerOptions?: any, condition?: Condition);
  1824. execute(): void;
  1825. serialize(parent: any): any;
  1826. }
  1827. class CombineAction extends Action {
  1828. children: Action[];
  1829. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  1830. _prepare(): void;
  1831. execute(evt: ActionEvent): void;
  1832. serialize(parent: any): any;
  1833. }
  1834. class ExecuteCodeAction extends Action {
  1835. func: (evt: ActionEvent) => void;
  1836. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  1837. execute(evt: ActionEvent): void;
  1838. }
  1839. class SetParentAction extends Action {
  1840. private _parent;
  1841. private _target;
  1842. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  1843. _prepare(): void;
  1844. execute(): void;
  1845. serialize(parent: any): any;
  1846. }
  1847. class PlaySoundAction extends Action {
  1848. private _sound;
  1849. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  1850. _prepare(): void;
  1851. execute(): void;
  1852. serialize(parent: any): any;
  1853. }
  1854. class StopSoundAction extends Action {
  1855. private _sound;
  1856. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  1857. _prepare(): void;
  1858. execute(): void;
  1859. serialize(parent: any): any;
  1860. }
  1861. }
  1862. declare module BABYLON {
  1863. class InterpolateValueAction extends Action {
  1864. propertyPath: string;
  1865. value: any;
  1866. duration: number;
  1867. stopOtherAnimations: boolean | undefined;
  1868. onInterpolationDone: (() => void) | undefined;
  1869. private _target;
  1870. private _effectiveTarget;
  1871. private _property;
  1872. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  1873. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  1874. _prepare(): void;
  1875. execute(): void;
  1876. serialize(parent: any): any;
  1877. }
  1878. }
  1879. declare module BABYLON {
  1880. class Animatable {
  1881. target: any;
  1882. fromFrame: number;
  1883. toFrame: number;
  1884. loopAnimation: boolean;
  1885. onAnimationEnd: (() => void) | null | undefined;
  1886. private _localDelayOffset;
  1887. private _pausedDelay;
  1888. private _runtimeAnimations;
  1889. private _paused;
  1890. private _scene;
  1891. private _speedRatio;
  1892. animationStarted: boolean;
  1893. speedRatio: number;
  1894. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  1895. getAnimations(): RuntimeAnimation[];
  1896. appendAnimations(target: any, animations: Animation[]): void;
  1897. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  1898. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  1899. reset(): void;
  1900. enableBlending(blendingSpeed: number): void;
  1901. disableBlending(): void;
  1902. goToFrame(frame: number): void;
  1903. pause(): void;
  1904. restart(): void;
  1905. stop(animationName?: string): void;
  1906. _animate(delay: number): boolean;
  1907. }
  1908. }
  1909. declare module BABYLON {
  1910. class AnimationRange {
  1911. name: string;
  1912. from: number;
  1913. to: number;
  1914. constructor(name: string, from: number, to: number);
  1915. clone(): AnimationRange;
  1916. }
  1917. /**
  1918. * Composed of a frame, and an action function
  1919. */
  1920. class AnimationEvent {
  1921. frame: number;
  1922. action: () => void;
  1923. onlyOnce: boolean | undefined;
  1924. isDone: boolean;
  1925. constructor(frame: number, action: () => void, onlyOnce?: boolean | undefined);
  1926. }
  1927. class PathCursor {
  1928. private path;
  1929. private _onchange;
  1930. value: number;
  1931. animations: Animation[];
  1932. constructor(path: Path2);
  1933. getPoint(): Vector3;
  1934. moveAhead(step?: number): PathCursor;
  1935. moveBack(step?: number): PathCursor;
  1936. move(step: number): PathCursor;
  1937. private ensureLimits();
  1938. private raiseOnChange();
  1939. onchange(f: (cursor: PathCursor) => void): PathCursor;
  1940. }
  1941. interface IAnimationKey {
  1942. frame: number;
  1943. value: any;
  1944. inTangent?: any;
  1945. outTangent?: any;
  1946. interpolation?: AnimationKeyInterpolation;
  1947. }
  1948. enum AnimationKeyInterpolation {
  1949. /**
  1950. * Do not interpolate between keys and use the start key value only. Tangents are ignored.
  1951. */
  1952. STEP = 1,
  1953. }
  1954. class Animation {
  1955. name: string;
  1956. targetProperty: string;
  1957. framePerSecond: number;
  1958. dataType: number;
  1959. loopMode: number | undefined;
  1960. enableBlending: boolean | undefined;
  1961. static AllowMatricesInterpolation: boolean;
  1962. private _keys;
  1963. private _easingFunction;
  1964. _runtimeAnimations: RuntimeAnimation[];
  1965. private _events;
  1966. targetPropertyPath: string[];
  1967. blendingSpeed: number;
  1968. private _ranges;
  1969. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  1970. /**
  1971. * Sets up an animation.
  1972. * @param property the property to animate
  1973. * @param animationType the animation type to apply
  1974. * @param easingFunction the easing function used in the animation
  1975. * @returns The created animation
  1976. */
  1977. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  1978. /**
  1979. * Create and start an animation on a node
  1980. * @param {string} name defines the name of the global animation that will be run on all nodes
  1981. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1982. * @param {string} targetProperty defines property to animate
  1983. * @param {number} framePerSecond defines the number of frame per second yo use
  1984. * @param {number} totalFrame defines the number of frames in total
  1985. * @param {any} from defines the initial value
  1986. * @param {any} to defines the final value
  1987. * @param {number} loopMode defines which loop mode you want to use (off by default)
  1988. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  1989. * @param onAnimationEnd defines the callback to call when animation end
  1990. * @returns the animatable created for this animation
  1991. */
  1992. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  1993. /**
  1994. * Create and start an animation on a node and its descendants
  1995. * @param {string} name defines the name of the global animation that will be run on all nodes
  1996. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1997. * @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.
  1998. * @param {string} targetProperty defines property to animate
  1999. * @param {number} framePerSecond defines the number of frame per second yo use
  2000. * @param {number} totalFrame defines the number of frames in total
  2001. * @param {any} from defines the initial value
  2002. * @param {any} to defines the final value
  2003. * @param {number} loopMode defines which loop mode you want to use (off by default)
  2004. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  2005. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  2006. * @returns the list of animatables created for all nodes
  2007. * @example https://www.babylonjs-playground.com/#MH0VLI
  2008. */
  2009. 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[]>;
  2010. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  2011. /**
  2012. * Transition property of the Camera to the target Value.
  2013. * @param property The property to transition
  2014. * @param targetValue The target Value of the property
  2015. * @param host The object where the property to animate belongs
  2016. * @param scene Scene used to run the animation
  2017. * @param frameRate Framerate (in frame/s) to use
  2018. * @param transition The transition type we want to use
  2019. * @param duration The duration of the animation, in milliseconds
  2020. * @param onAnimationEnd Call back trigger at the end of the animation.
  2021. */
  2022. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  2023. /**
  2024. * Return the array of runtime animations currently using this animation
  2025. */
  2026. readonly runtimeAnimations: RuntimeAnimation[];
  2027. readonly hasRunningRuntimeAnimations: boolean;
  2028. constructor(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number | undefined, enableBlending?: boolean | undefined);
  2029. /**
  2030. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  2031. */
  2032. toString(fullDetails?: boolean): string;
  2033. /**
  2034. * Add an event to this animation.
  2035. */
  2036. addEvent(event: AnimationEvent): void;
  2037. /**
  2038. * Remove all events found at the given frame
  2039. * @param frame
  2040. */
  2041. removeEvents(frame: number): void;
  2042. getEvents(): AnimationEvent[];
  2043. createRange(name: string, from: number, to: number): void;
  2044. deleteRange(name: string, deleteFrames?: boolean): void;
  2045. getRange(name: string): Nullable<AnimationRange>;
  2046. getKeys(): Array<IAnimationKey>;
  2047. getHighestFrame(): number;
  2048. getEasingFunction(): IEasingFunction;
  2049. setEasingFunction(easingFunction: EasingFunction): void;
  2050. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  2051. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  2052. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  2053. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  2054. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  2055. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  2056. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  2057. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  2058. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  2059. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  2060. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  2061. clone(): Animation;
  2062. setKeys(values: Array<IAnimationKey>): void;
  2063. serialize(): any;
  2064. private static _ANIMATIONTYPE_FLOAT;
  2065. private static _ANIMATIONTYPE_VECTOR3;
  2066. private static _ANIMATIONTYPE_QUATERNION;
  2067. private static _ANIMATIONTYPE_MATRIX;
  2068. private static _ANIMATIONTYPE_COLOR3;
  2069. private static _ANIMATIONTYPE_VECTOR2;
  2070. private static _ANIMATIONTYPE_SIZE;
  2071. private static _ANIMATIONLOOPMODE_RELATIVE;
  2072. private static _ANIMATIONLOOPMODE_CYCLE;
  2073. private static _ANIMATIONLOOPMODE_CONSTANT;
  2074. static readonly ANIMATIONTYPE_FLOAT: number;
  2075. static readonly ANIMATIONTYPE_VECTOR3: number;
  2076. static readonly ANIMATIONTYPE_VECTOR2: number;
  2077. static readonly ANIMATIONTYPE_SIZE: number;
  2078. static readonly ANIMATIONTYPE_QUATERNION: number;
  2079. static readonly ANIMATIONTYPE_MATRIX: number;
  2080. static readonly ANIMATIONTYPE_COLOR3: number;
  2081. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  2082. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  2083. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  2084. static Parse(parsedAnimation: any): Animation;
  2085. static AppendSerializedAnimations(source: IAnimatable, destination: any): any;
  2086. }
  2087. }
  2088. declare module BABYLON {
  2089. /**
  2090. * This class defines the direct association between an animation and a target
  2091. */
  2092. class TargetedAnimation {
  2093. animation: Animation;
  2094. target: any;
  2095. }
  2096. /**
  2097. * Use this class to create coordinated animations on multiple targets
  2098. */
  2099. class AnimationGroup implements IDisposable {
  2100. name: string;
  2101. private _scene;
  2102. private _targetedAnimations;
  2103. private _animatables;
  2104. private _from;
  2105. private _to;
  2106. private _isStarted;
  2107. private _speedRatio;
  2108. onAnimationEndObservable: Observable<TargetedAnimation>;
  2109. /**
  2110. * Define if the animations are started
  2111. */
  2112. readonly isStarted: boolean;
  2113. /**
  2114. * Gets or sets the speed ratio to use for all animations
  2115. */
  2116. /**
  2117. * Gets or sets the speed ratio to use for all animations
  2118. */
  2119. speedRatio: number;
  2120. /**
  2121. * Gets the targeted animations for this animation group
  2122. */
  2123. readonly targetedAnimations: Array<TargetedAnimation>;
  2124. constructor(name: string, scene?: Nullable<Scene>);
  2125. /**
  2126. * Add an animation (with its target) in the group
  2127. * @param animation defines the animation we want to add
  2128. * @param target defines the target of the animation
  2129. * @returns the {BABYLON.TargetedAnimation} object
  2130. */
  2131. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  2132. /**
  2133. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  2134. * It can add constant keys at begin or end
  2135. * @param beginFrame defines the new begin frame for all animations. It can't be bigger than the smallest begin frame of all animations
  2136. * @param endFrame defines the new end frame for all animations. It can't be smaller than the largest end frame of all animations
  2137. */
  2138. normalize(beginFrame?: number, endFrame?: number): AnimationGroup;
  2139. /**
  2140. * Start all animations on given targets
  2141. * @param loop defines if animations must loop
  2142. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  2143. */
  2144. start(loop?: boolean, speedRatio?: number): AnimationGroup;
  2145. /**
  2146. * Pause all animations
  2147. */
  2148. pause(): AnimationGroup;
  2149. /**
  2150. * Play all animations to initial state
  2151. * This function will start() the animations if they were not started or will restart() them if they were paused
  2152. * @param loop defines if animations must loop
  2153. */
  2154. play(loop?: boolean): AnimationGroup;
  2155. /**
  2156. * Reset all animations to initial state
  2157. */
  2158. reset(): AnimationGroup;
  2159. /**
  2160. * Restart animations from key 0
  2161. */
  2162. restart(): AnimationGroup;
  2163. /**
  2164. * Stop all animations
  2165. */
  2166. stop(): AnimationGroup;
  2167. /**
  2168. * Dispose all associated resources
  2169. */
  2170. dispose(): void;
  2171. }
  2172. }
  2173. declare module BABYLON {
  2174. interface IEasingFunction {
  2175. ease(gradient: number): number;
  2176. }
  2177. class EasingFunction implements IEasingFunction {
  2178. private static _EASINGMODE_EASEIN;
  2179. private static _EASINGMODE_EASEOUT;
  2180. private static _EASINGMODE_EASEINOUT;
  2181. static readonly EASINGMODE_EASEIN: number;
  2182. static readonly EASINGMODE_EASEOUT: number;
  2183. static readonly EASINGMODE_EASEINOUT: number;
  2184. private _easingMode;
  2185. setEasingMode(easingMode: number): void;
  2186. getEasingMode(): number;
  2187. easeInCore(gradient: number): number;
  2188. ease(gradient: number): number;
  2189. }
  2190. class CircleEase extends EasingFunction implements IEasingFunction {
  2191. easeInCore(gradient: number): number;
  2192. }
  2193. class BackEase extends EasingFunction implements IEasingFunction {
  2194. amplitude: number;
  2195. constructor(amplitude?: number);
  2196. easeInCore(gradient: number): number;
  2197. }
  2198. class BounceEase extends EasingFunction implements IEasingFunction {
  2199. bounces: number;
  2200. bounciness: number;
  2201. constructor(bounces?: number, bounciness?: number);
  2202. easeInCore(gradient: number): number;
  2203. }
  2204. class CubicEase extends EasingFunction implements IEasingFunction {
  2205. easeInCore(gradient: number): number;
  2206. }
  2207. class ElasticEase extends EasingFunction implements IEasingFunction {
  2208. oscillations: number;
  2209. springiness: number;
  2210. constructor(oscillations?: number, springiness?: number);
  2211. easeInCore(gradient: number): number;
  2212. }
  2213. class ExponentialEase extends EasingFunction implements IEasingFunction {
  2214. exponent: number;
  2215. constructor(exponent?: number);
  2216. easeInCore(gradient: number): number;
  2217. }
  2218. class PowerEase extends EasingFunction implements IEasingFunction {
  2219. power: number;
  2220. constructor(power?: number);
  2221. easeInCore(gradient: number): number;
  2222. }
  2223. class QuadraticEase extends EasingFunction implements IEasingFunction {
  2224. easeInCore(gradient: number): number;
  2225. }
  2226. class QuarticEase extends EasingFunction implements IEasingFunction {
  2227. easeInCore(gradient: number): number;
  2228. }
  2229. class QuinticEase extends EasingFunction implements IEasingFunction {
  2230. easeInCore(gradient: number): number;
  2231. }
  2232. class SineEase extends EasingFunction implements IEasingFunction {
  2233. easeInCore(gradient: number): number;
  2234. }
  2235. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  2236. x1: number;
  2237. y1: number;
  2238. x2: number;
  2239. y2: number;
  2240. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  2241. easeInCore(gradient: number): number;
  2242. }
  2243. }
  2244. declare module BABYLON {
  2245. class RuntimeAnimation {
  2246. currentFrame: number;
  2247. private _animation;
  2248. private _target;
  2249. private _originalBlendValue;
  2250. private _offsetsCache;
  2251. private _highLimitsCache;
  2252. private _stopped;
  2253. private _blendingFactor;
  2254. constructor(target: any, animation: Animation);
  2255. readonly animation: Animation;
  2256. reset(): void;
  2257. isStopped(): boolean;
  2258. dispose(): void;
  2259. private _getKeyValue(value);
  2260. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  2261. setValue(currentValue: any, blend?: boolean): void;
  2262. goToFrame(frame: number): void;
  2263. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  2264. private _ratioOffset;
  2265. private _previousDelay;
  2266. private _previousRatio;
  2267. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, blend?: boolean): boolean;
  2268. }
  2269. }
  2270. declare module BABYLON {
  2271. class Analyser {
  2272. SMOOTHING: number;
  2273. FFT_SIZE: number;
  2274. BARGRAPHAMPLITUDE: number;
  2275. DEBUGCANVASPOS: {
  2276. x: number;
  2277. y: number;
  2278. };
  2279. DEBUGCANVASSIZE: {
  2280. width: number;
  2281. height: number;
  2282. };
  2283. private _byteFreqs;
  2284. private _byteTime;
  2285. private _floatFreqs;
  2286. private _webAudioAnalyser;
  2287. private _debugCanvas;
  2288. private _debugCanvasContext;
  2289. private _scene;
  2290. private _registerFunc;
  2291. private _audioEngine;
  2292. constructor(scene: Scene);
  2293. getFrequencyBinCount(): number;
  2294. getByteFrequencyData(): Uint8Array;
  2295. getByteTimeDomainData(): Uint8Array;
  2296. getFloatFrequencyData(): Uint8Array;
  2297. drawDebugCanvas(): void;
  2298. stopDebugCanvas(): void;
  2299. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  2300. dispose(): void;
  2301. }
  2302. }
  2303. declare module BABYLON {
  2304. class AudioEngine {
  2305. private _audioContext;
  2306. private _audioContextInitialized;
  2307. canUseWebAudio: boolean;
  2308. masterGain: GainNode;
  2309. private _connectedAnalyser;
  2310. WarnedWebAudioUnsupported: boolean;
  2311. unlocked: boolean;
  2312. onAudioUnlocked: () => any;
  2313. isMP3supported: boolean;
  2314. isOGGsupported: boolean;
  2315. readonly audioContext: Nullable<AudioContext>;
  2316. constructor();
  2317. private _unlockiOSaudio();
  2318. private _initializeAudioContext();
  2319. dispose(): void;
  2320. getGlobalVolume(): number;
  2321. setGlobalVolume(newVolume: number): void;
  2322. connectToAnalyser(analyser: Analyser): void;
  2323. }
  2324. }
  2325. declare module BABYLON {
  2326. class Sound {
  2327. name: string;
  2328. autoplay: boolean;
  2329. loop: boolean;
  2330. useCustomAttenuation: boolean;
  2331. soundTrackId: number;
  2332. spatialSound: boolean;
  2333. refDistance: number;
  2334. rolloffFactor: number;
  2335. maxDistance: number;
  2336. distanceModel: string;
  2337. private _panningModel;
  2338. onended: () => any;
  2339. private _playbackRate;
  2340. private _streaming;
  2341. private _startTime;
  2342. private _startOffset;
  2343. private _position;
  2344. private _localDirection;
  2345. private _volume;
  2346. private _isReadyToPlay;
  2347. isPlaying: boolean;
  2348. isPaused: boolean;
  2349. private _isDirectional;
  2350. private _readyToPlayCallback;
  2351. private _audioBuffer;
  2352. private _soundSource;
  2353. private _streamingSource;
  2354. private _soundPanner;
  2355. private _soundGain;
  2356. private _inputAudioNode;
  2357. private _ouputAudioNode;
  2358. private _coneInnerAngle;
  2359. private _coneOuterAngle;
  2360. private _coneOuterGain;
  2361. private _scene;
  2362. private _connectedMesh;
  2363. private _customAttenuationFunction;
  2364. private _registerFunc;
  2365. private _isOutputConnected;
  2366. private _htmlAudioElement;
  2367. private _urlType;
  2368. /**
  2369. * Create a sound and attach it to a scene
  2370. * @param name Name of your sound
  2371. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  2372. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  2373. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  2374. */
  2375. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  2376. dispose(): void;
  2377. isReady(): boolean;
  2378. private _soundLoaded(audioData);
  2379. setAudioBuffer(audioBuffer: AudioBuffer): void;
  2380. updateOptions(options: any): void;
  2381. private _createSpatialParameters();
  2382. private _updateSpatialParameters();
  2383. switchPanningModelToHRTF(): void;
  2384. switchPanningModelToEqualPower(): void;
  2385. private _switchPanningModel();
  2386. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  2387. /**
  2388. * Transform this sound into a directional source
  2389. * @param coneInnerAngle Size of the inner cone in degree
  2390. * @param coneOuterAngle Size of the outer cone in degree
  2391. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  2392. */
  2393. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  2394. setPosition(newPosition: Vector3): void;
  2395. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  2396. private _updateDirection();
  2397. updateDistanceFromListener(): void;
  2398. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  2399. /**
  2400. * Play the sound
  2401. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  2402. * @param offset (optional) Start the sound setting it at a specific time
  2403. */
  2404. play(time?: number, offset?: number): void;
  2405. private _onended();
  2406. /**
  2407. * Stop the sound
  2408. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  2409. */
  2410. stop(time?: number): void;
  2411. pause(): void;
  2412. setVolume(newVolume: number, time?: number): void;
  2413. setPlaybackRate(newPlaybackRate: number): void;
  2414. getVolume(): number;
  2415. attachToMesh(meshToConnectTo: AbstractMesh): void;
  2416. detachFromMesh(): void;
  2417. private _onRegisterAfterWorldMatrixUpdate(node);
  2418. clone(): Nullable<Sound>;
  2419. getAudioBuffer(): AudioBuffer | null;
  2420. serialize(): any;
  2421. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  2422. }
  2423. }
  2424. declare module BABYLON {
  2425. class SoundTrack {
  2426. private _outputAudioNode;
  2427. private _scene;
  2428. id: number;
  2429. soundCollection: Array<Sound>;
  2430. private _isMainTrack;
  2431. private _connectedAnalyser;
  2432. private _options;
  2433. private _isInitialized;
  2434. constructor(scene: Scene, options?: any);
  2435. private _initializeSoundTrackAudioGraph();
  2436. dispose(): void;
  2437. AddSound(sound: Sound): void;
  2438. RemoveSound(sound: Sound): void;
  2439. setVolume(newVolume: number): void;
  2440. switchPanningModelToHRTF(): void;
  2441. switchPanningModelToEqualPower(): void;
  2442. connectToAnalyser(analyser: Analyser): void;
  2443. }
  2444. }
  2445. declare module BABYLON {
  2446. interface Behavior<T extends Node> {
  2447. name: string;
  2448. init(): void;
  2449. attach(node: T): void;
  2450. detach(): void;
  2451. }
  2452. }
  2453. declare module BABYLON {
  2454. class Bone extends Node {
  2455. name: string;
  2456. private static _tmpVecs;
  2457. private static _tmpQuat;
  2458. private static _tmpMats;
  2459. children: Bone[];
  2460. animations: Animation[];
  2461. length: number;
  2462. _index: Nullable<number>;
  2463. private _skeleton;
  2464. private _localMatrix;
  2465. private _restPose;
  2466. private _baseMatrix;
  2467. private _worldTransform;
  2468. private _absoluteTransform;
  2469. private _invertedAbsoluteTransform;
  2470. private _parent;
  2471. private _scaleMatrix;
  2472. private _scaleVector;
  2473. private _negateScaleChildren;
  2474. private _scalingDeterminant;
  2475. _matrix: Matrix;
  2476. constructor(name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  2477. getSkeleton(): Skeleton;
  2478. getParent(): Nullable<Bone>;
  2479. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  2480. getLocalMatrix(): Matrix;
  2481. getBaseMatrix(): Matrix;
  2482. getRestPose(): Matrix;
  2483. returnToRest(): void;
  2484. getWorldMatrix(): Matrix;
  2485. getInvertedAbsoluteTransform(): Matrix;
  2486. getAbsoluteTransform(): Matrix;
  2487. position: Vector3;
  2488. rotation: Vector3;
  2489. rotationQuaternion: Quaternion;
  2490. scaling: Vector3;
  2491. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean): void;
  2492. _updateDifferenceMatrix(rootMatrix?: Matrix): void;
  2493. markAsDirty(): void;
  2494. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  2495. /**
  2496. * Translate the bone in local or world space.
  2497. * @param vec The amount to translate the bone.
  2498. * @param space The space that the translation is in.
  2499. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2500. */
  2501. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2502. /**
  2503. * Set the postion of the bone in local or world space.
  2504. * @param position The position to set the bone.
  2505. * @param space The space that the position is in.
  2506. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2507. */
  2508. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2509. /**
  2510. * Set the absolute postion of the bone (world space).
  2511. * @param position The position to set the bone.
  2512. * @param mesh The mesh that this bone is attached to.
  2513. */
  2514. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  2515. /**
  2516. * Set the scale of the bone on the x, y and z axes.
  2517. * @param x The scale of the bone on the x axis.
  2518. * @param x The scale of the bone on the y axis.
  2519. * @param z The scale of the bone on the z axis.
  2520. * @param scaleChildren Set this to true if children of the bone should be scaled.
  2521. */
  2522. setScale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  2523. /**
  2524. * Scale the bone on the x, y and z axes.
  2525. * @param x The amount to scale the bone on the x axis.
  2526. * @param x The amount to scale the bone on the y axis.
  2527. * @param z The amount to scale the bone on the z axis.
  2528. * @param scaleChildren Set this to true if children of the bone should be scaled.
  2529. */
  2530. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  2531. /**
  2532. * Set the yaw, pitch, and roll of the bone in local or world space.
  2533. * @param yaw The rotation of the bone on the y axis.
  2534. * @param pitch The rotation of the bone on the x axis.
  2535. * @param roll The rotation of the bone on the z axis.
  2536. * @param space The space that the axes of rotation are in.
  2537. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2538. */
  2539. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  2540. /**
  2541. * Rotate the bone on an axis in local or world space.
  2542. * @param axis The axis to rotate the bone on.
  2543. * @param amount The amount to rotate the bone.
  2544. * @param space The space that the axis is in.
  2545. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2546. */
  2547. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  2548. /**
  2549. * Set the rotation of the bone to a particular axis angle in local or world space.
  2550. * @param axis The axis to rotate the bone on.
  2551. * @param angle The angle that the bone should be rotated to.
  2552. * @param space The space that the axis is in.
  2553. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2554. */
  2555. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  2556. /**
  2557. * Set the euler rotation of the bone in local of world space.
  2558. * @param rotation The euler rotation that the bone should be set to.
  2559. * @param space The space that the rotation is in.
  2560. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2561. */
  2562. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2563. /**
  2564. * Set the quaternion rotation of the bone in local of world space.
  2565. * @param quat The quaternion rotation that the bone should be set to.
  2566. * @param space The space that the rotation is in.
  2567. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2568. */
  2569. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  2570. /**
  2571. * Set the rotation matrix of the bone in local of world space.
  2572. * @param rotMat The rotation matrix that the bone should be set to.
  2573. * @param space The space that the rotation is in.
  2574. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2575. */
  2576. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  2577. private _rotateWithMatrix(rmat, space?, mesh?);
  2578. private _getNegativeRotationToRef(rotMatInv, space?, mesh?);
  2579. /**
  2580. * Get the scale of the bone
  2581. * @returns the scale of the bone
  2582. */
  2583. getScale(): Vector3;
  2584. /**
  2585. * Copy the scale of the bone to a vector3.
  2586. * @param result The vector3 to copy the scale to
  2587. */
  2588. getScaleToRef(result: Vector3): void;
  2589. /**
  2590. * Get the position of the bone in local or world space.
  2591. * @param space The space that the returned position is in.
  2592. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2593. * @returns The position of the bone
  2594. */
  2595. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  2596. /**
  2597. * Copy the position of the bone to a vector3 in local or world space.
  2598. * @param space The space that the returned position is in.
  2599. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2600. * @param result The vector3 to copy the position to.
  2601. */
  2602. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  2603. /**
  2604. * Get the absolute position of the bone (world space).
  2605. * @param mesh The mesh that this bone is attached to.
  2606. * @returns The absolute position of the bone
  2607. */
  2608. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  2609. /**
  2610. * Copy the absolute position of the bone (world space) to the result param.
  2611. * @param mesh The mesh that this bone is attached to.
  2612. * @param result The vector3 to copy the absolute position to.
  2613. */
  2614. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  2615. /**
  2616. * Compute the absolute transforms of this bone and its children.
  2617. */
  2618. computeAbsoluteTransforms(): void;
  2619. private _syncScaleVector();
  2620. /**
  2621. * Get the world direction from an axis that is in the local space of the bone.
  2622. * @param localAxis The local direction that is used to compute the world direction.
  2623. * @param mesh The mesh that this bone is attached to.
  2624. * @returns The world direction
  2625. */
  2626. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2627. /**
  2628. * Copy the world direction to a vector3 from an axis that is in the local space of the bone.
  2629. * @param localAxis The local direction that is used to compute the world direction.
  2630. * @param mesh The mesh that this bone is attached to.
  2631. * @param result The vector3 that the world direction will be copied to.
  2632. */
  2633. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2634. /**
  2635. * Get the euler rotation of the bone in local or world space.
  2636. * @param space The space that the rotation should be in.
  2637. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2638. * @returns The euler rotation
  2639. */
  2640. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  2641. /**
  2642. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space.
  2643. * @param space The space that the rotation should be in.
  2644. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2645. * @param result The vector3 that the rotation should be copied to.
  2646. */
  2647. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2648. /**
  2649. * Get the quaternion rotation of the bone in either local or world space.
  2650. * @param space The space that the rotation should be in.
  2651. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2652. * @returns The quaternion rotation
  2653. */
  2654. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  2655. /**
  2656. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space.
  2657. * @param space The space that the rotation should be in.
  2658. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2659. * @param result The quaternion that the rotation should be copied to.
  2660. */
  2661. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  2662. /**
  2663. * Get the rotation matrix of the bone in local or world space.
  2664. * @param space The space that the rotation should be in.
  2665. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2666. * @returns The rotation matrix
  2667. */
  2668. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  2669. /**
  2670. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space.
  2671. * @param space The space that the rotation should be in.
  2672. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2673. * @param result The quaternion that the rotation should be copied to.
  2674. */
  2675. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  2676. /**
  2677. * Get the world position of a point that is in the local space of the bone.
  2678. * @param position The local position
  2679. * @param mesh The mesh that this bone is attached to.
  2680. * @returns The world position
  2681. */
  2682. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2683. /**
  2684. * Get the world position of a point that is in the local space of the bone and copy it to the result param.
  2685. * @param position The local position
  2686. * @param mesh The mesh that this bone is attached to.
  2687. * @param result The vector3 that the world position should be copied to.
  2688. */
  2689. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2690. /**
  2691. * Get the local position of a point that is in world space.
  2692. * @param position The world position
  2693. * @param mesh The mesh that this bone is attached to.
  2694. * @returns The local position
  2695. */
  2696. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2697. /**
  2698. * Get the local position of a point that is in world space and copy it to the result param.
  2699. * @param position The world position
  2700. * @param mesh The mesh that this bone is attached to.
  2701. * @param result The vector3 that the local position should be copied to.
  2702. */
  2703. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2704. }
  2705. }
  2706. declare module BABYLON {
  2707. class BoneIKController {
  2708. private static _tmpVecs;
  2709. private static _tmpQuat;
  2710. private static _tmpMats;
  2711. targetMesh: AbstractMesh;
  2712. poleTargetMesh: AbstractMesh;
  2713. poleTargetBone: Nullable<Bone>;
  2714. targetPosition: Vector3;
  2715. poleTargetPosition: Vector3;
  2716. poleTargetLocalOffset: Vector3;
  2717. poleAngle: number;
  2718. mesh: AbstractMesh;
  2719. slerpAmount: number;
  2720. private _bone1Quat;
  2721. private _bone1Mat;
  2722. private _bone2Ang;
  2723. private _bone1;
  2724. private _bone2;
  2725. private _bone1Length;
  2726. private _bone2Length;
  2727. private _maxAngle;
  2728. private _maxReach;
  2729. private _rightHandedSystem;
  2730. private _bendAxis;
  2731. private _slerping;
  2732. private _adjustRoll;
  2733. maxAngle: number;
  2734. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  2735. targetMesh?: AbstractMesh;
  2736. poleTargetMesh?: AbstractMesh;
  2737. poleTargetBone?: Bone;
  2738. poleTargetLocalOffset?: Vector3;
  2739. poleAngle?: number;
  2740. bendAxis?: Vector3;
  2741. maxAngle?: number;
  2742. slerpAmount?: number;
  2743. });
  2744. private _setMaxAngle(ang);
  2745. update(): void;
  2746. }
  2747. }
  2748. declare module BABYLON {
  2749. class BoneLookController {
  2750. private static _tmpVecs;
  2751. private static _tmpQuat;
  2752. private static _tmpMats;
  2753. /**
  2754. * The target Vector3 that the bone will look at.
  2755. */
  2756. target: Vector3;
  2757. /**
  2758. * The mesh that the bone is attached to.
  2759. */
  2760. mesh: AbstractMesh;
  2761. /**
  2762. * The bone that will be looking to the target.
  2763. */
  2764. bone: Bone;
  2765. /**
  2766. * The up axis of the coordinate system that is used when the bone is rotated.
  2767. */
  2768. upAxis: Vector3;
  2769. /**
  2770. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  2771. */
  2772. upAxisSpace: Space;
  2773. /**
  2774. * Used to make an adjustment to the yaw of the bone.
  2775. */
  2776. adjustYaw: number;
  2777. /**
  2778. * Used to make an adjustment to the pitch of the bone.
  2779. */
  2780. adjustPitch: number;
  2781. /**
  2782. * Used to make an adjustment to the roll of the bone.
  2783. */
  2784. adjustRoll: number;
  2785. /**
  2786. * 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).
  2787. */
  2788. slerpAmount: number;
  2789. private _minYaw;
  2790. private _maxYaw;
  2791. private _minPitch;
  2792. private _maxPitch;
  2793. private _minYawSin;
  2794. private _minYawCos;
  2795. private _maxYawSin;
  2796. private _maxYawCos;
  2797. private _midYawConstraint;
  2798. private _minPitchTan;
  2799. private _maxPitchTan;
  2800. private _boneQuat;
  2801. private _slerping;
  2802. private _transformYawPitch;
  2803. private _transformYawPitchInv;
  2804. private _firstFrameSkipped;
  2805. private _yawRange;
  2806. private _fowardAxis;
  2807. /**
  2808. * Get/set the minimum yaw angle that the bone can look to.
  2809. */
  2810. minYaw: number;
  2811. /**
  2812. * Get/set the maximum yaw angle that the bone can look to.
  2813. */
  2814. maxYaw: number;
  2815. /**
  2816. * Get/set the minimum pitch angle that the bone can look to.
  2817. */
  2818. minPitch: number;
  2819. /**
  2820. * Get/set the maximum pitch angle that the bone can look to.
  2821. */
  2822. maxPitch: number;
  2823. /**
  2824. * Create a BoneLookController
  2825. * @param mesh the mesh that the bone belongs to
  2826. * @param bone the bone that will be looking to the target
  2827. * @param target the target Vector3 to look at
  2828. * @param settings optional settings:
  2829. * - maxYaw: the maximum angle the bone will yaw to
  2830. * - minYaw: the minimum angle the bone will yaw to
  2831. * - maxPitch: the maximum angle the bone will pitch to
  2832. * - minPitch: the minimum angle the bone will yaw to
  2833. * - slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  2834. * - upAxis: the up axis of the coordinate system
  2835. * - upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  2836. * - yawAxis: set yawAxis if the bone does not yaw on the y axis
  2837. * - pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  2838. * - adjustYaw: used to make an adjustment to the yaw of the bone
  2839. * - adjustPitch: used to make an adjustment to the pitch of the bone
  2840. * - adjustRoll: used to make an adjustment to the roll of the bone
  2841. **/
  2842. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  2843. maxYaw?: number;
  2844. minYaw?: number;
  2845. maxPitch?: number;
  2846. minPitch?: number;
  2847. slerpAmount?: number;
  2848. upAxis?: Vector3;
  2849. upAxisSpace?: Space;
  2850. yawAxis?: Vector3;
  2851. pitchAxis?: Vector3;
  2852. adjustYaw?: number;
  2853. adjustPitch?: number;
  2854. adjustRoll?: number;
  2855. });
  2856. /**
  2857. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender()).
  2858. */
  2859. update(): void;
  2860. private _getAngleDiff(ang1, ang2);
  2861. private _getAngleBetween(ang1, ang2);
  2862. private _isAngleBetween(ang, ang1, ang2);
  2863. }
  2864. }
  2865. declare module BABYLON {
  2866. class Skeleton implements IAnimatable {
  2867. name: string;
  2868. id: string;
  2869. bones: Bone[];
  2870. dimensionsAtRest: Vector3;
  2871. needInitialSkinMatrix: boolean;
  2872. animations: Array<Animation>;
  2873. private _scene;
  2874. private _isDirty;
  2875. private _transformMatrices;
  2876. private _meshesWithPoseMatrix;
  2877. private _animatables;
  2878. private _identity;
  2879. private _synchronizedWithMesh;
  2880. private _ranges;
  2881. private _lastAbsoluteTransformsUpdateId;
  2882. /**
  2883. * An event triggered before computing the skeleton's matrices
  2884. * @type {BABYLON.Observable}
  2885. */
  2886. onBeforeComputeObservable: Observable<Skeleton>;
  2887. constructor(name: string, id: string, scene: Scene);
  2888. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  2889. getScene(): Scene;
  2890. /**
  2891. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  2892. */
  2893. toString(fullDetails?: boolean): string;
  2894. /**
  2895. * Get bone's index searching by name
  2896. * @param {string} name is bone's name to search for
  2897. * @return {number} Indice of the bone. Returns -1 if not found
  2898. */
  2899. getBoneIndexByName(name: string): number;
  2900. createAnimationRange(name: string, from: number, to: number): void;
  2901. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  2902. getAnimationRange(name: string): Nullable<AnimationRange>;
  2903. /**
  2904. * Returns as an Array, all AnimationRanges defined on this skeleton
  2905. */
  2906. getAnimationRanges(): Nullable<AnimationRange>[];
  2907. /**
  2908. * note: This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  2909. */
  2910. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  2911. returnToRest(): void;
  2912. private _getHighestAnimationFrame();
  2913. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  2914. _markAsDirty(): void;
  2915. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  2916. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  2917. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  2918. prepare(): void;
  2919. getAnimatables(): IAnimatable[];
  2920. clone(name: string, id: string): Skeleton;
  2921. enableBlending(blendingSpeed?: number): void;
  2922. dispose(): void;
  2923. serialize(): any;
  2924. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  2925. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  2926. getPoseMatrix(): Nullable<Matrix>;
  2927. sortBones(): void;
  2928. private _sortBones(index, bones, visited);
  2929. }
  2930. }
  2931. declare module BABYLON {
  2932. class BoundingBox implements ICullable {
  2933. minimum: Vector3;
  2934. maximum: Vector3;
  2935. vectors: Vector3[];
  2936. center: Vector3;
  2937. centerWorld: Vector3;
  2938. extendSize: Vector3;
  2939. extendSizeWorld: Vector3;
  2940. directions: Vector3[];
  2941. vectorsWorld: Vector3[];
  2942. minimumWorld: Vector3;
  2943. maximumWorld: Vector3;
  2944. private _worldMatrix;
  2945. constructor(minimum: Vector3, maximum: Vector3);
  2946. getWorldMatrix(): Matrix;
  2947. setWorldMatrix(matrix: Matrix): BoundingBox;
  2948. _update(world: Matrix): void;
  2949. isInFrustum(frustumPlanes: Plane[]): boolean;
  2950. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  2951. intersectsPoint(point: Vector3): boolean;
  2952. intersectsSphere(sphere: BoundingSphere): boolean;
  2953. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  2954. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  2955. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  2956. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  2957. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  2958. }
  2959. }
  2960. declare module BABYLON {
  2961. interface ICullable {
  2962. isInFrustum(frustumPlanes: Plane[]): boolean;
  2963. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  2964. }
  2965. class BoundingInfo implements ICullable {
  2966. minimum: Vector3;
  2967. maximum: Vector3;
  2968. boundingBox: BoundingBox;
  2969. boundingSphere: BoundingSphere;
  2970. private _isLocked;
  2971. constructor(minimum: Vector3, maximum: Vector3);
  2972. isLocked: boolean;
  2973. update(world: Matrix): void;
  2974. /**
  2975. * Recreate the bounding info to be centered around a specific point given a specific extend.
  2976. * @param center New center of the bounding info
  2977. * @param extend New extend of the bounding info
  2978. */
  2979. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  2980. isInFrustum(frustumPlanes: Plane[]): boolean;
  2981. /**
  2982. * Gets the world distance between the min and max points of the bounding box
  2983. */
  2984. readonly diagonalLength: number;
  2985. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  2986. _checkCollision(collider: Collider): boolean;
  2987. intersectsPoint(point: Vector3): boolean;
  2988. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  2989. }
  2990. }
  2991. declare module BABYLON {
  2992. class BoundingSphere {
  2993. minimum: Vector3;
  2994. maximum: Vector3;
  2995. center: Vector3;
  2996. radius: number;
  2997. centerWorld: Vector3;
  2998. radiusWorld: number;
  2999. private _tempRadiusVector;
  3000. constructor(minimum: Vector3, maximum: Vector3);
  3001. _update(world: Matrix): void;
  3002. isInFrustum(frustumPlanes: Plane[]): boolean;
  3003. intersectsPoint(point: Vector3): boolean;
  3004. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  3005. }
  3006. }
  3007. declare module BABYLON {
  3008. class Ray {
  3009. origin: Vector3;
  3010. direction: Vector3;
  3011. length: number;
  3012. private _edge1;
  3013. private _edge2;
  3014. private _pvec;
  3015. private _tvec;
  3016. private _qvec;
  3017. private _tmpRay;
  3018. constructor(origin: Vector3, direction: Vector3, length?: number);
  3019. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  3020. intersectsBox(box: BoundingBox): boolean;
  3021. intersectsSphere(sphere: BoundingSphere): boolean;
  3022. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  3023. intersectsPlane(plane: Plane): Nullable<number>;
  3024. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  3025. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  3026. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  3027. private static smallnum;
  3028. private static rayl;
  3029. /**
  3030. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  3031. * @param sega the first point of the segment to test the intersection against
  3032. * @param segb the second point of the segment to test the intersection against
  3033. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  3034. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  3035. */
  3036. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  3037. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  3038. static Zero(): Ray;
  3039. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  3040. /**
  3041. * 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
  3042. * transformed to the given world matrix.
  3043. * @param origin The origin point
  3044. * @param end The end point
  3045. * @param world a matrix to transform the ray to. Default is the identity matrix.
  3046. */
  3047. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  3048. static Transform(ray: Ray, matrix: Matrix): Ray;
  3049. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  3050. }
  3051. }
  3052. declare module BABYLON {
  3053. class ArcRotateCamera extends TargetCamera {
  3054. alpha: number;
  3055. beta: number;
  3056. radius: number;
  3057. protected _target: Vector3;
  3058. protected _targetHost: Nullable<AbstractMesh>;
  3059. target: Vector3;
  3060. inertialAlphaOffset: number;
  3061. inertialBetaOffset: number;
  3062. inertialRadiusOffset: number;
  3063. lowerAlphaLimit: Nullable<number>;
  3064. upperAlphaLimit: Nullable<number>;
  3065. lowerBetaLimit: number;
  3066. upperBetaLimit: number;
  3067. lowerRadiusLimit: Nullable<number>;
  3068. upperRadiusLimit: Nullable<number>;
  3069. inertialPanningX: number;
  3070. inertialPanningY: number;
  3071. pinchToPanMaxDistance: number;
  3072. panningDistanceLimit: Nullable<number>;
  3073. panningOriginTarget: Vector3;
  3074. panningInertia: number;
  3075. angularSensibilityX: number;
  3076. angularSensibilityY: number;
  3077. pinchPrecision: number;
  3078. pinchDeltaPercentage: number;
  3079. panningSensibility: number;
  3080. keysUp: number[];
  3081. keysDown: number[];
  3082. keysLeft: number[];
  3083. keysRight: number[];
  3084. wheelPrecision: number;
  3085. wheelDeltaPercentage: number;
  3086. zoomOnFactor: number;
  3087. targetScreenOffset: Vector2;
  3088. allowUpsideDown: boolean;
  3089. _viewMatrix: Matrix;
  3090. _useCtrlForPanning: boolean;
  3091. _panningMouseButton: number;
  3092. inputs: ArcRotateCameraInputsManager;
  3093. _reset: () => void;
  3094. panningAxis: Vector3;
  3095. protected _localDirection: Vector3;
  3096. protected _transformedDirection: Vector3;
  3097. private _bouncingBehavior;
  3098. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  3099. useBouncingBehavior: boolean;
  3100. private _framingBehavior;
  3101. readonly framingBehavior: Nullable<FramingBehavior>;
  3102. useFramingBehavior: boolean;
  3103. private _autoRotationBehavior;
  3104. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  3105. useAutoRotationBehavior: boolean;
  3106. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  3107. onCollide: (collidedMesh: AbstractMesh) => void;
  3108. checkCollisions: boolean;
  3109. collisionRadius: Vector3;
  3110. protected _collider: Collider;
  3111. protected _previousPosition: Vector3;
  3112. protected _collisionVelocity: Vector3;
  3113. protected _newPosition: Vector3;
  3114. protected _previousAlpha: number;
  3115. protected _previousBeta: number;
  3116. protected _previousRadius: number;
  3117. protected _collisionTriggered: boolean;
  3118. protected _targetBoundingCenter: Nullable<Vector3>;
  3119. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene);
  3120. _initCache(): void;
  3121. _updateCache(ignoreParentClass?: boolean): void;
  3122. protected _getTargetPosition(): Vector3;
  3123. /**
  3124. * Store current camera state (fov, position, etc..)
  3125. */
  3126. private _storedAlpha;
  3127. private _storedBeta;
  3128. private _storedRadius;
  3129. private _storedTarget;
  3130. storeState(): Camera;
  3131. /**
  3132. * Restored camera state. You must call storeState() first
  3133. */
  3134. _restoreStateValues(): boolean;
  3135. _isSynchronizedViewMatrix(): boolean;
  3136. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  3137. detachControl(element: HTMLElement): void;
  3138. _checkInputs(): void;
  3139. protected _checkLimits(): void;
  3140. rebuildAnglesAndRadius(): void;
  3141. setPosition(position: Vector3): void;
  3142. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  3143. _getViewMatrix(): Matrix;
  3144. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  3145. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  3146. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  3147. min: Vector3;
  3148. max: Vector3;
  3149. distance: number;
  3150. }, doNotUpdateMaxZ?: boolean): void;
  3151. /**
  3152. * @override
  3153. * Override Camera.createRigCamera
  3154. */
  3155. createRigCamera(name: string, cameraIndex: number): Camera;
  3156. /**
  3157. * @override
  3158. * Override Camera._updateRigCameras
  3159. */
  3160. _updateRigCameras(): void;
  3161. dispose(): void;
  3162. getClassName(): string;
  3163. }
  3164. }
  3165. declare module BABYLON {
  3166. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  3167. constructor(camera: ArcRotateCamera);
  3168. addMouseWheel(): ArcRotateCameraInputsManager;
  3169. addPointers(): ArcRotateCameraInputsManager;
  3170. addKeyboard(): ArcRotateCameraInputsManager;
  3171. addGamepad(): ArcRotateCameraInputsManager;
  3172. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  3173. }
  3174. }
  3175. declare module BABYLON {
  3176. class Camera extends Node {
  3177. inputs: CameraInputsManager<Camera>;
  3178. private static _PERSPECTIVE_CAMERA;
  3179. private static _ORTHOGRAPHIC_CAMERA;
  3180. private static _FOVMODE_VERTICAL_FIXED;
  3181. private static _FOVMODE_HORIZONTAL_FIXED;
  3182. private static _RIG_MODE_NONE;
  3183. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  3184. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  3185. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  3186. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  3187. private static _RIG_MODE_VR;
  3188. private static _RIG_MODE_WEBVR;
  3189. static readonly PERSPECTIVE_CAMERA: number;
  3190. static readonly ORTHOGRAPHIC_CAMERA: number;
  3191. /**
  3192. * This is the default FOV mode for perspective cameras.
  3193. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  3194. *
  3195. */
  3196. static readonly FOVMODE_VERTICAL_FIXED: number;
  3197. /**
  3198. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  3199. *
  3200. */
  3201. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  3202. static readonly RIG_MODE_NONE: number;
  3203. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  3204. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  3205. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  3206. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  3207. static readonly RIG_MODE_VR: number;
  3208. static readonly RIG_MODE_WEBVR: number;
  3209. static ForceAttachControlToAlwaysPreventDefault: boolean;
  3210. static UseAlternateWebVRRendering: boolean;
  3211. position: Vector3;
  3212. /**
  3213. * The vector the camera should consider as up.
  3214. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  3215. */
  3216. upVector: Vector3;
  3217. orthoLeft: Nullable<number>;
  3218. orthoRight: Nullable<number>;
  3219. orthoBottom: Nullable<number>;
  3220. orthoTop: Nullable<number>;
  3221. /**
  3222. * FOV is set in Radians. (default is 0.8)
  3223. */
  3224. fov: number;
  3225. minZ: number;
  3226. maxZ: number;
  3227. inertia: number;
  3228. mode: number;
  3229. isIntermediate: boolean;
  3230. viewport: Viewport;
  3231. /**
  3232. * Restricts the camera to viewing objects with the same layerMask.
  3233. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  3234. */
  3235. layerMask: number;
  3236. /**
  3237. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  3238. */
  3239. fovMode: number;
  3240. cameraRigMode: number;
  3241. interaxialDistance: number;
  3242. isStereoscopicSideBySide: boolean;
  3243. _cameraRigParams: any;
  3244. _rigCameras: Camera[];
  3245. _rigPostProcess: Nullable<PostProcess>;
  3246. protected _webvrViewMatrix: Matrix;
  3247. _skipRendering: boolean;
  3248. _alternateCamera: Camera;
  3249. customRenderTargets: RenderTargetTexture[];
  3250. onViewMatrixChangedObservable: Observable<Camera>;
  3251. onProjectionMatrixChangedObservable: Observable<Camera>;
  3252. onAfterCheckInputsObservable: Observable<Camera>;
  3253. onRestoreStateObservable: Observable<Camera>;
  3254. private _computedViewMatrix;
  3255. _projectionMatrix: Matrix;
  3256. private _doNotComputeProjectionMatrix;
  3257. private _worldMatrix;
  3258. _postProcesses: PostProcess[];
  3259. private _transformMatrix;
  3260. _activeMeshes: SmartArray<AbstractMesh>;
  3261. private _globalPosition;
  3262. private _frustumPlanes;
  3263. private _refreshFrustumPlanes;
  3264. constructor(name: string, position: Vector3, scene: Scene);
  3265. private _storedFov;
  3266. private _stateStored;
  3267. /**
  3268. * Store current camera state (fov, position, etc..)
  3269. */
  3270. storeState(): Camera;
  3271. /**
  3272. * Restores the camera state values if it has been stored. You must call storeState() first
  3273. */
  3274. protected _restoreStateValues(): boolean;
  3275. /**
  3276. * Restored camera state. You must call storeState() first
  3277. */
  3278. restoreState(): boolean;
  3279. getClassName(): string;
  3280. /**
  3281. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  3282. */
  3283. toString(fullDetails?: boolean): string;
  3284. readonly globalPosition: Vector3;
  3285. getActiveMeshes(): SmartArray<AbstractMesh>;
  3286. isActiveMesh(mesh: Mesh): boolean;
  3287. _initCache(): void;
  3288. _updateCache(ignoreParentClass?: boolean): void;
  3289. _isSynchronized(): boolean;
  3290. _isSynchronizedViewMatrix(): boolean;
  3291. _isSynchronizedProjectionMatrix(): boolean;
  3292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  3293. detachControl(element: HTMLElement): void;
  3294. update(): void;
  3295. _checkInputs(): void;
  3296. readonly rigCameras: Camera[];
  3297. readonly rigPostProcess: Nullable<PostProcess>;
  3298. private _cascadePostProcessesToRigCams();
  3299. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  3300. detachPostProcess(postProcess: PostProcess): void;
  3301. getWorldMatrix(): Matrix;
  3302. _getViewMatrix(): Matrix;
  3303. getViewMatrix(force?: boolean): Matrix;
  3304. freezeProjectionMatrix(projection?: Matrix): void;
  3305. unfreezeProjectionMatrix(): void;
  3306. getProjectionMatrix(force?: boolean): Matrix;
  3307. getTranformationMatrix(): Matrix;
  3308. private updateFrustumPlanes();
  3309. isInFrustum(target: ICullable): boolean;
  3310. isCompletelyInFrustum(target: ICullable): boolean;
  3311. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  3312. dispose(): void;
  3313. readonly leftCamera: Nullable<FreeCamera>;
  3314. readonly rightCamera: Nullable<FreeCamera>;
  3315. getLeftTarget(): Nullable<Vector3>;
  3316. getRightTarget(): Nullable<Vector3>;
  3317. setCameraRigMode(mode: number, rigParams: any): void;
  3318. private _getVRProjectionMatrix();
  3319. protected _updateCameraRotationMatrix(): void;
  3320. protected _updateWebVRCameraRotationMatrix(): void;
  3321. /**
  3322. * This function MUST be overwritten by the different WebVR cameras available.
  3323. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  3324. */
  3325. protected _getWebVRProjectionMatrix(): Matrix;
  3326. /**
  3327. * This function MUST be overwritten by the different WebVR cameras available.
  3328. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  3329. */
  3330. protected _getWebVRViewMatrix(): Matrix;
  3331. setCameraRigParameter(name: string, value: any): void;
  3332. /**
  3333. * needs to be overridden by children so sub has required properties to be copied
  3334. */
  3335. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  3336. /**
  3337. * May need to be overridden by children
  3338. */
  3339. _updateRigCameras(): void;
  3340. _setupInputs(): void;
  3341. serialize(): any;
  3342. clone(name: string): Camera;
  3343. getDirection(localAxis: Vector3): Vector3;
  3344. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  3345. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  3346. computeWorldMatrix(): Matrix;
  3347. static Parse(parsedCamera: any, scene: Scene): Camera;
  3348. }
  3349. }
  3350. declare module BABYLON {
  3351. var CameraInputTypes: {};
  3352. interface ICameraInput<TCamera extends Camera> {
  3353. camera: Nullable<TCamera>;
  3354. getClassName(): string;
  3355. getSimpleName(): string;
  3356. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  3357. detachControl: (element: Nullable<HTMLElement>) => void;
  3358. checkInputs?: () => void;
  3359. }
  3360. interface CameraInputsMap<TCamera extends Camera> {
  3361. [name: string]: ICameraInput<TCamera>;
  3362. [idx: number]: ICameraInput<TCamera>;
  3363. }
  3364. class CameraInputsManager<TCamera extends Camera> {
  3365. attached: CameraInputsMap<TCamera>;
  3366. attachedElement: Nullable<HTMLElement>;
  3367. noPreventDefault: boolean;
  3368. camera: TCamera;
  3369. checkInputs: () => void;
  3370. constructor(camera: TCamera);
  3371. /**
  3372. * Add an input method to a camera.
  3373. * builtin inputs example: camera.inputs.addGamepad();
  3374. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  3375. * @param input camera input method
  3376. */
  3377. add(input: ICameraInput<TCamera>): void;
  3378. /**
  3379. * Remove a specific input method from a camera
  3380. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  3381. * @param inputToRemove camera input method
  3382. */
  3383. remove(inputToRemove: ICameraInput<TCamera>): void;
  3384. removeByType(inputType: string): void;
  3385. private _addCheckInputs(fn);
  3386. attachInput(input: ICameraInput<TCamera>): void;
  3387. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  3388. detachElement(element: HTMLElement, disconnect?: boolean): void;
  3389. rebuildInputCheck(): void;
  3390. /**
  3391. * Remove all attached input methods from a camera
  3392. */
  3393. clear(): void;
  3394. serialize(serializedCamera: any): void;
  3395. parse(parsedCamera: any): void;
  3396. }
  3397. }
  3398. declare module BABYLON {
  3399. /**
  3400. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  3401. * being tilted forward or back and left or right.
  3402. */
  3403. class DeviceOrientationCamera extends FreeCamera {
  3404. private _initialQuaternion;
  3405. private _quaternionCache;
  3406. /**
  3407. * Creates a new device orientation camera. @see DeviceOrientationCamera
  3408. * @param name The name of the camera
  3409. * @param position The start position camera
  3410. * @param scene The scene the camera belongs to
  3411. */
  3412. constructor(name: string, position: Vector3, scene: Scene);
  3413. /**
  3414. * Gets the current instance class name ("DeviceOrientationCamera").
  3415. * This helps avoiding instanceof at run time.
  3416. * @returns the class name
  3417. */
  3418. getClassName(): string;
  3419. /**
  3420. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  3421. */
  3422. _checkInputs(): void;
  3423. /**
  3424. * Reset the camera to its default orientation on the specified axis only.
  3425. * @param axis The axis to reset
  3426. */
  3427. resetToCurrentRotation(axis?: Axis): void;
  3428. }
  3429. }
  3430. declare module BABYLON {
  3431. class FollowCamera extends TargetCamera {
  3432. radius: number;
  3433. rotationOffset: number;
  3434. heightOffset: number;
  3435. cameraAcceleration: number;
  3436. maxCameraSpeed: number;
  3437. lockedTarget: Nullable<AbstractMesh>;
  3438. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  3439. private getRadians(degrees);
  3440. private follow(cameraTarget);
  3441. _checkInputs(): void;
  3442. getClassName(): string;
  3443. }
  3444. class ArcFollowCamera extends TargetCamera {
  3445. alpha: number;
  3446. beta: number;
  3447. radius: number;
  3448. target: Nullable<AbstractMesh>;
  3449. private _cartesianCoordinates;
  3450. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  3451. private follow();
  3452. _checkInputs(): void;
  3453. getClassName(): string;
  3454. }
  3455. }
  3456. declare module BABYLON {
  3457. class FreeCamera extends TargetCamera {
  3458. ellipsoid: Vector3;
  3459. ellipsoidOffset: Vector3;
  3460. checkCollisions: boolean;
  3461. applyGravity: boolean;
  3462. inputs: FreeCameraInputsManager;
  3463. /**
  3464. * Gets the input sensibility for a mouse input. (default is 2000.0)
  3465. * Higher values reduce sensitivity.
  3466. */
  3467. /**
  3468. * Sets the input sensibility for a mouse input. (default is 2000.0)
  3469. * Higher values reduce sensitivity.
  3470. */
  3471. angularSensibility: number;
  3472. keysUp: number[];
  3473. keysDown: number[];
  3474. keysLeft: number[];
  3475. keysRight: number[];
  3476. onCollide: (collidedMesh: AbstractMesh) => void;
  3477. private _collider;
  3478. private _needMoveForGravity;
  3479. private _oldPosition;
  3480. private _diffPosition;
  3481. private _newPosition;
  3482. _localDirection: Vector3;
  3483. _transformedDirection: Vector3;
  3484. constructor(name: string, position: Vector3, scene: Scene);
  3485. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  3486. detachControl(element: HTMLElement): void;
  3487. private _collisionMask;
  3488. collisionMask: number;
  3489. _collideWithWorld(displacement: Vector3): void;
  3490. private _onCollisionPositionChange;
  3491. _checkInputs(): void;
  3492. _decideIfNeedsToMove(): boolean;
  3493. _updatePosition(): void;
  3494. dispose(): void;
  3495. getClassName(): string;
  3496. }
  3497. }
  3498. declare module BABYLON {
  3499. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  3500. constructor(camera: FreeCamera);
  3501. addKeyboard(): FreeCameraInputsManager;
  3502. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  3503. addGamepad(): FreeCameraInputsManager;
  3504. addDeviceOrientation(): FreeCameraInputsManager;
  3505. addTouch(): FreeCameraInputsManager;
  3506. addVirtualJoystick(): FreeCameraInputsManager;
  3507. }
  3508. }
  3509. declare module BABYLON {
  3510. class GamepadCamera extends UniversalCamera {
  3511. gamepadAngularSensibility: number;
  3512. gamepadMoveSensibility: number;
  3513. constructor(name: string, position: Vector3, scene: Scene);
  3514. getClassName(): string;
  3515. }
  3516. }
  3517. declare module BABYLON {
  3518. class AnaglyphFreeCamera extends FreeCamera {
  3519. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3520. getClassName(): string;
  3521. }
  3522. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  3523. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  3524. getClassName(): string;
  3525. }
  3526. class AnaglyphGamepadCamera extends GamepadCamera {
  3527. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3528. getClassName(): string;
  3529. }
  3530. class AnaglyphUniversalCamera extends UniversalCamera {
  3531. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3532. getClassName(): string;
  3533. }
  3534. class StereoscopicFreeCamera extends FreeCamera {
  3535. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3536. getClassName(): string;
  3537. }
  3538. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  3539. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3540. getClassName(): string;
  3541. }
  3542. class StereoscopicGamepadCamera extends GamepadCamera {
  3543. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3544. getClassName(): string;
  3545. }
  3546. class StereoscopicUniversalCamera extends UniversalCamera {
  3547. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3548. getClassName(): string;
  3549. }
  3550. }
  3551. declare module BABYLON {
  3552. class TargetCamera extends Camera {
  3553. cameraDirection: Vector3;
  3554. cameraRotation: Vector2;
  3555. rotation: Vector3;
  3556. rotationQuaternion: Quaternion;
  3557. speed: number;
  3558. noRotationConstraint: boolean;
  3559. lockedTarget: any;
  3560. _currentTarget: Vector3;
  3561. _viewMatrix: Matrix;
  3562. _camMatrix: Matrix;
  3563. _cameraTransformMatrix: Matrix;
  3564. _cameraRotationMatrix: Matrix;
  3565. private _rigCamTransformMatrix;
  3566. _referencePoint: Vector3;
  3567. private _currentUpVector;
  3568. _transformedReferencePoint: Vector3;
  3569. _lookAtTemp: Matrix;
  3570. _tempMatrix: Matrix;
  3571. _reset: () => void;
  3572. constructor(name: string, position: Vector3, scene: Scene);
  3573. getFrontPosition(distance: number): Vector3;
  3574. _getLockedTargetPosition(): Nullable<Vector3>;
  3575. /**
  3576. * Store current camera state (fov, position, etc..)
  3577. */
  3578. private _storedPosition;
  3579. private _storedRotation;
  3580. private _storedRotationQuaternion;
  3581. storeState(): Camera;
  3582. /**
  3583. * Restored camera state. You must call storeState() first
  3584. */
  3585. _restoreStateValues(): boolean;
  3586. _initCache(): void;
  3587. _updateCache(ignoreParentClass?: boolean): void;
  3588. _isSynchronizedViewMatrix(): boolean;
  3589. _computeLocalCameraSpeed(): number;
  3590. setTarget(target: Vector3): void;
  3591. /**
  3592. * Return the current target position of the camera. This value is expressed in local space.
  3593. */
  3594. getTarget(): Vector3;
  3595. _decideIfNeedsToMove(): boolean;
  3596. _updatePosition(): void;
  3597. _checkInputs(): void;
  3598. protected _updateCameraRotationMatrix(): void;
  3599. _getViewMatrix(): Matrix;
  3600. /**
  3601. * @override
  3602. * Override Camera.createRigCamera
  3603. */
  3604. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  3605. /**
  3606. * @override
  3607. * Override Camera._updateRigCameras
  3608. */
  3609. _updateRigCameras(): void;
  3610. private _getRigCamPosition(halfSpace, result);
  3611. getClassName(): string;
  3612. }
  3613. }
  3614. declare module BABYLON {
  3615. class TouchCamera extends FreeCamera {
  3616. touchAngularSensibility: number;
  3617. touchMoveSensibility: number;
  3618. constructor(name: string, position: Vector3, scene: Scene);
  3619. getClassName(): string;
  3620. _setupInputs(): void;
  3621. }
  3622. }
  3623. declare module BABYLON {
  3624. class UniversalCamera extends TouchCamera {
  3625. gamepadAngularSensibility: number;
  3626. gamepadMoveSensibility: number;
  3627. constructor(name: string, position: Vector3, scene: Scene);
  3628. getClassName(): string;
  3629. }
  3630. }
  3631. declare module BABYLON {
  3632. class VirtualJoysticksCamera extends FreeCamera {
  3633. constructor(name: string, position: Vector3, scene: Scene);
  3634. getClassName(): string;
  3635. }
  3636. }
  3637. declare module BABYLON {
  3638. class DebugLayer {
  3639. private _scene;
  3640. static InspectorURL: string;
  3641. private _inspector;
  3642. private BJSINSPECTOR;
  3643. constructor(scene: Scene);
  3644. /** Creates the inspector window. */
  3645. private _createInspector(config?);
  3646. isVisible(): boolean;
  3647. hide(): void;
  3648. show(config?: {
  3649. popup?: boolean;
  3650. initialTab?: number;
  3651. parentElement?: HTMLElement;
  3652. newColors?: {
  3653. backgroundColor?: string;
  3654. backgroundColorLighter?: string;
  3655. backgroundColorLighter2?: string;
  3656. backgroundColorLighter3?: string;
  3657. color?: string;
  3658. colorTop?: string;
  3659. colorBot?: string;
  3660. };
  3661. }): void;
  3662. }
  3663. }
  3664. declare module BABYLON {
  3665. class Debug {
  3666. static AxesViewer: {
  3667. new (scene: Scene, scaleLines?: number): {
  3668. _xline: Vector3[];
  3669. _yline: Vector3[];
  3670. _zline: Vector3[];
  3671. _xmesh: Nullable<LinesMesh>;
  3672. _ymesh: Nullable<LinesMesh>;
  3673. _zmesh: Nullable<LinesMesh>;
  3674. scene: Nullable<Scene>;
  3675. scaleLines: number;
  3676. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  3677. dispose(): void;
  3678. };
  3679. };
  3680. static BoneAxesViewer: {
  3681. new (scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number): {
  3682. mesh: Nullable<Mesh>;
  3683. bone: Nullable<Bone>;
  3684. pos: Vector3;
  3685. xaxis: Vector3;
  3686. yaxis: Vector3;
  3687. zaxis: Vector3;
  3688. update(): void;
  3689. dispose(): void;
  3690. _xline: Vector3[];
  3691. _yline: Vector3[];
  3692. _zline: Vector3[];
  3693. _xmesh: Nullable<LinesMesh>;
  3694. _ymesh: Nullable<LinesMesh>;
  3695. _zmesh: Nullable<LinesMesh>;
  3696. scene: Nullable<Scene>;
  3697. scaleLines: number;
  3698. };
  3699. };
  3700. static PhysicsViewer: {
  3701. new (scene: Scene): {
  3702. _impostors: Nullable<PhysicsImpostor>[];
  3703. _meshes: Nullable<AbstractMesh>[];
  3704. _scene: Nullable<Scene>;
  3705. _numMeshes: number;
  3706. _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  3707. _renderFunction: () => void;
  3708. _debugBoxMesh: Mesh;
  3709. _debugSphereMesh: Mesh;
  3710. _debugMaterial: StandardMaterial;
  3711. _updateDebugMeshes(): void;
  3712. showImpostor(impostor: PhysicsImpostor): void;
  3713. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  3714. _getDebugMaterial(scene: Scene): Material;
  3715. _getDebugBoxMesh(scene: Scene): AbstractMesh;
  3716. _getDebugSphereMesh(scene: Scene): AbstractMesh;
  3717. _getDebugMesh(impostor: PhysicsImpostor, scene: Scene): Nullable<AbstractMesh>;
  3718. dispose(): void;
  3719. };
  3720. };
  3721. static SkeletonViewer: {
  3722. new (skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number): {
  3723. color: Color3;
  3724. _scene: Scene;
  3725. _debugLines: Vector3[][];
  3726. _debugMesh: Nullable<LinesMesh>;
  3727. _isEnabled: boolean;
  3728. _renderFunction: () => void;
  3729. skeleton: Skeleton;
  3730. mesh: AbstractMesh;
  3731. autoUpdateBonesMatrices: boolean;
  3732. renderingGroupId: number;
  3733. isEnabled: boolean;
  3734. _getBonePosition(position: Vector3, bone: Bone, meshMat: Matrix, x?: number, y?: number, z?: number): void;
  3735. _getLinesForBonesWithLength(bones: Bone[], meshMat: Matrix): void;
  3736. _getLinesForBonesNoLength(bones: Bone[], meshMat: Matrix): void;
  3737. update(): void;
  3738. dispose(): void;
  3739. };
  3740. };
  3741. }
  3742. }
  3743. declare module BABYLON {
  3744. class RayHelper {
  3745. ray: Nullable<Ray>;
  3746. private _renderPoints;
  3747. private _renderLine;
  3748. private _renderFunction;
  3749. private _scene;
  3750. private _updateToMeshFunction;
  3751. private _attachedToMesh;
  3752. private _meshSpaceDirection;
  3753. private _meshSpaceOrigin;
  3754. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  3755. constructor(ray: Ray);
  3756. show(scene: Scene, color: Color3): void;
  3757. hide(): void;
  3758. private _render();
  3759. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  3760. detachFromMesh(): void;
  3761. private _updateToMesh();
  3762. dispose(): void;
  3763. }
  3764. }
  3765. declare module BABYLON {
  3766. class InstancingAttributeInfo {
  3767. /**
  3768. * Index/offset of the attribute in the vertex shader
  3769. */
  3770. index: number;
  3771. /**
  3772. * size of the attribute, 1, 2, 3 or 4
  3773. */
  3774. attributeSize: number;
  3775. /**
  3776. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  3777. * default is FLOAT
  3778. */
  3779. attribyteType: number;
  3780. /**
  3781. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  3782. */
  3783. normalized: boolean;
  3784. /**
  3785. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  3786. */
  3787. offset: number;
  3788. /**
  3789. * Name of the GLSL attribute, for debugging purpose only
  3790. */
  3791. attributeName: string;
  3792. }
  3793. /**
  3794. * Define options used to create a render target texture
  3795. */
  3796. class RenderTargetCreationOptions {
  3797. generateMipMaps?: boolean;
  3798. generateDepthBuffer?: boolean;
  3799. generateStencilBuffer?: boolean;
  3800. type?: number;
  3801. samplingMode?: number;
  3802. }
  3803. /**
  3804. * Regroup several parameters relative to the browser in use
  3805. */
  3806. class EngineCapabilities {
  3807. /** The maximum textures image */
  3808. maxTexturesImageUnits: number;
  3809. maxVertexTextureImageUnits: number;
  3810. maxCombinedTexturesImageUnits: number;
  3811. /** The maximum texture size */
  3812. maxTextureSize: number;
  3813. maxCubemapTextureSize: number;
  3814. maxRenderTextureSize: number;
  3815. maxVertexAttribs: number;
  3816. maxVaryingVectors: number;
  3817. maxVertexUniformVectors: number;
  3818. maxFragmentUniformVectors: number;
  3819. standardDerivatives: boolean;
  3820. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  3821. pvrtc: any;
  3822. etc1: any;
  3823. etc2: any;
  3824. astc: any;
  3825. textureFloat: boolean;
  3826. vertexArrayObject: boolean;
  3827. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  3828. maxAnisotropy: number;
  3829. instancedArrays: boolean;
  3830. uintIndices: boolean;
  3831. highPrecisionShaderSupported: boolean;
  3832. fragmentDepthSupported: boolean;
  3833. textureFloatLinearFiltering: boolean;
  3834. textureFloatRender: boolean;
  3835. textureHalfFloat: boolean;
  3836. textureHalfFloatLinearFiltering: boolean;
  3837. textureHalfFloatRender: boolean;
  3838. textureLOD: boolean;
  3839. drawBuffersExtension: boolean;
  3840. depthTextureExtension: boolean;
  3841. colorBufferFloat: boolean;
  3842. timerQuery: EXT_disjoint_timer_query;
  3843. canUseTimestampForTimerQuery: boolean;
  3844. }
  3845. interface EngineOptions extends WebGLContextAttributes {
  3846. limitDeviceRatio?: number;
  3847. autoEnableWebVR?: boolean;
  3848. disableWebGL2Support?: boolean;
  3849. audioEngine?: boolean;
  3850. deterministicLockstep?: boolean;
  3851. lockstepMaxSteps?: number;
  3852. doNotHandleContextLost?: boolean;
  3853. }
  3854. interface IDisplayChangedEventArgs {
  3855. vrDisplay: any;
  3856. vrSupported: boolean;
  3857. }
  3858. /**
  3859. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio.
  3860. */
  3861. class Engine {
  3862. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  3863. static ExceptionList: ({
  3864. key: string;
  3865. capture: string;
  3866. captureConstraint: number;
  3867. targets: string[];
  3868. } | {
  3869. key: string;
  3870. capture: null;
  3871. captureConstraint: null;
  3872. targets: string[];
  3873. })[];
  3874. static Instances: Engine[];
  3875. static readonly LastCreatedEngine: Nullable<Engine>;
  3876. static readonly LastCreatedScene: Nullable<Scene>;
  3877. /**
  3878. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  3879. */
  3880. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  3881. private static _ALPHA_DISABLE;
  3882. private static _ALPHA_ADD;
  3883. private static _ALPHA_COMBINE;
  3884. private static _ALPHA_SUBTRACT;
  3885. private static _ALPHA_MULTIPLY;
  3886. private static _ALPHA_MAXIMIZED;
  3887. private static _ALPHA_ONEONE;
  3888. private static _ALPHA_PREMULTIPLIED;
  3889. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  3890. private static _ALPHA_INTERPOLATE;
  3891. private static _ALPHA_SCREENMODE;
  3892. private static _DELAYLOADSTATE_NONE;
  3893. private static _DELAYLOADSTATE_LOADED;
  3894. private static _DELAYLOADSTATE_LOADING;
  3895. private static _DELAYLOADSTATE_NOTLOADED;
  3896. private static _TEXTUREFORMAT_ALPHA;
  3897. private static _TEXTUREFORMAT_LUMINANCE;
  3898. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  3899. private static _TEXTUREFORMAT_RGB;
  3900. private static _TEXTUREFORMAT_RGBA;
  3901. private static _TEXTURETYPE_UNSIGNED_INT;
  3902. private static _TEXTURETYPE_FLOAT;
  3903. private static _TEXTURETYPE_HALF_FLOAT;
  3904. private static _NEVER;
  3905. private static _ALWAYS;
  3906. private static _LESS;
  3907. private static _EQUAL;
  3908. private static _LEQUAL;
  3909. private static _GREATER;
  3910. private static _GEQUAL;
  3911. private static _NOTEQUAL;
  3912. static readonly NEVER: number;
  3913. static readonly ALWAYS: number;
  3914. static readonly LESS: number;
  3915. static readonly EQUAL: number;
  3916. static readonly LEQUAL: number;
  3917. static readonly GREATER: number;
  3918. static readonly GEQUAL: number;
  3919. static readonly NOTEQUAL: number;
  3920. private static _KEEP;
  3921. private static _REPLACE;
  3922. private static _INCR;
  3923. private static _DECR;
  3924. private static _INVERT;
  3925. private static _INCR_WRAP;
  3926. private static _DECR_WRAP;
  3927. static readonly KEEP: number;
  3928. static readonly REPLACE: number;
  3929. static readonly INCR: number;
  3930. static readonly DECR: number;
  3931. static readonly INVERT: number;
  3932. static readonly INCR_WRAP: number;
  3933. static readonly DECR_WRAP: number;
  3934. static readonly ALPHA_DISABLE: number;
  3935. static readonly ALPHA_ONEONE: number;
  3936. static readonly ALPHA_ADD: number;
  3937. static readonly ALPHA_COMBINE: number;
  3938. static readonly ALPHA_SUBTRACT: number;
  3939. static readonly ALPHA_MULTIPLY: number;
  3940. static readonly ALPHA_MAXIMIZED: number;
  3941. static readonly ALPHA_PREMULTIPLIED: number;
  3942. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  3943. static readonly ALPHA_INTERPOLATE: number;
  3944. static readonly ALPHA_SCREENMODE: number;
  3945. static readonly DELAYLOADSTATE_NONE: number;
  3946. static readonly DELAYLOADSTATE_LOADED: number;
  3947. static readonly DELAYLOADSTATE_LOADING: number;
  3948. static readonly DELAYLOADSTATE_NOTLOADED: number;
  3949. static readonly TEXTUREFORMAT_ALPHA: number;
  3950. static readonly TEXTUREFORMAT_LUMINANCE: number;
  3951. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  3952. static readonly TEXTUREFORMAT_RGB: number;
  3953. static readonly TEXTUREFORMAT_RGBA: number;
  3954. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  3955. static readonly TEXTURETYPE_FLOAT: number;
  3956. static readonly TEXTURETYPE_HALF_FLOAT: number;
  3957. private static _SCALEMODE_FLOOR;
  3958. private static _SCALEMODE_NEAREST;
  3959. private static _SCALEMODE_CEILING;
  3960. static readonly SCALEMODE_FLOOR: number;
  3961. static readonly SCALEMODE_NEAREST: number;
  3962. static readonly SCALEMODE_CEILING: number;
  3963. static readonly Version: string;
  3964. static CollisionsEpsilon: number;
  3965. static CodeRepository: string;
  3966. static ShadersRepository: string;
  3967. forcePOTTextures: boolean;
  3968. isFullscreen: boolean;
  3969. isPointerLock: boolean;
  3970. cullBackFaces: boolean;
  3971. renderEvenInBackground: boolean;
  3972. preventCacheWipeBetweenFrames: boolean;
  3973. enableOfflineSupport: boolean;
  3974. scenes: Scene[];
  3975. postProcesses: PostProcess[];
  3976. /**
  3977. * Observable event triggered each time the rendering canvas is resized
  3978. */
  3979. onResizeObservable: Observable<Engine>;
  3980. /**
  3981. * Observable event triggered each time the canvas loses focus
  3982. */
  3983. onCanvasBlurObservable: Observable<Engine>;
  3984. /**
  3985. * Observable event triggered each time the canvas gains focus
  3986. */
  3987. onCanvasFocusObservable: Observable<Engine>;
  3988. /**
  3989. * Observable event triggered each time the canvas receives pointerout event
  3990. */
  3991. onCanvasPointerOutObservable: Observable<Engine>;
  3992. /**
  3993. * Observable event triggered before each texture is initialized
  3994. */
  3995. onBeforeTextureInitObservable: Observable<Texture>;
  3996. private _vrDisplay;
  3997. private _vrSupported;
  3998. private _oldSize;
  3999. private _oldHardwareScaleFactor;
  4000. private _vrExclusivePointerMode;
  4001. readonly isInVRExclusivePointerMode: boolean;
  4002. disableUniformBuffers: boolean;
  4003. _uniformBuffers: UniformBuffer[];
  4004. readonly supportsUniformBuffers: boolean;
  4005. /**
  4006. * Observable raised when the engine begins a new frame
  4007. */
  4008. onBeginFrameObservable: Observable<Engine>;
  4009. /**
  4010. * Observable raised when the engine ends the current frame
  4011. */
  4012. onEndFrameObservable: Observable<Engine>;
  4013. /**
  4014. * Observable raised when the engine is about to compile a shader
  4015. */
  4016. onBeforeShaderCompilationObservable: Observable<Engine>;
  4017. /**
  4018. * Observable raised when the engine has jsut compiled a shader
  4019. */
  4020. onAfterShaderCompilationObservable: Observable<Engine>;
  4021. private _gl;
  4022. private _renderingCanvas;
  4023. private _windowIsBackground;
  4024. private _webGLVersion;
  4025. readonly needPOTTextures: boolean;
  4026. private _badOS;
  4027. readonly badOS: boolean;
  4028. private _badDesktopOS;
  4029. readonly badDesktopOS: boolean;
  4030. /**
  4031. * Gets or sets a value indicating if we want to disable texture binding optmization.
  4032. * This could be required on some buggy drivers which wants to have textures bound in a progressive order
  4033. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is.
  4034. */
  4035. disableTextureBindingOptimization: boolean;
  4036. static audioEngine: AudioEngine;
  4037. private _onFocus;
  4038. private _onBlur;
  4039. private _onCanvasPointerOut;
  4040. private _onCanvasBlur;
  4041. private _onCanvasFocus;
  4042. private _onFullscreenChange;
  4043. private _onPointerLockChange;
  4044. private _onVRDisplayPointerRestricted;
  4045. private _onVRDisplayPointerUnrestricted;
  4046. private _onVrDisplayConnect;
  4047. private _onVrDisplayDisconnect;
  4048. private _onVrDisplayPresentChange;
  4049. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  4050. onVRRequestPresentComplete: Observable<boolean>;
  4051. onVRRequestPresentStart: Observable<Engine>;
  4052. private _hardwareScalingLevel;
  4053. protected _caps: EngineCapabilities;
  4054. private _pointerLockRequested;
  4055. private _isStencilEnable;
  4056. private _colorWrite;
  4057. private _loadingScreen;
  4058. _drawCalls: PerfCounter;
  4059. _textureCollisions: PerfCounter;
  4060. private _glVersion;
  4061. private _glRenderer;
  4062. private _glVendor;
  4063. private _videoTextureSupported;
  4064. private _renderingQueueLaunched;
  4065. private _activeRenderLoops;
  4066. private _deterministicLockstep;
  4067. private _lockstepMaxSteps;
  4068. onContextLostObservable: Observable<Engine>;
  4069. onContextRestoredObservable: Observable<Engine>;
  4070. private _onContextLost;
  4071. private _onContextRestored;
  4072. private _contextWasLost;
  4073. private _doNotHandleContextLost;
  4074. private _performanceMonitor;
  4075. private _fps;
  4076. private _deltaTime;
  4077. /**
  4078. * Turn this value on if you want to pause FPS computation when in background
  4079. */
  4080. disablePerformanceMonitorInBackground: boolean;
  4081. readonly performanceMonitor: PerformanceMonitor;
  4082. protected _depthCullingState: _DepthCullingState;
  4083. protected _stencilState: _StencilState;
  4084. protected _alphaState: _AlphaState;
  4085. protected _alphaMode: number;
  4086. private _internalTexturesCache;
  4087. protected _activeChannel: number;
  4088. private _currentTextureChannel;
  4089. protected _boundTexturesCache: {
  4090. [key: string]: Nullable<InternalTexture>;
  4091. };
  4092. protected _currentEffect: Nullable<Effect>;
  4093. protected _currentProgram: Nullable<WebGLProgram>;
  4094. private _compiledEffects;
  4095. private _vertexAttribArraysEnabled;
  4096. protected _cachedViewport: Nullable<Viewport>;
  4097. private _cachedVertexArrayObject;
  4098. protected _cachedVertexBuffers: any;
  4099. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  4100. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  4101. protected _currentRenderTarget: Nullable<InternalTexture>;
  4102. private _uintIndicesCurrentlySet;
  4103. private _currentBoundBuffer;
  4104. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  4105. private _currentBufferPointers;
  4106. private _currentInstanceLocations;
  4107. private _currentInstanceBuffers;
  4108. private _textureUnits;
  4109. private _firstBoundInternalTextureTracker;
  4110. private _lastBoundInternalTextureTracker;
  4111. private _workingCanvas;
  4112. private _workingContext;
  4113. private _rescalePostProcess;
  4114. private _dummyFramebuffer;
  4115. private _externalData;
  4116. private _bindedRenderFunction;
  4117. private _vaoRecordInProgress;
  4118. private _mustWipeVertexAttributes;
  4119. private _emptyTexture;
  4120. private _emptyCubeTexture;
  4121. private _emptyTexture3D;
  4122. private _frameHandler;
  4123. private _nextFreeTextureSlots;
  4124. private _maxSimultaneousTextures;
  4125. private _activeRequests;
  4126. private _texturesSupported;
  4127. private _textureFormatInUse;
  4128. readonly texturesSupported: Array<string>;
  4129. readonly textureFormatInUse: Nullable<string>;
  4130. readonly currentViewport: Nullable<Viewport>;
  4131. readonly emptyTexture: InternalTexture;
  4132. readonly emptyTexture3D: InternalTexture;
  4133. readonly emptyCubeTexture: InternalTexture;
  4134. /**
  4135. * @constructor
  4136. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  4137. * @param antialias defines enable antialiasing (default: false)
  4138. * @param options defines further options to be sent to the getContext() function
  4139. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  4140. */
  4141. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  4142. private _rebuildInternalTextures();
  4143. private _rebuildEffects();
  4144. private _rebuildBuffers();
  4145. private _initGLContext();
  4146. readonly webGLVersion: number;
  4147. /**
  4148. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  4149. */
  4150. readonly isStencilEnable: boolean;
  4151. private _prepareWorkingCanvas();
  4152. resetTextureCache(): void;
  4153. isDeterministicLockStep(): boolean;
  4154. getLockstepMaxSteps(): number;
  4155. getGlInfo(): {
  4156. vendor: string;
  4157. renderer: string;
  4158. version: string;
  4159. };
  4160. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  4161. getRenderWidth(useScreen?: boolean): number;
  4162. getRenderHeight(useScreen?: boolean): number;
  4163. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  4164. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  4165. setHardwareScalingLevel(level: number): void;
  4166. getHardwareScalingLevel(): number;
  4167. getLoadedTexturesCache(): InternalTexture[];
  4168. getCaps(): EngineCapabilities;
  4169. /** The number of draw calls submitted last frame */
  4170. readonly drawCalls: number;
  4171. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  4172. getDepthFunction(): Nullable<number>;
  4173. setDepthFunction(depthFunc: number): void;
  4174. setDepthFunctionToGreater(): void;
  4175. setDepthFunctionToGreaterOrEqual(): void;
  4176. setDepthFunctionToLess(): void;
  4177. setDepthFunctionToLessOrEqual(): void;
  4178. getStencilBuffer(): boolean;
  4179. setStencilBuffer(enable: boolean): void;
  4180. getStencilMask(): number;
  4181. setStencilMask(mask: number): void;
  4182. getStencilFunction(): number;
  4183. getStencilFunctionReference(): number;
  4184. getStencilFunctionMask(): number;
  4185. setStencilFunction(stencilFunc: number): void;
  4186. setStencilFunctionReference(reference: number): void;
  4187. setStencilFunctionMask(mask: number): void;
  4188. getStencilOperationFail(): number;
  4189. getStencilOperationDepthFail(): number;
  4190. getStencilOperationPass(): number;
  4191. setStencilOperationFail(operation: number): void;
  4192. setStencilOperationDepthFail(operation: number): void;
  4193. setStencilOperationPass(operation: number): void;
  4194. setDitheringState(value: boolean): void;
  4195. setRasterizerState(value: boolean): void;
  4196. /**
  4197. * stop executing a render loop function and remove it from the execution array
  4198. * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
  4199. */
  4200. stopRenderLoop(renderFunction?: () => void): void;
  4201. _renderLoop(): void;
  4202. /**
  4203. * Register and execute a render loop. The engine can have more than one render function.
  4204. * @param {Function} renderFunction - the function to continuously execute starting the next render loop.
  4205. * @example
  4206. * engine.runRenderLoop(function () {
  4207. * scene.render()
  4208. * })
  4209. */
  4210. runRenderLoop(renderFunction: () => void): void;
  4211. /**
  4212. * Toggle full screen mode.
  4213. * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
  4214. * @param {any} options - an options object to be sent to the requestFullscreen function
  4215. */
  4216. switchFullscreen(requestPointerLock: boolean): void;
  4217. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  4218. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  4219. /**
  4220. * Set the WebGL's viewport
  4221. * @param {BABYLON.Viewport} viewport - the viewport element to be used.
  4222. * @param {number} [requiredWidth] - the width required for rendering. If not provided the rendering canvas' width is used.
  4223. * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
  4224. */
  4225. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  4226. /**
  4227. * Directly set the WebGL Viewport
  4228. * The x, y, width & height are directly passed to the WebGL call
  4229. * @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.
  4230. */
  4231. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  4232. beginFrame(): void;
  4233. endFrame(): void;
  4234. /**
  4235. * resize the view according to the canvas' size.
  4236. * @example
  4237. * window.addEventListener("resize", function () {
  4238. * engine.resize();
  4239. * });
  4240. */
  4241. resize(): void;
  4242. /**
  4243. * force a specific size of the canvas
  4244. * @param {number} width - the new canvas' width
  4245. * @param {number} height - the new canvas' height
  4246. */
  4247. setSize(width: number, height: number): void;
  4248. isVRDevicePresent(): boolean;
  4249. getVRDevice(): any;
  4250. initWebVR(): Observable<{
  4251. vrDisplay: any;
  4252. vrSupported: any;
  4253. }>;
  4254. enableVR(): void;
  4255. disableVR(): void;
  4256. private _onVRFullScreenTriggered;
  4257. private _getVRDisplays(callback);
  4258. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  4259. private bindUnboundFramebuffer(framebuffer);
  4260. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  4261. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  4262. generateMipMapsForCubemap(texture: InternalTexture): void;
  4263. flushFramebuffer(): void;
  4264. restoreDefaultFramebuffer(): void;
  4265. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  4266. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  4267. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  4268. private _resetVertexBufferBinding();
  4269. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4270. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4271. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  4272. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  4273. private _resetIndexBufferBinding();
  4274. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  4275. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  4276. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  4277. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  4278. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  4279. private bindIndexBuffer(buffer);
  4280. private bindBuffer(buffer, target);
  4281. updateArrayBuffer(data: Float32Array): void;
  4282. private vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  4283. private _bindIndexBufferWithCache(indexBuffer);
  4284. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  4285. recordVertexArrayObject(vertexBuffers: {
  4286. [key: string]: VertexBuffer;
  4287. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  4288. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  4289. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  4290. private _unbindVertexArrayObject();
  4291. bindBuffers(vertexBuffers: {
  4292. [key: string]: Nullable<VertexBuffer>;
  4293. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  4294. unbindInstanceAttributes(): void;
  4295. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  4296. _releaseBuffer(buffer: WebGLBuffer): boolean;
  4297. createInstancesBuffer(capacity: number): WebGLBuffer;
  4298. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  4299. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  4300. applyStates(): void;
  4301. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  4302. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4303. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4304. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  4305. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4306. private DrawMode(fillMode);
  4307. _releaseEffect(effect: Effect): void;
  4308. _deleteProgram(program: WebGLProgram): void;
  4309. /**
  4310. * @param baseName The base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  4311. * @param samplers An array of string used to represent textures
  4312. */
  4313. 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;
  4314. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  4315. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  4316. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  4317. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  4318. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  4319. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  4320. enableEffect(effect: Nullable<Effect>): void;
  4321. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4322. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4323. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4324. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4325. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4326. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4327. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4328. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4329. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4330. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4331. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4332. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4333. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  4334. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  4335. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  4336. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  4337. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  4338. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  4339. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  4340. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  4341. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  4342. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  4343. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  4344. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  4345. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  4346. setZOffset(value: number): void;
  4347. getZOffset(): number;
  4348. setDepthBuffer(enable: boolean): void;
  4349. getDepthWrite(): boolean;
  4350. setDepthWrite(enable: boolean): void;
  4351. setColorWrite(enable: boolean): void;
  4352. getColorWrite(): boolean;
  4353. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  4354. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  4355. getAlphaMode(): number;
  4356. wipeCaches(bruteForce?: boolean): void;
  4357. /**
  4358. * Set the compressed texture format to use, based on the formats you have, and the formats
  4359. * supported by the hardware / browser.
  4360. *
  4361. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  4362. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  4363. * to API arguments needed to compressed textures. This puts the burden on the container
  4364. * generator to house the arcane code for determining these for current & future formats.
  4365. *
  4366. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  4367. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  4368. *
  4369. * Note: The result of this call is not taken into account when a texture is base64.
  4370. *
  4371. * @param {Array<string>} formatsAvailable- The list of those format families you have created
  4372. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  4373. *
  4374. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  4375. * @returns The extension selected.
  4376. */
  4377. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  4378. _createTexture(): WebGLTexture;
  4379. /**
  4380. * Usually called from BABYLON.Texture.ts. Passed information to create a WebGLTexture.
  4381. * @param {string} urlArg- This contains one of the following:
  4382. * 1. A conventional http URL, e.g. 'http://...' or 'file://...'
  4383. * 2. A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  4384. * 3. An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  4385. *
  4386. * @param {boolean} noMipmap- When true, no mipmaps shall be generated. Ignored for compressed textures. They must be in the file.
  4387. * @param {boolean} invertY- When true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file.
  4388. * @param {Scene} scene- Needed for loading to the correct scene.
  4389. * @param {number} samplingMode- Mode with should be used sample / access the texture. Default: TRILINEAR
  4390. * @param {callback} onLoad- Optional callback to be called upon successful completion.
  4391. * @param {callback} onError- Optional callback to be called upon failure.
  4392. * @param {ArrayBuffer | HTMLImageElement} buffer- A source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
  4393. * @param {WebGLTexture} fallback- An internal argument in case the function must be called again, due to etc1 not having alpha capabilities.
  4394. * @param {number} format- Internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures.
  4395. *
  4396. * @returns {WebGLTexture} for assignment back into BABYLON.Texture
  4397. */
  4398. 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;
  4399. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  4400. private _getInternalFormat(format);
  4401. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  4402. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  4403. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  4404. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  4405. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  4406. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  4407. createRenderTargetTexture(size: number | {
  4408. width: number;
  4409. height: number;
  4410. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  4411. createMultipleRenderTarget(size: any, options: any): InternalTexture[];
  4412. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  4413. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  4414. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  4415. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  4416. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  4417. createRenderTargetCubeTexture(size: number, options?: RenderTargetCreationOptions): InternalTexture;
  4418. 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;
  4419. 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;
  4420. private setCubeMapTextureParams(gl, loadMipmap);
  4421. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  4422. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  4423. 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;
  4424. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  4425. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  4426. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  4427. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  4428. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  4429. _releaseFramebufferObjects(texture: InternalTexture): void;
  4430. _releaseTexture(texture: InternalTexture): void;
  4431. private setProgram(program);
  4432. private _boundUniforms;
  4433. bindSamplers(effect: Effect): void;
  4434. private _moveBoundTextureOnTop(internalTexture);
  4435. private _getCorrectTextureChannel(channel, internalTexture);
  4436. private _linkTrackers(previous, next);
  4437. private _removeDesignatedSlot(internalTexture);
  4438. private _activateCurrentTexture();
  4439. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean): void;
  4440. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  4441. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  4442. unbindAllTextures(): void;
  4443. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  4444. private _bindSamplerUniformToChannel(sourceSlot, destination);
  4445. private _setTexture(channel, texture, isPartOfTextureArray?);
  4446. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  4447. _setAnisotropicLevel(key: number, texture: BaseTexture): void;
  4448. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  4449. /**
  4450. * Add an externaly attached data from its key.
  4451. * This method call will fail and return false, if such key already exists.
  4452. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  4453. * @param key the unique key that identifies the data
  4454. * @param data the data object to associate to the key for this Engine instance
  4455. * @return true if no such key were already present and the data was added successfully, false otherwise
  4456. */
  4457. addExternalData<T>(key: string, data: T): boolean;
  4458. /**
  4459. * Get an externaly attached data from its key
  4460. * @param key the unique key that identifies the data
  4461. * @return the associated data, if present (can be null), or undefined if not present
  4462. */
  4463. getExternalData<T>(key: string): T;
  4464. /**
  4465. * Get an externaly attached data from its key, create it using a factory if it's not already present
  4466. * @param key the unique key that identifies the data
  4467. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  4468. * @return the associated data, can be null if the factory returned null.
  4469. */
  4470. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  4471. /**
  4472. * Remove an externaly attached data from the Engine instance
  4473. * @param key the unique key that identifies the data
  4474. * @return true if the data was successfully removed, false if it doesn't exist
  4475. */
  4476. removeExternalData(key: string): boolean;
  4477. unbindAllAttributes(): void;
  4478. releaseEffects(): void;
  4479. dispose(): void;
  4480. displayLoadingUI(): void;
  4481. hideLoadingUI(): void;
  4482. loadingScreen: ILoadingScreen;
  4483. loadingUIText: string;
  4484. loadingUIBackgroundColor: string;
  4485. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  4486. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  4487. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  4488. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  4489. getError(): number;
  4490. getFps(): number;
  4491. getDeltaTime(): number;
  4492. private _measureFps();
  4493. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  4494. private _canRenderToFloatFramebuffer();
  4495. private _canRenderToHalfFloatFramebuffer();
  4496. private _canRenderToFramebuffer(type);
  4497. _getWebGLTextureType(type: number): number;
  4498. _getRGBABufferInternalSizedFormat(type: number): number;
  4499. _getRGBAMultiSampleBufferFormat(type: number): number;
  4500. createQuery(): WebGLQuery;
  4501. deleteQuery(query: WebGLQuery): Engine;
  4502. isQueryResultAvailable(query: WebGLQuery): boolean;
  4503. getQueryResult(query: WebGLQuery): number;
  4504. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  4505. endOcclusionQuery(algorithmType: number): Engine;
  4506. private _createTimeQuery();
  4507. private _deleteTimeQuery(query);
  4508. private _getTimeQueryResult(query);
  4509. private _getTimeQueryAvailability(query);
  4510. private _currentNonTimestampToken;
  4511. startTimeQuery(): Nullable<_TimeToken>;
  4512. endTimeQuery(token: _TimeToken): int;
  4513. private getGlAlgorithmType(algorithmType);
  4514. createTransformFeedback(): WebGLTransformFeedback;
  4515. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  4516. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  4517. beginTransformFeedback(usePoints?: boolean): void;
  4518. endTransformFeedback(): void;
  4519. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  4520. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  4521. _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;
  4522. /** @ignore */
  4523. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  4524. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  4525. private _cascadeLoadFiles(rootUrl, scene, onfinish, files, onError?);
  4526. static isSupported(): boolean;
  4527. }
  4528. }
  4529. declare module BABYLON {
  4530. class NullEngineOptions {
  4531. renderWidth: number;
  4532. renderHeight: number;
  4533. textureSize: number;
  4534. deterministicLockstep: boolean;
  4535. lockstepMaxSteps: number;
  4536. }
  4537. /**
  4538. * The null engine class provides support for headless version of babylon.js.
  4539. * This can be used in server side scenario or for testing purposes
  4540. */
  4541. class NullEngine extends Engine {
  4542. private _options;
  4543. isDeterministicLockStep(): boolean;
  4544. getLockstepMaxSteps(): number;
  4545. constructor(options?: NullEngineOptions);
  4546. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4547. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  4548. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  4549. getRenderWidth(useScreen?: boolean): number;
  4550. getRenderHeight(useScreen?: boolean): number;
  4551. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  4552. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  4553. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  4554. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  4555. bindSamplers(effect: Effect): void;
  4556. enableEffect(effect: Effect): void;
  4557. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  4558. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  4559. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  4560. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  4561. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  4562. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  4563. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  4564. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  4565. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  4566. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  4567. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  4568. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  4569. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  4570. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  4571. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  4572. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  4573. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  4574. setFloat(uniform: WebGLUniformLocation, value: number): void;
  4575. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  4576. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  4577. setBool(uniform: WebGLUniformLocation, bool: number): void;
  4578. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  4579. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  4580. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  4581. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  4582. bindBuffers(vertexBuffers: {
  4583. [key: string]: VertexBuffer;
  4584. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  4585. wipeCaches(bruteForce?: boolean): void;
  4586. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  4587. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  4588. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4589. _createTexture(): WebGLTexture;
  4590. 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;
  4591. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  4592. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  4593. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  4594. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  4595. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4596. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  4597. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  4598. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  4599. _bindTexture(channel: number, texture: InternalTexture): void;
  4600. _releaseBuffer(buffer: WebGLBuffer): boolean;
  4601. }
  4602. }
  4603. interface WebGLRenderingContext {
  4604. readonly RASTERIZER_DISCARD: number;
  4605. readonly TEXTURE_3D: number;
  4606. readonly TEXTURE_2D_ARRAY: number;
  4607. readonly TEXTURE_WRAP_R: number;
  4608. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  4609. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  4610. 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;
  4611. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  4612. readonly TRANSFORM_FEEDBACK: number;
  4613. readonly INTERLEAVED_ATTRIBS: number;
  4614. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  4615. createTransformFeedback(): WebGLTransformFeedback;
  4616. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  4617. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  4618. beginTransformFeedback(primitiveMode: number): void;
  4619. endTransformFeedback(): void;
  4620. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  4621. }
  4622. interface ImageBitmap {
  4623. readonly width: number;
  4624. readonly height: number;
  4625. close(): void;
  4626. }
  4627. interface WebGLQuery extends WebGLObject {
  4628. }
  4629. declare var WebGLQuery: {
  4630. prototype: WebGLQuery;
  4631. new (): WebGLQuery;
  4632. };
  4633. interface WebGLSampler extends WebGLObject {
  4634. }
  4635. declare var WebGLSampler: {
  4636. prototype: WebGLSampler;
  4637. new (): WebGLSampler;
  4638. };
  4639. interface WebGLSync extends WebGLObject {
  4640. }
  4641. declare var WebGLSync: {
  4642. prototype: WebGLSync;
  4643. new (): WebGLSync;
  4644. };
  4645. interface WebGLTransformFeedback extends WebGLObject {
  4646. }
  4647. declare var WebGLTransformFeedback: {
  4648. prototype: WebGLTransformFeedback;
  4649. new (): WebGLTransformFeedback;
  4650. };
  4651. interface WebGLVertexArrayObject extends WebGLObject {
  4652. }
  4653. declare var WebGLVertexArrayObject: {
  4654. prototype: WebGLVertexArrayObject;
  4655. new (): WebGLVertexArrayObject;
  4656. };
  4657. declare module BABYLON {
  4658. class KeyboardEventTypes {
  4659. static _KEYDOWN: number;
  4660. static _KEYUP: number;
  4661. static readonly KEYDOWN: number;
  4662. static readonly KEYUP: number;
  4663. }
  4664. class KeyboardInfo {
  4665. type: number;
  4666. event: KeyboardEvent;
  4667. constructor(type: number, event: KeyboardEvent);
  4668. }
  4669. /**
  4670. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  4671. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  4672. */
  4673. class KeyboardInfoPre extends KeyboardInfo {
  4674. constructor(type: number, event: KeyboardEvent);
  4675. skipOnPointerObservable: boolean;
  4676. }
  4677. }
  4678. declare module BABYLON {
  4679. class PointerEventTypes {
  4680. static _POINTERDOWN: number;
  4681. static _POINTERUP: number;
  4682. static _POINTERMOVE: number;
  4683. static _POINTERWHEEL: number;
  4684. static _POINTERPICK: number;
  4685. static _POINTERTAP: number;
  4686. static _POINTERDOUBLETAP: number;
  4687. static readonly POINTERDOWN: number;
  4688. static readonly POINTERUP: number;
  4689. static readonly POINTERMOVE: number;
  4690. static readonly POINTERWHEEL: number;
  4691. static readonly POINTERPICK: number;
  4692. static readonly POINTERTAP: number;
  4693. static readonly POINTERDOUBLETAP: number;
  4694. }
  4695. class PointerInfoBase {
  4696. type: number;
  4697. event: PointerEvent | MouseWheelEvent;
  4698. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  4699. }
  4700. /**
  4701. * This class is used to store pointer related info for the onPrePointerObservable event.
  4702. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  4703. */
  4704. class PointerInfoPre extends PointerInfoBase {
  4705. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  4706. localPosition: Vector2;
  4707. skipOnPointerObservable: boolean;
  4708. }
  4709. /**
  4710. * This type contains all the data related to a pointer event in Babylon.js.
  4711. * 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.
  4712. */
  4713. class PointerInfo extends PointerInfoBase {
  4714. pickInfo: Nullable<PickingInfo>;
  4715. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  4716. }
  4717. }
  4718. declare module BABYLON {
  4719. class Collider {
  4720. /** Define if a collision was found */
  4721. collisionFound: boolean;
  4722. /**
  4723. * Define last intersection point in local space
  4724. */
  4725. intersectionPoint: Vector3;
  4726. /**
  4727. * Define last collided mesh
  4728. */
  4729. collidedMesh: Nullable<AbstractMesh>;
  4730. private _collisionPoint;
  4731. private _planeIntersectionPoint;
  4732. private _tempVector;
  4733. private _tempVector2;
  4734. private _tempVector3;
  4735. private _tempVector4;
  4736. private _edge;
  4737. private _baseToVertex;
  4738. private _destinationPoint;
  4739. private _slidePlaneNormal;
  4740. private _displacementVector;
  4741. _radius: Vector3;
  4742. _retry: number;
  4743. private _velocity;
  4744. private _basePoint;
  4745. private _epsilon;
  4746. _velocityWorldLength: number;
  4747. _basePointWorld: Vector3;
  4748. private _velocityWorld;
  4749. private _normalizedVelocity;
  4750. _initialVelocity: Vector3;
  4751. _initialPosition: Vector3;
  4752. private _nearestDistance;
  4753. private _collisionMask;
  4754. collisionMask: number;
  4755. /**
  4756. * Gets the plane normal used to compute the sliding response (in local space)
  4757. */
  4758. readonly slidePlaneNormal: Vector3;
  4759. _initialize(source: Vector3, dir: Vector3, e: number): void;
  4760. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  4761. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  4762. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  4763. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  4764. _getResponse(pos: Vector3, vel: Vector3): void;
  4765. }
  4766. }
  4767. declare module BABYLON {
  4768. var CollisionWorker: string;
  4769. interface ICollisionCoordinator {
  4770. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4771. init(scene: Scene): void;
  4772. destroy(): void;
  4773. onMeshAdded(mesh: AbstractMesh): void;
  4774. onMeshUpdated(mesh: AbstractMesh): void;
  4775. onMeshRemoved(mesh: AbstractMesh): void;
  4776. onGeometryAdded(geometry: Geometry): void;
  4777. onGeometryUpdated(geometry: Geometry): void;
  4778. onGeometryDeleted(geometry: Geometry): void;
  4779. }
  4780. interface SerializedMesh {
  4781. id: string;
  4782. name: string;
  4783. uniqueId: number;
  4784. geometryId: Nullable<string>;
  4785. sphereCenter: Array<number>;
  4786. sphereRadius: number;
  4787. boxMinimum: Array<number>;
  4788. boxMaximum: Array<number>;
  4789. worldMatrixFromCache: any;
  4790. subMeshes: Array<SerializedSubMesh>;
  4791. checkCollisions: boolean;
  4792. }
  4793. interface SerializedSubMesh {
  4794. position: number;
  4795. verticesStart: number;
  4796. verticesCount: number;
  4797. indexStart: number;
  4798. indexCount: number;
  4799. hasMaterial: boolean;
  4800. sphereCenter: Array<number>;
  4801. sphereRadius: number;
  4802. boxMinimum: Array<number>;
  4803. boxMaximum: Array<number>;
  4804. }
  4805. /**
  4806. * Interface describing the value associated with a geometry
  4807. */
  4808. interface SerializedGeometry {
  4809. /**
  4810. * Defines the unique ID of the geometry
  4811. */
  4812. id: string;
  4813. /**
  4814. * Defines the array containing the positions
  4815. */
  4816. positions: Float32Array;
  4817. /**
  4818. * Defines the array containing the indices
  4819. */
  4820. indices: Uint32Array;
  4821. /**
  4822. * Defines the array containing the normals
  4823. */
  4824. normals: Float32Array;
  4825. }
  4826. interface BabylonMessage {
  4827. taskType: WorkerTaskType;
  4828. payload: InitPayload | CollidePayload | UpdatePayload;
  4829. }
  4830. interface SerializedColliderToWorker {
  4831. position: Array<number>;
  4832. velocity: Array<number>;
  4833. radius: Array<number>;
  4834. }
  4835. enum WorkerTaskType {
  4836. INIT = 0,
  4837. UPDATE = 1,
  4838. COLLIDE = 2,
  4839. }
  4840. interface WorkerReply {
  4841. error: WorkerReplyType;
  4842. taskType: WorkerTaskType;
  4843. payload?: any;
  4844. }
  4845. interface CollisionReplyPayload {
  4846. newPosition: Array<number>;
  4847. collisionId: number;
  4848. collidedMeshUniqueId: number;
  4849. }
  4850. interface InitPayload {
  4851. }
  4852. interface CollidePayload {
  4853. collisionId: number;
  4854. collider: SerializedColliderToWorker;
  4855. maximumRetry: number;
  4856. excludedMeshUniqueId: Nullable<number>;
  4857. }
  4858. interface UpdatePayload {
  4859. updatedMeshes: {
  4860. [n: number]: SerializedMesh;
  4861. };
  4862. updatedGeometries: {
  4863. [s: string]: SerializedGeometry;
  4864. };
  4865. removedMeshes: Array<number>;
  4866. removedGeometries: Array<string>;
  4867. }
  4868. enum WorkerReplyType {
  4869. SUCCESS = 0,
  4870. UNKNOWN_ERROR = 1,
  4871. }
  4872. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  4873. private _scene;
  4874. private _scaledPosition;
  4875. private _scaledVelocity;
  4876. private _collisionsCallbackArray;
  4877. private _init;
  4878. private _runningUpdated;
  4879. private _worker;
  4880. private _addUpdateMeshesList;
  4881. private _addUpdateGeometriesList;
  4882. private _toRemoveMeshesArray;
  4883. private _toRemoveGeometryArray;
  4884. constructor();
  4885. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  4886. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  4887. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4888. init(scene: Scene): void;
  4889. destroy(): void;
  4890. onMeshAdded(mesh: AbstractMesh): void;
  4891. onMeshUpdated: (transformNode: TransformNode) => void;
  4892. onMeshRemoved(mesh: AbstractMesh): void;
  4893. onGeometryAdded(geometry: Geometry): void;
  4894. onGeometryUpdated: (geometry: Geometry) => void;
  4895. onGeometryDeleted(geometry: Geometry): void;
  4896. private _afterRender;
  4897. private _onMessageFromWorker;
  4898. }
  4899. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  4900. private _scene;
  4901. private _scaledPosition;
  4902. private _scaledVelocity;
  4903. private _finalPosition;
  4904. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  4905. init(scene: Scene): void;
  4906. destroy(): void;
  4907. onMeshAdded(mesh: AbstractMesh): void;
  4908. onMeshUpdated(mesh: AbstractMesh): void;
  4909. onMeshRemoved(mesh: AbstractMesh): void;
  4910. onGeometryAdded(geometry: Geometry): void;
  4911. onGeometryUpdated(geometry: Geometry): void;
  4912. onGeometryDeleted(geometry: Geometry): void;
  4913. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  4914. }
  4915. }
  4916. declare function importScripts(...urls: string[]): void;
  4917. declare module BABYLON {
  4918. var WorkerIncluded: boolean;
  4919. class CollisionCache {
  4920. private _meshes;
  4921. private _geometries;
  4922. getMeshes(): {
  4923. [n: number]: SerializedMesh;
  4924. };
  4925. getGeometries(): {
  4926. [s: number]: SerializedGeometry;
  4927. };
  4928. getMesh(id: any): SerializedMesh;
  4929. addMesh(mesh: SerializedMesh): void;
  4930. removeMesh(uniqueId: number): void;
  4931. getGeometry(id: string): SerializedGeometry;
  4932. addGeometry(geometry: SerializedGeometry): void;
  4933. removeGeometry(id: string): void;
  4934. }
  4935. class CollideWorker {
  4936. collider: Collider;
  4937. private _collisionCache;
  4938. private finalPosition;
  4939. private collisionsScalingMatrix;
  4940. private collisionTranformationMatrix;
  4941. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  4942. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  4943. private checkCollision(mesh);
  4944. private processCollisionsForSubMeshes(transformMatrix, mesh);
  4945. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  4946. private checkSubmeshCollision(subMesh);
  4947. }
  4948. interface ICollisionDetector {
  4949. onInit(payload: InitPayload): void;
  4950. onUpdate(payload: UpdatePayload): void;
  4951. onCollision(payload: CollidePayload): void;
  4952. }
  4953. class CollisionDetectorTransferable implements ICollisionDetector {
  4954. private _collisionCache;
  4955. onInit(payload: InitPayload): void;
  4956. onUpdate(payload: UpdatePayload): void;
  4957. onCollision(payload: CollidePayload): void;
  4958. }
  4959. }
  4960. declare module BABYLON {
  4961. class IntersectionInfo {
  4962. bu: Nullable<number>;
  4963. bv: Nullable<number>;
  4964. distance: number;
  4965. faceId: number;
  4966. subMeshId: number;
  4967. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  4968. }
  4969. class PickingInfo {
  4970. hit: boolean;
  4971. distance: number;
  4972. pickedPoint: Nullable<Vector3>;
  4973. pickedMesh: Nullable<AbstractMesh>;
  4974. bu: number;
  4975. bv: number;
  4976. faceId: number;
  4977. subMeshId: number;
  4978. pickedSprite: Nullable<Sprite>;
  4979. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  4980. getTextureCoordinates(): Nullable<Vector2>;
  4981. }
  4982. }
  4983. declare module BABYLON {
  4984. class StickValues {
  4985. x: number;
  4986. y: number;
  4987. constructor(x: number, y: number);
  4988. }
  4989. interface GamepadButtonChanges {
  4990. changed: boolean;
  4991. pressChanged: boolean;
  4992. touchChanged: boolean;
  4993. valueChanged: boolean;
  4994. }
  4995. class Gamepad {
  4996. id: string;
  4997. index: number;
  4998. browserGamepad: any;
  4999. type: number;
  5000. private _leftStick;
  5001. private _rightStick;
  5002. _isConnected: boolean;
  5003. private _leftStickAxisX;
  5004. private _leftStickAxisY;
  5005. private _rightStickAxisX;
  5006. private _rightStickAxisY;
  5007. private _onleftstickchanged;
  5008. private _onrightstickchanged;
  5009. static GAMEPAD: number;
  5010. static GENERIC: number;
  5011. static XBOX: number;
  5012. static POSE_ENABLED: number;
  5013. protected _invertLeftStickY: boolean;
  5014. readonly isConnected: boolean;
  5015. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  5016. onleftstickchanged(callback: (values: StickValues) => void): void;
  5017. onrightstickchanged(callback: (values: StickValues) => void): void;
  5018. leftStick: StickValues;
  5019. rightStick: StickValues;
  5020. update(): void;
  5021. dispose(): void;
  5022. }
  5023. class GenericPad extends Gamepad {
  5024. private _buttons;
  5025. private _onbuttondown;
  5026. private _onbuttonup;
  5027. onButtonDownObservable: Observable<number>;
  5028. onButtonUpObservable: Observable<number>;
  5029. onbuttondown(callback: (buttonPressed: number) => void): void;
  5030. onbuttonup(callback: (buttonReleased: number) => void): void;
  5031. constructor(id: string, index: number, browserGamepad: any);
  5032. private _setButtonValue(newValue, currentValue, buttonIndex);
  5033. update(): void;
  5034. dispose(): void;
  5035. }
  5036. }
  5037. declare module BABYLON {
  5038. class GamepadManager {
  5039. private _scene;
  5040. private _babylonGamepads;
  5041. private _oneGamepadConnected;
  5042. _isMonitoring: boolean;
  5043. private _gamepadEventSupported;
  5044. private _gamepadSupport;
  5045. onGamepadConnectedObservable: Observable<Gamepad>;
  5046. onGamepadDisconnectedObservable: Observable<Gamepad>;
  5047. private _onGamepadConnectedEvent;
  5048. private _onGamepadDisconnectedEvent;
  5049. constructor(_scene?: Scene | undefined);
  5050. readonly gamepads: Gamepad[];
  5051. getGamepadByType(type?: number): Nullable<Gamepad>;
  5052. dispose(): void;
  5053. private _addNewGamepad(gamepad);
  5054. private _startMonitoringGamepads();
  5055. private _stopMonitoringGamepads();
  5056. _checkGamepadsStatus(): void;
  5057. private _updateGamepadObjects();
  5058. }
  5059. }
  5060. declare module BABYLON {
  5061. enum Xbox360Button {
  5062. A = 0,
  5063. B = 1,
  5064. X = 2,
  5065. Y = 3,
  5066. Start = 4,
  5067. Back = 5,
  5068. LB = 6,
  5069. RB = 7,
  5070. LeftStick = 8,
  5071. RightStick = 9,
  5072. }
  5073. enum Xbox360Dpad {
  5074. Up = 0,
  5075. Down = 1,
  5076. Left = 2,
  5077. Right = 3,
  5078. }
  5079. class Xbox360Pad extends Gamepad {
  5080. private _leftTrigger;
  5081. private _rightTrigger;
  5082. private _onlefttriggerchanged;
  5083. private _onrighttriggerchanged;
  5084. private _onbuttondown;
  5085. private _onbuttonup;
  5086. private _ondpaddown;
  5087. private _ondpadup;
  5088. onButtonDownObservable: Observable<Xbox360Button>;
  5089. onButtonUpObservable: Observable<Xbox360Button>;
  5090. onPadDownObservable: Observable<Xbox360Dpad>;
  5091. onPadUpObservable: Observable<Xbox360Dpad>;
  5092. private _buttonA;
  5093. private _buttonB;
  5094. private _buttonX;
  5095. private _buttonY;
  5096. private _buttonBack;
  5097. private _buttonStart;
  5098. private _buttonLB;
  5099. private _buttonRB;
  5100. private _buttonLeftStick;
  5101. private _buttonRightStick;
  5102. private _dPadUp;
  5103. private _dPadDown;
  5104. private _dPadLeft;
  5105. private _dPadRight;
  5106. private _isXboxOnePad;
  5107. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  5108. onlefttriggerchanged(callback: (value: number) => void): void;
  5109. onrighttriggerchanged(callback: (value: number) => void): void;
  5110. leftTrigger: number;
  5111. rightTrigger: number;
  5112. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  5113. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  5114. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  5115. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  5116. private _setButtonValue(newValue, currentValue, buttonType);
  5117. private _setDPadValue(newValue, currentValue, buttonType);
  5118. buttonA: number;
  5119. buttonB: number;
  5120. buttonX: number;
  5121. buttonY: number;
  5122. buttonStart: number;
  5123. buttonBack: number;
  5124. buttonLB: number;
  5125. buttonRB: number;
  5126. buttonLeftStick: number;
  5127. buttonRightStick: number;
  5128. dPadUp: number;
  5129. dPadDown: number;
  5130. dPadLeft: number;
  5131. dPadRight: number;
  5132. update(): void;
  5133. dispose(): void;
  5134. }
  5135. }
  5136. declare module BABYLON {
  5137. /**
  5138. * Represents the different options available during the creation of
  5139. * a Environment helper.
  5140. *
  5141. * This can control the default ground, skybox and image processing setup of your scene.
  5142. */
  5143. interface IEnvironmentHelperOptions {
  5144. /**
  5145. * Specifies wether or not to create a ground.
  5146. * True by default.
  5147. */
  5148. createGround: boolean;
  5149. /**
  5150. * Specifies the ground size.
  5151. * 15 by default.
  5152. */
  5153. groundSize: number;
  5154. /**
  5155. * The texture used on the ground for the main color.
  5156. * Comes from the BabylonJS CDN by default.
  5157. *
  5158. * Remarks: Can be either a texture or a url.
  5159. */
  5160. groundTexture: string | BaseTexture;
  5161. /**
  5162. * The color mixed in the ground texture by default.
  5163. * BabylonJS clearColor by default.
  5164. */
  5165. groundColor: Color3;
  5166. /**
  5167. * Specifies the ground opacity.
  5168. * 1 by default.
  5169. */
  5170. groundOpacity: number;
  5171. /**
  5172. * Enables the ground to receive shadows.
  5173. * True by default.
  5174. */
  5175. enableGroundShadow: boolean;
  5176. /**
  5177. * Helps preventing the shadow to be fully black on the ground.
  5178. * 0.5 by default.
  5179. */
  5180. groundShadowLevel: number;
  5181. /**
  5182. * Creates a mirror texture attach to the ground.
  5183. * false by default.
  5184. */
  5185. enableGroundMirror: boolean;
  5186. /**
  5187. * Specifies the ground mirror size ratio.
  5188. * 0.3 by default as the default kernel is 64.
  5189. */
  5190. groundMirrorSizeRatio: number;
  5191. /**
  5192. * Specifies the ground mirror blur kernel size.
  5193. * 64 by default.
  5194. */
  5195. groundMirrorBlurKernel: number;
  5196. /**
  5197. * Specifies the ground mirror visibility amount.
  5198. * 1 by default
  5199. */
  5200. groundMirrorAmount: number;
  5201. /**
  5202. * Specifies the ground mirror reflectance weight.
  5203. * This uses the standard weight of the background material to setup the fresnel effect
  5204. * of the mirror.
  5205. * 1 by default.
  5206. */
  5207. groundMirrorFresnelWeight: number;
  5208. /**
  5209. * Specifies the ground mirror Falloff distance.
  5210. * This can helps reducing the size of the reflection.
  5211. * 0 by Default.
  5212. */
  5213. groundMirrorFallOffDistance: number;
  5214. /**
  5215. * Specifies the ground mirror texture type.
  5216. * Unsigned Int by Default.
  5217. */
  5218. groundMirrorTextureType: number;
  5219. /**
  5220. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  5221. * the shown objects.
  5222. */
  5223. groundYBias: number;
  5224. /**
  5225. * Specifies wether or not to create a skybox.
  5226. * True by default.
  5227. */
  5228. createSkybox: boolean;
  5229. /**
  5230. * Specifies the skybox size.
  5231. * 20 by default.
  5232. */
  5233. skyboxSize: number;
  5234. /**
  5235. * The texture used on the skybox for the main color.
  5236. * Comes from the BabylonJS CDN by default.
  5237. *
  5238. * Remarks: Can be either a texture or a url.
  5239. */
  5240. skyboxTexture: string | BaseTexture;
  5241. /**
  5242. * The color mixed in the skybox texture by default.
  5243. * BabylonJS clearColor by default.
  5244. */
  5245. skyboxColor: Color3;
  5246. /**
  5247. * The background rotation around the Y axis of the scene.
  5248. * This helps aligning the key lights of your scene with the background.
  5249. * 0 by default.
  5250. */
  5251. backgroundYRotation: number;
  5252. /**
  5253. * Compute automatically the size of the elements to best fit with the scene.
  5254. */
  5255. sizeAuto: boolean;
  5256. /**
  5257. * Default position of the rootMesh if autoSize is not true.
  5258. */
  5259. rootPosition: Vector3;
  5260. /**
  5261. * Sets up the image processing in the scene.
  5262. * true by default.
  5263. */
  5264. setupImageProcessing: boolean;
  5265. /**
  5266. * The texture used as your environment texture in the scene.
  5267. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  5268. *
  5269. * Remarks: Can be either a texture or a url.
  5270. */
  5271. environmentTexture: string | BaseTexture;
  5272. /**
  5273. * The value of the exposure to apply to the scene.
  5274. * 0.6 by default if setupImageProcessing is true.
  5275. */
  5276. cameraExposure: number;
  5277. /**
  5278. * The value of the contrast to apply to the scene.
  5279. * 1.6 by default if setupImageProcessing is true.
  5280. */
  5281. cameraContrast: number;
  5282. /**
  5283. * Specifies wether or not tonemapping should be enabled in the scene.
  5284. * true by default if setupImageProcessing is true.
  5285. */
  5286. toneMappingEnabled: boolean;
  5287. }
  5288. /**
  5289. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  5290. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  5291. * It also helps with the default setup of your imageProcessing configuration.
  5292. */
  5293. class EnvironmentHelper {
  5294. /**
  5295. * Default ground texture URL.
  5296. */
  5297. private static _groundTextureCDNUrl;
  5298. /**
  5299. * Default skybox texture URL.
  5300. */
  5301. private static _skyboxTextureCDNUrl;
  5302. /**
  5303. * Default environment texture URL.
  5304. */
  5305. private static _environmentTextureCDNUrl;
  5306. /**
  5307. * Creates the default options for the helper.
  5308. */
  5309. private static _getDefaultOptions();
  5310. private _rootMesh;
  5311. /**
  5312. * Gets the root mesh created by the helper.
  5313. */
  5314. readonly rootMesh: Mesh;
  5315. private _skybox;
  5316. /**
  5317. * Gets the skybox created by the helper.
  5318. */
  5319. readonly skybox: Nullable<Mesh>;
  5320. private _skyboxTexture;
  5321. /**
  5322. * Gets the skybox texture created by the helper.
  5323. */
  5324. readonly skyboxTexture: Nullable<BaseTexture>;
  5325. private _skyboxMaterial;
  5326. /**
  5327. * Gets the skybox material created by the helper.
  5328. */
  5329. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  5330. private _ground;
  5331. /**
  5332. * Gets the ground mesh created by the helper.
  5333. */
  5334. readonly ground: Nullable<Mesh>;
  5335. private _groundTexture;
  5336. /**
  5337. * Gets the ground texture created by the helper.
  5338. */
  5339. readonly groundTexture: Nullable<BaseTexture>;
  5340. private _groundMirror;
  5341. /**
  5342. * Gets the ground mirror created by the helper.
  5343. */
  5344. readonly groundMirror: Nullable<MirrorTexture>;
  5345. /**
  5346. * Gets the ground mirror render list to helps pushing the meshes
  5347. * you wish in the ground reflection.
  5348. */
  5349. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  5350. private _groundMaterial;
  5351. /**
  5352. * Gets the ground material created by the helper.
  5353. */
  5354. readonly groundMaterial: Nullable<BackgroundMaterial>;
  5355. /**
  5356. * Stores the creation options.
  5357. */
  5358. private readonly _scene;
  5359. private _options;
  5360. /**
  5361. * constructor
  5362. * @param options
  5363. * @param scene The scene to add the material to
  5364. */
  5365. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  5366. /**
  5367. * Updates the background according to the new options
  5368. * @param options
  5369. */
  5370. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  5371. /**
  5372. * Sets the primary color of all the available elements.
  5373. * @param color
  5374. */
  5375. setMainColor(color: Color3): void;
  5376. /**
  5377. * Setup the image processing according to the specified options.
  5378. */
  5379. private _setupImageProcessing();
  5380. /**
  5381. * Setup the environment texture according to the specified options.
  5382. */
  5383. private _setupEnvironmentTexture();
  5384. /**
  5385. * Setup the background according to the specified options.
  5386. */
  5387. private _setupBackground();
  5388. /**
  5389. * Get the scene sizes according to the setup.
  5390. */
  5391. private _getSceneSize();
  5392. /**
  5393. * Setup the ground according to the specified options.
  5394. */
  5395. private _setupGround(sceneSize);
  5396. /**
  5397. * Setup the ground material according to the specified options.
  5398. */
  5399. private _setupGroundMaterial();
  5400. /**
  5401. * Setup the ground diffuse texture according to the specified options.
  5402. */
  5403. private _setupGroundDiffuseTexture();
  5404. /**
  5405. * Setup the ground mirror texture according to the specified options.
  5406. */
  5407. private _setupGroundMirrorTexture(sceneSize);
  5408. /**
  5409. * Setup the ground to receive the mirror texture.
  5410. */
  5411. private _setupMirrorInGroundMaterial();
  5412. /**
  5413. * Setup the skybox according to the specified options.
  5414. */
  5415. private _setupSkybox(sceneSize);
  5416. /**
  5417. * Setup the skybox material according to the specified options.
  5418. */
  5419. private _setupSkyboxMaterial();
  5420. /**
  5421. * Setup the skybox reflection texture according to the specified options.
  5422. */
  5423. private _setupSkyboxReflectionTexture();
  5424. /**
  5425. * Dispose all the elements created by the Helper.
  5426. */
  5427. dispose(): void;
  5428. }
  5429. }
  5430. declare module BABYLON {
  5431. /**
  5432. * This class can be used to get instrumentation data from a Babylon engine
  5433. */
  5434. class EngineInstrumentation implements IDisposable {
  5435. engine: Engine;
  5436. private _captureGPUFrameTime;
  5437. private _gpuFrameTimeToken;
  5438. private _gpuFrameTime;
  5439. private _captureShaderCompilationTime;
  5440. private _shaderCompilationTime;
  5441. private _onBeginFrameObserver;
  5442. private _onEndFrameObserver;
  5443. private _onBeforeShaderCompilationObserver;
  5444. private _onAfterShaderCompilationObserver;
  5445. /**
  5446. * Gets the perf counter used for GPU frame time
  5447. */
  5448. readonly gpuFrameTimeCounter: PerfCounter;
  5449. /**
  5450. * Gets the GPU frame time capture status
  5451. */
  5452. /**
  5453. * Enable or disable the GPU frame time capture
  5454. */
  5455. captureGPUFrameTime: boolean;
  5456. /**
  5457. * Gets the perf counter used for shader compilation time
  5458. */
  5459. readonly shaderCompilationTimeCounter: PerfCounter;
  5460. /**
  5461. * Gets the shader compilation time capture status
  5462. */
  5463. /**
  5464. * Enable or disable the shader compilation time capture
  5465. */
  5466. captureShaderCompilationTime: boolean;
  5467. constructor(engine: Engine);
  5468. dispose(): void;
  5469. }
  5470. }
  5471. declare module BABYLON {
  5472. /**
  5473. * This class can be used to get instrumentation data from a Babylon engine
  5474. */
  5475. class SceneInstrumentation implements IDisposable {
  5476. scene: Scene;
  5477. private _captureActiveMeshesEvaluationTime;
  5478. private _activeMeshesEvaluationTime;
  5479. private _captureRenderTargetsRenderTime;
  5480. private _renderTargetsRenderTime;
  5481. private _captureFrameTime;
  5482. private _frameTime;
  5483. private _captureRenderTime;
  5484. private _renderTime;
  5485. private _captureInterFrameTime;
  5486. private _interFrameTime;
  5487. private _captureParticlesRenderTime;
  5488. private _particlesRenderTime;
  5489. private _captureSpritesRenderTime;
  5490. private _spritesRenderTime;
  5491. private _capturePhysicsTime;
  5492. private _physicsTime;
  5493. private _captureAnimationsTime;
  5494. private _animationsTime;
  5495. private _onBeforeActiveMeshesEvaluationObserver;
  5496. private _onAfterActiveMeshesEvaluationObserver;
  5497. private _onBeforeRenderTargetsRenderObserver;
  5498. private _onAfterRenderTargetsRenderObserver;
  5499. private _onAfterRenderObserver;
  5500. private _onBeforeDrawPhaseObserver;
  5501. private _onAfterDrawPhaseObserver;
  5502. private _onBeforeAnimationsObserver;
  5503. private _onBeforeParticlesRenderingObserver;
  5504. private _onAfterParticlesRenderingObserver;
  5505. private _onBeforeSpritesRenderingObserver;
  5506. private _onAfterSpritesRenderingObserver;
  5507. private _onBeforePhysicsObserver;
  5508. private _onAfterPhysicsObserver;
  5509. private _onAfterAnimationsObserver;
  5510. /**
  5511. * Gets the perf counter used for active meshes evaluation time
  5512. */
  5513. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  5514. /**
  5515. * Gets the active meshes evaluation time capture status
  5516. */
  5517. /**
  5518. * Enable or disable the active meshes evaluation time capture
  5519. */
  5520. captureActiveMeshesEvaluationTime: boolean;
  5521. /**
  5522. * Gets the perf counter used for render targets render time
  5523. */
  5524. readonly renderTargetsRenderTimeCounter: PerfCounter;
  5525. /**
  5526. * Gets the render targets render time capture status
  5527. */
  5528. /**
  5529. * Enable or disable the render targets render time capture
  5530. */
  5531. captureRenderTargetsRenderTime: boolean;
  5532. /**
  5533. * Gets the perf counter used for particles render time
  5534. */
  5535. readonly particlesRenderTimeCounter: PerfCounter;
  5536. /**
  5537. * Gets the particles render time capture status
  5538. */
  5539. /**
  5540. * Enable or disable the particles render time capture
  5541. */
  5542. captureParticlesRenderTime: boolean;
  5543. /**
  5544. * Gets the perf counter used for sprites render time
  5545. */
  5546. readonly spritesRenderTimeCounter: PerfCounter;
  5547. /**
  5548. * Gets the sprites render time capture status
  5549. */
  5550. /**
  5551. * Enable or disable the sprites render time capture
  5552. */
  5553. captureSpritesRenderTime: boolean;
  5554. /**
  5555. * Gets the perf counter used for physics time
  5556. */
  5557. readonly physicsTimeCounter: PerfCounter;
  5558. /**
  5559. * Gets the physics time capture status
  5560. */
  5561. /**
  5562. * Enable or disable the physics time capture
  5563. */
  5564. capturePhysicsTime: boolean;
  5565. /**
  5566. * Gets the perf counter used for animations time
  5567. */
  5568. readonly animationsTimeCounter: PerfCounter;
  5569. /**
  5570. * Gets the animations time capture status
  5571. */
  5572. /**
  5573. * Enable or disable the animations time capture
  5574. */
  5575. captureAnimationsTime: boolean;
  5576. /**
  5577. * Gets the perf counter used for frame time capture
  5578. */
  5579. readonly frameTimeCounter: PerfCounter;
  5580. /**
  5581. * Gets the frame time capture status
  5582. */
  5583. /**
  5584. * Enable or disable the frame time capture
  5585. */
  5586. captureFrameTime: boolean;
  5587. /**
  5588. * Gets the perf counter used for inter-frames time capture
  5589. */
  5590. readonly interFrameTimeCounter: PerfCounter;
  5591. /**
  5592. * Gets the inter-frames time capture status
  5593. */
  5594. /**
  5595. * Enable or disable the inter-frames time capture
  5596. */
  5597. captureInterFrameTime: boolean;
  5598. /**
  5599. * Gets the perf counter used for render time capture
  5600. */
  5601. readonly renderTimeCounter: PerfCounter;
  5602. /**
  5603. * Gets the render time capture status
  5604. */
  5605. /**
  5606. * Enable or disable the render time capture
  5607. */
  5608. captureRenderTime: boolean;
  5609. /**
  5610. * Gets the perf counter used for draw calls
  5611. */
  5612. readonly drawCallsCounter: PerfCounter;
  5613. /**
  5614. * Gets the perf counter used for texture collisions
  5615. */
  5616. readonly textureCollisionsCounter: PerfCounter;
  5617. constructor(scene: Scene);
  5618. dispose(): void;
  5619. }
  5620. }
  5621. declare module BABYLON {
  5622. class _TimeToken {
  5623. _startTimeQuery: Nullable<WebGLQuery>;
  5624. _endTimeQuery: Nullable<WebGLQuery>;
  5625. _timeElapsedQuery: Nullable<WebGLQuery>;
  5626. _timeElapsedQueryEnded: boolean;
  5627. }
  5628. }
  5629. declare module BABYLON {
  5630. class LensFlare {
  5631. size: number;
  5632. position: number;
  5633. color: Color3;
  5634. texture: Nullable<Texture>;
  5635. alphaMode: number;
  5636. private _system;
  5637. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  5638. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  5639. dispose(): void;
  5640. }
  5641. }
  5642. declare module BABYLON {
  5643. class LensFlareSystem {
  5644. name: string;
  5645. lensFlares: LensFlare[];
  5646. borderLimit: number;
  5647. viewportBorder: number;
  5648. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  5649. layerMask: number;
  5650. id: string;
  5651. private _scene;
  5652. private _emitter;
  5653. private _vertexBuffers;
  5654. private _indexBuffer;
  5655. private _effect;
  5656. private _positionX;
  5657. private _positionY;
  5658. private _isEnabled;
  5659. constructor(name: string, emitter: any, scene: Scene);
  5660. isEnabled: boolean;
  5661. getScene(): Scene;
  5662. getEmitter(): any;
  5663. setEmitter(newEmitter: any): void;
  5664. getEmitterPosition(): Vector3;
  5665. computeEffectivePosition(globalViewport: Viewport): boolean;
  5666. _isVisible(): boolean;
  5667. render(): boolean;
  5668. dispose(): void;
  5669. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  5670. serialize(): any;
  5671. }
  5672. }
  5673. declare module BABYLON {
  5674. /**
  5675. * Highlight layer options. This helps customizing the behaviour
  5676. * of the highlight layer.
  5677. */
  5678. interface IHighlightLayerOptions {
  5679. /**
  5680. * Multiplication factor apply to the canvas size to compute the render target size
  5681. * used to generated the glowing objects (the smaller the faster).
  5682. */
  5683. mainTextureRatio: number;
  5684. /**
  5685. * Enforces a fixed size texture to ensure resize independant blur.
  5686. */
  5687. mainTextureFixedSize?: number;
  5688. /**
  5689. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  5690. * of the picture to blur (the smaller the faster).
  5691. */
  5692. blurTextureSizeRatio: number;
  5693. /**
  5694. * How big in texel of the blur texture is the vertical blur.
  5695. */
  5696. blurVerticalSize: number;
  5697. /**
  5698. * How big in texel of the blur texture is the horizontal blur.
  5699. */
  5700. blurHorizontalSize: number;
  5701. /**
  5702. * Alpha blending mode used to apply the blur. Default is combine.
  5703. */
  5704. alphaBlendingMode: number;
  5705. /**
  5706. * The camera attached to the layer.
  5707. */
  5708. camera: Nullable<Camera>;
  5709. /**
  5710. * Should we display highlight as a solid stroke?
  5711. */
  5712. isStroke?: boolean;
  5713. }
  5714. /**
  5715. * The highlight layer Helps adding a glow effect around a mesh.
  5716. *
  5717. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  5718. * glowy meshes to your scene.
  5719. *
  5720. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  5721. */
  5722. class HighlightLayer {
  5723. name: string;
  5724. /**
  5725. * The neutral color used during the preparation of the glow effect.
  5726. * This is black by default as the blend operation is a blend operation.
  5727. */
  5728. static neutralColor: Color4;
  5729. /**
  5730. * Stencil value used for glowing meshes.
  5731. */
  5732. static glowingMeshStencilReference: number;
  5733. /**
  5734. * Stencil value used for the other meshes in the scene.
  5735. */
  5736. static normalMeshStencilReference: number;
  5737. private _scene;
  5738. private _engine;
  5739. private _options;
  5740. private _vertexBuffers;
  5741. private _indexBuffer;
  5742. private _downSamplePostprocess;
  5743. private _horizontalBlurPostprocess;
  5744. private _verticalBlurPostprocess;
  5745. private _cachedDefines;
  5746. private _glowMapGenerationEffect;
  5747. private _glowMapMergeEffect;
  5748. private _blurTexture;
  5749. private _mainTexture;
  5750. private _mainTextureDesiredSize;
  5751. private _meshes;
  5752. private _maxSize;
  5753. private _shouldRender;
  5754. private _instanceGlowingMeshStencilReference;
  5755. private _excludedMeshes;
  5756. /**
  5757. * Specifies whether or not the inner glow is ACTIVE in the layer.
  5758. */
  5759. innerGlow: boolean;
  5760. /**
  5761. * Specifies whether or not the outer glow is ACTIVE in the layer.
  5762. */
  5763. outerGlow: boolean;
  5764. /**
  5765. * Specifies wether the highlight layer is enabled or not.
  5766. */
  5767. isEnabled: boolean;
  5768. /**
  5769. * Gets the horizontal size of the blur.
  5770. */
  5771. /**
  5772. * Specifies the horizontal size of the blur.
  5773. */
  5774. blurHorizontalSize: number;
  5775. /**
  5776. * Gets the vertical size of the blur.
  5777. */
  5778. /**
  5779. * Specifies the vertical size of the blur.
  5780. */
  5781. blurVerticalSize: number;
  5782. /**
  5783. * Gets the camera attached to the layer.
  5784. */
  5785. readonly camera: Nullable<Camera>;
  5786. /**
  5787. * An event triggered when the highlight layer has been disposed.
  5788. * @type {BABYLON.Observable}
  5789. */
  5790. onDisposeObservable: Observable<HighlightLayer>;
  5791. /**
  5792. * An event triggered when the highlight layer is about rendering the main texture with the glowy parts.
  5793. * @type {BABYLON.Observable}
  5794. */
  5795. onBeforeRenderMainTextureObservable: Observable<HighlightLayer>;
  5796. /**
  5797. * An event triggered when the highlight layer is being blurred.
  5798. * @type {BABYLON.Observable}
  5799. */
  5800. onBeforeBlurObservable: Observable<HighlightLayer>;
  5801. /**
  5802. * An event triggered when the highlight layer has been blurred.
  5803. * @type {BABYLON.Observable}
  5804. */
  5805. onAfterBlurObservable: Observable<HighlightLayer>;
  5806. /**
  5807. * An event triggered when the glowing blurred texture is being merged in the scene.
  5808. * @type {BABYLON.Observable}
  5809. */
  5810. onBeforeComposeObservable: Observable<HighlightLayer>;
  5811. /**
  5812. * An event triggered when the glowing blurred texture has been merged in the scene.
  5813. * @type {BABYLON.Observable}
  5814. */
  5815. onAfterComposeObservable: Observable<HighlightLayer>;
  5816. /**
  5817. * An event triggered when the highlight layer changes its size.
  5818. * @type {BABYLON.Observable}
  5819. */
  5820. onSizeChangedObservable: Observable<HighlightLayer>;
  5821. /**
  5822. * Instantiates a new highlight Layer and references it to the scene..
  5823. * @param name The name of the layer
  5824. * @param scene The scene to use the layer in
  5825. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  5826. */
  5827. constructor(name: string, scene: Scene, options?: IHighlightLayerOptions);
  5828. private _createIndexBuffer();
  5829. _rebuild(): void;
  5830. /**
  5831. * Creates the render target textures and post processes used in the highlight layer.
  5832. */
  5833. private createTextureAndPostProcesses();
  5834. /**
  5835. * Checks for the readiness of the element composing the layer.
  5836. * @param subMesh the mesh to check for
  5837. * @param useInstances specify wether or not to use instances to render the mesh
  5838. * @param emissiveTexture the associated emissive texture used to generate the glow
  5839. * @return true if ready otherwise, false
  5840. */
  5841. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  5842. /**
  5843. * Checks for the readiness of the element composing the layer.
  5844. * @param subMesh the mesh to check for
  5845. * @param useInstances specify wether or not to use instances to render the mesh
  5846. * @param emissiveTexture the associated emissive texture used to generate the glow
  5847. * @return true if ready otherwise, false
  5848. */
  5849. private _isReady(subMesh, useInstances, emissiveTexture);
  5850. /**
  5851. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  5852. */
  5853. render(): void;
  5854. /**
  5855. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  5856. * @param mesh The mesh to exclude from the highlight layer
  5857. */
  5858. addExcludedMesh(mesh: Mesh): void;
  5859. /**
  5860. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  5861. * @param mesh The mesh to highlight
  5862. */
  5863. removeExcludedMesh(mesh: Mesh): void;
  5864. /**
  5865. * Determine if a given mesh will be highlighted by the current HighlightLayer
  5866. * @param mesh mesh to test
  5867. * @returns true if the mesh will be highlighted by the current HighlightLayer
  5868. */
  5869. hasMesh(mesh: AbstractMesh): boolean;
  5870. /**
  5871. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  5872. * @param mesh The mesh to highlight
  5873. * @param color The color of the highlight
  5874. * @param glowEmissiveOnly Extract the glow from the emissive texture
  5875. */
  5876. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  5877. /**
  5878. * Remove a mesh from the highlight layer in order to make it stop glowing.
  5879. * @param mesh The mesh to highlight
  5880. */
  5881. removeMesh(mesh: Mesh): void;
  5882. /**
  5883. * Returns true if the layer contains information to display, otherwise false.
  5884. */
  5885. shouldRender(): boolean;
  5886. /**
  5887. * Sets the main texture desired size which is the closest power of two
  5888. * of the engine canvas size.
  5889. */
  5890. private setMainTextureSize();
  5891. /**
  5892. * Force the stencil to the normal expected value for none glowing parts
  5893. */
  5894. private defaultStencilReference(mesh);
  5895. /**
  5896. * Dispose only the render target textures and post process.
  5897. */
  5898. private disposeTextureAndPostProcesses();
  5899. /**
  5900. * Dispose the highlight layer and free resources.
  5901. */
  5902. dispose(): void;
  5903. }
  5904. }
  5905. declare module BABYLON {
  5906. class Layer {
  5907. name: string;
  5908. texture: Nullable<Texture>;
  5909. isBackground: boolean;
  5910. color: Color4;
  5911. scale: Vector2;
  5912. offset: Vector2;
  5913. alphaBlendingMode: number;
  5914. alphaTest: boolean;
  5915. layerMask: number;
  5916. private _scene;
  5917. private _vertexBuffers;
  5918. private _indexBuffer;
  5919. private _effect;
  5920. private _alphaTestEffect;
  5921. /**
  5922. * An event triggered when the layer is disposed.
  5923. * @type {BABYLON.Observable}
  5924. */
  5925. onDisposeObservable: Observable<Layer>;
  5926. private _onDisposeObserver;
  5927. onDispose: () => void;
  5928. /**
  5929. * An event triggered before rendering the scene
  5930. * @type {BABYLON.Observable}
  5931. */
  5932. onBeforeRenderObservable: Observable<Layer>;
  5933. private _onBeforeRenderObserver;
  5934. onBeforeRender: () => void;
  5935. /**
  5936. * An event triggered after rendering the scene
  5937. * @type {BABYLON.Observable}
  5938. */
  5939. onAfterRenderObservable: Observable<Layer>;
  5940. private _onAfterRenderObserver;
  5941. onAfterRender: () => void;
  5942. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  5943. private _createIndexBuffer();
  5944. _rebuild(): void;
  5945. render(): void;
  5946. dispose(): void;
  5947. }
  5948. }
  5949. declare module BABYLON {
  5950. /**
  5951. * A directional light is defined by a direction (what a surprise!).
  5952. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  5953. * 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.
  5954. * Documentation: https://doc.babylonjs.com/babylon101/lights
  5955. */
  5956. class DirectionalLight extends ShadowLight {
  5957. private _shadowFrustumSize;
  5958. /**
  5959. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  5960. */
  5961. /**
  5962. * Specifies a fix frustum size for the shadow generation.
  5963. */
  5964. shadowFrustumSize: number;
  5965. private _shadowOrthoScale;
  5966. /**
  5967. * Gets the shadow projection scale against the optimal computed one.
  5968. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  5969. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  5970. */
  5971. /**
  5972. * Sets the shadow projection scale against the optimal computed one.
  5973. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  5974. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  5975. */
  5976. shadowOrthoScale: number;
  5977. /**
  5978. * Automatically compute the projection matrix to best fit (including all the casters)
  5979. * on each frame.
  5980. */
  5981. autoUpdateExtends: boolean;
  5982. private _orthoLeft;
  5983. private _orthoRight;
  5984. private _orthoTop;
  5985. private _orthoBottom;
  5986. /**
  5987. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  5988. * The directional light is emitted from everywhere in the given direction.
  5989. * It can cast shawdows.
  5990. * Documentation : http://doc.babylonjs.com/tutorials/lights
  5991. * @param name The friendly name of the light
  5992. * @param direction The direction of the light
  5993. * @param scene The scene the light belongs to
  5994. */
  5995. constructor(name: string, direction: Vector3, scene: Scene);
  5996. /**
  5997. * Returns the string "DirectionalLight".
  5998. * @return The class name
  5999. */
  6000. getClassName(): string;
  6001. /**
  6002. * Returns the integer 1.
  6003. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  6004. */
  6005. getTypeID(): number;
  6006. /**
  6007. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  6008. * Returns the DirectionalLight Shadow projection matrix.
  6009. */
  6010. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  6011. /**
  6012. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  6013. * Returns the DirectionalLight Shadow projection matrix.
  6014. */
  6015. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  6016. /**
  6017. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  6018. * Returns the DirectionalLight Shadow projection matrix.
  6019. */
  6020. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  6021. protected _buildUniformLayout(): void;
  6022. /**
  6023. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  6024. * @param effect The effect to update
  6025. * @param lightIndex The index of the light in the effect to update
  6026. * @returns The directional light
  6027. */
  6028. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  6029. /**
  6030. * Gets the minZ used for shadow according to both the scene and the light.
  6031. *
  6032. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  6033. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  6034. * @param activeCamera The camera we are returning the min for
  6035. * @returns the depth min z
  6036. */
  6037. getDepthMinZ(activeCamera: Camera): number;
  6038. /**
  6039. * Gets the maxZ used for shadow according to both the scene and the light.
  6040. *
  6041. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  6042. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  6043. * @param activeCamera The camera we are returning the max for
  6044. * @returns the depth max z
  6045. */
  6046. getDepthMaxZ(activeCamera: Camera): number;
  6047. }
  6048. }
  6049. declare module BABYLON {
  6050. /**
  6051. * The HemisphericLight simulates the ambient environment light,
  6052. * so the passed direction is the light reflection direction, not the incoming direction.
  6053. */
  6054. class HemisphericLight extends Light {
  6055. /**
  6056. * The groundColor is the light in the opposite direction to the one specified during creation.
  6057. * 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.
  6058. */
  6059. groundColor: Color3;
  6060. /**
  6061. * The light reflection direction, not the incoming direction.
  6062. */
  6063. direction: Vector3;
  6064. private _worldMatrix;
  6065. /**
  6066. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  6067. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  6068. * The HemisphericLight can't cast shadows.
  6069. * Documentation : http://doc.babylonjs.com/tutorials/lights
  6070. * @param name The friendly name of the light
  6071. * @param direction The direction of the light reflection
  6072. * @param scene The scene the light belongs to
  6073. */
  6074. constructor(name: string, direction: Vector3, scene: Scene);
  6075. protected _buildUniformLayout(): void;
  6076. /**
  6077. * Returns the string "HemisphericLight".
  6078. * @return The class name
  6079. */
  6080. getClassName(): string;
  6081. /**
  6082. * Sets the HemisphericLight direction towards the passed target (Vector3).
  6083. * Returns the updated direction.
  6084. * @param target The target the direction should point to
  6085. * @return The computed direction
  6086. */
  6087. setDirectionToTarget(target: Vector3): Vector3;
  6088. /**
  6089. * Returns the shadow generator associated to the light.
  6090. * @returns Always null for hemispheric lights because it does not support shadows.
  6091. */
  6092. getShadowGenerator(): Nullable<ShadowGenerator>;
  6093. /**
  6094. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  6095. * @param effect The effect to update
  6096. * @param lightIndex The index of the light in the effect to update
  6097. * @returns The hemispheric light
  6098. */
  6099. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  6100. /**
  6101. * @ignore internal use only.
  6102. */
  6103. _getWorldMatrix(): Matrix;
  6104. /**
  6105. * Returns the integer 3.
  6106. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  6107. */
  6108. getTypeID(): number;
  6109. }
  6110. }
  6111. declare module BABYLON {
  6112. /**
  6113. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  6114. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  6115. * 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.
  6116. */
  6117. abstract class Light extends Node {
  6118. private static _LIGHTMAP_DEFAULT;
  6119. private static _LIGHTMAP_SPECULAR;
  6120. private static _LIGHTMAP_SHADOWSONLY;
  6121. /**
  6122. * If every light affecting the material is in this lightmapMode,
  6123. * material.lightmapTexture adds or multiplies
  6124. * (depends on material.useLightmapAsShadowmap)
  6125. * after every other light calculations.
  6126. */
  6127. static readonly LIGHTMAP_DEFAULT: number;
  6128. /**
  6129. * material.lightmapTexture as only diffuse lighting from this light
  6130. * adds only specular lighting from this light
  6131. * adds dynamic shadows
  6132. */
  6133. static readonly LIGHTMAP_SPECULAR: number;
  6134. /**
  6135. * material.lightmapTexture as only lighting
  6136. * no light calculation from this light
  6137. * only adds dynamic shadows from this light
  6138. */
  6139. static readonly LIGHTMAP_SHADOWSONLY: number;
  6140. private static _INTENSITYMODE_AUTOMATIC;
  6141. private static _INTENSITYMODE_LUMINOUSPOWER;
  6142. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  6143. private static _INTENSITYMODE_ILLUMINANCE;
  6144. private static _INTENSITYMODE_LUMINANCE;
  6145. /**
  6146. * Each light type uses the default quantity according to its type:
  6147. * point/spot lights use luminous intensity
  6148. * directional lights use illuminance
  6149. */
  6150. static readonly INTENSITYMODE_AUTOMATIC: number;
  6151. /**
  6152. * lumen (lm)
  6153. */
  6154. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  6155. /**
  6156. * candela (lm/sr)
  6157. */
  6158. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  6159. /**
  6160. * lux (lm/m^2)
  6161. */
  6162. static readonly INTENSITYMODE_ILLUMINANCE: number;
  6163. /**
  6164. * nit (cd/m^2)
  6165. */
  6166. static readonly INTENSITYMODE_LUMINANCE: number;
  6167. private static _LIGHTTYPEID_POINTLIGHT;
  6168. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  6169. private static _LIGHTTYPEID_SPOTLIGHT;
  6170. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  6171. /**
  6172. * Light type const id of the point light.
  6173. */
  6174. static readonly LIGHTTYPEID_POINTLIGHT: number;
  6175. /**
  6176. * Light type const id of the directional light.
  6177. */
  6178. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  6179. /**
  6180. * Light type const id of the spot light.
  6181. */
  6182. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  6183. /**
  6184. * Light type const id of the hemispheric light.
  6185. */
  6186. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  6187. /**
  6188. * Diffuse gives the basic color to an object.
  6189. */
  6190. diffuse: Color3;
  6191. /**
  6192. * Specular produces a highlight color on an object.
  6193. * Note: This is note affecting PBR materials.
  6194. */
  6195. specular: Color3;
  6196. /**
  6197. * Strength of the light.
  6198. * Note: By default it is define in the framework own unit.
  6199. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  6200. */
  6201. intensity: number;
  6202. /**
  6203. * Defines how far from the source the light is impacting in scene units.
  6204. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  6205. */
  6206. range: number;
  6207. /**
  6208. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  6209. * of light.
  6210. */
  6211. private _photometricScale;
  6212. private _intensityMode;
  6213. /**
  6214. * Gets the photometric scale used to interpret the intensity.
  6215. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  6216. */
  6217. /**
  6218. * Sets the photometric scale used to interpret the intensity.
  6219. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  6220. */
  6221. intensityMode: number;
  6222. private _radius;
  6223. /**
  6224. * Gets the light radius used by PBR Materials to simulate soft area lights.
  6225. */
  6226. /**
  6227. * sets the light radius used by PBR Materials to simulate soft area lights.
  6228. */
  6229. radius: number;
  6230. private _renderPriority;
  6231. /**
  6232. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  6233. * exceeding the number allowed of the materials.
  6234. */
  6235. renderPriority: number;
  6236. /**
  6237. * Defines wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  6238. * the current shadow generator.
  6239. */
  6240. shadowEnabled: boolean;
  6241. private _includedOnlyMeshes;
  6242. /**
  6243. * Gets the only meshes impacted by this light.
  6244. */
  6245. /**
  6246. * Sets the only meshes impacted by this light.
  6247. */
  6248. includedOnlyMeshes: AbstractMesh[];
  6249. private _excludedMeshes;
  6250. /**
  6251. * Gets the meshes not impacted by this light.
  6252. */
  6253. /**
  6254. * Sets the meshes not impacted by this light.
  6255. */
  6256. excludedMeshes: AbstractMesh[];
  6257. private _excludeWithLayerMask;
  6258. /**
  6259. * Gets the layer id use to find what meshes are not impacted by the light.
  6260. * Inactive if 0
  6261. */
  6262. /**
  6263. * Sets the layer id use to find what meshes are not impacted by the light.
  6264. * Inactive if 0
  6265. */
  6266. excludeWithLayerMask: number;
  6267. private _includeOnlyWithLayerMask;
  6268. /**
  6269. * Gets the layer id use to find what meshes are impacted by the light.
  6270. * Inactive if 0
  6271. */
  6272. /**
  6273. * Sets the layer id use to find what meshes are impacted by the light.
  6274. * Inactive if 0
  6275. */
  6276. includeOnlyWithLayerMask: number;
  6277. private _lightmapMode;
  6278. /**
  6279. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  6280. */
  6281. /**
  6282. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  6283. */
  6284. lightmapMode: number;
  6285. private _parentedWorldMatrix;
  6286. /**
  6287. * Shadow generator associted to the light.
  6288. * Internal use only.
  6289. */
  6290. _shadowGenerator: Nullable<IShadowGenerator>;
  6291. /**
  6292. * @ignore Internal use only.
  6293. */
  6294. _excludedMeshesIds: string[];
  6295. /**
  6296. * @ignore Internal use only.
  6297. */
  6298. _includedOnlyMeshesIds: string[];
  6299. /**
  6300. * The current light unifom buffer.
  6301. * @ignore Internal use only.
  6302. */
  6303. _uniformBuffer: UniformBuffer;
  6304. /**
  6305. * Creates a Light object in the scene.
  6306. * Documentation : http://doc.babylonjs.com/tutorials/lights
  6307. * @param name The firendly name of the light
  6308. * @param scene The scene the light belongs too
  6309. */
  6310. constructor(name: string, scene: Scene);
  6311. protected abstract _buildUniformLayout(): void;
  6312. /**
  6313. * Sets the passed Effect "effect" with the Light information.
  6314. * @param effect The effect to update
  6315. * @param lightIndex The index of the light in the effect to update
  6316. * @returns The light
  6317. */
  6318. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  6319. /**
  6320. * @ignore internal use only.
  6321. */
  6322. abstract _getWorldMatrix(): Matrix;
  6323. /**
  6324. * Returns the string "Light".
  6325. * @returns the class name
  6326. */
  6327. getClassName(): string;
  6328. /**
  6329. * Converts the light information to a readable string for debug purpose.
  6330. * @param fullDetails Supports for multiple levels of logging within scene loading
  6331. * @returns the human readable light info
  6332. */
  6333. toString(fullDetails?: boolean): string;
  6334. /**
  6335. * Set the enabled state of this node.
  6336. * @param value - the new enabled state
  6337. * @see isEnabled
  6338. */
  6339. setEnabled(value: boolean): void;
  6340. /**
  6341. * Returns the Light associated shadow generator if any.
  6342. * @return the associated shadow generator.
  6343. */
  6344. getShadowGenerator(): Nullable<IShadowGenerator>;
  6345. /**
  6346. * Returns a Vector3, the absolute light position in the World.
  6347. * @returns the world space position of the light
  6348. */
  6349. getAbsolutePosition(): Vector3;
  6350. /**
  6351. * Specifies if the light will affect the passed mesh.
  6352. * @param mesh The mesh to test against the light
  6353. * @return true the mesh is affected otherwise, false.
  6354. */
  6355. canAffectMesh(mesh: AbstractMesh): boolean;
  6356. /**
  6357. * Computes and Returns the light World matrix.
  6358. * @returns the world matrix
  6359. */
  6360. getWorldMatrix(): Matrix;
  6361. /**
  6362. * Sort function to order lights for rendering.
  6363. * @param a First Light object to compare to second.
  6364. * @param b Second Light object to compare first.
  6365. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  6366. */
  6367. static CompareLightsPriority(a: Light, b: Light): number;
  6368. /**
  6369. * Disposes the light.
  6370. */
  6371. dispose(): void;
  6372. /**
  6373. * Returns the light type ID (integer).
  6374. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  6375. */
  6376. getTypeID(): number;
  6377. /**
  6378. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  6379. * @returns the scaled intensity in intensity mode unit
  6380. */
  6381. getScaledIntensity(): number;
  6382. /**
  6383. * Returns a new Light object, named "name", from the current one.
  6384. * @param name The name of the cloned light
  6385. * @returns the new created light
  6386. */
  6387. clone(name: string): Nullable<Light>;
  6388. /**
  6389. * Serializes the current light into a Serialization object.
  6390. * @returns the serialized object.
  6391. */
  6392. serialize(): any;
  6393. /**
  6394. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  6395. * This new light is named "name" and added to the passed scene.
  6396. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  6397. * @param name The friendly name of the light
  6398. * @param scene The scene the new light will belong to
  6399. * @returns the constructor function
  6400. */
  6401. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  6402. /**
  6403. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  6404. * @param parsedLight The JSON representation of the light
  6405. * @param scene The scene to create the parsed light in
  6406. * @returns the created light after parsing
  6407. */
  6408. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  6409. private _hookArrayForExcluded(array);
  6410. private _hookArrayForIncludedOnly(array);
  6411. private _resyncMeshes();
  6412. /**
  6413. * Forces the meshes to update their light related information in their rendering used effects
  6414. * @ignore Internal Use Only
  6415. */
  6416. _markMeshesAsLightDirty(): void;
  6417. /**
  6418. * Recomputes the cached photometric scale if needed.
  6419. */
  6420. private _computePhotometricScale();
  6421. /**
  6422. * Returns the Photometric Scale according to the light type and intensity mode.
  6423. */
  6424. private _getPhotometricScale();
  6425. /**
  6426. * Reorder the light in the scene according to their defined priority.
  6427. * @ignore Internal Use Only
  6428. */
  6429. _reorderLightsInScene(): void;
  6430. }
  6431. }
  6432. declare module BABYLON {
  6433. /**
  6434. * A point light is a light defined by an unique point in world space.
  6435. * The light is emitted in every direction from this point.
  6436. * A good example of a point light is a standard light bulb.
  6437. * Documentation: https://doc.babylonjs.com/babylon101/lights
  6438. */
  6439. class PointLight extends ShadowLight {
  6440. private _shadowAngle;
  6441. /**
  6442. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  6443. * This specifies what angle the shadow will use to be created.
  6444. *
  6445. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  6446. */
  6447. /**
  6448. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  6449. * This specifies what angle the shadow will use to be created.
  6450. *
  6451. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  6452. */
  6453. shadowAngle: number;
  6454. /**
  6455. * Gets the direction if it has been set.
  6456. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  6457. */
  6458. /**
  6459. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  6460. */
  6461. direction: Vector3;
  6462. /**
  6463. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  6464. * A PointLight emits the light in every direction.
  6465. * It can cast shadows.
  6466. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  6467. * ```javascript
  6468. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  6469. * ```
  6470. * Documentation : http://doc.babylonjs.com/tutorials/lights
  6471. * @param name The light friendly name
  6472. * @param position The position of the point light in the scene
  6473. * @param scene The scene the lights belongs to
  6474. */
  6475. constructor(name: string, position: Vector3, scene: Scene);
  6476. /**
  6477. * Returns the string "PointLight"
  6478. * @returns the class name
  6479. */
  6480. getClassName(): string;
  6481. /**
  6482. * Returns the integer 0.
  6483. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  6484. */
  6485. getTypeID(): number;
  6486. /**
  6487. * Specifies wether or not the shadowmap should be a cube texture.
  6488. * @returns true if the shadowmap needs to be a cube texture.
  6489. */
  6490. needCube(): boolean;
  6491. /**
  6492. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  6493. * @param faceIndex The index of the face we are computed the direction to generate shadow
  6494. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  6495. */
  6496. getShadowDirection(faceIndex?: number): Vector3;
  6497. /**
  6498. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  6499. * - fov = PI / 2
  6500. * - aspect ratio : 1.0
  6501. * - z-near and far equal to the active camera minZ and maxZ.
  6502. * Returns the PointLight.
  6503. */
  6504. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  6505. protected _buildUniformLayout(): void;
  6506. /**
  6507. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  6508. * @param effect The effect to update
  6509. * @param lightIndex The index of the light in the effect to update
  6510. * @returns The point light
  6511. */
  6512. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  6513. }
  6514. }
  6515. declare module BABYLON {
  6516. /**
  6517. * Interface describing all the common properties and methods a shadow light needs to implement.
  6518. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  6519. * as well as binding the different shadow properties to the effects.
  6520. */
  6521. interface IShadowLight extends Light {
  6522. /**
  6523. * The light id in the scene (used in scene.findLighById for instance)
  6524. */
  6525. id: string;
  6526. /**
  6527. * The position the shdow will be casted from.
  6528. */
  6529. position: Vector3;
  6530. /**
  6531. * In 2d mode (needCube being false), the direction used to cast the shadow.
  6532. */
  6533. direction: Vector3;
  6534. /**
  6535. * The transformed position. Position of the light in world space taking parenting in account.
  6536. */
  6537. transformedPosition: Vector3;
  6538. /**
  6539. * The transformed direction. Direction of the light in world space taking parenting in account.
  6540. */
  6541. transformedDirection: Vector3;
  6542. /**
  6543. * The friendly name of the light in the scene.
  6544. */
  6545. name: string;
  6546. /**
  6547. * Defines the shadow projection clipping minimum z value.
  6548. */
  6549. shadowMinZ: number;
  6550. /**
  6551. * Defines the shadow projection clipping maximum z value.
  6552. */
  6553. shadowMaxZ: number;
  6554. /**
  6555. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  6556. * @returns true if the information has been computed, false if it does not need to (no parenting)
  6557. */
  6558. computeTransformedInformation(): boolean;
  6559. /**
  6560. * Gets the scene the light belongs to.
  6561. * @returns The scene
  6562. */
  6563. getScene(): Scene;
  6564. /**
  6565. * Callback defining a custom Projection Matrix Builder.
  6566. * This can be used to override the default projection matrix computation.
  6567. */
  6568. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  6569. /**
  6570. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  6571. * @param matrix The materix to updated with the projection information
  6572. * @param viewMatrix The transform matrix of the light
  6573. * @param renderList The list of mesh to render in the map
  6574. * @returns The current light
  6575. */
  6576. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  6577. /**
  6578. * Gets the current depth scale used in ESM.
  6579. * @returns The scale
  6580. */
  6581. getDepthScale(): number;
  6582. /**
  6583. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  6584. * @returns true if a cube texture needs to be use
  6585. */
  6586. needCube(): boolean;
  6587. /**
  6588. * Detects if the projection matrix requires to be recomputed this frame.
  6589. * @returns true if it requires to be recomputed otherwise, false.
  6590. */
  6591. needProjectionMatrixCompute(): boolean;
  6592. /**
  6593. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  6594. */
  6595. forceProjectionMatrixCompute(): void;
  6596. /**
  6597. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  6598. * @param faceIndex The index of the face we are computed the direction to generate shadow
  6599. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  6600. */
  6601. getShadowDirection(faceIndex?: number): Vector3;
  6602. /**
  6603. * Gets the minZ used for shadow according to both the scene and the light.
  6604. * @param activeCamera The camera we are returning the min for
  6605. * @returns the depth min z
  6606. */
  6607. getDepthMinZ(activeCamera: Camera): number;
  6608. /**
  6609. * Gets the maxZ used for shadow according to both the scene and the light.
  6610. * @param activeCamera The camera we are returning the max for
  6611. * @returns the depth max z
  6612. */
  6613. getDepthMaxZ(activeCamera: Camera): number;
  6614. }
  6615. /**
  6616. * Base implementation of @see IShadowLight
  6617. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  6618. */
  6619. abstract class ShadowLight extends Light implements IShadowLight {
  6620. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  6621. protected _position: Vector3;
  6622. protected _setPosition(value: Vector3): void;
  6623. /**
  6624. * Sets the position the shadow will be casted from. Also use as the light position for both
  6625. * point and spot lights.
  6626. */
  6627. /**
  6628. * Sets the position the shadow will be casted from. Also use as the light position for both
  6629. * point and spot lights.
  6630. */
  6631. position: Vector3;
  6632. protected _direction: Vector3;
  6633. protected _setDirection(value: Vector3): void;
  6634. /**
  6635. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  6636. * Also use as the light direction on spot and directional lights.
  6637. */
  6638. /**
  6639. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  6640. * Also use as the light direction on spot and directional lights.
  6641. */
  6642. direction: Vector3;
  6643. private _shadowMinZ;
  6644. /**
  6645. * Gets the shadow projection clipping minimum z value.
  6646. */
  6647. /**
  6648. * Sets the shadow projection clipping minimum z value.
  6649. */
  6650. shadowMinZ: number;
  6651. private _shadowMaxZ;
  6652. /**
  6653. * Sets the shadow projection clipping maximum z value.
  6654. */
  6655. /**
  6656. * Gets the shadow projection clipping maximum z value.
  6657. */
  6658. shadowMaxZ: number;
  6659. /**
  6660. * Callback defining a custom Projection Matrix Builder.
  6661. * This can be used to override the default projection matrix computation.
  6662. */
  6663. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  6664. /**
  6665. * The transformed position. Position of the light in world space taking parenting in account.
  6666. */
  6667. transformedPosition: Vector3;
  6668. /**
  6669. * The transformed direction. Direction of the light in world space taking parenting in account.
  6670. */
  6671. transformedDirection: Vector3;
  6672. private _worldMatrix;
  6673. private _needProjectionMatrixCompute;
  6674. /**
  6675. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  6676. * @returns true if the information has been computed, false if it does not need to (no parenting)
  6677. */
  6678. computeTransformedInformation(): boolean;
  6679. /**
  6680. * Return the depth scale used for the shadow map.
  6681. * @returns the depth scale.
  6682. */
  6683. getDepthScale(): number;
  6684. /**
  6685. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  6686. * @param faceIndex The index of the face we are computed the direction to generate shadow
  6687. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  6688. */
  6689. getShadowDirection(faceIndex?: number): Vector3;
  6690. /**
  6691. * Returns the ShadowLight absolute position in the World.
  6692. * @returns the position vector in world space
  6693. */
  6694. getAbsolutePosition(): Vector3;
  6695. /**
  6696. * Sets the ShadowLight direction toward the passed target.
  6697. * @param target The point tot target in local space
  6698. * @returns the updated ShadowLight direction
  6699. */
  6700. setDirectionToTarget(target: Vector3): Vector3;
  6701. /**
  6702. * Returns the light rotation in euler definition.
  6703. * @returns the x y z rotation in local space.
  6704. */
  6705. getRotation(): Vector3;
  6706. /**
  6707. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  6708. * @returns true if a cube texture needs to be use
  6709. */
  6710. needCube(): boolean;
  6711. /**
  6712. * Detects if the projection matrix requires to be recomputed this frame.
  6713. * @returns true if it requires to be recomputed otherwise, false.
  6714. */
  6715. needProjectionMatrixCompute(): boolean;
  6716. /**
  6717. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  6718. */
  6719. forceProjectionMatrixCompute(): void;
  6720. /**
  6721. * Get the world matrix of the sahdow lights.
  6722. * @ignore Internal Use Only
  6723. */
  6724. _getWorldMatrix(): Matrix;
  6725. /**
  6726. * Gets the minZ used for shadow according to both the scene and the light.
  6727. * @param activeCamera The camera we are returning the min for
  6728. * @returns the depth min z
  6729. */
  6730. getDepthMinZ(activeCamera: Camera): number;
  6731. /**
  6732. * Gets the maxZ used for shadow according to both the scene and the light.
  6733. * @param activeCamera The camera we are returning the max for
  6734. * @returns the depth max z
  6735. */
  6736. getDepthMaxZ(activeCamera: Camera): number;
  6737. /**
  6738. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  6739. * @param matrix The materix to updated with the projection information
  6740. * @param viewMatrix The transform matrix of the light
  6741. * @param renderList The list of mesh to render in the map
  6742. * @returns The current light
  6743. */
  6744. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  6745. }
  6746. }
  6747. declare module BABYLON {
  6748. /**
  6749. * A spot light is defined by a position, a direction, an angle, and an exponent.
  6750. * These values define a cone of light starting from the position, emitting toward the direction.
  6751. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  6752. * and the exponent defines the speed of the decay of the light with distance (reach).
  6753. * Documentation: https://doc.babylonjs.com/babylon101/lights
  6754. */
  6755. class SpotLight extends ShadowLight {
  6756. private _angle;
  6757. /**
  6758. * Gets the cone angle of the spot light in Radians.
  6759. */
  6760. /**
  6761. * Sets the cone angle of the spot light in Radians.
  6762. */
  6763. angle: number;
  6764. private _shadowAngleScale;
  6765. /**
  6766. * Allows scaling the angle of the light for shadow generation only.
  6767. */
  6768. /**
  6769. * Allows scaling the angle of the light for shadow generation only.
  6770. */
  6771. shadowAngleScale: number;
  6772. /**
  6773. * The light decay speed with the distance from the emission spot.
  6774. */
  6775. exponent: number;
  6776. private _projectionTextureMatrix;
  6777. /**
  6778. * Allows reading the projecton texture
  6779. */
  6780. readonly projectionTextureMatrix: Matrix;
  6781. protected _projectionTextureLightNear: number;
  6782. /**
  6783. * Gets the near clip of the Spotlight for texture projection.
  6784. */
  6785. /**
  6786. * Sets the near clip of the Spotlight for texture projection.
  6787. */
  6788. projectionTextureLightNear: number;
  6789. protected _projectionTextureLightFar: number;
  6790. /**
  6791. * Gets the far clip of the Spotlight for texture projection.
  6792. */
  6793. /**
  6794. * Sets the far clip of the Spotlight for texture projection.
  6795. */
  6796. projectionTextureLightFar: number;
  6797. protected _projectionTextureUpDirection: Vector3;
  6798. /**
  6799. * Gets the Up vector of the Spotlight for texture projection.
  6800. */
  6801. /**
  6802. * Sets the Up vector of the Spotlight for texture projection.
  6803. */
  6804. projectionTextureUpDirection: Vector3;
  6805. private _projectionTexture;
  6806. /**
  6807. * Gets the projection texture of the light.
  6808. */
  6809. /**
  6810. * Sets the projection texture of the light.
  6811. */
  6812. projectionTexture: Nullable<BaseTexture>;
  6813. private _projectionTextureViewLightDirty;
  6814. private _projectionTextureProjectionLightDirty;
  6815. private _projectionTextureDirty;
  6816. private _projectionTextureViewTargetVector;
  6817. private _projectionTextureViewLightMatrix;
  6818. private _projectionTextureProjectionLightMatrix;
  6819. private _projectionTextureScalingMatrix;
  6820. /**
  6821. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  6822. * It can cast shadows.
  6823. * Documentation : http://doc.babylonjs.com/tutorials/lights
  6824. * @param name The light friendly name
  6825. * @param position The position of the spot light in the scene
  6826. * @param direction The direction of the light in the scene
  6827. * @param angle The cone angle of the light in Radians
  6828. * @param exponent The light decay speed with the distance from the emission spot
  6829. * @param scene The scene the lights belongs to
  6830. */
  6831. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  6832. /**
  6833. * Returns the string "SpotLight".
  6834. * @returns the class name
  6835. */
  6836. getClassName(): string;
  6837. /**
  6838. * Returns the integer 2.
  6839. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  6840. */
  6841. getTypeID(): number;
  6842. /**
  6843. * Overrides the direction setter to recompute the projection texture view light Matrix.
  6844. */
  6845. protected _setDirection(value: Vector3): void;
  6846. /**
  6847. * Overrides the position setter to recompute the projection texture view light Matrix.
  6848. */
  6849. protected _setPosition(value: Vector3): void;
  6850. /**
  6851. * 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.
  6852. * Returns the SpotLight.
  6853. */
  6854. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  6855. protected _computeProjectionTextureViewLightMatrix(): void;
  6856. protected _computeProjectionTextureProjectionLightMatrix(): void;
  6857. /**
  6858. * Main function for light texture projection matrix computing.
  6859. */
  6860. protected _computeProjectionTextureMatrix(): void;
  6861. protected _buildUniformLayout(): void;
  6862. /**
  6863. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  6864. * @param effect The effect to update
  6865. * @param lightIndex The index of the light in the effect to update
  6866. * @returns The spot light
  6867. */
  6868. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  6869. /**
  6870. * Disposes the light and the associated resources.
  6871. */
  6872. dispose(): void;
  6873. }
  6874. }
  6875. declare module BABYLON {
  6876. interface ILoadingScreen {
  6877. displayLoadingUI: () => void;
  6878. hideLoadingUI: () => void;
  6879. loadingUIBackgroundColor: string;
  6880. loadingUIText: string;
  6881. }
  6882. class DefaultLoadingScreen implements ILoadingScreen {
  6883. private _renderingCanvas;
  6884. private _loadingText;
  6885. private _loadingDivBackgroundColor;
  6886. private _loadingDiv;
  6887. private _loadingTextDiv;
  6888. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  6889. displayLoadingUI(): void;
  6890. hideLoadingUI(): void;
  6891. loadingUIText: string;
  6892. loadingUIBackgroundColor: string;
  6893. private _resizeLoadingUI;
  6894. }
  6895. }
  6896. declare module BABYLON {
  6897. class SceneLoaderProgressEvent {
  6898. readonly lengthComputable: boolean;
  6899. readonly loaded: number;
  6900. readonly total: number;
  6901. constructor(lengthComputable: boolean, loaded: number, total: number);
  6902. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  6903. }
  6904. interface ISceneLoaderPluginExtensions {
  6905. [extension: string]: {
  6906. isBinary: boolean;
  6907. };
  6908. }
  6909. interface ISceneLoaderPluginFactory {
  6910. name: string;
  6911. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  6912. canDirectLoad?: (data: string) => boolean;
  6913. }
  6914. interface ISceneLoaderPlugin {
  6915. name: string;
  6916. extensions: string | ISceneLoaderPluginExtensions;
  6917. importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void) => boolean;
  6918. load: (scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void) => boolean;
  6919. canDirectLoad?: (data: string) => boolean;
  6920. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  6921. loadAssets: (scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void) => Nullable<AssetContainer>;
  6922. }
  6923. interface ISceneLoaderPluginAsync {
  6924. name: string;
  6925. extensions: string | ISceneLoaderPluginExtensions;
  6926. importMeshAsync: (meshesNames: any, scene: Scene, data: any, rootUrl: string, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => void;
  6927. loadAsync: (scene: Scene, data: string, rootUrl: string, onSuccess?: () => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => void;
  6928. canDirectLoad?: (data: string) => boolean;
  6929. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  6930. loadAssetsAsync: (scene: Scene, data: string, rootUrl: string, onSuccess?: (assets: Nullable<AssetContainer>) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => void;
  6931. }
  6932. class SceneLoader {
  6933. private static _ForceFullSceneLoadingForIncremental;
  6934. private static _ShowLoadingScreen;
  6935. private static _CleanBoneMatrixWeights;
  6936. static readonly NO_LOGGING: number;
  6937. static readonly MINIMAL_LOGGING: number;
  6938. static readonly SUMMARY_LOGGING: number;
  6939. static readonly DETAILED_LOGGING: number;
  6940. private static _loggingLevel;
  6941. static ForceFullSceneLoadingForIncremental: boolean;
  6942. static ShowLoadingScreen: boolean;
  6943. static loggingLevel: number;
  6944. static CleanBoneMatrixWeights: boolean;
  6945. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  6946. private static _registeredPlugins;
  6947. private static _getDefaultPlugin();
  6948. private static _getPluginForExtension(extension);
  6949. private static _getPluginForDirectLoad(data);
  6950. private static _getPluginForFilename(sceneFilename);
  6951. private static _getDirectLoad(sceneFilename);
  6952. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  6953. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  6954. static IsPluginForExtensionAvailable(extension: string): boolean;
  6955. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  6956. /**
  6957. * Import meshes into a scene
  6958. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  6959. * @param rootUrl a string that defines the root url for scene and resources
  6960. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  6961. * @param scene the instance of BABYLON.Scene to append to
  6962. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  6963. * @param onProgress a callback with a progress event for each file being loaded
  6964. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  6965. */
  6966. 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>;
  6967. /**
  6968. * Load a scene
  6969. * @param rootUrl a string that defines the root url for scene and resources
  6970. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  6971. * @param engine is the instance of BABYLON.Engine to use to create the scene
  6972. * @param onSuccess a callback with the scene when import succeeds
  6973. * @param onProgress a callback with a progress event for each file being loaded
  6974. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  6975. */
  6976. 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>;
  6977. /**
  6978. * Append a scene
  6979. * @param rootUrl a string that defines the root url for scene and resources
  6980. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  6981. * @param scene is the instance of BABYLON.Scene to append to
  6982. * @param onSuccess a callback with the scene when import succeeds
  6983. * @param onProgress a callback with a progress event for each file being loaded
  6984. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  6985. */
  6986. 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>;
  6987. 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>;
  6988. }
  6989. }
  6990. declare module BABYLON {
  6991. /**
  6992. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  6993. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  6994. * 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;
  6995. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  6996. */
  6997. class ColorCurves {
  6998. private _dirty;
  6999. private _tempColor;
  7000. private _globalCurve;
  7001. private _highlightsCurve;
  7002. private _midtonesCurve;
  7003. private _shadowsCurve;
  7004. private _positiveCurve;
  7005. private _negativeCurve;
  7006. private _globalHue;
  7007. private _globalDensity;
  7008. private _globalSaturation;
  7009. private _globalExposure;
  7010. /**
  7011. * Gets the global Hue value.
  7012. * 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).
  7013. */
  7014. /**
  7015. * Sets the global Hue value.
  7016. * 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).
  7017. */
  7018. globalHue: number;
  7019. /**
  7020. * Gets the global Density value.
  7021. * 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.
  7022. * Values less than zero provide a filter of opposite hue.
  7023. */
  7024. /**
  7025. * Sets the global Density value.
  7026. * 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.
  7027. * Values less than zero provide a filter of opposite hue.
  7028. */
  7029. globalDensity: number;
  7030. /**
  7031. * Gets the global Saturation value.
  7032. * 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.
  7033. */
  7034. /**
  7035. * Sets the global Saturation value.
  7036. * 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.
  7037. */
  7038. globalSaturation: number;
  7039. private _highlightsHue;
  7040. private _highlightsDensity;
  7041. private _highlightsSaturation;
  7042. private _highlightsExposure;
  7043. /**
  7044. * Gets the highlights Hue value.
  7045. * 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).
  7046. */
  7047. /**
  7048. * Sets the highlights Hue value.
  7049. * 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).
  7050. */
  7051. highlightsHue: number;
  7052. /**
  7053. * Gets the highlights Density value.
  7054. * 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.
  7055. * Values less than zero provide a filter of opposite hue.
  7056. */
  7057. /**
  7058. * Sets the highlights Density value.
  7059. * 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.
  7060. * Values less than zero provide a filter of opposite hue.
  7061. */
  7062. highlightsDensity: number;
  7063. /**
  7064. * Gets the highlights Saturation value.
  7065. * 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.
  7066. */
  7067. /**
  7068. * Sets the highlights Saturation value.
  7069. * 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.
  7070. */
  7071. highlightsSaturation: number;
  7072. /**
  7073. * Gets the highlights Exposure value.
  7074. * 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.
  7075. */
  7076. /**
  7077. * Sets the highlights Exposure value.
  7078. * 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.
  7079. */
  7080. highlightsExposure: number;
  7081. private _midtonesHue;
  7082. private _midtonesDensity;
  7083. private _midtonesSaturation;
  7084. private _midtonesExposure;
  7085. /**
  7086. * Gets the midtones Hue value.
  7087. * 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).
  7088. */
  7089. /**
  7090. * Sets the midtones Hue value.
  7091. * 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).
  7092. */
  7093. midtonesHue: number;
  7094. /**
  7095. * Gets the midtones Density value.
  7096. * 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.
  7097. * Values less than zero provide a filter of opposite hue.
  7098. */
  7099. /**
  7100. * Sets the midtones Density value.
  7101. * 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.
  7102. * Values less than zero provide a filter of opposite hue.
  7103. */
  7104. midtonesDensity: number;
  7105. /**
  7106. * Gets the midtones Saturation value.
  7107. * 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.
  7108. */
  7109. /**
  7110. * Sets the midtones Saturation value.
  7111. * 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.
  7112. */
  7113. midtonesSaturation: number;
  7114. /**
  7115. * Gets the midtones Exposure value.
  7116. * 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.
  7117. */
  7118. /**
  7119. * Sets the midtones Exposure value.
  7120. * 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.
  7121. */
  7122. midtonesExposure: number;
  7123. private _shadowsHue;
  7124. private _shadowsDensity;
  7125. private _shadowsSaturation;
  7126. private _shadowsExposure;
  7127. /**
  7128. * Gets the shadows Hue value.
  7129. * 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).
  7130. */
  7131. /**
  7132. * Sets the shadows Hue value.
  7133. * 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).
  7134. */
  7135. shadowsHue: number;
  7136. /**
  7137. * Gets the shadows Density value.
  7138. * 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.
  7139. * Values less than zero provide a filter of opposite hue.
  7140. */
  7141. /**
  7142. * Sets the shadows Density value.
  7143. * 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.
  7144. * Values less than zero provide a filter of opposite hue.
  7145. */
  7146. shadowsDensity: number;
  7147. /**
  7148. * Gets the shadows Saturation value.
  7149. * 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.
  7150. */
  7151. /**
  7152. * Sets the shadows Saturation value.
  7153. * 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.
  7154. */
  7155. shadowsSaturation: number;
  7156. /**
  7157. * Gets the shadows Exposure value.
  7158. * 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.
  7159. */
  7160. /**
  7161. * Sets the shadows Exposure value.
  7162. * 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.
  7163. */
  7164. shadowsExposure: number;
  7165. getClassName(): string;
  7166. /**
  7167. * Binds the color curves to the shader.
  7168. * @param colorCurves The color curve to bind
  7169. * @param effect The effect to bind to
  7170. */
  7171. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7172. /**
  7173. * Prepare the list of uniforms associated with the ColorCurves effects.
  7174. * @param uniformsList The list of uniforms used in the effect
  7175. */
  7176. static PrepareUniforms(uniformsList: string[]): void;
  7177. /**
  7178. * Returns color grading data based on a hue, density, saturation and exposure value.
  7179. * @param filterHue The hue of the color filter.
  7180. * @param filterDensity The density of the color filter.
  7181. * @param saturation The saturation.
  7182. * @param exposure The exposure.
  7183. * @param result The result data container.
  7184. */
  7185. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  7186. /**
  7187. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7188. * @param value The input slider value in range [-100,100].
  7189. * @returns Adjusted value.
  7190. */
  7191. private static applyColorGradingSliderNonlinear(value);
  7192. /**
  7193. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7194. * @param hue The hue (H) input.
  7195. * @param saturation The saturation (S) input.
  7196. * @param brightness The brightness (B) input.
  7197. * @result An RGBA color represented as Vector4.
  7198. */
  7199. private static fromHSBToRef(hue, saturation, brightness, result);
  7200. /**
  7201. * Returns a value clamped between min and max
  7202. * @param value The value to clamp
  7203. * @param min The minimum of value
  7204. * @param max The maximum of value
  7205. * @returns The clamped value.
  7206. */
  7207. private static clamp(value, min, max);
  7208. /**
  7209. * Clones the current color curve instance.
  7210. * @return The cloned curves
  7211. */
  7212. clone(): ColorCurves;
  7213. /**
  7214. * Serializes the current color curve instance to a json representation.
  7215. * @return a JSON representation
  7216. */
  7217. serialize(): any;
  7218. /**
  7219. * Parses the color curve from a json representation.
  7220. * @param source the JSON source to parse
  7221. * @return The parsed curves
  7222. */
  7223. static Parse(source: any): ColorCurves;
  7224. }
  7225. }
  7226. declare module BABYLON {
  7227. class EffectFallbacks {
  7228. private _defines;
  7229. private _currentRank;
  7230. private _maxRank;
  7231. private _mesh;
  7232. unBindMesh(): void;
  7233. addFallback(rank: number, define: string): void;
  7234. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  7235. readonly isMoreFallbacks: boolean;
  7236. reduce(currentDefines: string): string;
  7237. }
  7238. class EffectCreationOptions {
  7239. attributes: string[];
  7240. uniformsNames: string[];
  7241. uniformBuffersNames: string[];
  7242. samplers: string[];
  7243. defines: any;
  7244. fallbacks: Nullable<EffectFallbacks>;
  7245. onCompiled: Nullable<(effect: Effect) => void>;
  7246. onError: Nullable<(effect: Effect, errors: string) => void>;
  7247. indexParameters: any;
  7248. maxSimultaneousLights: number;
  7249. transformFeedbackVaryings: Nullable<string[]>;
  7250. }
  7251. class Effect {
  7252. name: any;
  7253. defines: string;
  7254. onCompiled: Nullable<(effect: Effect) => void>;
  7255. onError: Nullable<(effect: Effect, errors: string) => void>;
  7256. onBind: Nullable<(effect: Effect) => void>;
  7257. uniqueId: number;
  7258. onCompileObservable: Observable<Effect>;
  7259. onErrorObservable: Observable<Effect>;
  7260. onBindObservable: Observable<Effect>;
  7261. private static _uniqueIdSeed;
  7262. private _engine;
  7263. private _uniformBuffersNames;
  7264. private _uniformsNames;
  7265. private _samplers;
  7266. private _isReady;
  7267. private _compilationError;
  7268. private _attributesNames;
  7269. private _attributes;
  7270. private _uniforms;
  7271. _key: string;
  7272. private _indexParameters;
  7273. private _fallbacks;
  7274. private _vertexSourceCode;
  7275. private _fragmentSourceCode;
  7276. private _vertexSourceCodeOverride;
  7277. private _fragmentSourceCodeOverride;
  7278. private _transformFeedbackVaryings;
  7279. _program: WebGLProgram;
  7280. private _valueCache;
  7281. private static _baseCache;
  7282. 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);
  7283. readonly key: string;
  7284. isReady(): boolean;
  7285. getEngine(): Engine;
  7286. getProgram(): WebGLProgram;
  7287. getAttributesNames(): string[];
  7288. getAttributeLocation(index: number): number;
  7289. getAttributeLocationByName(name: string): number;
  7290. getAttributesCount(): number;
  7291. getUniformIndex(uniformName: string): number;
  7292. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  7293. getSamplers(): string[];
  7294. getCompilationError(): string;
  7295. executeWhenCompiled(func: (effect: Effect) => void): void;
  7296. /** @ignore */
  7297. _loadVertexShaderAsync(vertex: any): Promise<any>;
  7298. /** @ignore */
  7299. _loadFragmentShaderAsync(fragment: any): Promise<any>;
  7300. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  7301. private _processShaderConversion(sourceCode, isFragment);
  7302. private _processIncludesAsync(sourceCode);
  7303. private _processPrecision(source);
  7304. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  7305. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  7306. _prepareEffect(): void;
  7307. readonly isSupported: boolean;
  7308. _bindTexture(channel: string, texture: InternalTexture): void;
  7309. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  7310. setTextureArray(channel: string, textures: BaseTexture[]): void;
  7311. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  7312. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  7313. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  7314. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  7315. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  7316. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  7317. bindUniformBlock(blockName: string, index: number): void;
  7318. setInt(uniformName: string, value: number): Effect;
  7319. setIntArray(uniformName: string, array: Int32Array): Effect;
  7320. setIntArray2(uniformName: string, array: Int32Array): Effect;
  7321. setIntArray3(uniformName: string, array: Int32Array): Effect;
  7322. setIntArray4(uniformName: string, array: Int32Array): Effect;
  7323. setFloatArray(uniformName: string, array: Float32Array): Effect;
  7324. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  7325. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  7326. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  7327. setArray(uniformName: string, array: number[]): Effect;
  7328. setArray2(uniformName: string, array: number[]): Effect;
  7329. setArray3(uniformName: string, array: number[]): Effect;
  7330. setArray4(uniformName: string, array: number[]): Effect;
  7331. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  7332. setMatrix(uniformName: string, matrix: Matrix): Effect;
  7333. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  7334. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  7335. setFloat(uniformName: string, value: number): Effect;
  7336. setBool(uniformName: string, bool: boolean): Effect;
  7337. setVector2(uniformName: string, vector2: Vector2): Effect;
  7338. setFloat2(uniformName: string, x: number, y: number): Effect;
  7339. setVector3(uniformName: string, vector3: Vector3): Effect;
  7340. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  7341. setVector4(uniformName: string, vector4: Vector4): Effect;
  7342. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  7343. setColor3(uniformName: string, color3: Color3): Effect;
  7344. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  7345. static ShadersStore: {
  7346. [key: string]: string;
  7347. };
  7348. static IncludesShadersStore: {
  7349. [key: string]: string;
  7350. };
  7351. static ResetCache(): void;
  7352. }
  7353. }
  7354. declare module BABYLON {
  7355. class FresnelParameters {
  7356. private _isEnabled;
  7357. isEnabled: boolean;
  7358. leftColor: Color3;
  7359. rightColor: Color3;
  7360. bias: number;
  7361. power: number;
  7362. clone(): FresnelParameters;
  7363. serialize(): any;
  7364. static Parse(parsedFresnelParameters: any): FresnelParameters;
  7365. }
  7366. }
  7367. declare module BABYLON {
  7368. /**
  7369. * Interface to follow in your material defines to integrate easily the
  7370. * Image proccessing functions.
  7371. */
  7372. interface IImageProcessingConfigurationDefines {
  7373. IMAGEPROCESSING: boolean;
  7374. VIGNETTE: boolean;
  7375. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7376. VIGNETTEBLENDMODEOPAQUE: boolean;
  7377. TONEMAPPING: boolean;
  7378. CONTRAST: boolean;
  7379. EXPOSURE: boolean;
  7380. COLORCURVES: boolean;
  7381. COLORGRADING: boolean;
  7382. COLORGRADING3D: boolean;
  7383. SAMPLER3DGREENDEPTH: boolean;
  7384. SAMPLER3DBGRMAP: boolean;
  7385. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7386. }
  7387. /**
  7388. * This groups together the common properties used for image processing either in direct forward pass
  7389. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7390. * or not.
  7391. */
  7392. class ImageProcessingConfiguration {
  7393. /**
  7394. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  7395. */
  7396. colorCurves: Nullable<ColorCurves>;
  7397. private _colorCurvesEnabled;
  7398. /**
  7399. * Gets wether the color curves effect is enabled.
  7400. */
  7401. /**
  7402. * Sets wether the color curves effect is enabled.
  7403. */
  7404. colorCurvesEnabled: boolean;
  7405. /**
  7406. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7407. */
  7408. colorGradingTexture: Nullable<BaseTexture>;
  7409. private _colorGradingEnabled;
  7410. /**
  7411. * Gets wether the color grading effect is enabled.
  7412. */
  7413. /**
  7414. * Sets wether the color grading effect is enabled.
  7415. */
  7416. colorGradingEnabled: boolean;
  7417. private _colorGradingWithGreenDepth;
  7418. /**
  7419. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  7420. */
  7421. /**
  7422. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  7423. */
  7424. colorGradingWithGreenDepth: boolean;
  7425. private _colorGradingBGR;
  7426. /**
  7427. * Gets wether the color grading texture contains BGR values.
  7428. */
  7429. /**
  7430. * Sets wether the color grading texture contains BGR values.
  7431. */
  7432. colorGradingBGR: boolean;
  7433. _exposure: number;
  7434. /**
  7435. * Gets the Exposure used in the effect.
  7436. */
  7437. /**
  7438. * Sets the Exposure used in the effect.
  7439. */
  7440. exposure: number;
  7441. private _toneMappingEnabled;
  7442. /**
  7443. * Gets wether the tone mapping effect is enabled.
  7444. */
  7445. /**
  7446. * Sets wether the tone mapping effect is enabled.
  7447. */
  7448. toneMappingEnabled: boolean;
  7449. protected _contrast: number;
  7450. /**
  7451. * Gets the contrast used in the effect.
  7452. */
  7453. /**
  7454. * Sets the contrast used in the effect.
  7455. */
  7456. contrast: number;
  7457. /**
  7458. * Vignette stretch size.
  7459. */
  7460. vignetteStretch: number;
  7461. /**
  7462. * Vignette centre X Offset.
  7463. */
  7464. vignetteCentreX: number;
  7465. /**
  7466. * Vignette centre Y Offset.
  7467. */
  7468. vignetteCentreY: number;
  7469. /**
  7470. * Vignette weight or intensity of the vignette effect.
  7471. */
  7472. vignetteWeight: number;
  7473. /**
  7474. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  7475. * if vignetteEnabled is set to true.
  7476. */
  7477. vignetteColor: Color4;
  7478. /**
  7479. * Camera field of view used by the Vignette effect.
  7480. */
  7481. vignetteCameraFov: number;
  7482. private _vignetteBlendMode;
  7483. /**
  7484. * Gets the vignette blend mode allowing different kind of effect.
  7485. */
  7486. /**
  7487. * Sets the vignette blend mode allowing different kind of effect.
  7488. */
  7489. vignetteBlendMode: number;
  7490. private _vignetteEnabled;
  7491. /**
  7492. * Gets wether the vignette effect is enabled.
  7493. */
  7494. /**
  7495. * Sets wether the vignette effect is enabled.
  7496. */
  7497. vignetteEnabled: boolean;
  7498. private _applyByPostProcess;
  7499. /**
  7500. * Gets wether the image processing is applied through a post process or not.
  7501. */
  7502. /**
  7503. * Sets wether the image processing is applied through a post process or not.
  7504. */
  7505. applyByPostProcess: boolean;
  7506. private _isEnabled;
  7507. /**
  7508. * Gets wether the image processing is enabled or not.
  7509. */
  7510. /**
  7511. * Sets wether the image processing is enabled or not.
  7512. */
  7513. isEnabled: boolean;
  7514. /**
  7515. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  7516. * @type {BABYLON.Observable}
  7517. */
  7518. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  7519. /**
  7520. * Method called each time the image processing information changes requires to recompile the effect.
  7521. */
  7522. protected _updateParameters(): void;
  7523. getClassName(): string;
  7524. /**
  7525. * Prepare the list of uniforms associated with the Image Processing effects.
  7526. * @param uniformsList The list of uniforms used in the effect
  7527. * @param defines the list of defines currently in use
  7528. */
  7529. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  7530. /**
  7531. * Prepare the list of samplers associated with the Image Processing effects.
  7532. * @param uniformsList The list of uniforms used in the effect
  7533. * @param defines the list of defines currently in use
  7534. */
  7535. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  7536. /**
  7537. * Prepare the list of defines associated to the shader.
  7538. * @param defines the list of defines to complete
  7539. */
  7540. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  7541. /**
  7542. * Returns true if all the image processing information are ready.
  7543. */
  7544. isReady(): boolean;
  7545. /**
  7546. * Binds the image processing to the shader.
  7547. * @param effect The effect to bind to
  7548. */
  7549. bind(effect: Effect, aspectRatio?: number): void;
  7550. /**
  7551. * Clones the current image processing instance.
  7552. * @return The cloned image processing
  7553. */
  7554. clone(): ImageProcessingConfiguration;
  7555. /**
  7556. * Serializes the current image processing instance to a json representation.
  7557. * @return a JSON representation
  7558. */
  7559. serialize(): any;
  7560. /**
  7561. * Parses the image processing from a json representation.
  7562. * @param source the JSON source to parse
  7563. * @return The parsed image processing
  7564. */
  7565. static Parse(source: any): ImageProcessingConfiguration;
  7566. private static _VIGNETTEMODE_MULTIPLY;
  7567. private static _VIGNETTEMODE_OPAQUE;
  7568. /**
  7569. * Used to apply the vignette as a mix with the pixel color.
  7570. */
  7571. static readonly VIGNETTEMODE_MULTIPLY: number;
  7572. /**
  7573. * Used to apply the vignette as a replacement of the pixel color.
  7574. */
  7575. static readonly VIGNETTEMODE_OPAQUE: number;
  7576. }
  7577. }
  7578. declare module BABYLON {
  7579. class MaterialDefines {
  7580. private _keys;
  7581. private _isDirty;
  7582. _renderId: number;
  7583. _areLightsDirty: boolean;
  7584. _areAttributesDirty: boolean;
  7585. _areTexturesDirty: boolean;
  7586. _areFresnelDirty: boolean;
  7587. _areMiscDirty: boolean;
  7588. _areImageProcessingDirty: boolean;
  7589. _normals: boolean;
  7590. _uvs: boolean;
  7591. _needNormals: boolean;
  7592. _needUVs: boolean;
  7593. readonly isDirty: boolean;
  7594. markAsProcessed(): void;
  7595. markAsUnprocessed(): void;
  7596. markAllAsDirty(): void;
  7597. markAsImageProcessingDirty(): void;
  7598. markAsLightDirty(): void;
  7599. markAsAttributesDirty(): void;
  7600. markAsTexturesDirty(): void;
  7601. markAsFresnelDirty(): void;
  7602. markAsMiscDirty(): void;
  7603. rebuild(): void;
  7604. isEqual(other: MaterialDefines): boolean;
  7605. cloneTo(other: MaterialDefines): void;
  7606. reset(): void;
  7607. toString(): string;
  7608. }
  7609. class Material implements IAnimatable {
  7610. private static _TriangleFillMode;
  7611. private static _WireFrameFillMode;
  7612. private static _PointFillMode;
  7613. private static _PointListDrawMode;
  7614. private static _LineListDrawMode;
  7615. private static _LineLoopDrawMode;
  7616. private static _LineStripDrawMode;
  7617. private static _TriangleStripDrawMode;
  7618. private static _TriangleFanDrawMode;
  7619. static readonly TriangleFillMode: number;
  7620. static readonly WireFrameFillMode: number;
  7621. static readonly PointFillMode: number;
  7622. static readonly PointListDrawMode: number;
  7623. static readonly LineListDrawMode: number;
  7624. static readonly LineLoopDrawMode: number;
  7625. static readonly LineStripDrawMode: number;
  7626. static readonly TriangleStripDrawMode: number;
  7627. static readonly TriangleFanDrawMode: number;
  7628. private static _ClockWiseSideOrientation;
  7629. private static _CounterClockWiseSideOrientation;
  7630. static readonly ClockWiseSideOrientation: number;
  7631. static readonly CounterClockWiseSideOrientation: number;
  7632. private static _TextureDirtyFlag;
  7633. private static _LightDirtyFlag;
  7634. private static _FresnelDirtyFlag;
  7635. private static _AttributesDirtyFlag;
  7636. private static _MiscDirtyFlag;
  7637. static readonly TextureDirtyFlag: number;
  7638. static readonly LightDirtyFlag: number;
  7639. static readonly FresnelDirtyFlag: number;
  7640. static readonly AttributesDirtyFlag: number;
  7641. static readonly MiscDirtyFlag: number;
  7642. id: string;
  7643. name: string;
  7644. checkReadyOnEveryCall: boolean;
  7645. checkReadyOnlyOnce: boolean;
  7646. state: string;
  7647. protected _alpha: number;
  7648. alpha: number;
  7649. protected _backFaceCulling: boolean;
  7650. backFaceCulling: boolean;
  7651. sideOrientation: number;
  7652. onCompiled: (effect: Effect) => void;
  7653. onError: (effect: Effect, errors: string) => void;
  7654. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  7655. doNotSerialize: boolean;
  7656. storeEffectOnSubMeshes: boolean;
  7657. animations: Array<Animation>;
  7658. /**
  7659. * An event triggered when the material is disposed.
  7660. * @type {BABYLON.Observable}
  7661. */
  7662. onDisposeObservable: Observable<Material>;
  7663. private _onDisposeObserver;
  7664. onDispose: () => void;
  7665. /**
  7666. * An event triggered when the material is bound.
  7667. * @type {BABYLON.Observable}
  7668. */
  7669. onBindObservable: Observable<AbstractMesh>;
  7670. private _onBindObserver;
  7671. onBind: (Mesh: AbstractMesh) => void;
  7672. /**
  7673. * An event triggered when the material is unbound.
  7674. * @type {BABYLON.Observable}
  7675. */
  7676. onUnBindObservable: Observable<Material>;
  7677. private _alphaMode;
  7678. alphaMode: number;
  7679. private _needDepthPrePass;
  7680. needDepthPrePass: boolean;
  7681. disableDepthWrite: boolean;
  7682. forceDepthWrite: boolean;
  7683. separateCullingPass: boolean;
  7684. private _fogEnabled;
  7685. fogEnabled: boolean;
  7686. pointSize: number;
  7687. zOffset: number;
  7688. wireframe: boolean;
  7689. pointsCloud: boolean;
  7690. fillMode: number;
  7691. _effect: Nullable<Effect>;
  7692. _wasPreviouslyReady: boolean;
  7693. private _useUBO;
  7694. private _scene;
  7695. private _fillMode;
  7696. private _cachedDepthWriteState;
  7697. protected _uniformBuffer: UniformBuffer;
  7698. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  7699. /**
  7700. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  7701. * subclasses should override adding information pertainent to themselves
  7702. */
  7703. toString(fullDetails?: boolean): string;
  7704. /**
  7705. * Child classes can use it to update shaders
  7706. */
  7707. getClassName(): string;
  7708. readonly isFrozen: boolean;
  7709. freeze(): void;
  7710. unfreeze(): void;
  7711. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  7712. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7713. getEffect(): Nullable<Effect>;
  7714. getScene(): Scene;
  7715. needAlphaBlending(): boolean;
  7716. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  7717. needAlphaTesting(): boolean;
  7718. getAlphaTestTexture(): Nullable<BaseTexture>;
  7719. markDirty(): void;
  7720. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  7721. bind(world: Matrix, mesh?: Mesh): void;
  7722. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  7723. bindOnlyWorldMatrix(world: Matrix): void;
  7724. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  7725. bindView(effect: Effect): void;
  7726. bindViewProjection(effect: Effect): void;
  7727. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  7728. protected _afterBind(mesh?: Mesh): void;
  7729. unbind(): void;
  7730. getActiveTextures(): BaseTexture[];
  7731. hasTexture(texture: BaseTexture): boolean;
  7732. clone(name: string): Nullable<Material>;
  7733. getBindedMeshes(): AbstractMesh[];
  7734. /**
  7735. * Force shader compilation including textures ready check
  7736. */
  7737. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  7738. clipPlane: boolean;
  7739. }>): void;
  7740. markAsDirty(flag: number): void;
  7741. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  7742. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  7743. protected _markAllSubMeshesAsTexturesDirty(): void;
  7744. protected _markAllSubMeshesAsFresnelDirty(): void;
  7745. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  7746. protected _markAllSubMeshesAsLightsDirty(): void;
  7747. protected _markAllSubMeshesAsAttributesDirty(): void;
  7748. protected _markAllSubMeshesAsMiscDirty(): void;
  7749. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  7750. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  7751. serialize(): any;
  7752. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7753. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  7754. }
  7755. }
  7756. declare module BABYLON {
  7757. /**
  7758. * "Static Class" containing the most commonly used helper while dealing with material for
  7759. * rendering purpose.
  7760. *
  7761. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  7762. *
  7763. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  7764. */
  7765. class MaterialHelper {
  7766. /**
  7767. * Bind the current view position to an effect.
  7768. * @param effect The effect to be bound
  7769. * @param scene The scene the eyes position is used from
  7770. */
  7771. static BindEyePosition(effect: Effect, scene: Scene): void;
  7772. /**
  7773. * Helps preparing the defines values about the UVs in used in the effect.
  7774. * UVs are shared as much as we can accross chanels in the shaders.
  7775. * @param texture The texture we are preparing the UVs for
  7776. * @param defines The defines to update
  7777. * @param key The chanel key "diffuse", "specular"... used in the shader
  7778. */
  7779. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  7780. /**
  7781. * Binds a texture matrix value to its corrsponding uniform
  7782. * @param texture The texture to bind the matrix for
  7783. * @param uniformBuffer The uniform buffer receivin the data
  7784. * @param key The chanel key "diffuse", "specular"... used in the shader
  7785. */
  7786. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  7787. /**
  7788. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  7789. * @param mesh defines the current mesh
  7790. * @param scene defines the current scene
  7791. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  7792. * @param pointsCloud defines if point cloud rendering has to be turned on
  7793. * @param fogEnabled defines if fog has to be turned on
  7794. * @param alphaTest defines if alpha testing has to be turned on
  7795. * @param defines defines the current list of defines
  7796. */
  7797. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  7798. /**
  7799. * Helper used to prepare the list of defines associated with frame values for shader compilation
  7800. * @param scene defines the current scene
  7801. * @param engine defines the current engine
  7802. * @param defines specifies the list of active defines
  7803. * @param useInstances defines if instances have to be turned on
  7804. */
  7805. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean): void;
  7806. /**
  7807. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  7808. * @param mesh The mesh containing the geometry data we will draw
  7809. * @param defines The defines to update
  7810. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  7811. * @param useBones Precise whether bones should be used or not (override mesh info)
  7812. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  7813. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  7814. * @returns false if defines are considered not dirty and have not been checked
  7815. */
  7816. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  7817. /**
  7818. * Prepares the defines related to the light information passed in parameter
  7819. * @param scene The scene we are intending to draw
  7820. * @param mesh The mesh the effect is compiling for
  7821. * @param defines The defines to update
  7822. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  7823. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  7824. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  7825. * @returns true if normals will be required for the rest of the effect
  7826. */
  7827. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  7828. /**
  7829. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  7830. * that won t be acctive due to defines being turned off.
  7831. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  7832. * @param samplersList The samplers list
  7833. * @param defines The defines helping in the list generation
  7834. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  7835. */
  7836. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  7837. /**
  7838. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  7839. * @param defines The defines to update while falling back
  7840. * @param fallbacks The authorized effect fallbacks
  7841. * @param maxSimultaneousLights The maximum number of lights allowed
  7842. * @param rank the current rank of the Effect
  7843. * @returns The newly affected rank
  7844. */
  7845. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  7846. /**
  7847. * Prepares the list of attributes required for morph targets according to the effect defines.
  7848. * @param attribs The current list of supported attribs
  7849. * @param mesh The mesh to prepare the morph targets attributes for
  7850. * @param defines The current Defines of the effect
  7851. */
  7852. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  7853. /**
  7854. * Prepares the list of attributes required for bones according to the effect defines.
  7855. * @param attribs The current list of supported attribs
  7856. * @param mesh The mesh to prepare the bones attributes for
  7857. * @param defines The current Defines of the effect
  7858. * @param fallbacks The current efffect fallback strategy
  7859. */
  7860. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  7861. /**
  7862. * Prepares the list of attributes required for instances according to the effect defines.
  7863. * @param attribs The current list of supported attribs
  7864. * @param defines The current Defines of the effect
  7865. */
  7866. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  7867. /**
  7868. * Binds the light shadow information to the effect for the given mesh.
  7869. * @param light The light containing the generator
  7870. * @param scene The scene the lights belongs to
  7871. * @param mesh The mesh we are binding the information to render
  7872. * @param lightIndex The light index in the effect used to render the mesh
  7873. * @param effect The effect we are binding the data to
  7874. */
  7875. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  7876. /**
  7877. * Binds the light information to the effect.
  7878. * @param light The light containing the generator
  7879. * @param effect The effect we are binding the data to
  7880. * @param lightIndex The light index in the effect used to render
  7881. */
  7882. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  7883. /**
  7884. * Binds the lights information from the scene to the effect for the given mesh.
  7885. * @param scene The scene the lights belongs to
  7886. * @param mesh The mesh we are binding the information to render
  7887. * @param effect The effect we are binding the data to
  7888. * @param defines The generated defines for the effect
  7889. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  7890. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  7891. */
  7892. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  7893. /**
  7894. * Binds the fog information from the scene to the effect for the given mesh.
  7895. * @param scene The scene the lights belongs to
  7896. * @param mesh The mesh we are binding the information to render
  7897. * @param effect The effect we are binding the data to
  7898. */
  7899. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  7900. /**
  7901. * Binds the bones information from the mesh to the effect.
  7902. * @param mesh The mesh we are binding the information to render
  7903. * @param effect The effect we are binding the data to
  7904. */
  7905. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  7906. /**
  7907. * Binds the morph targets information from the mesh to the effect.
  7908. * @param abstractMesh The mesh we are binding the information to render
  7909. * @param effect The effect we are binding the data to
  7910. */
  7911. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  7912. /**
  7913. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  7914. * @param defines The generated defines used in the effect
  7915. * @param effect The effect we are binding the data to
  7916. * @param scene The scene we are willing to render with logarithmic scale for
  7917. */
  7918. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  7919. /**
  7920. * Binds the clip plane information from the scene to the effect.
  7921. * @param scene The scene the clip plane information are extracted from
  7922. * @param effect The effect we are binding the data to
  7923. */
  7924. static BindClipPlane(effect: Effect, scene: Scene): void;
  7925. }
  7926. }
  7927. declare module BABYLON {
  7928. class MultiMaterial extends Material {
  7929. private _subMaterials;
  7930. subMaterials: Nullable<Material>[];
  7931. constructor(name: string, scene: Scene);
  7932. private _hookArray(array);
  7933. getSubMaterial(index: number): Nullable<Material>;
  7934. getActiveTextures(): BaseTexture[];
  7935. getClassName(): string;
  7936. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7937. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7938. serialize(): any;
  7939. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  7940. }
  7941. }
  7942. declare module BABYLON {
  7943. class PushMaterial extends Material {
  7944. protected _activeEffect: Effect;
  7945. constructor(name: string, scene: Scene);
  7946. getEffect(): Effect;
  7947. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  7948. bindOnlyWorldMatrix(world: Matrix): void;
  7949. bind(world: Matrix, mesh?: Mesh): void;
  7950. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  7951. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  7952. }
  7953. }
  7954. declare module BABYLON {
  7955. class ShaderMaterial extends Material {
  7956. private _shaderPath;
  7957. private _options;
  7958. private _textures;
  7959. private _textureArrays;
  7960. private _floats;
  7961. private _ints;
  7962. private _floatsArrays;
  7963. private _colors3;
  7964. private _colors3Arrays;
  7965. private _colors4;
  7966. private _vectors2;
  7967. private _vectors3;
  7968. private _vectors4;
  7969. private _matrices;
  7970. private _matrices3x3;
  7971. private _matrices2x2;
  7972. private _vectors2Arrays;
  7973. private _vectors3Arrays;
  7974. private _cachedWorldViewMatrix;
  7975. private _renderId;
  7976. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  7977. getClassName(): string;
  7978. needAlphaBlending(): boolean;
  7979. needAlphaTesting(): boolean;
  7980. private _checkUniform(uniformName);
  7981. setTexture(name: string, texture: Texture): ShaderMaterial;
  7982. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  7983. setFloat(name: string, value: number): ShaderMaterial;
  7984. setInt(name: string, value: number): ShaderMaterial;
  7985. setFloats(name: string, value: number[]): ShaderMaterial;
  7986. setColor3(name: string, value: Color3): ShaderMaterial;
  7987. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  7988. setColor4(name: string, value: Color4): ShaderMaterial;
  7989. setVector2(name: string, value: Vector2): ShaderMaterial;
  7990. setVector3(name: string, value: Vector3): ShaderMaterial;
  7991. setVector4(name: string, value: Vector4): ShaderMaterial;
  7992. setMatrix(name: string, value: Matrix): ShaderMaterial;
  7993. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  7994. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  7995. setArray2(name: string, value: number[]): ShaderMaterial;
  7996. setArray3(name: string, value: number[]): ShaderMaterial;
  7997. private _checkCache(scene, mesh?, useInstances?);
  7998. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  7999. bindOnlyWorldMatrix(world: Matrix): void;
  8000. bind(world: Matrix, mesh?: Mesh): void;
  8001. getActiveTextures(): BaseTexture[];
  8002. hasTexture(texture: BaseTexture): boolean;
  8003. clone(name: string): ShaderMaterial;
  8004. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  8005. serialize(): any;
  8006. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  8007. }
  8008. }
  8009. declare module BABYLON {
  8010. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8011. MAINUV1: boolean;
  8012. MAINUV2: boolean;
  8013. DIFFUSE: boolean;
  8014. DIFFUSEDIRECTUV: number;
  8015. AMBIENT: boolean;
  8016. AMBIENTDIRECTUV: number;
  8017. OPACITY: boolean;
  8018. OPACITYDIRECTUV: number;
  8019. OPACITYRGB: boolean;
  8020. REFLECTION: boolean;
  8021. EMISSIVE: boolean;
  8022. EMISSIVEDIRECTUV: number;
  8023. SPECULAR: boolean;
  8024. SPECULARDIRECTUV: number;
  8025. BUMP: boolean;
  8026. BUMPDIRECTUV: number;
  8027. PARALLAX: boolean;
  8028. PARALLAXOCCLUSION: boolean;
  8029. SPECULAROVERALPHA: boolean;
  8030. CLIPPLANE: boolean;
  8031. ALPHATEST: boolean;
  8032. DEPTHPREPASS: boolean;
  8033. ALPHAFROMDIFFUSE: boolean;
  8034. POINTSIZE: boolean;
  8035. FOG: boolean;
  8036. SPECULARTERM: boolean;
  8037. DIFFUSEFRESNEL: boolean;
  8038. OPACITYFRESNEL: boolean;
  8039. REFLECTIONFRESNEL: boolean;
  8040. REFRACTIONFRESNEL: boolean;
  8041. EMISSIVEFRESNEL: boolean;
  8042. FRESNEL: boolean;
  8043. NORMAL: boolean;
  8044. UV1: boolean;
  8045. UV2: boolean;
  8046. VERTEXCOLOR: boolean;
  8047. VERTEXALPHA: boolean;
  8048. NUM_BONE_INFLUENCERS: number;
  8049. BonesPerMesh: number;
  8050. INSTANCES: boolean;
  8051. GLOSSINESS: boolean;
  8052. ROUGHNESS: boolean;
  8053. EMISSIVEASILLUMINATION: boolean;
  8054. LINKEMISSIVEWITHDIFFUSE: boolean;
  8055. REFLECTIONFRESNELFROMSPECULAR: boolean;
  8056. LIGHTMAP: boolean;
  8057. LIGHTMAPDIRECTUV: number;
  8058. USELIGHTMAPASSHADOWMAP: boolean;
  8059. REFLECTIONMAP_3D: boolean;
  8060. REFLECTIONMAP_SPHERICAL: boolean;
  8061. REFLECTIONMAP_PLANAR: boolean;
  8062. REFLECTIONMAP_CUBIC: boolean;
  8063. REFLECTIONMAP_PROJECTION: boolean;
  8064. REFLECTIONMAP_SKYBOX: boolean;
  8065. REFLECTIONMAP_EXPLICIT: boolean;
  8066. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  8067. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  8068. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  8069. INVERTCUBICMAP: boolean;
  8070. LOGARITHMICDEPTH: boolean;
  8071. REFRACTION: boolean;
  8072. REFRACTIONMAP_3D: boolean;
  8073. REFLECTIONOVERALPHA: boolean;
  8074. TWOSIDEDLIGHTING: boolean;
  8075. SHADOWFLOAT: boolean;
  8076. MORPHTARGETS: boolean;
  8077. MORPHTARGETS_NORMAL: boolean;
  8078. MORPHTARGETS_TANGENT: boolean;
  8079. NUM_MORPH_INFLUENCERS: number;
  8080. NONUNIFORMSCALING: boolean;
  8081. PREMULTIPLYALPHA: boolean;
  8082. IMAGEPROCESSING: boolean;
  8083. VIGNETTE: boolean;
  8084. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8085. VIGNETTEBLENDMODEOPAQUE: boolean;
  8086. TONEMAPPING: boolean;
  8087. CONTRAST: boolean;
  8088. COLORCURVES: boolean;
  8089. COLORGRADING: boolean;
  8090. COLORGRADING3D: boolean;
  8091. SAMPLER3DGREENDEPTH: boolean;
  8092. SAMPLER3DBGRMAP: boolean;
  8093. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8094. EXPOSURE: boolean;
  8095. constructor();
  8096. setReflectionMode(modeToEnable: string): void;
  8097. }
  8098. class StandardMaterial extends PushMaterial {
  8099. private _diffuseTexture;
  8100. diffuseTexture: Nullable<BaseTexture>;
  8101. private _ambientTexture;
  8102. ambientTexture: Nullable<BaseTexture>;
  8103. private _opacityTexture;
  8104. opacityTexture: Nullable<BaseTexture>;
  8105. private _reflectionTexture;
  8106. reflectionTexture: Nullable<BaseTexture>;
  8107. private _emissiveTexture;
  8108. emissiveTexture: Nullable<BaseTexture>;
  8109. private _specularTexture;
  8110. specularTexture: Nullable<BaseTexture>;
  8111. private _bumpTexture;
  8112. bumpTexture: Nullable<BaseTexture>;
  8113. private _lightmapTexture;
  8114. lightmapTexture: Nullable<BaseTexture>;
  8115. private _refractionTexture;
  8116. refractionTexture: Nullable<BaseTexture>;
  8117. ambientColor: Color3;
  8118. diffuseColor: Color3;
  8119. specularColor: Color3;
  8120. emissiveColor: Color3;
  8121. specularPower: number;
  8122. private _useAlphaFromDiffuseTexture;
  8123. useAlphaFromDiffuseTexture: boolean;
  8124. private _useEmissiveAsIllumination;
  8125. useEmissiveAsIllumination: boolean;
  8126. private _linkEmissiveWithDiffuse;
  8127. linkEmissiveWithDiffuse: boolean;
  8128. private _useSpecularOverAlpha;
  8129. useSpecularOverAlpha: boolean;
  8130. private _useReflectionOverAlpha;
  8131. useReflectionOverAlpha: boolean;
  8132. private _disableLighting;
  8133. disableLighting: boolean;
  8134. private _useParallax;
  8135. useParallax: boolean;
  8136. private _useParallaxOcclusion;
  8137. useParallaxOcclusion: boolean;
  8138. parallaxScaleBias: number;
  8139. private _roughness;
  8140. roughness: number;
  8141. indexOfRefraction: number;
  8142. invertRefractionY: boolean;
  8143. private _useLightmapAsShadowmap;
  8144. useLightmapAsShadowmap: boolean;
  8145. private _diffuseFresnelParameters;
  8146. diffuseFresnelParameters: FresnelParameters;
  8147. private _opacityFresnelParameters;
  8148. opacityFresnelParameters: FresnelParameters;
  8149. private _reflectionFresnelParameters;
  8150. reflectionFresnelParameters: FresnelParameters;
  8151. private _refractionFresnelParameters;
  8152. refractionFresnelParameters: FresnelParameters;
  8153. private _emissiveFresnelParameters;
  8154. emissiveFresnelParameters: FresnelParameters;
  8155. private _useReflectionFresnelFromSpecular;
  8156. useReflectionFresnelFromSpecular: boolean;
  8157. private _useGlossinessFromSpecularMapAlpha;
  8158. useGlossinessFromSpecularMapAlpha: boolean;
  8159. private _maxSimultaneousLights;
  8160. maxSimultaneousLights: number;
  8161. /**
  8162. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  8163. */
  8164. private _invertNormalMapX;
  8165. invertNormalMapX: boolean;
  8166. /**
  8167. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  8168. */
  8169. private _invertNormalMapY;
  8170. invertNormalMapY: boolean;
  8171. /**
  8172. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  8173. */
  8174. private _twoSidedLighting;
  8175. twoSidedLighting: boolean;
  8176. /**
  8177. * Default configuration related to image processing available in the standard Material.
  8178. */
  8179. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  8180. /**
  8181. * Gets the image processing configuration used either in this material.
  8182. */
  8183. /**
  8184. * Sets the Default image processing configuration used either in the this material.
  8185. *
  8186. * If sets to null, the scene one is in use.
  8187. */
  8188. imageProcessingConfiguration: ImageProcessingConfiguration;
  8189. /**
  8190. * Keep track of the image processing observer to allow dispose and replace.
  8191. */
  8192. private _imageProcessingObserver;
  8193. /**
  8194. * Attaches a new image processing configuration to the Standard Material.
  8195. * @param configuration
  8196. */
  8197. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  8198. /**
  8199. * Gets wether the color curves effect is enabled.
  8200. */
  8201. /**
  8202. * Sets wether the color curves effect is enabled.
  8203. */
  8204. cameraColorCurvesEnabled: boolean;
  8205. /**
  8206. * Gets wether the color grading effect is enabled.
  8207. */
  8208. /**
  8209. * Gets wether the color grading effect is enabled.
  8210. */
  8211. cameraColorGradingEnabled: boolean;
  8212. /**
  8213. * Gets wether tonemapping is enabled or not.
  8214. */
  8215. /**
  8216. * Sets wether tonemapping is enabled or not
  8217. */
  8218. cameraToneMappingEnabled: boolean;
  8219. /**
  8220. * The camera exposure used on this material.
  8221. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  8222. * This corresponds to a photographic exposure.
  8223. */
  8224. /**
  8225. * The camera exposure used on this material.
  8226. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  8227. * This corresponds to a photographic exposure.
  8228. */
  8229. cameraExposure: number;
  8230. /**
  8231. * Gets The camera contrast used on this material.
  8232. */
  8233. /**
  8234. * Sets The camera contrast used on this material.
  8235. */
  8236. cameraContrast: number;
  8237. /**
  8238. * Gets the Color Grading 2D Lookup Texture.
  8239. */
  8240. /**
  8241. * Sets the Color Grading 2D Lookup Texture.
  8242. */
  8243. cameraColorGradingTexture: Nullable<BaseTexture>;
  8244. /**
  8245. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8246. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8247. * 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;
  8248. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8249. */
  8250. /**
  8251. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8252. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8253. * 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;
  8254. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8255. */
  8256. cameraColorCurves: Nullable<ColorCurves>;
  8257. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  8258. protected _renderTargets: SmartArray<RenderTargetTexture>;
  8259. protected _worldViewProjectionMatrix: Matrix;
  8260. protected _globalAmbientColor: Color3;
  8261. protected _useLogarithmicDepth: boolean;
  8262. constructor(name: string, scene: Scene);
  8263. getClassName(): string;
  8264. useLogarithmicDepth: boolean;
  8265. needAlphaBlending(): boolean;
  8266. needAlphaTesting(): boolean;
  8267. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  8268. getAlphaTestTexture(): Nullable<BaseTexture>;
  8269. /**
  8270. * Child classes can use it to update shaders
  8271. */
  8272. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  8273. buildUniformLayout(): void;
  8274. unbind(): void;
  8275. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  8276. getAnimatables(): IAnimatable[];
  8277. getActiveTextures(): BaseTexture[];
  8278. hasTexture(texture: BaseTexture): boolean;
  8279. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  8280. clone(name: string): StandardMaterial;
  8281. serialize(): any;
  8282. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  8283. static _DiffuseTextureEnabled: boolean;
  8284. static DiffuseTextureEnabled: boolean;
  8285. static _AmbientTextureEnabled: boolean;
  8286. static AmbientTextureEnabled: boolean;
  8287. static _OpacityTextureEnabled: boolean;
  8288. static OpacityTextureEnabled: boolean;
  8289. static _ReflectionTextureEnabled: boolean;
  8290. static ReflectionTextureEnabled: boolean;
  8291. static _EmissiveTextureEnabled: boolean;
  8292. static EmissiveTextureEnabled: boolean;
  8293. static _SpecularTextureEnabled: boolean;
  8294. static SpecularTextureEnabled: boolean;
  8295. static _BumpTextureEnabled: boolean;
  8296. static BumpTextureEnabled: boolean;
  8297. static _LightmapTextureEnabled: boolean;
  8298. static LightmapTextureEnabled: boolean;
  8299. static _RefractionTextureEnabled: boolean;
  8300. static RefractionTextureEnabled: boolean;
  8301. static _ColorGradingTextureEnabled: boolean;
  8302. static ColorGradingTextureEnabled: boolean;
  8303. static _FresnelEnabled: boolean;
  8304. static FresnelEnabled: boolean;
  8305. }
  8306. }
  8307. declare module BABYLON {
  8308. class UniformBuffer {
  8309. private _engine;
  8310. private _buffer;
  8311. private _data;
  8312. private _bufferData;
  8313. private _dynamic?;
  8314. private _uniformLocations;
  8315. private _uniformSizes;
  8316. private _uniformLocationPointer;
  8317. private _needSync;
  8318. private _noUBO;
  8319. private _currentEffect;
  8320. private static _MAX_UNIFORM_SIZE;
  8321. private static _tempBuffer;
  8322. /**
  8323. * Wrapper for updateUniform.
  8324. * @method updateMatrix3x3
  8325. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8326. * @param {Float32Array} matrix
  8327. */
  8328. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8329. /**
  8330. * Wrapper for updateUniform.
  8331. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8332. * @param {Float32Array} matrix
  8333. */
  8334. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8335. /**
  8336. * Wrapper for updateUniform.
  8337. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8338. * @param {number} x
  8339. */
  8340. updateFloat: (name: string, x: number) => void;
  8341. /**
  8342. * Wrapper for updateUniform.
  8343. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8344. * @param {number} x
  8345. * @param {number} y
  8346. * @param {string} [suffix] Suffix to add to the uniform name.
  8347. */
  8348. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8349. /**
  8350. * Wrapper for updateUniform.
  8351. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8352. * @param {number} x
  8353. * @param {number} y
  8354. * @param {number} z
  8355. * @param {string} [suffix] Suffix to add to the uniform name.
  8356. */
  8357. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8358. /**
  8359. * Wrapper for updateUniform.
  8360. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8361. * @param {number} x
  8362. * @param {number} y
  8363. * @param {number} z
  8364. * @param {number} w
  8365. * @param {string} [suffix] Suffix to add to the uniform name.
  8366. */
  8367. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8368. /**
  8369. * Wrapper for updateUniform.
  8370. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8371. * @param {Matrix} A 4x4 matrix.
  8372. */
  8373. updateMatrix: (name: string, mat: Matrix) => void;
  8374. /**
  8375. * Wrapper for updateUniform.
  8376. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8377. * @param {Vector3} vector
  8378. */
  8379. updateVector3: (name: string, vector: Vector3) => void;
  8380. /**
  8381. * Wrapper for updateUniform.
  8382. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8383. * @param {Vector4} vector
  8384. */
  8385. updateVector4: (name: string, vector: Vector4) => void;
  8386. /**
  8387. * Wrapper for updateUniform.
  8388. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8389. * @param {Color3} color
  8390. * @param {string} [suffix] Suffix to add to the uniform name.
  8391. */
  8392. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8393. /**
  8394. * Wrapper for updateUniform.
  8395. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8396. * @param {Color3} color
  8397. * @param {number} alpha
  8398. * @param {string} [suffix] Suffix to add to the uniform name.
  8399. */
  8400. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8401. /**
  8402. * Uniform buffer objects.
  8403. *
  8404. * Handles blocks of uniform on the GPU.
  8405. *
  8406. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8407. *
  8408. * For more information, please refer to :
  8409. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8410. */
  8411. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  8412. /**
  8413. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8414. * or just falling back on setUniformXXX calls.
  8415. */
  8416. readonly useUbo: boolean;
  8417. /**
  8418. * Indicates if the WebGL underlying uniform buffer is in sync
  8419. * with the javascript cache data.
  8420. */
  8421. readonly isSync: boolean;
  8422. /**
  8423. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8424. * Also, a dynamic UniformBuffer will disable cache verification and always
  8425. * update the underlying WebGL uniform buffer to the GPU.
  8426. */
  8427. isDynamic(): boolean;
  8428. /**
  8429. * The data cache on JS side.
  8430. */
  8431. getData(): Float32Array;
  8432. /**
  8433. * The underlying WebGL Uniform buffer.
  8434. */
  8435. getBuffer(): Nullable<WebGLBuffer>;
  8436. /**
  8437. * std140 layout specifies how to align data within an UBO structure.
  8438. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8439. * for specs.
  8440. */
  8441. private _fillAlignment(size);
  8442. /**
  8443. * Adds an uniform in the buffer.
  8444. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8445. * for the layout to be correct !
  8446. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8447. * @param {number|number[]} size Data size, or data directly.
  8448. */
  8449. addUniform(name: string, size: number | number[]): void;
  8450. /**
  8451. * Wrapper for addUniform.
  8452. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8453. * @param {Matrix} mat A 4x4 matrix.
  8454. */
  8455. addMatrix(name: string, mat: Matrix): void;
  8456. /**
  8457. * Wrapper for addUniform.
  8458. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8459. * @param {number} x
  8460. * @param {number} y
  8461. */
  8462. addFloat2(name: string, x: number, y: number): void;
  8463. /**
  8464. * Wrapper for addUniform.
  8465. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8466. * @param {number} x
  8467. * @param {number} y
  8468. * @param {number} z
  8469. */
  8470. addFloat3(name: string, x: number, y: number, z: number): void;
  8471. /**
  8472. * Wrapper for addUniform.
  8473. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8474. * @param {Color3} color
  8475. */
  8476. addColor3(name: string, color: Color3): void;
  8477. /**
  8478. * Wrapper for addUniform.
  8479. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8480. * @param {Color3} color
  8481. * @param {number} alpha
  8482. */
  8483. addColor4(name: string, color: Color3, alpha: number): void;
  8484. /**
  8485. * Wrapper for addUniform.
  8486. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8487. * @param {Vector3} vector
  8488. */
  8489. addVector3(name: string, vector: Vector3): void;
  8490. /**
  8491. * Wrapper for addUniform.
  8492. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8493. */
  8494. addMatrix3x3(name: string): void;
  8495. /**
  8496. * Wrapper for addUniform.
  8497. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  8498. */
  8499. addMatrix2x2(name: string): void;
  8500. /**
  8501. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8502. */
  8503. create(): void;
  8504. _rebuild(): void;
  8505. /**
  8506. * Updates the WebGL Uniform Buffer on the GPU.
  8507. * If the `dynamic` flag is set to true, no cache comparison is done.
  8508. * Otherwise, the buffer will be updated only if the cache differs.
  8509. */
  8510. update(): void;
  8511. /**
  8512. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8513. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  8514. * @param {number[]|Float32Array} data Flattened data
  8515. * @param {number} size Size of the data.
  8516. */
  8517. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8518. private _updateMatrix3x3ForUniform(name, matrix);
  8519. private _updateMatrix3x3ForEffect(name, matrix);
  8520. private _updateMatrix2x2ForEffect(name, matrix);
  8521. private _updateMatrix2x2ForUniform(name, matrix);
  8522. private _updateFloatForEffect(name, x);
  8523. private _updateFloatForUniform(name, x);
  8524. private _updateFloat2ForEffect(name, x, y, suffix?);
  8525. private _updateFloat2ForUniform(name, x, y, suffix?);
  8526. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  8527. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  8528. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  8529. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  8530. private _updateMatrixForEffect(name, mat);
  8531. private _updateMatrixForUniform(name, mat);
  8532. private _updateVector3ForEffect(name, vector);
  8533. private _updateVector3ForUniform(name, vector);
  8534. private _updateVector4ForEffect(name, vector);
  8535. private _updateVector4ForUniform(name, vector);
  8536. private _updateColor3ForEffect(name, color, suffix?);
  8537. private _updateColor3ForUniform(name, color, suffix?);
  8538. private _updateColor4ForEffect(name, color, alpha, suffix?);
  8539. private _updateColor4ForUniform(name, color, alpha, suffix?);
  8540. /**
  8541. * Sets a sampler uniform on the effect.
  8542. * @param {string} name Name of the sampler.
  8543. * @param {Texture} texture
  8544. */
  8545. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8546. /**
  8547. * Directly updates the value of the uniform in the cache AND on the GPU.
  8548. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  8549. * @param {number[]|Float32Array} data Flattened data
  8550. */
  8551. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8552. /**
  8553. * Binds this uniform buffer to an effect.
  8554. * @param {Effect} effect
  8555. * @param {string} name Name of the uniform block in the shader.
  8556. */
  8557. bindToEffect(effect: Effect, name: string): void;
  8558. /**
  8559. * Disposes the uniform buffer.
  8560. */
  8561. dispose(): void;
  8562. }
  8563. }
  8564. declare module BABYLON {
  8565. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  8566. static OCCLUSION_TYPE_NONE: number;
  8567. static OCCLUSION_TYPE_OPTIMISTIC: number;
  8568. static OCCLUSION_TYPE_STRICT: number;
  8569. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  8570. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  8571. static readonly BILLBOARDMODE_NONE: number;
  8572. static readonly BILLBOARDMODE_X: number;
  8573. static readonly BILLBOARDMODE_Y: number;
  8574. static readonly BILLBOARDMODE_Z: number;
  8575. static readonly BILLBOARDMODE_ALL: number;
  8576. private _facetPositions;
  8577. private _facetNormals;
  8578. private _facetPartitioning;
  8579. private _facetNb;
  8580. private _partitioningSubdivisions;
  8581. private _partitioningBBoxRatio;
  8582. private _facetDataEnabled;
  8583. private _facetParameters;
  8584. private _bbSize;
  8585. private _subDiv;
  8586. private _facetDepthSort;
  8587. private _facetDepthSortEnabled;
  8588. private _depthSortedIndices;
  8589. private _depthSortedFacets;
  8590. private _facetDepthSortFunction;
  8591. private _facetDepthSortFrom;
  8592. private _facetDepthSortOrigin;
  8593. private _invertedMatrix;
  8594. /**
  8595. * Read-only : the number of facets in the mesh
  8596. */
  8597. readonly facetNb: number;
  8598. /**
  8599. * The number (integer) of subdivisions per axis in the partioning space
  8600. */
  8601. partitioningSubdivisions: number;
  8602. /**
  8603. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  8604. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box.
  8605. */
  8606. partitioningBBoxRatio: number;
  8607. /**
  8608. * Boolean : must the facet be depth sorted on next call to `updateFacetData()` ?
  8609. * Works only for updatable meshes.
  8610. * Doesn't work with multi-materials.
  8611. */
  8612. mustDepthSortFacets: boolean;
  8613. /**
  8614. * The location (Vector3) where the facet depth sort must be computed from.
  8615. * By default, the active camera position.
  8616. * Used only when facet depth sort is enabled.
  8617. */
  8618. facetDepthSortFrom: Vector3;
  8619. /**
  8620. * Read-only boolean : is the feature facetData enabled ?
  8621. */
  8622. readonly isFacetDataEnabled: boolean;
  8623. _updateNonUniformScalingState(value: boolean): boolean;
  8624. /**
  8625. * An event triggered when this mesh collides with another one
  8626. * @type {BABYLON.Observable}
  8627. */
  8628. onCollideObservable: Observable<AbstractMesh>;
  8629. private _onCollideObserver;
  8630. onCollide: () => void;
  8631. /**
  8632. * An event triggered when the collision's position changes
  8633. * @type {BABYLON.Observable}
  8634. */
  8635. onCollisionPositionChangeObservable: Observable<Vector3>;
  8636. private _onCollisionPositionChangeObserver;
  8637. onCollisionPositionChange: () => void;
  8638. /**
  8639. * An event triggered when material is changed
  8640. * @type {BABYLON.Observable}
  8641. */
  8642. onMaterialChangedObservable: Observable<AbstractMesh>;
  8643. definedFacingForward: boolean;
  8644. /**
  8645. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  8646. * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  8647. * or
  8648. * 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.
  8649. * for more info check WebGl documentations
  8650. */
  8651. occlusionQueryAlgorithmType: number;
  8652. /**
  8653. * 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:
  8654. * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  8655. * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  8656. * 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.
  8657. */
  8658. occlusionType: number;
  8659. /**
  8660. * 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.
  8661. * The default value is -1 which means don't break the query and wait till the result.
  8662. */
  8663. occlusionRetryCount: number;
  8664. private _occlusionInternalRetryCounter;
  8665. protected _isOccluded: boolean;
  8666. /**
  8667. * 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.
  8668. */
  8669. isOccluded: boolean;
  8670. private _isOcclusionQueryInProgress;
  8671. /**
  8672. * Flag to check the progress status of the query
  8673. */
  8674. readonly isOcclusionQueryInProgress: boolean;
  8675. private _occlusionQuery;
  8676. private _visibility;
  8677. /**
  8678. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  8679. */
  8680. /**
  8681. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  8682. */
  8683. visibility: number;
  8684. alphaIndex: number;
  8685. isVisible: boolean;
  8686. isPickable: boolean;
  8687. showBoundingBox: boolean;
  8688. showSubMeshesBoundingBox: boolean;
  8689. isBlocker: boolean;
  8690. enablePointerMoveEvents: boolean;
  8691. renderingGroupId: number;
  8692. private _material;
  8693. material: Nullable<Material>;
  8694. private _receiveShadows;
  8695. receiveShadows: boolean;
  8696. renderOutline: boolean;
  8697. outlineColor: Color3;
  8698. outlineWidth: number;
  8699. renderOverlay: boolean;
  8700. overlayColor: Color3;
  8701. overlayAlpha: number;
  8702. private _hasVertexAlpha;
  8703. hasVertexAlpha: boolean;
  8704. private _useVertexColors;
  8705. useVertexColors: boolean;
  8706. private _computeBonesUsingShaders;
  8707. computeBonesUsingShaders: boolean;
  8708. private _numBoneInfluencers;
  8709. numBoneInfluencers: number;
  8710. private _applyFog;
  8711. applyFog: boolean;
  8712. useOctreeForRenderingSelection: boolean;
  8713. useOctreeForPicking: boolean;
  8714. useOctreeForCollisions: boolean;
  8715. private _layerMask;
  8716. layerMask: number;
  8717. /**
  8718. * True if the mesh must be rendered in any case.
  8719. */
  8720. alwaysSelectAsActiveMesh: boolean;
  8721. /**
  8722. * This scene's action manager
  8723. * @type {BABYLON.ActionManager}
  8724. */
  8725. actionManager: Nullable<ActionManager>;
  8726. physicsImpostor: Nullable<PhysicsImpostor>;
  8727. private _checkCollisions;
  8728. private _collisionMask;
  8729. private _collisionGroup;
  8730. ellipsoid: Vector3;
  8731. ellipsoidOffset: Vector3;
  8732. private _collider;
  8733. private _oldPositionForCollisions;
  8734. private _diffPositionForCollisions;
  8735. collisionMask: number;
  8736. collisionGroup: number;
  8737. edgesWidth: number;
  8738. edgesColor: Color4;
  8739. _edgesRenderer: Nullable<EdgesRenderer>;
  8740. private _collisionsTransformMatrix;
  8741. private _collisionsScalingMatrix;
  8742. _masterMesh: Nullable<AbstractMesh>;
  8743. _boundingInfo: Nullable<BoundingInfo>;
  8744. _isDisposed: boolean;
  8745. _renderId: number;
  8746. subMeshes: SubMesh[];
  8747. _submeshesOctree: Octree<SubMesh>;
  8748. _intersectionsInProgress: AbstractMesh[];
  8749. _unIndexed: boolean;
  8750. _lightSources: Light[];
  8751. readonly _positions: Nullable<Vector3[]>;
  8752. _waitingActions: any;
  8753. _waitingFreezeWorldMatrix: Nullable<boolean>;
  8754. private _skeleton;
  8755. _bonesTransformMatrices: Nullable<Float32Array>;
  8756. skeleton: Nullable<Skeleton>;
  8757. constructor(name: string, scene?: Nullable<Scene>);
  8758. /**
  8759. * Boolean : true if the mesh has been disposed.
  8760. */
  8761. isDisposed(): boolean;
  8762. /**
  8763. * Returns the string "AbstractMesh"
  8764. */
  8765. getClassName(): string;
  8766. /**
  8767. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  8768. */
  8769. toString(fullDetails?: boolean): string;
  8770. _rebuild(): void;
  8771. _resyncLightSources(): void;
  8772. _resyncLighSource(light: Light): void;
  8773. _removeLightSource(light: Light): void;
  8774. private _markSubMeshesAsDirty(func);
  8775. _markSubMeshesAsLightDirty(): void;
  8776. _markSubMeshesAsAttributesDirty(): void;
  8777. _markSubMeshesAsMiscDirty(): void;
  8778. /**
  8779. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  8780. * Default : (1.0, 1.0, 1.0)
  8781. */
  8782. /**
  8783. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  8784. * Default : (1.0, 1.0, 1.0)
  8785. */
  8786. scaling: Vector3;
  8787. /**
  8788. * Disables the mesh edger rendering mode.
  8789. * Returns the AbstractMesh.
  8790. */
  8791. disableEdgesRendering(): AbstractMesh;
  8792. /**
  8793. * Enables the edge rendering mode on the mesh.
  8794. * This mode makes the mesh edges visible.
  8795. * Returns the AbstractMesh.
  8796. */
  8797. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  8798. /**
  8799. * Returns true if the mesh is blocked. Used by the class Mesh.
  8800. * Returns the boolean `false` by default.
  8801. */
  8802. readonly isBlocked: boolean;
  8803. /**
  8804. * Returns the mesh itself by default, used by the class Mesh.
  8805. * Returned type : AbstractMesh
  8806. */
  8807. getLOD(camera: Camera): AbstractMesh;
  8808. /**
  8809. * Returns 0 by default, used by the class Mesh.
  8810. * Returns an integer.
  8811. */
  8812. getTotalVertices(): number;
  8813. /**
  8814. * Returns null by default, used by the class Mesh.
  8815. * Returned type : integer array
  8816. */
  8817. getIndices(): Nullable<IndicesArray>;
  8818. /**
  8819. * Returns the array of the requested vertex data kind. Used by the class Mesh. Returns null here.
  8820. * Returned type : float array or Float32Array
  8821. */
  8822. getVerticesData(kind: string): Nullable<FloatArray>;
  8823. /**
  8824. * Sets the vertex data of the mesh geometry for the requested `kind`.
  8825. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  8826. * The `data` are either a numeric array either a Float32Array.
  8827. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  8828. * 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).
  8829. * Note that a new underlying VertexBuffer object is created each call.
  8830. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  8831. *
  8832. * Possible `kind` values :
  8833. * - BABYLON.VertexBuffer.PositionKind
  8834. * - BABYLON.VertexBuffer.UVKind
  8835. * - BABYLON.VertexBuffer.UV2Kind
  8836. * - BABYLON.VertexBuffer.UV3Kind
  8837. * - BABYLON.VertexBuffer.UV4Kind
  8838. * - BABYLON.VertexBuffer.UV5Kind
  8839. * - BABYLON.VertexBuffer.UV6Kind
  8840. * - BABYLON.VertexBuffer.ColorKind
  8841. * - BABYLON.VertexBuffer.MatricesIndicesKind
  8842. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  8843. * - BABYLON.VertexBuffer.MatricesWeightsKind
  8844. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  8845. *
  8846. * Returns the Mesh.
  8847. */
  8848. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  8849. /**
  8850. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  8851. * If the mesh has no geometry, it is simply returned as it is.
  8852. * The `data` are either a numeric array either a Float32Array.
  8853. * No new underlying VertexBuffer object is created.
  8854. * 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.
  8855. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  8856. *
  8857. * Possible `kind` values :
  8858. * - BABYLON.VertexBuffer.PositionKind
  8859. * - BABYLON.VertexBuffer.UVKind
  8860. * - BABYLON.VertexBuffer.UV2Kind
  8861. * - BABYLON.VertexBuffer.UV3Kind
  8862. * - BABYLON.VertexBuffer.UV4Kind
  8863. * - BABYLON.VertexBuffer.UV5Kind
  8864. * - BABYLON.VertexBuffer.UV6Kind
  8865. * - BABYLON.VertexBuffer.ColorKind
  8866. * - BABYLON.VertexBuffer.MatricesIndicesKind
  8867. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  8868. * - BABYLON.VertexBuffer.MatricesWeightsKind
  8869. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  8870. *
  8871. * Returns the Mesh.
  8872. */
  8873. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  8874. /**
  8875. * Sets the mesh indices.
  8876. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  8877. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  8878. * This method creates a new index buffer each call.
  8879. * Returns the Mesh.
  8880. */
  8881. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  8882. /** Returns false by default, used by the class Mesh.
  8883. * Returns a boolean
  8884. */
  8885. isVerticesDataPresent(kind: string): boolean;
  8886. /**
  8887. * Returns the mesh BoundingInfo object or creates a new one and returns it if undefined.
  8888. * Returns a BoundingInfo
  8889. */
  8890. getBoundingInfo(): BoundingInfo;
  8891. /**
  8892. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units).
  8893. * @param includeDescendants Take the hierarchy's bounding box instead of the mesh's bounding box.
  8894. */
  8895. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  8896. /**
  8897. * Sets a mesh new object BoundingInfo.
  8898. * Returns the AbstractMesh.
  8899. */
  8900. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  8901. readonly useBones: boolean;
  8902. _preActivate(): void;
  8903. _preActivateForIntermediateRendering(renderId: number): void;
  8904. _activate(renderId: number): void;
  8905. /**
  8906. * Returns the latest update of the World matrix
  8907. * Returns a Matrix.
  8908. */
  8909. getWorldMatrix(): Matrix;
  8910. /**
  8911. * Returns the latest update of the World matrix determinant.
  8912. */
  8913. protected _getWorldMatrixDeterminant(): number;
  8914. /**
  8915. * Perform relative position change from the point of view of behind the front of the mesh.
  8916. * This is performed taking into account the meshes current rotation, so you do not have to care.
  8917. * Supports definition of mesh facing forward or backward.
  8918. * @param {number} amountRight
  8919. * @param {number} amountUp
  8920. * @param {number} amountForward
  8921. *
  8922. * Returns the AbstractMesh.
  8923. */
  8924. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  8925. /**
  8926. * Calculate relative position change from the point of view of behind the front of the mesh.
  8927. * This is performed taking into account the meshes current rotation, so you do not have to care.
  8928. * Supports definition of mesh facing forward or backward.
  8929. * @param {number} amountRight
  8930. * @param {number} amountUp
  8931. * @param {number} amountForward
  8932. *
  8933. * Returns a new Vector3.
  8934. */
  8935. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  8936. /**
  8937. * Perform relative rotation change from the point of view of behind the front of the mesh.
  8938. * Supports definition of mesh facing forward or backward.
  8939. * @param {number} flipBack
  8940. * @param {number} twirlClockwise
  8941. * @param {number} tiltRight
  8942. *
  8943. * Returns the AbstractMesh.
  8944. */
  8945. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  8946. /**
  8947. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  8948. * Supports definition of mesh facing forward or backward.
  8949. * @param {number} flipBack
  8950. * @param {number} twirlClockwise
  8951. * @param {number} tiltRight
  8952. *
  8953. * Returns a new Vector3.
  8954. */
  8955. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  8956. /**
  8957. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  8958. * @param includeDescendants Include bounding info from descendants as well (true by default).
  8959. */
  8960. getHierarchyBoundingVectors(includeDescendants?: boolean): {
  8961. min: Vector3;
  8962. max: Vector3;
  8963. };
  8964. /**
  8965. * Updates the mesh BoundingInfo object and all its children BoundingInfo objects also.
  8966. * Returns the AbstractMesh.
  8967. */
  8968. _updateBoundingInfo(): AbstractMesh;
  8969. /**
  8970. * Update a mesh's children BoundingInfo objects only.
  8971. * Returns the AbstractMesh.
  8972. */
  8973. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  8974. protected _afterComputeWorldMatrix(): void;
  8975. /**
  8976. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  8977. * A mesh is in the frustum if its bounding box intersects the frustum.
  8978. * Boolean returned.
  8979. */
  8980. isInFrustum(frustumPlanes: Plane[]): boolean;
  8981. /**
  8982. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  8983. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  8984. * Boolean returned.
  8985. */
  8986. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8987. /**
  8988. * True if the mesh intersects another mesh or a SolidParticle object.
  8989. * 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)
  8990. * includeDescendants can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  8991. * Returns a boolean.
  8992. */
  8993. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  8994. /**
  8995. * Returns true if the passed point (Vector3) is inside the mesh bounding box.
  8996. * Returns a boolean.
  8997. */
  8998. intersectsPoint(point: Vector3): boolean;
  8999. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  9000. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  9001. /**
  9002. * Returns the distance from the mesh to the active camera.
  9003. * Returns a float.
  9004. */
  9005. getDistanceToCamera(camera?: Nullable<Camera>): number;
  9006. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  9007. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  9008. /**
  9009. * Property checkCollisions : Boolean, whether the camera should check the collisions against the mesh.
  9010. * Default `false`.
  9011. */
  9012. checkCollisions: boolean;
  9013. /**
  9014. * Gets Collider object used to compute collisions (not physics)
  9015. */
  9016. readonly collider: Collider;
  9017. moveWithCollisions(displacement: Vector3): AbstractMesh;
  9018. private _onCollisionPositionChange;
  9019. /**
  9020. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  9021. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree.
  9022. * Returns an Octree of submeshes.
  9023. */
  9024. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  9025. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  9026. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  9027. _checkCollision(collider: Collider): AbstractMesh;
  9028. _generatePointsArray(): boolean;
  9029. /**
  9030. * Checks if the passed Ray intersects with the mesh.
  9031. * Returns an object PickingInfo.
  9032. */
  9033. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  9034. /**
  9035. * Clones the mesh, used by the class Mesh.
  9036. * Just returns `null` for an AbstractMesh.
  9037. */
  9038. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  9039. /**
  9040. * Disposes all the mesh submeshes.
  9041. * Returns the AbstractMesh.
  9042. */
  9043. releaseSubMeshes(): AbstractMesh;
  9044. /**
  9045. * Disposes the AbstractMesh.
  9046. * By default, all the mesh children are also disposed unless the parameter `doNotRecurse` is set to `true`.
  9047. * Returns nothing.
  9048. */
  9049. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9050. /**
  9051. * Adds the passed mesh as a child to the current mesh.
  9052. * Returns the AbstractMesh.
  9053. */
  9054. addChild(mesh: AbstractMesh): AbstractMesh;
  9055. /**
  9056. * Removes the passed mesh from the current mesh children list.
  9057. * Returns the AbstractMesh.
  9058. */
  9059. removeChild(mesh: AbstractMesh): AbstractMesh;
  9060. /**
  9061. * Initialize the facet data arrays : facetNormals, facetPositions and facetPartitioning.
  9062. * Returns the AbstractMesh.
  9063. */
  9064. private _initFacetData();
  9065. /**
  9066. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  9067. * This method can be called within the render loop.
  9068. * 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.
  9069. * Returns the AbstractMesh.
  9070. */
  9071. updateFacetData(): AbstractMesh;
  9072. /**
  9073. * Returns the facetLocalNormals array.
  9074. * The normals are expressed in the mesh local space.
  9075. */
  9076. getFacetLocalNormals(): Vector3[];
  9077. /**
  9078. * Returns the facetLocalPositions array.
  9079. * The facet positions are expressed in the mesh local space.
  9080. */
  9081. getFacetLocalPositions(): Vector3[];
  9082. /**
  9083. * Returns the facetLocalPartioning array.
  9084. */
  9085. getFacetLocalPartitioning(): number[][];
  9086. /**
  9087. * Returns the i-th facet position in the world system.
  9088. * This method allocates a new Vector3 per call.
  9089. */
  9090. getFacetPosition(i: number): Vector3;
  9091. /**
  9092. * Sets the reference Vector3 with the i-th facet position in the world system.
  9093. * Returns the AbstractMesh.
  9094. */
  9095. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  9096. /**
  9097. * Returns the i-th facet normal in the world system.
  9098. * This method allocates a new Vector3 per call.
  9099. */
  9100. getFacetNormal(i: number): Vector3;
  9101. /**
  9102. * Sets the reference Vector3 with the i-th facet normal in the world system.
  9103. * Returns the AbstractMesh.
  9104. */
  9105. getFacetNormalToRef(i: number, ref: Vector3): this;
  9106. /**
  9107. * 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).
  9108. */
  9109. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  9110. /**
  9111. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found.
  9112. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) World projection on the facet.
  9113. * 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.
  9114. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  9115. * 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.
  9116. */
  9117. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  9118. /**
  9119. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found.
  9120. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) local projection on the facet.
  9121. * 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.
  9122. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  9123. * 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.
  9124. */
  9125. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  9126. /**
  9127. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  9128. */
  9129. getFacetDataParameters(): any;
  9130. /**
  9131. * Disables the feature FacetData and frees the related memory.
  9132. * Returns the AbstractMesh.
  9133. */
  9134. disableFacetData(): AbstractMesh;
  9135. /**
  9136. * Updates the AbstractMesh indices array. Actually, used by the Mesh object.
  9137. * Returns the mesh.
  9138. */
  9139. updateIndices(indices: IndicesArray): AbstractMesh;
  9140. /**
  9141. * The mesh Geometry. Actually used by the Mesh object.
  9142. * Returns a blank geometry object.
  9143. */
  9144. /**
  9145. * Creates new normals data for the mesh.
  9146. * @param updatable.
  9147. */
  9148. createNormals(updatable: boolean): void;
  9149. /**
  9150. * Align the mesh with a normal.
  9151. * Returns the mesh.
  9152. */
  9153. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  9154. protected checkOcclusionQuery(): void;
  9155. }
  9156. }
  9157. declare module BABYLON {
  9158. class Buffer {
  9159. private _engine;
  9160. private _buffer;
  9161. private _data;
  9162. private _updatable;
  9163. private _strideSize;
  9164. private _instanced;
  9165. private _instanceDivisor;
  9166. constructor(engine: any, data: FloatArray, updatable: boolean, stride: number, postponeInternalCreation?: boolean, instanced?: boolean);
  9167. createVertexBuffer(kind: string, offset: number, size: number, stride?: number): VertexBuffer;
  9168. isUpdatable(): boolean;
  9169. getData(): Nullable<FloatArray>;
  9170. getBuffer(): Nullable<WebGLBuffer>;
  9171. getStrideSize(): number;
  9172. getIsInstanced(): boolean;
  9173. instanceDivisor: number;
  9174. create(data?: Nullable<FloatArray>): void;
  9175. _rebuild(): void;
  9176. update(data: FloatArray): void;
  9177. updateDirectly(data: Float32Array, offset: number, vertexCount?: number): void;
  9178. dispose(): void;
  9179. }
  9180. }
  9181. declare module BABYLON {
  9182. class CSG {
  9183. private polygons;
  9184. matrix: Matrix;
  9185. position: Vector3;
  9186. rotation: Vector3;
  9187. rotationQuaternion: Nullable<Quaternion>;
  9188. scaling: Vector3;
  9189. static FromMesh(mesh: Mesh): CSG;
  9190. private static FromPolygons(polygons);
  9191. clone(): CSG;
  9192. union(csg: CSG): CSG;
  9193. unionInPlace(csg: CSG): void;
  9194. subtract(csg: CSG): CSG;
  9195. subtractInPlace(csg: CSG): void;
  9196. intersect(csg: CSG): CSG;
  9197. intersectInPlace(csg: CSG): void;
  9198. inverse(): CSG;
  9199. inverseInPlace(): void;
  9200. copyTransformAttributes(csg: CSG): CSG;
  9201. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  9202. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  9203. }
  9204. }
  9205. declare module BABYLON {
  9206. /**
  9207. * Class used to store geometry data (vertex buffers + index buffer)
  9208. */
  9209. class Geometry implements IGetSetVerticesData {
  9210. /**
  9211. * Gets or sets the unique ID of the geometry
  9212. */
  9213. id: string;
  9214. /**
  9215. * Gets the delay loading state of the geometry (none by default which means not delayed)
  9216. */
  9217. delayLoadState: number;
  9218. /**
  9219. * Gets the file containing the data to load when running in delay load state
  9220. */
  9221. delayLoadingFile: Nullable<string>;
  9222. /**
  9223. * Callback called when the geometry is updated
  9224. */
  9225. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  9226. private _scene;
  9227. private _engine;
  9228. private _meshes;
  9229. private _totalVertices;
  9230. private _indices;
  9231. private _vertexBuffers;
  9232. private _isDisposed;
  9233. private _extend;
  9234. private _boundingBias;
  9235. /** @ignore */
  9236. _delayInfo: Array<string>;
  9237. private _indexBuffer;
  9238. private _indexBufferIsUpdatable;
  9239. /** @ignore */
  9240. _boundingInfo: Nullable<BoundingInfo>;
  9241. /** @ignore */
  9242. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  9243. /** @ignore */
  9244. _softwareSkinningRenderId: number;
  9245. private _vertexArrayObjects;
  9246. private _updatable;
  9247. /** @ignore */
  9248. _positions: Nullable<Vector3[]>;
  9249. /**
  9250. * 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
  9251. */
  9252. /**
  9253. * 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
  9254. */
  9255. boundingBias: Vector2;
  9256. /**
  9257. * Static function used to attach a new empty geometry to a mesh
  9258. * @param mesh defines the mesh to attach the geometry to
  9259. * @returns the new {BABYLON.Geometry}
  9260. */
  9261. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  9262. /**
  9263. * Creates a new geometry
  9264. * @param id defines the unique ID
  9265. * @param scene defines the hosting scene
  9266. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  9267. * @param updatable defines if geometry must be updatable (false by default)
  9268. * @param mesh defines the mesh that will be associated with the geometry
  9269. */
  9270. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  9271. /**
  9272. * Gets the current extend of the geometry
  9273. */
  9274. readonly extend: {
  9275. minimum: Vector3;
  9276. maximum: Vector3;
  9277. };
  9278. /**
  9279. * Gets the hosting scene
  9280. * @returns the hosting {BABYLON.Scene}
  9281. */
  9282. getScene(): Scene;
  9283. /**
  9284. * Gets the hosting engine
  9285. * @returns the hosting {BABYLON.Engine}
  9286. */
  9287. getEngine(): Engine;
  9288. /**
  9289. * Defines if the geometry is ready to use
  9290. * @returns true if the geometry is ready to be used
  9291. */
  9292. isReady(): boolean;
  9293. /**
  9294. * Gets a value indicating that the geometry should not be serialized
  9295. */
  9296. readonly doNotSerialize: boolean;
  9297. /** @ignore */
  9298. _rebuild(): void;
  9299. /**
  9300. * Affects all gemetry data in one call
  9301. * @param vertexData defines the geometry data
  9302. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  9303. */
  9304. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  9305. /**
  9306. * Set specific vertex data
  9307. * @param kind defines the data kind (Position, normal, etc...)
  9308. * @param data defines the vertex data to use
  9309. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  9310. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  9311. */
  9312. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  9313. /**
  9314. * Removes a specific vertex data
  9315. * @param kind defines the data kind (Position, normal, etc...)
  9316. */
  9317. removeVerticesData(kind: string): void;
  9318. /**
  9319. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  9320. * @param buffer defines the vertex buffer to use
  9321. */
  9322. setVerticesBuffer(buffer: VertexBuffer): void;
  9323. /**
  9324. * Update a specific vertex buffer
  9325. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  9326. * It will do nothing if the buffer is not updatable
  9327. * @param kind defines the data kind (Position, normal, etc...)
  9328. * @param data defines the data to use
  9329. * @param offset defines the offset in the target buffer where to store the data
  9330. */
  9331. updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void;
  9332. /**
  9333. * Update a specific vertex buffer
  9334. * This function will create a new buffer if the current one is not updatable
  9335. * @param kind defines the data kind (Position, normal, etc...)
  9336. * @param data defines the data to use
  9337. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  9338. */
  9339. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  9340. private updateBoundingInfo(updateExtends, data);
  9341. /** @ignore */
  9342. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  9343. /**
  9344. * Gets total number of vertices
  9345. * @returns the total number of vertices
  9346. */
  9347. getTotalVertices(): number;
  9348. /**
  9349. * Gets a specific vertex data attached to this geometry
  9350. * @param kind defines the data kind (Position, normal, etc...)
  9351. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  9352. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  9353. * @returns a float array containing vertex data
  9354. */
  9355. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  9356. /**
  9357. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  9358. * @param kind defines the data kind (Position, normal, etc...)
  9359. * @returns true if the vertex buffer with the specified kind is updatable
  9360. */
  9361. isVertexBufferUpdatable(kind: string): boolean;
  9362. /**
  9363. * Gets a specific vertex buffer
  9364. * @param kind defines the data kind (Position, normal, etc...)
  9365. * @returns a {BABYLON.VertexBuffer}
  9366. */
  9367. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  9368. /**
  9369. * Returns all vertex buffers
  9370. * @return an object holding all vertex buffers indexed by kind
  9371. */
  9372. getVertexBuffers(): Nullable<{
  9373. [key: string]: VertexBuffer;
  9374. }>;
  9375. /**
  9376. * Gets a boolean indicating if specific vertex buffer is present
  9377. * @param kind defines the data kind (Position, normal, etc...)
  9378. * @returns true if data is present
  9379. */
  9380. isVerticesDataPresent(kind: string): boolean;
  9381. /**
  9382. * Gets a list of all attached data kinds (Position, normal, etc...)
  9383. * @returns a list of string containing all kinds
  9384. */
  9385. getVerticesDataKinds(): string[];
  9386. /**
  9387. * Update index buffer
  9388. * @param indices defines the indices to store in the index buffer
  9389. * @param offset defines the offset in the target buffer where to store the data
  9390. */
  9391. updateIndices(indices: IndicesArray, offset?: number): void;
  9392. /**
  9393. * Creates a new index buffer
  9394. * @param indices defines the indices to store in the index buffer
  9395. * @param totalVertices defines the total number of vertices (could be null)
  9396. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  9397. */
  9398. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  9399. /**
  9400. * Return the total number of indices
  9401. * @returns the total number of indices
  9402. */
  9403. getTotalIndices(): number;
  9404. /**
  9405. * Gets the index buffer array
  9406. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  9407. * @returns the index buffer array
  9408. */
  9409. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  9410. /**
  9411. * Gets the index buffer
  9412. * @return the index buffer
  9413. */
  9414. getIndexBuffer(): Nullable<WebGLBuffer>;
  9415. /** @ignore */
  9416. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  9417. /**
  9418. * Release the associated resources for a specific mesh
  9419. * @param mesh defines the source mesh
  9420. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  9421. */
  9422. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  9423. /**
  9424. * Apply current geometry to a given mesh
  9425. * @param mesh defines the mesh to apply geometry to
  9426. */
  9427. applyToMesh(mesh: Mesh): void;
  9428. private updateExtend(data?, stride?);
  9429. private _applyToMesh(mesh);
  9430. private notifyUpdate(kind?);
  9431. /**
  9432. * Load the geometry if it was flagged as delay loaded
  9433. * @param scene defines the hosting scene
  9434. * @param onLoaded defines a callback called when the geometry is loaded
  9435. */
  9436. load(scene: Scene, onLoaded?: () => void): void;
  9437. private _queueLoad(scene, onLoaded?);
  9438. /**
  9439. * Invert the geometry to move from a right handed system to a left handed one.
  9440. */
  9441. toLeftHanded(): void;
  9442. /** @ignore */
  9443. _resetPointsArrayCache(): void;
  9444. /** @ignore */
  9445. _generatePointsArray(): boolean;
  9446. /**
  9447. * Gets a value indicating if the geometry is disposed
  9448. * @returns true if the geometry was disposed
  9449. */
  9450. isDisposed(): boolean;
  9451. private _disposeVertexArrayObjects();
  9452. /**
  9453. * Free all associated resources
  9454. */
  9455. dispose(): void;
  9456. /**
  9457. * Clone the current geometry into a new geometry
  9458. * @param id defines the unique ID of the new geometry
  9459. * @returns a new geometry object
  9460. */
  9461. copy(id: string): Geometry;
  9462. /**
  9463. * Serialize the current geometry info (and not the vertices data) into a JSON object
  9464. * @return a JSON representation of the current geometry data (without the vertices data)
  9465. */
  9466. serialize(): any;
  9467. private toNumberArray(origin);
  9468. /**
  9469. * Serialize all vertices data into a JSON oject
  9470. * @returns a JSON representation of the current geometry data
  9471. */
  9472. serializeVerticeData(): any;
  9473. /**
  9474. * Extracts a clone of a mesh geometry
  9475. * @param mesh defines the source mesh
  9476. * @param id defines the unique ID of the new geometry object
  9477. * @returns the new geometry object
  9478. */
  9479. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  9480. /**
  9481. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  9482. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  9483. * Be aware Math.random() could cause collisions, but:
  9484. * "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"
  9485. * @returns a string containing a new GUID
  9486. */
  9487. static RandomId(): string;
  9488. /** @ignore */
  9489. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  9490. private static _CleanMatricesWeights(parsedGeometry, mesh);
  9491. /**
  9492. * Create a new geometry from persisted data (Using .babylon file format)
  9493. * @param parsedVertexData defines the persisted data
  9494. * @param scene defines the hosting scene
  9495. * @param rootUrl defines the root url to use to load assets (like delayed data)
  9496. * @returns the new geometry object
  9497. */
  9498. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  9499. }
  9500. /**
  9501. * Abstract class used to provide common services for all typed geometries
  9502. */
  9503. class _PrimitiveGeometry extends Geometry {
  9504. private _canBeRegenerated;
  9505. private _beingRegenerated;
  9506. /**
  9507. * Creates a new typed geometry
  9508. * @param id defines the unique ID of the geometry
  9509. * @param scene defines the hosting scene
  9510. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  9511. * @param mesh defines the hosting mesh (can be null)
  9512. */
  9513. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  9514. /**
  9515. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  9516. * @returns true if the geometry can be regenerated
  9517. */
  9518. canBeRegenerated(): boolean;
  9519. /**
  9520. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  9521. */
  9522. regenerate(): void;
  9523. /**
  9524. * Clone the geometry
  9525. * @param id defines the unique ID of the new geometry
  9526. * @returns the new geometry
  9527. */
  9528. asNewGeometry(id: string): Geometry;
  9529. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  9530. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  9531. /** @ignore */
  9532. _regenerateVertexData(): VertexData;
  9533. copy(id: string): Geometry;
  9534. serialize(): any;
  9535. }
  9536. /**
  9537. * Creates a ribbon geometry
  9538. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  9539. */
  9540. class RibbonGeometry extends _PrimitiveGeometry {
  9541. /**
  9542. * Defines the array of paths to use
  9543. */
  9544. pathArray: Vector3[][];
  9545. /**
  9546. * Defines if the last and first points of each path in your pathArray must be joined
  9547. */
  9548. closeArray: boolean;
  9549. /**
  9550. * Defines if the last and first points of each path in your pathArray must be joined
  9551. */
  9552. closePath: boolean;
  9553. /**
  9554. * Defines the offset between points
  9555. */
  9556. offset: number;
  9557. /**
  9558. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9559. */
  9560. side: number;
  9561. /**
  9562. * Creates a ribbon geometry
  9563. * @param id defines the unique ID of the geometry
  9564. * @param scene defines the hosting scene
  9565. * @param pathArray defines the array of paths to use
  9566. * @param closeArray defines if the last path and the first path must be joined
  9567. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  9568. * @param offset defines the offset between points
  9569. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  9570. * @param mesh defines the hosting mesh (can be null)
  9571. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9572. */
  9573. constructor(id: string, scene: Scene,
  9574. /**
  9575. * Defines the array of paths to use
  9576. */
  9577. pathArray: Vector3[][],
  9578. /**
  9579. * Defines if the last and first points of each path in your pathArray must be joined
  9580. */
  9581. closeArray: boolean,
  9582. /**
  9583. * Defines if the last and first points of each path in your pathArray must be joined
  9584. */
  9585. closePath: boolean,
  9586. /**
  9587. * Defines the offset between points
  9588. */
  9589. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  9590. /**
  9591. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9592. */
  9593. side?: number);
  9594. /** @ignore */
  9595. _regenerateVertexData(): VertexData;
  9596. copy(id: string): Geometry;
  9597. }
  9598. /**
  9599. * Creates a box geometry
  9600. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  9601. */
  9602. class BoxGeometry extends _PrimitiveGeometry {
  9603. /**
  9604. * Defines the zise of the box (width, height and depth are the same)
  9605. */
  9606. size: number;
  9607. /**
  9608. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9609. */
  9610. side: number;
  9611. /**
  9612. * Creates a box geometry
  9613. * @param id defines the unique ID of the geometry
  9614. * @param scene defines the hosting scene
  9615. * @param size defines the zise of the box (width, height and depth are the same)
  9616. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  9617. * @param mesh defines the hosting mesh (can be null)
  9618. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9619. */
  9620. constructor(id: string, scene: Scene,
  9621. /**
  9622. * Defines the zise of the box (width, height and depth are the same)
  9623. */
  9624. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  9625. /**
  9626. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9627. */
  9628. side?: number);
  9629. _regenerateVertexData(): VertexData;
  9630. copy(id: string): Geometry;
  9631. serialize(): any;
  9632. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  9633. }
  9634. /**
  9635. * Creates a sphere geometry
  9636. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  9637. */
  9638. class SphereGeometry extends _PrimitiveGeometry {
  9639. /**
  9640. * Defines the number of segments to use to create the sphere
  9641. */
  9642. segments: number;
  9643. /**
  9644. * Defines the diameter of the sphere
  9645. */
  9646. diameter: number;
  9647. /**
  9648. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9649. */
  9650. side: number;
  9651. /**
  9652. * Create a new sphere geometry
  9653. * @param id defines the unique ID of the geometry
  9654. * @param scene defines the hosting scene
  9655. * @param segments defines the number of segments to use to create the sphere
  9656. * @param diameter defines the diameter of the sphere
  9657. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  9658. * @param mesh defines the hosting mesh (can be null)
  9659. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9660. */
  9661. constructor(id: string, scene: Scene,
  9662. /**
  9663. * Defines the number of segments to use to create the sphere
  9664. */
  9665. segments: number,
  9666. /**
  9667. * Defines the diameter of the sphere
  9668. */
  9669. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  9670. /**
  9671. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9672. */
  9673. side?: number);
  9674. _regenerateVertexData(): VertexData;
  9675. copy(id: string): Geometry;
  9676. serialize(): any;
  9677. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  9678. }
  9679. /**
  9680. * Creates a disc geometry
  9681. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  9682. */
  9683. class DiscGeometry extends _PrimitiveGeometry {
  9684. /**
  9685. * Defines the radius of the disc
  9686. */
  9687. radius: number;
  9688. /**
  9689. * Defines the tesselation factor to apply to the disc
  9690. */
  9691. tessellation: number;
  9692. /**
  9693. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9694. */
  9695. side: number;
  9696. /**
  9697. * Creates a new disc geometry
  9698. * @param id defines the unique ID of the geometry
  9699. * @param scene defines the hosting scene
  9700. * @param radius defines the radius of the disc
  9701. * @param tessellation defines the tesselation factor to apply to the disc
  9702. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  9703. * @param mesh defines the hosting mesh (can be null)
  9704. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9705. */
  9706. constructor(id: string, scene: Scene,
  9707. /**
  9708. * Defines the radius of the disc
  9709. */
  9710. radius: number,
  9711. /**
  9712. * Defines the tesselation factor to apply to the disc
  9713. */
  9714. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  9715. /**
  9716. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9717. */
  9718. side?: number);
  9719. _regenerateVertexData(): VertexData;
  9720. copy(id: string): Geometry;
  9721. }
  9722. /**
  9723. * Creates a new cylinder geometry
  9724. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  9725. */
  9726. class CylinderGeometry extends _PrimitiveGeometry {
  9727. /**
  9728. * Defines the height of the cylinder
  9729. */
  9730. height: number;
  9731. /**
  9732. * Defines the diameter of the cylinder's top cap
  9733. */
  9734. diameterTop: number;
  9735. /**
  9736. * Defines the diameter of the cylinder's bottom cap
  9737. */
  9738. diameterBottom: number;
  9739. /**
  9740. * Defines the tessellation factor to apply to the cylinder
  9741. */
  9742. tessellation: number;
  9743. /**
  9744. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  9745. */
  9746. subdivisions: number;
  9747. /**
  9748. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9749. */
  9750. side: number;
  9751. /**
  9752. * Creates a new cylinder geometry
  9753. * @param id defines the unique ID of the geometry
  9754. * @param scene defines the hosting scene
  9755. * @param height defines the height of the cylinder
  9756. * @param diameterTop defines the diameter of the cylinder's top cap
  9757. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  9758. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  9759. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  9760. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  9761. * @param mesh defines the hosting mesh (can be null)
  9762. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9763. */
  9764. constructor(id: string, scene: Scene,
  9765. /**
  9766. * Defines the height of the cylinder
  9767. */
  9768. height: number,
  9769. /**
  9770. * Defines the diameter of the cylinder's top cap
  9771. */
  9772. diameterTop: number,
  9773. /**
  9774. * Defines the diameter of the cylinder's bottom cap
  9775. */
  9776. diameterBottom: number,
  9777. /**
  9778. * Defines the tessellation factor to apply to the cylinder
  9779. */
  9780. tessellation: number,
  9781. /**
  9782. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  9783. */
  9784. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  9785. /**
  9786. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9787. */
  9788. side?: number);
  9789. _regenerateVertexData(): VertexData;
  9790. copy(id: string): Geometry;
  9791. serialize(): any;
  9792. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  9793. }
  9794. /**
  9795. * Creates a new torus geometry
  9796. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  9797. */
  9798. class TorusGeometry extends _PrimitiveGeometry {
  9799. /**
  9800. * Defines the diameter of the torus
  9801. */
  9802. diameter: number;
  9803. /**
  9804. * Defines the thickness of the torus (ie. internal diameter)
  9805. */
  9806. thickness: number;
  9807. /**
  9808. * Defines the tesselation factor to apply to the torus
  9809. */
  9810. tessellation: number;
  9811. /**
  9812. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9813. */
  9814. side: number;
  9815. /**
  9816. * Creates a new torus geometry
  9817. * @param id defines the unique ID of the geometry
  9818. * @param scene defines the hosting scene
  9819. * @param diameter defines the diameter of the torus
  9820. * @param thickness defines the thickness of the torus (ie. internal diameter)
  9821. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  9822. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  9823. * @param mesh defines the hosting mesh (can be null)
  9824. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9825. */
  9826. constructor(id: string, scene: Scene,
  9827. /**
  9828. * Defines the diameter of the torus
  9829. */
  9830. diameter: number,
  9831. /**
  9832. * Defines the thickness of the torus (ie. internal diameter)
  9833. */
  9834. thickness: number,
  9835. /**
  9836. * Defines the tesselation factor to apply to the torus
  9837. */
  9838. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  9839. /**
  9840. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9841. */
  9842. side?: number);
  9843. _regenerateVertexData(): VertexData;
  9844. copy(id: string): Geometry;
  9845. serialize(): any;
  9846. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  9847. }
  9848. /**
  9849. * Creates a new ground geometry
  9850. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  9851. */
  9852. class GroundGeometry extends _PrimitiveGeometry {
  9853. /**
  9854. * Defines the width of the ground
  9855. */
  9856. width: number;
  9857. /**
  9858. * Defines the height of the ground
  9859. */
  9860. height: number;
  9861. /**
  9862. * Defines the subdivisions to apply to the ground
  9863. */
  9864. subdivisions: number;
  9865. /**
  9866. * Creates a new ground geometry
  9867. * @param id defines the unique ID of the geometry
  9868. * @param scene defines the hosting scene
  9869. * @param width defines the width of the ground
  9870. * @param height defines the height of the ground
  9871. * @param subdivisions defines the subdivisions to apply to the ground
  9872. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  9873. * @param mesh defines the hosting mesh (can be null)
  9874. */
  9875. constructor(id: string, scene: Scene,
  9876. /**
  9877. * Defines the width of the ground
  9878. */
  9879. width: number,
  9880. /**
  9881. * Defines the height of the ground
  9882. */
  9883. height: number,
  9884. /**
  9885. * Defines the subdivisions to apply to the ground
  9886. */
  9887. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  9888. _regenerateVertexData(): VertexData;
  9889. copy(id: string): Geometry;
  9890. serialize(): any;
  9891. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  9892. }
  9893. /**
  9894. * Creates a tiled ground geometry
  9895. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  9896. */
  9897. class TiledGroundGeometry extends _PrimitiveGeometry {
  9898. /**
  9899. * Defines the minimum value on X axis
  9900. */
  9901. xmin: number;
  9902. /**
  9903. * Defines the minimum value on Z axis
  9904. */
  9905. zmin: number;
  9906. /**
  9907. * Defines the maximum value on X axis
  9908. */
  9909. xmax: number;
  9910. /**
  9911. * Defines the maximum value on Z axis
  9912. */
  9913. zmax: number;
  9914. /**
  9915. * Defines the subdivisions to apply to the ground
  9916. */
  9917. subdivisions: {
  9918. w: number;
  9919. h: number;
  9920. };
  9921. /**
  9922. * Defines the precision to use when computing the tiles
  9923. */
  9924. precision: {
  9925. w: number;
  9926. h: number;
  9927. };
  9928. /**
  9929. * Creates a tiled ground geometry
  9930. * @param id defines the unique ID of the geometry
  9931. * @param scene defines the hosting scene
  9932. * @param xmin defines the minimum value on X axis
  9933. * @param zmin defines the minimum value on Z axis
  9934. * @param xmax defines the maximum value on X axis
  9935. * @param zmax defines the maximum value on Z axis
  9936. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  9937. * @param precision defines the precision to use when computing the tiles
  9938. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  9939. * @param mesh defines the hosting mesh (can be null)
  9940. */
  9941. constructor(id: string, scene: Scene,
  9942. /**
  9943. * Defines the minimum value on X axis
  9944. */
  9945. xmin: number,
  9946. /**
  9947. * Defines the minimum value on Z axis
  9948. */
  9949. zmin: number,
  9950. /**
  9951. * Defines the maximum value on X axis
  9952. */
  9953. xmax: number,
  9954. /**
  9955. * Defines the maximum value on Z axis
  9956. */
  9957. zmax: number,
  9958. /**
  9959. * Defines the subdivisions to apply to the ground
  9960. */
  9961. subdivisions: {
  9962. w: number;
  9963. h: number;
  9964. },
  9965. /**
  9966. * Defines the precision to use when computing the tiles
  9967. */
  9968. precision: {
  9969. w: number;
  9970. h: number;
  9971. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  9972. _regenerateVertexData(): VertexData;
  9973. copy(id: string): Geometry;
  9974. }
  9975. /**
  9976. * Creates a plane geometry
  9977. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  9978. */
  9979. class PlaneGeometry extends _PrimitiveGeometry {
  9980. /**
  9981. * Defines the size of the plane (width === height)
  9982. */
  9983. size: number;
  9984. /**
  9985. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9986. */
  9987. side: number;
  9988. /**
  9989. * Creates a plane geometry
  9990. * @param id defines the unique ID of the geometry
  9991. * @param scene defines the hosting scene
  9992. * @param size defines the size of the plane (width === height)
  9993. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  9994. * @param mesh defines the hosting mesh (can be null)
  9995. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  9996. */
  9997. constructor(id: string, scene: Scene,
  9998. /**
  9999. * Defines the size of the plane (width === height)
  10000. */
  10001. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  10002. /**
  10003. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  10004. */
  10005. side?: number);
  10006. _regenerateVertexData(): VertexData;
  10007. copy(id: string): Geometry;
  10008. serialize(): any;
  10009. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  10010. }
  10011. /**
  10012. * Creates a torus knot geometry
  10013. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  10014. */
  10015. class TorusKnotGeometry extends _PrimitiveGeometry {
  10016. /**
  10017. * Defines the radius of the torus knot
  10018. */
  10019. radius: number;
  10020. /**
  10021. * Defines the thickness of the torus knot tube
  10022. */
  10023. tube: number;
  10024. /**
  10025. * Defines the number of radial segments
  10026. */
  10027. radialSegments: number;
  10028. /**
  10029. * Defines the number of tubular segments
  10030. */
  10031. tubularSegments: number;
  10032. /**
  10033. * Defines the first number of windings
  10034. */
  10035. p: number;
  10036. /**
  10037. * Defines the second number of windings
  10038. */
  10039. q: number;
  10040. /**
  10041. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  10042. */
  10043. side: number;
  10044. /**
  10045. * Creates a torus knot geometry
  10046. * @param id defines the unique ID of the geometry
  10047. * @param scene defines the hosting scene
  10048. * @param radius defines the radius of the torus knot
  10049. * @param tube defines the thickness of the torus knot tube
  10050. * @param radialSegments defines the number of radial segments
  10051. * @param tubularSegments defines the number of tubular segments
  10052. * @param p defines the first number of windings
  10053. * @param q defines the second number of windings
  10054. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  10055. * @param mesh defines the hosting mesh (can be null)
  10056. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  10057. */
  10058. constructor(id: string, scene: Scene,
  10059. /**
  10060. * Defines the radius of the torus knot
  10061. */
  10062. radius: number,
  10063. /**
  10064. * Defines the thickness of the torus knot tube
  10065. */
  10066. tube: number,
  10067. /**
  10068. * Defines the number of radial segments
  10069. */
  10070. radialSegments: number,
  10071. /**
  10072. * Defines the number of tubular segments
  10073. */
  10074. tubularSegments: number,
  10075. /**
  10076. * Defines the first number of windings
  10077. */
  10078. p: number,
  10079. /**
  10080. * Defines the second number of windings
  10081. */
  10082. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  10083. /**
  10084. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  10085. */
  10086. side?: number);
  10087. _regenerateVertexData(): VertexData;
  10088. copy(id: string): Geometry;
  10089. serialize(): any;
  10090. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  10091. }
  10092. }
  10093. declare module BABYLON {
  10094. class GroundMesh extends Mesh {
  10095. generateOctree: boolean;
  10096. private _heightQuads;
  10097. _subdivisionsX: number;
  10098. _subdivisionsY: number;
  10099. _width: number;
  10100. _height: number;
  10101. _minX: number;
  10102. _maxX: number;
  10103. _minZ: number;
  10104. _maxZ: number;
  10105. constructor(name: string, scene: Scene);
  10106. getClassName(): string;
  10107. readonly subdivisions: number;
  10108. readonly subdivisionsX: number;
  10109. readonly subdivisionsY: number;
  10110. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  10111. /**
  10112. * Returns a height (y) value in the Worl system :
  10113. * the ground altitude at the coordinates (x, z) expressed in the World system.
  10114. * Returns the ground y position if (x, z) are outside the ground surface.
  10115. */
  10116. getHeightAtCoordinates(x: number, z: number): number;
  10117. /**
  10118. * Returns a normalized vector (Vector3) orthogonal to the ground
  10119. * at the ground coordinates (x, z) expressed in the World system.
  10120. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  10121. */
  10122. getNormalAtCoordinates(x: number, z: number): Vector3;
  10123. /**
  10124. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  10125. * at the ground coordinates (x, z) expressed in the World system.
  10126. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  10127. * Returns the GroundMesh.
  10128. */
  10129. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  10130. /**
  10131. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  10132. * if the ground has been updated.
  10133. * This can be used in the render loop.
  10134. * Returns the GroundMesh.
  10135. */
  10136. updateCoordinateHeights(): GroundMesh;
  10137. private _getFacetAt(x, z);
  10138. private _initHeightQuads();
  10139. private _computeHeightQuads();
  10140. serialize(serializationObject: any): void;
  10141. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  10142. }
  10143. }
  10144. declare module BABYLON {
  10145. /**
  10146. * Creates an instance based on a source mesh.
  10147. */
  10148. class InstancedMesh extends AbstractMesh {
  10149. private _sourceMesh;
  10150. private _currentLOD;
  10151. constructor(name: string, source: Mesh);
  10152. /**
  10153. * Returns the string "InstancedMesh".
  10154. */
  10155. getClassName(): string;
  10156. readonly receiveShadows: boolean;
  10157. readonly material: Nullable<Material>;
  10158. readonly visibility: number;
  10159. readonly skeleton: Nullable<Skeleton>;
  10160. readonly renderingGroupId: number;
  10161. /**
  10162. * Returns the total number of vertices (integer).
  10163. */
  10164. getTotalVertices(): number;
  10165. readonly sourceMesh: Mesh;
  10166. /**
  10167. * Is this node ready to be used/rendered
  10168. * @return {boolean} is it ready
  10169. */
  10170. isReady(): boolean;
  10171. /**
  10172. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  10173. */
  10174. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  10175. /**
  10176. * Sets the vertex data of the mesh geometry for the requested `kind`.
  10177. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  10178. * The `data` are either a numeric array either a Float32Array.
  10179. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  10180. * 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).
  10181. * Note that a new underlying VertexBuffer object is created each call.
  10182. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  10183. *
  10184. * Possible `kind` values :
  10185. * - BABYLON.VertexBuffer.PositionKind
  10186. * - BABYLON.VertexBuffer.UVKind
  10187. * - BABYLON.VertexBuffer.UV2Kind
  10188. * - BABYLON.VertexBuffer.UV3Kind
  10189. * - BABYLON.VertexBuffer.UV4Kind
  10190. * - BABYLON.VertexBuffer.UV5Kind
  10191. * - BABYLON.VertexBuffer.UV6Kind
  10192. * - BABYLON.VertexBuffer.ColorKind
  10193. * - BABYLON.VertexBuffer.MatricesIndicesKind
  10194. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  10195. * - BABYLON.VertexBuffer.MatricesWeightsKind
  10196. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  10197. *
  10198. * Returns the Mesh.
  10199. */
  10200. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  10201. /**
  10202. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  10203. * If the mesh has no geometry, it is simply returned as it is.
  10204. * The `data` are either a numeric array either a Float32Array.
  10205. * No new underlying VertexBuffer object is created.
  10206. * 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.
  10207. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  10208. *
  10209. * Possible `kind` values :
  10210. * - BABYLON.VertexBuffer.PositionKind
  10211. * - BABYLON.VertexBuffer.UVKind
  10212. * - BABYLON.VertexBuffer.UV2Kind
  10213. * - BABYLON.VertexBuffer.UV3Kind
  10214. * - BABYLON.VertexBuffer.UV4Kind
  10215. * - BABYLON.VertexBuffer.UV5Kind
  10216. * - BABYLON.VertexBuffer.UV6Kind
  10217. * - BABYLON.VertexBuffer.ColorKind
  10218. * - BABYLON.VertexBuffer.MatricesIndicesKind
  10219. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  10220. * - BABYLON.VertexBuffer.MatricesWeightsKind
  10221. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  10222. *
  10223. * Returns the Mesh.
  10224. */
  10225. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  10226. /**
  10227. * Sets the mesh indices.
  10228. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  10229. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  10230. * This method creates a new index buffer each call.
  10231. * Returns the Mesh.
  10232. */
  10233. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  10234. /**
  10235. * Boolean : True if the mesh owns the requested kind of data.
  10236. */
  10237. isVerticesDataPresent(kind: string): boolean;
  10238. /**
  10239. * Returns an array of indices (IndicesArray).
  10240. */
  10241. getIndices(): Nullable<IndicesArray>;
  10242. readonly _positions: Nullable<Vector3[]>;
  10243. /**
  10244. * Sets a new updated BoundingInfo to the mesh.
  10245. * Returns the mesh.
  10246. */
  10247. refreshBoundingInfo(): InstancedMesh;
  10248. _preActivate(): InstancedMesh;
  10249. _activate(renderId: number): InstancedMesh;
  10250. /**
  10251. * Returns the current associated LOD AbstractMesh.
  10252. */
  10253. getLOD(camera: Camera): AbstractMesh;
  10254. _syncSubMeshes(): InstancedMesh;
  10255. _generatePointsArray(): boolean;
  10256. /**
  10257. * Creates a new InstancedMesh from the current mesh.
  10258. * - name (string) : the cloned mesh name
  10259. * - newParent (optional Node) : the optional Node to parent the clone to.
  10260. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  10261. *
  10262. * Returns the clone.
  10263. */
  10264. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  10265. /**
  10266. * Disposes the InstancedMesh.
  10267. * Returns nothing.
  10268. */
  10269. dispose(doNotRecurse?: boolean): void;
  10270. }
  10271. }
  10272. declare module BABYLON {
  10273. class LinesMesh extends Mesh {
  10274. useVertexColor: boolean | undefined;
  10275. useVertexAlpha: boolean | undefined;
  10276. color: Color3;
  10277. alpha: number;
  10278. /**
  10279. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  10280. * This margin is expressed in world space coordinates, so its value may vary.
  10281. * Default value is 0.1
  10282. * @returns the intersection Threshold value.
  10283. */
  10284. /**
  10285. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  10286. * This margin is expressed in world space coordinates, so its value may vary.
  10287. * @param value the new threshold to apply
  10288. */
  10289. intersectionThreshold: number;
  10290. private _intersectionThreshold;
  10291. private _colorShader;
  10292. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  10293. /**
  10294. * Returns the string "LineMesh"
  10295. */
  10296. getClassName(): string;
  10297. material: Material;
  10298. readonly checkCollisions: boolean;
  10299. createInstance(name: string): InstancedMesh;
  10300. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  10301. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  10302. dispose(doNotRecurse?: boolean): void;
  10303. /**
  10304. * Returns a new LineMesh object cloned from the current one.
  10305. */
  10306. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  10307. }
  10308. }
  10309. declare module BABYLON {
  10310. class _InstancesBatch {
  10311. mustReturn: boolean;
  10312. visibleInstances: Nullable<InstancedMesh[]>[];
  10313. renderSelf: boolean[];
  10314. }
  10315. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  10316. static _FRONTSIDE: number;
  10317. static _BACKSIDE: number;
  10318. static _DOUBLESIDE: number;
  10319. static _DEFAULTSIDE: number;
  10320. static _NO_CAP: number;
  10321. static _CAP_START: number;
  10322. static _CAP_END: number;
  10323. static _CAP_ALL: number;
  10324. /**
  10325. * Mesh side orientation : usually the external or front surface
  10326. */
  10327. static readonly FRONTSIDE: number;
  10328. /**
  10329. * Mesh side orientation : usually the internal or back surface
  10330. */
  10331. static readonly BACKSIDE: number;
  10332. /**
  10333. * Mesh side orientation : both internal and external or front and back surfaces
  10334. */
  10335. static readonly DOUBLESIDE: number;
  10336. /**
  10337. * Mesh side orientation : by default, `FRONTSIDE`
  10338. */
  10339. static readonly DEFAULTSIDE: number;
  10340. /**
  10341. * Mesh cap setting : no cap
  10342. */
  10343. static readonly NO_CAP: number;
  10344. /**
  10345. * Mesh cap setting : one cap at the beginning of the mesh
  10346. */
  10347. static readonly CAP_START: number;
  10348. /**
  10349. * Mesh cap setting : one cap at the end of the mesh
  10350. */
  10351. static readonly CAP_END: number;
  10352. /**
  10353. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  10354. */
  10355. static readonly CAP_ALL: number;
  10356. /**
  10357. * An event triggered before rendering the mesh
  10358. * @type {BABYLON.Observable}
  10359. */
  10360. onBeforeRenderObservable: Observable<Mesh>;
  10361. /**
  10362. * An event triggered after rendering the mesh
  10363. * @type {BABYLON.Observable}
  10364. */
  10365. onAfterRenderObservable: Observable<Mesh>;
  10366. /**
  10367. * An event triggered before drawing the mesh
  10368. * @type {BABYLON.Observable}
  10369. */
  10370. onBeforeDrawObservable: Observable<Mesh>;
  10371. private _onBeforeDrawObserver;
  10372. onBeforeDraw: () => void;
  10373. delayLoadState: number;
  10374. instances: InstancedMesh[];
  10375. delayLoadingFile: string;
  10376. _binaryInfo: any;
  10377. private _LODLevels;
  10378. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  10379. private _morphTargetManager;
  10380. morphTargetManager: Nullable<MorphTargetManager>;
  10381. _geometry: Nullable<Geometry>;
  10382. _delayInfo: Array<string>;
  10383. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  10384. _visibleInstances: any;
  10385. private _renderIdForInstances;
  10386. private _batchCache;
  10387. private _instancesBufferSize;
  10388. private _instancesBuffer;
  10389. private _instancesData;
  10390. private _overridenInstanceCount;
  10391. private _effectiveMaterial;
  10392. _shouldGenerateFlatShading: boolean;
  10393. private _preActivateId;
  10394. _originalBuilderSideOrientation: number;
  10395. overrideMaterialSideOrientation: Nullable<number>;
  10396. private _areNormalsFrozen;
  10397. private _sourcePositions;
  10398. private _sourceNormals;
  10399. private _source;
  10400. readonly source: Nullable<Mesh>;
  10401. isUnIndexed: boolean;
  10402. /**
  10403. * @constructor
  10404. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  10405. * @param {Scene} scene The scene to add this mesh to.
  10406. * @param {Node} parent The parent of this mesh, if it has one
  10407. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  10408. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  10409. * When false, achieved by calling a clone(), also passing False.
  10410. * This will make creation of children, recursive.
  10411. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  10412. */
  10413. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  10414. /**
  10415. * Returns the string "Mesh".
  10416. */
  10417. getClassName(): string;
  10418. /**
  10419. * Returns a string.
  10420. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  10421. */
  10422. toString(fullDetails?: boolean): string;
  10423. /**
  10424. * True if the mesh has some Levels Of Details (LOD).
  10425. * Returns a boolean.
  10426. */
  10427. readonly hasLODLevels: boolean;
  10428. /**
  10429. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  10430. * @returns an array of {BABYLON.MeshLODLevel}
  10431. */
  10432. getLODLevels(): MeshLODLevel[];
  10433. private _sortLODLevels();
  10434. /**
  10435. * Add a mesh as LOD level triggered at the given distance.
  10436. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  10437. * @param {number} distance The distance from the center of the object to show this level
  10438. * @param {Mesh} mesh The mesh to be added as LOD level
  10439. * @return {Mesh} This mesh (for chaining)
  10440. */
  10441. addLODLevel(distance: number, mesh: Mesh): Mesh;
  10442. /**
  10443. * Returns the LOD level mesh at the passed distance or null if not found.
  10444. * It is related to the method `addLODLevel(distance, mesh)`.
  10445. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  10446. * Returns an object Mesh or `null`.
  10447. */
  10448. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  10449. /**
  10450. * Remove a mesh from the LOD array
  10451. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  10452. * @param {Mesh} mesh The mesh to be removed.
  10453. * @return {Mesh} This mesh (for chaining)
  10454. */
  10455. removeLODLevel(mesh: Mesh): Mesh;
  10456. /**
  10457. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  10458. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  10459. */
  10460. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  10461. /**
  10462. * Returns the mesh internal Geometry object.
  10463. */
  10464. readonly geometry: Nullable<Geometry>;
  10465. /**
  10466. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  10467. */
  10468. getTotalVertices(): number;
  10469. /**
  10470. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  10471. * 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.
  10472. * You can force the copy with forceCopy === true
  10473. * Returns null if the mesh has no geometry or no vertex buffer.
  10474. * Possible `kind` values :
  10475. * - BABYLON.VertexBuffer.PositionKind
  10476. * - BABYLON.VertexBuffer.UVKind
  10477. * - BABYLON.VertexBuffer.UV2Kind
  10478. * - BABYLON.VertexBuffer.UV3Kind
  10479. * - BABYLON.VertexBuffer.UV4Kind
  10480. * - BABYLON.VertexBuffer.UV5Kind
  10481. * - BABYLON.VertexBuffer.UV6Kind
  10482. * - BABYLON.VertexBuffer.ColorKind
  10483. * - BABYLON.VertexBuffer.MatricesIndicesKind
  10484. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  10485. * - BABYLON.VertexBuffer.MatricesWeightsKind
  10486. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  10487. */
  10488. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  10489. /**
  10490. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  10491. * Returns `null` if the mesh has no geometry.
  10492. * Possible `kind` values :
  10493. * - BABYLON.VertexBuffer.PositionKind
  10494. * - BABYLON.VertexBuffer.UVKind
  10495. * - BABYLON.VertexBuffer.UV2Kind
  10496. * - BABYLON.VertexBuffer.UV3Kind
  10497. * - BABYLON.VertexBuffer.UV4Kind
  10498. * - BABYLON.VertexBuffer.UV5Kind
  10499. * - BABYLON.VertexBuffer.UV6Kind
  10500. * - BABYLON.VertexBuffer.ColorKind
  10501. * - BABYLON.VertexBuffer.MatricesIndicesKind
  10502. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  10503. * - BABYLON.VertexBuffer.MatricesWeightsKind
  10504. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  10505. */
  10506. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  10507. /**
  10508. * Returns a boolean depending on the existence of the Vertex Data for the requested `kind`.
  10509. * Possible `kind` values :
  10510. * - BABYLON.VertexBuffer.PositionKind
  10511. * - BABYLON.VertexBuffer.UVKind
  10512. * - BABYLON.VertexBuffer.UV2Kind
  10513. * - BABYLON.VertexBuffer.UV3Kind
  10514. * - BABYLON.VertexBuffer.UV4Kind
  10515. * - BABYLON.VertexBuffer.UV5Kind
  10516. * - BABYLON.VertexBuffer.UV6Kind
  10517. * - BABYLON.VertexBuffer.ColorKind
  10518. * - BABYLON.VertexBuffer.MatricesIndicesKind
  10519. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  10520. * - BABYLON.VertexBuffer.MatricesWeightsKind
  10521. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  10522. */
  10523. isVerticesDataPresent(kind: string): boolean;
  10524. /**
  10525. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  10526. * Possible `kind` values :
  10527. * - BABYLON.VertexBuffer.PositionKind
  10528. * - BABYLON.VertexBuffer.UVKind
  10529. * - BABYLON.VertexBuffer.UV2Kind
  10530. * - BABYLON.VertexBuffer.UV3Kind
  10531. * - BABYLON.VertexBuffer.UV4Kind
  10532. * - BABYLON.VertexBuffer.UV5Kind
  10533. * - BABYLON.VertexBuffer.UV6Kind
  10534. * - BABYLON.VertexBuffer.ColorKind
  10535. * - BABYLON.VertexBuffer.MatricesIndicesKind
  10536. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  10537. * - BABYLON.VertexBuffer.MatricesWeightsKind
  10538. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  10539. */
  10540. isVertexBufferUpdatable(kind: string): boolean;
  10541. /**
  10542. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  10543. * Possible `kind` values :
  10544. * - BABYLON.VertexBuffer.PositionKind
  10545. * - BABYLON.VertexBuffer.UVKind
  10546. * - BABYLON.VertexBuffer.UV2Kind
  10547. * - BABYLON.VertexBuffer.UV3Kind
  10548. * - BABYLON.VertexBuffer.UV4Kind
  10549. * - BABYLON.VertexBuffer.UV5Kind
  10550. * - BABYLON.VertexBuffer.UV6Kind
  10551. * - BABYLON.VertexBuffer.ColorKind
  10552. * - BABYLON.VertexBuffer.MatricesIndicesKind
  10553. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  10554. * - BABYLON.VertexBuffer.MatricesWeightsKind
  10555. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  10556. */
  10557. getVerticesDataKinds(): string[];
  10558. /**
  10559. * Returns a positive integer : the total number of indices in this mesh geometry.
  10560. * Returns zero if the mesh has no geometry.
  10561. */
  10562. getTotalIndices(): number;
  10563. /**
  10564. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  10565. * 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.
  10566. * Returns an empty array if the mesh has no geometry.
  10567. */
  10568. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  10569. readonly isBlocked: boolean;
  10570. /**
  10571. * Determine if the current mesh is ready to be rendered
  10572. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  10573. * @returns true if all associated assets are ready (material, textures, shaders)
  10574. */
  10575. isReady(forceInstanceSupport?: boolean): boolean;
  10576. /**
  10577. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  10578. * This property is pertinent only for updatable parametric shapes.
  10579. */
  10580. readonly areNormalsFrozen: boolean;
  10581. /**
  10582. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  10583. * It has no effect at all on other shapes.
  10584. * It prevents the mesh normals from being recomputed on next `positions` array update.
  10585. * Returns the Mesh.
  10586. */
  10587. freezeNormals(): Mesh;
  10588. /**
  10589. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  10590. * It has no effect at all on other shapes.
  10591. * It reactivates the mesh normals computation if it was previously frozen.
  10592. * Returns the Mesh.
  10593. */
  10594. unfreezeNormals(): Mesh;
  10595. /**
  10596. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  10597. */
  10598. overridenInstanceCount: number;
  10599. _preActivate(): Mesh;
  10600. _preActivateForIntermediateRendering(renderId: number): Mesh;
  10601. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  10602. /**
  10603. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  10604. * This means the mesh underlying bounding box and sphere are recomputed.
  10605. * Returns the Mesh.
  10606. */
  10607. refreshBoundingInfo(): Mesh;
  10608. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  10609. private _getPositionData(applySkeleton);
  10610. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  10611. subdivide(count: number): void;
  10612. /**
  10613. * Sets the vertex data of the mesh geometry for the requested `kind`.
  10614. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  10615. * The `data` are either a numeric array either a Float32Array.
  10616. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  10617. * 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).
  10618. * Note that a new underlying VertexBuffer object is created each call.
  10619. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  10620. *
  10621. * Possible `kind` values :
  10622. * - BABYLON.VertexBuffer.PositionKind
  10623. * - BABYLON.VertexBuffer.UVKind
  10624. * - BABYLON.VertexBuffer.UV2Kind
  10625. * - BABYLON.VertexBuffer.UV3Kind
  10626. * - BABYLON.VertexBuffer.UV4Kind
  10627. * - BABYLON.VertexBuffer.UV5Kind
  10628. * - BABYLON.VertexBuffer.UV6Kind
  10629. * - BABYLON.VertexBuffer.ColorKind
  10630. * - BABYLON.VertexBuffer.MatricesIndicesKind
  10631. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  10632. * - BABYLON.VertexBuffer.MatricesWeightsKind
  10633. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  10634. *
  10635. * Returns the Mesh.
  10636. */
  10637. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  10638. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  10639. /**
  10640. * Sets the mesh VertexBuffer.
  10641. * Returns the Mesh.
  10642. */
  10643. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  10644. /**
  10645. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  10646. * If the mesh has no geometry, it is simply returned as it is.
  10647. * The `data` are either a numeric array either a Float32Array.
  10648. * No new underlying VertexBuffer object is created.
  10649. * 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.
  10650. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  10651. *
  10652. * Possible `kind` values :
  10653. * - BABYLON.VertexBuffer.PositionKind
  10654. * - BABYLON.VertexBuffer.UVKind
  10655. * - BABYLON.VertexBuffer.UV2Kind
  10656. * - BABYLON.VertexBuffer.UV3Kind
  10657. * - BABYLON.VertexBuffer.UV4Kind
  10658. * - BABYLON.VertexBuffer.UV5Kind
  10659. * - BABYLON.VertexBuffer.UV6Kind
  10660. * - BABYLON.VertexBuffer.ColorKind
  10661. * - BABYLON.VertexBuffer.MatricesIndicesKind
  10662. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  10663. * - BABYLON.VertexBuffer.MatricesWeightsKind
  10664. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  10665. *
  10666. * Returns the Mesh.
  10667. */
  10668. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  10669. /**
  10670. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  10671. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  10672. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  10673. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  10674. * Returns the Mesh.
  10675. */
  10676. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  10677. /**
  10678. * Creates a un-shared specific occurence of the geometry for the mesh.
  10679. * Returns the Mesh.
  10680. */
  10681. makeGeometryUnique(): Mesh;
  10682. /**
  10683. * Sets the mesh indices.
  10684. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  10685. * Type is Uint16Array by default unless the mesh has more than 65536 vertices.
  10686. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  10687. * This method creates a new index buffer each call.
  10688. * Returns the Mesh.
  10689. */
  10690. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  10691. /**
  10692. * Update the current index buffer
  10693. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  10694. * Returns the Mesh.
  10695. */
  10696. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  10697. /**
  10698. * Invert the geometry to move from a right handed system to a left handed one.
  10699. * Returns the Mesh.
  10700. */
  10701. toLeftHanded(): Mesh;
  10702. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  10703. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  10704. /**
  10705. * Registers for this mesh a javascript function called just before the rendering process.
  10706. * This function is passed the current mesh.
  10707. * Return the Mesh.
  10708. */
  10709. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  10710. /**
  10711. * Disposes a previously registered javascript function called before the rendering.
  10712. * This function is passed the current mesh.
  10713. * Returns the Mesh.
  10714. */
  10715. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  10716. /**
  10717. * Registers for this mesh a javascript function called just after the rendering is complete.
  10718. * This function is passed the current mesh.
  10719. * Returns the Mesh.
  10720. */
  10721. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  10722. /**
  10723. * Disposes a previously registered javascript function called after the rendering.
  10724. * This function is passed the current mesh.
  10725. * Return the Mesh.
  10726. */
  10727. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  10728. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  10729. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  10730. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  10731. /**
  10732. * Triggers the draw call for the mesh.
  10733. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  10734. * Returns the Mesh.
  10735. */
  10736. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  10737. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  10738. /**
  10739. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  10740. */
  10741. getEmittedParticleSystems(): IParticleSystem[];
  10742. /**
  10743. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  10744. */
  10745. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  10746. _checkDelayState(): Mesh;
  10747. private _queueLoad(scene);
  10748. /**
  10749. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  10750. */
  10751. isInFrustum(frustumPlanes: Plane[]): boolean;
  10752. /**
  10753. * Sets the mesh material by the material or multiMaterial `id` property.
  10754. * The material `id` is a string identifying the material or the multiMaterial.
  10755. * This method returns the Mesh.
  10756. */
  10757. setMaterialByID(id: string): Mesh;
  10758. /**
  10759. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  10760. */
  10761. getAnimatables(): IAnimatable[];
  10762. /**
  10763. * Modifies the mesh geometry according to the passed transformation matrix.
  10764. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  10765. * The mesh normals are modified accordingly the same transformation.
  10766. * tuto : http://doc.babylonjs.com/tutorials/How_Rotations_and_Translations_Work#baking-transform
  10767. * Note that, under the hood, this method sets a new VertexBuffer each call.
  10768. * Returns the Mesh.
  10769. */
  10770. bakeTransformIntoVertices(transform: Matrix): Mesh;
  10771. /**
  10772. * Modifies the mesh geometry according to its own current World Matrix.
  10773. * The mesh World Matrix is then reset.
  10774. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  10775. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  10776. * Note that, under the hood, this method sets a new VertexBuffer each call.
  10777. * Returns the Mesh.
  10778. */
  10779. bakeCurrentTransformIntoVertices(): Mesh;
  10780. readonly _positions: Nullable<Vector3[]>;
  10781. _resetPointsArrayCache(): Mesh;
  10782. _generatePointsArray(): boolean;
  10783. /**
  10784. * Returns a new Mesh object generated from the current mesh properties.
  10785. * This method must not get confused with createInstance().
  10786. * The parameter `name` is a string, the name given to the new mesh.
  10787. * The optional parameter `newParent` can be any Node object (default `null`).
  10788. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  10789. * 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.
  10790. */
  10791. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  10792. /**
  10793. * Disposes the Mesh.
  10794. * By default, all the mesh children are also disposed unless the parameter `doNotRecurse` is set to `true`.
  10795. * Returns nothing.
  10796. */
  10797. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10798. /**
  10799. * Modifies the mesh geometry according to a displacement map.
  10800. * 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.
  10801. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  10802. * This method returns nothing.
  10803. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  10804. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  10805. * 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.
  10806. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  10807. * The parameter `uvScale` is an optional vector2 used to scale UV.
  10808. *
  10809. * Returns the Mesh.
  10810. */
  10811. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  10812. /**
  10813. * Modifies the mesh geometry according to a displacementMap buffer.
  10814. * 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.
  10815. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  10816. * This method returns nothing.
  10817. * 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.
  10818. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  10819. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  10820. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  10821. * The parameter `uvScale` is an optional vector2 used to scale UV.
  10822. *
  10823. * Returns the Mesh.
  10824. */
  10825. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  10826. /**
  10827. * Modify the mesh to get a flat shading rendering.
  10828. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  10829. * This method returns the Mesh.
  10830. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  10831. */
  10832. convertToFlatShadedMesh(): Mesh;
  10833. /**
  10834. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  10835. * In other words, more vertices, no more indices and a single bigger VBO.
  10836. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  10837. * Returns the Mesh.
  10838. */
  10839. convertToUnIndexedMesh(): Mesh;
  10840. /**
  10841. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  10842. * This method returns the Mesh.
  10843. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  10844. */
  10845. flipFaces(flipNormals?: boolean): Mesh;
  10846. /**
  10847. * Creates a new InstancedMesh object from the mesh model.
  10848. * An instance shares the same properties and the same material than its model.
  10849. * Only these properties of each instance can then be set individually :
  10850. * - position
  10851. * - rotation
  10852. * - rotationQuaternion
  10853. * - setPivotMatrix
  10854. * - scaling
  10855. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  10856. * Warning : this method is not supported for Line mesh and LineSystem
  10857. */
  10858. createInstance(name: string): InstancedMesh;
  10859. /**
  10860. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  10861. * After this call, all the mesh instances have the same submeshes than the current mesh.
  10862. * This method returns the Mesh.
  10863. */
  10864. synchronizeInstances(): Mesh;
  10865. /**
  10866. * Simplify the mesh according to the given array of settings.
  10867. * Function will return immediately and will simplify async. It returns the Mesh.
  10868. * @param settings a collection of simplification settings.
  10869. * @param parallelProcessing should all levels calculate parallel or one after the other.
  10870. * @param type the type of simplification to run.
  10871. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  10872. */
  10873. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  10874. /**
  10875. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  10876. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  10877. * This should be used together with the simplification to avoid disappearing triangles.
  10878. * Returns the Mesh.
  10879. * @param successCallback an optional success callback to be called after the optimization finished.
  10880. */
  10881. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  10882. serialize(serializationObject: any): void;
  10883. _syncGeometryWithMorphTargetManager(): void;
  10884. /**
  10885. * Returns a new Mesh object parsed from the source provided.
  10886. * The parameter `parsedMesh` is the source.
  10887. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  10888. */
  10889. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  10890. /**
  10891. * Creates a ribbon mesh.
  10892. * Please consider using the same method from the MeshBuilder class instead.
  10893. * 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.
  10894. *
  10895. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  10896. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  10897. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  10898. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  10899. * 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.
  10900. * 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.
  10901. * 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
  10902. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  10903. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  10904. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10905. */
  10906. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  10907. /**
  10908. * Creates a plane polygonal mesh. By default, this is a disc.
  10909. * Please consider using the same method from the MeshBuilder class instead.
  10910. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  10911. * 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.
  10912. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  10913. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  10914. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10915. */
  10916. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  10917. /**
  10918. * Creates a box mesh.
  10919. * Please consider using the same method from the MeshBuilder class instead.
  10920. * The parameter `size` sets the size (float) of each box side (default 1).
  10921. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  10922. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  10923. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10924. */
  10925. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  10926. /**
  10927. * Creates a sphere mesh.
  10928. * Please consider using the same method from the MeshBuilder class instead.
  10929. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  10930. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  10931. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  10932. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  10933. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10934. */
  10935. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  10936. /**
  10937. * Creates a cylinder or a cone mesh.
  10938. * Please consider using the same method from the MeshBuilder class instead.
  10939. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  10940. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  10941. * 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.
  10942. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  10943. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  10944. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  10945. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  10946. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10947. */
  10948. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  10949. /**
  10950. * Creates a torus mesh.
  10951. * Please consider using the same method from the MeshBuilder class instead.
  10952. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  10953. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  10954. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  10955. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  10956. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  10957. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10958. */
  10959. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  10960. /**
  10961. * Creates a torus knot mesh.
  10962. * Please consider using the same method from the MeshBuilder class instead.
  10963. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  10964. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  10965. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  10966. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  10967. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  10968. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  10969. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10970. */
  10971. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  10972. /**
  10973. * Creates a line mesh.
  10974. * Please consider using the same method from the MeshBuilder class instead.
  10975. * 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.
  10976. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  10977. * The parameter `points` is an array successive Vector3.
  10978. * 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
  10979. * When updating an instance, remember that only point positions can change, not the number of points.
  10980. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10981. */
  10982. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  10983. /**
  10984. * Creates a dashed line mesh.
  10985. * Please consider using the same method from the MeshBuilder class instead.
  10986. * 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.
  10987. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  10988. * The parameter `points` is an array successive Vector3.
  10989. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  10990. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  10991. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  10992. * 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
  10993. * When updating an instance, remember that only point positions can change, not the number of points.
  10994. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10995. */
  10996. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  10997. /**
  10998. * Creates a polygon mesh.
  10999. * Please consider using the same method from the MeshBuilder class instead.
  11000. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  11001. * 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.
  11002. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11003. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11004. * Remember you can only change the shape positions, not their number when updating a polygon.
  11005. */
  11006. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  11007. /**
  11008. * Creates an extruded polygon mesh, with depth in the Y direction.
  11009. * Please consider using the same method from the MeshBuilder class instead.
  11010. */
  11011. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  11012. /**
  11013. * Creates an extruded shape mesh.
  11014. * 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.
  11015. * Please consider using the same method from the MeshBuilder class instead.
  11016. *
  11017. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  11018. * 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
  11019. * extruded along the Z axis.
  11020. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  11021. * 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.
  11022. * The parameter `scale` (float, default 1) is the value to scale the shape.
  11023. * 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
  11024. * 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
  11025. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  11026. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11027. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11028. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11029. */
  11030. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  11031. /**
  11032. * Creates an custom extruded shape mesh.
  11033. * 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.
  11034. * Please consider using the same method from the MeshBuilder class instead.
  11035. *
  11036. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  11037. * 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
  11038. * extruded along the Z axis.
  11039. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  11040. * 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
  11041. * and the distance of this point from the begining of the path :
  11042. * ```javascript
  11043. * var rotationFunction = function(i, distance) {
  11044. * // do things
  11045. * return rotationValue; }
  11046. * ```
  11047. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  11048. * 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
  11049. * and the distance of this point from the begining of the path :
  11050. * ```javascript
  11051. * var scaleFunction = function(i, distance) {
  11052. * // do things
  11053. * return scaleValue;}
  11054. * ```
  11055. * It must returns a float value that will be the scale value applied to the shape on each path point.
  11056. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  11057. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  11058. * 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
  11059. * 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
  11060. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  11061. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11062. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11063. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11064. */
  11065. 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;
  11066. /**
  11067. * Creates lathe mesh.
  11068. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  11069. * Please consider using the same method from the MeshBuilder class instead.
  11070. * 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
  11071. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  11072. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  11073. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  11074. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11075. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11076. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11077. */
  11078. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  11079. /**
  11080. * Creates a plane mesh.
  11081. * Please consider using the same method from the MeshBuilder class instead.
  11082. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  11083. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11084. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11085. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11086. */
  11087. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  11088. /**
  11089. * Creates a ground mesh.
  11090. * Please consider using the same method from the MeshBuilder class instead.
  11091. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  11092. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  11093. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11094. */
  11095. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  11096. /**
  11097. * Creates a tiled ground mesh.
  11098. * Please consider using the same method from the MeshBuilder class instead.
  11099. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  11100. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  11101. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  11102. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  11103. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  11104. * numbers of subdivisions on the ground width and height of each tile.
  11105. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11106. */
  11107. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  11108. w: number;
  11109. h: number;
  11110. }, precision: {
  11111. w: number;
  11112. h: number;
  11113. }, scene: Scene, updatable?: boolean): Mesh;
  11114. /**
  11115. * Creates a ground mesh from a height map.
  11116. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  11117. * Please consider using the same method from the MeshBuilder class instead.
  11118. * The parameter `url` sets the URL of the height map image resource.
  11119. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  11120. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  11121. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  11122. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  11123. * 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).
  11124. * This function is passed the newly built mesh :
  11125. * ```javascript
  11126. * function(mesh) { // do things
  11127. * return; }
  11128. * ```
  11129. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11130. */
  11131. 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;
  11132. /**
  11133. * Creates a tube mesh.
  11134. * 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.
  11135. * Please consider using the same method from the MeshBuilder class instead.
  11136. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  11137. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  11138. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  11139. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  11140. * 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.
  11141. * It must return a radius value (positive float) :
  11142. * ```javascript
  11143. * var radiusFunction = function(i, distance) {
  11144. * // do things
  11145. * return radius; }
  11146. * ```
  11147. * 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
  11148. * 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
  11149. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11150. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11151. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11152. */
  11153. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  11154. (i: number, distance: number): number;
  11155. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  11156. /**
  11157. * Creates a polyhedron mesh.
  11158. * Please consider using the same method from the MeshBuilder class instead.
  11159. * 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
  11160. * to choose the wanted type.
  11161. * The parameter `size` (positive float, default 1) sets the polygon size.
  11162. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  11163. * 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`.
  11164. * 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
  11165. * 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)`).
  11166. * 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
  11167. * 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.
  11168. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11169. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11170. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11171. */
  11172. static CreatePolyhedron(name: string, options: {
  11173. type?: number;
  11174. size?: number;
  11175. sizeX?: number;
  11176. sizeY?: number;
  11177. sizeZ?: number;
  11178. custom?: any;
  11179. faceUV?: Vector4[];
  11180. faceColors?: Color4[];
  11181. updatable?: boolean;
  11182. sideOrientation?: number;
  11183. }, scene: Scene): Mesh;
  11184. /**
  11185. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  11186. * Please consider using the same method from the MeshBuilder class instead.
  11187. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  11188. * 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`).
  11189. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  11190. * 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.
  11191. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11192. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11193. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11194. */
  11195. static CreateIcoSphere(name: string, options: {
  11196. radius?: number;
  11197. flat?: boolean;
  11198. subdivisions?: number;
  11199. sideOrientation?: number;
  11200. updatable?: boolean;
  11201. }, scene: Scene): Mesh;
  11202. /**
  11203. * Creates a decal mesh.
  11204. * Please consider using the same method from the MeshBuilder class instead.
  11205. * 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.
  11206. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  11207. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  11208. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  11209. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  11210. */
  11211. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  11212. /**
  11213. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  11214. */
  11215. setPositionsForCPUSkinning(): Float32Array;
  11216. /**
  11217. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  11218. */
  11219. setNormalsForCPUSkinning(): Float32Array;
  11220. /**
  11221. * Updates the vertex buffer by applying transformation from the bones.
  11222. * Returns the Mesh.
  11223. *
  11224. * @param {skeleton} skeleton to apply
  11225. */
  11226. applySkeleton(skeleton: Skeleton): Mesh;
  11227. /**
  11228. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  11229. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  11230. */
  11231. static MinMax(meshes: AbstractMesh[]): {
  11232. min: Vector3;
  11233. max: Vector3;
  11234. };
  11235. /**
  11236. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  11237. */
  11238. static Center(meshesOrMinMaxVector: {
  11239. min: Vector3;
  11240. max: Vector3;
  11241. } | AbstractMesh[]): Vector3;
  11242. /**
  11243. * Merge the array of meshes into a single mesh for performance reasons.
  11244. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  11245. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  11246. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  11247. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  11248. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  11249. */
  11250. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  11251. }
  11252. }
  11253. declare module BABYLON {
  11254. interface IGetSetVerticesData {
  11255. isVerticesDataPresent(kind: string): boolean;
  11256. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  11257. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  11258. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  11259. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  11260. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  11261. }
  11262. class VertexData {
  11263. positions: Nullable<FloatArray>;
  11264. normals: Nullable<FloatArray>;
  11265. tangents: Nullable<FloatArray>;
  11266. uvs: Nullable<FloatArray>;
  11267. uvs2: Nullable<FloatArray>;
  11268. uvs3: Nullable<FloatArray>;
  11269. uvs4: Nullable<FloatArray>;
  11270. uvs5: Nullable<FloatArray>;
  11271. uvs6: Nullable<FloatArray>;
  11272. colors: Nullable<FloatArray>;
  11273. matricesIndices: Nullable<FloatArray>;
  11274. matricesWeights: Nullable<FloatArray>;
  11275. matricesIndicesExtra: Nullable<FloatArray>;
  11276. matricesWeightsExtra: Nullable<FloatArray>;
  11277. indices: Nullable<IndicesArray>;
  11278. set(data: FloatArray, kind: string): void;
  11279. /**
  11280. * Associates the vertexData to the passed Mesh.
  11281. * Sets it as updatable or not (default `false`).
  11282. * Returns the VertexData.
  11283. */
  11284. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  11285. /**
  11286. * Associates the vertexData to the passed Geometry.
  11287. * Sets it as updatable or not (default `false`).
  11288. * Returns the VertexData.
  11289. */
  11290. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  11291. /**
  11292. * Updates the associated mesh.
  11293. * Returns the VertexData.
  11294. */
  11295. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  11296. /**
  11297. * Updates the associated geometry.
  11298. * Returns the VertexData.
  11299. */
  11300. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  11301. private _applyTo(meshOrGeometry, updatable?);
  11302. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  11303. /**
  11304. * Transforms each position and each normal of the vertexData according to the passed Matrix.
  11305. * Returns the VertexData.
  11306. */
  11307. transform(matrix: Matrix): VertexData;
  11308. /**
  11309. * Merges the passed VertexData into the current one.
  11310. * Returns the modified VertexData.
  11311. */
  11312. merge(other: VertexData, options?: {
  11313. tangentLength?: number;
  11314. }): VertexData;
  11315. private _mergeElement(source, other, length?, defaultValue?);
  11316. /**
  11317. * Serializes the VertexData.
  11318. * Returns a serialized object.
  11319. */
  11320. serialize(): any;
  11321. /**
  11322. * Returns the object VertexData associated to the passed mesh.
  11323. */
  11324. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  11325. /**
  11326. * Returns the object VertexData associated to the passed geometry.
  11327. */
  11328. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  11329. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  11330. /**
  11331. * Creates the vertexData of the Ribbon.
  11332. */
  11333. static CreateRibbon(options: {
  11334. pathArray: Vector3[][];
  11335. closeArray?: boolean;
  11336. closePath?: boolean;
  11337. offset?: number;
  11338. sideOrientation?: number;
  11339. frontUVs?: Vector4;
  11340. backUVs?: Vector4;
  11341. invertUV?: boolean;
  11342. uvs?: Vector2[];
  11343. colors?: Color4[];
  11344. }): VertexData;
  11345. /**
  11346. * Creates the VertexData of the Box.
  11347. */
  11348. static CreateBox(options: {
  11349. size?: number;
  11350. width?: number;
  11351. height?: number;
  11352. depth?: number;
  11353. faceUV?: Vector4[];
  11354. faceColors?: Color4[];
  11355. sideOrientation?: number;
  11356. frontUVs?: Vector4;
  11357. backUVs?: Vector4;
  11358. }): VertexData;
  11359. /**
  11360. * Creates the VertexData of the Sphere.
  11361. */
  11362. static CreateSphere(options: {
  11363. segments?: number;
  11364. diameter?: number;
  11365. diameterX?: number;
  11366. diameterY?: number;
  11367. diameterZ?: number;
  11368. arc?: number;
  11369. slice?: number;
  11370. sideOrientation?: number;
  11371. frontUVs?: Vector4;
  11372. backUVs?: Vector4;
  11373. }): VertexData;
  11374. /**
  11375. * Creates the VertexData of the Cylinder or Cone.
  11376. */
  11377. static CreateCylinder(options: {
  11378. height?: number;
  11379. diameterTop?: number;
  11380. diameterBottom?: number;
  11381. diameter?: number;
  11382. tessellation?: number;
  11383. subdivisions?: number;
  11384. arc?: number;
  11385. faceColors?: Color4[];
  11386. faceUV?: Vector4[];
  11387. hasRings?: boolean;
  11388. enclose?: boolean;
  11389. sideOrientation?: number;
  11390. frontUVs?: Vector4;
  11391. backUVs?: Vector4;
  11392. }): VertexData;
  11393. /**
  11394. * Creates the VertexData of the Torus.
  11395. */
  11396. static CreateTorus(options: {
  11397. diameter?: number;
  11398. thickness?: number;
  11399. tessellation?: number;
  11400. sideOrientation?: number;
  11401. frontUVs?: Vector4;
  11402. backUVs?: Vector4;
  11403. }): VertexData;
  11404. /**
  11405. * Creates the VertexData of the LineSystem.
  11406. */
  11407. static CreateLineSystem(options: {
  11408. lines: Vector3[][];
  11409. colors?: Nullable<Color4[][]>;
  11410. }): VertexData;
  11411. /**
  11412. * Create the VertexData of the DashedLines.
  11413. */
  11414. static CreateDashedLines(options: {
  11415. points: Vector3[];
  11416. dashSize?: number;
  11417. gapSize?: number;
  11418. dashNb?: number;
  11419. }): VertexData;
  11420. /**
  11421. * Creates the VertexData of the Ground.
  11422. */
  11423. static CreateGround(options: {
  11424. width?: number;
  11425. height?: number;
  11426. subdivisions?: number;
  11427. subdivisionsX?: number;
  11428. subdivisionsY?: number;
  11429. }): VertexData;
  11430. /**
  11431. * Creates the VertexData of the TiledGround.
  11432. */
  11433. static CreateTiledGround(options: {
  11434. xmin: number;
  11435. zmin: number;
  11436. xmax: number;
  11437. zmax: number;
  11438. subdivisions?: {
  11439. w: number;
  11440. h: number;
  11441. };
  11442. precision?: {
  11443. w: number;
  11444. h: number;
  11445. };
  11446. }): VertexData;
  11447. /**
  11448. * Creates the VertexData of the Ground designed from a heightmap.
  11449. */
  11450. static CreateGroundFromHeightMap(options: {
  11451. width: number;
  11452. height: number;
  11453. subdivisions: number;
  11454. minHeight: number;
  11455. maxHeight: number;
  11456. colorFilter: Color3;
  11457. buffer: Uint8Array;
  11458. bufferWidth: number;
  11459. bufferHeight: number;
  11460. }): VertexData;
  11461. /**
  11462. * Creates the VertexData of the Plane.
  11463. */
  11464. static CreatePlane(options: {
  11465. size?: number;
  11466. width?: number;
  11467. height?: number;
  11468. sideOrientation?: number;
  11469. frontUVs?: Vector4;
  11470. backUVs?: Vector4;
  11471. }): VertexData;
  11472. /**
  11473. * Creates the VertexData of the Disc or regular Polygon.
  11474. */
  11475. static CreateDisc(options: {
  11476. radius?: number;
  11477. tessellation?: number;
  11478. arc?: number;
  11479. sideOrientation?: number;
  11480. frontUVs?: Vector4;
  11481. backUVs?: Vector4;
  11482. }): VertexData;
  11483. /**
  11484. * Re-creates the VertexData of the Polygon for sideOrientation.
  11485. */
  11486. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  11487. /**
  11488. * Creates the VertexData of the IcoSphere.
  11489. */
  11490. static CreateIcoSphere(options: {
  11491. radius?: number;
  11492. radiusX?: number;
  11493. radiusY?: number;
  11494. radiusZ?: number;
  11495. flat?: boolean;
  11496. subdivisions?: number;
  11497. sideOrientation?: number;
  11498. frontUVs?: Vector4;
  11499. backUVs?: Vector4;
  11500. }): VertexData;
  11501. /**
  11502. * Creates the VertexData of the Polyhedron.
  11503. */
  11504. static CreatePolyhedron(options: {
  11505. type?: number;
  11506. size?: number;
  11507. sizeX?: number;
  11508. sizeY?: number;
  11509. sizeZ?: number;
  11510. custom?: any;
  11511. faceUV?: Vector4[];
  11512. faceColors?: Color4[];
  11513. flat?: boolean;
  11514. sideOrientation?: number;
  11515. frontUVs?: Vector4;
  11516. backUVs?: Vector4;
  11517. }): VertexData;
  11518. /**
  11519. * Creates the VertexData of the Torus Knot.
  11520. */
  11521. static CreateTorusKnot(options: {
  11522. radius?: number;
  11523. tube?: number;
  11524. radialSegments?: number;
  11525. tubularSegments?: number;
  11526. p?: number;
  11527. q?: number;
  11528. sideOrientation?: number;
  11529. frontUVs?: Vector4;
  11530. backUVs?: Vector4;
  11531. }): VertexData;
  11532. /**
  11533. * @param {any} - positions (number[] or Float32Array)
  11534. * @param {any} - indices (number[] or Uint16Array)
  11535. * @param {any} - normals (number[] or Float32Array)
  11536. * options (optional) :
  11537. * facetPositions : optional array of facet positions (vector3)
  11538. * facetNormals : optional array of facet normals (vector3)
  11539. * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  11540. * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  11541. * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  11542. * bbSize : optional bounding box size data, required for facetPartitioning computation
  11543. * bInfo : optional bounding info, required for facetPartitioning computation
  11544. * useRightHandedSystem: optional boolean to for right handed system computation
  11545. * depthSort : optional boolean to enable the facet depth sort computation
  11546. * distanceTo : optional Vector3 to compute the facet depth from this location
  11547. * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  11548. */
  11549. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  11550. facetNormals?: any;
  11551. facetPositions?: any;
  11552. facetPartitioning?: any;
  11553. ratio?: number;
  11554. bInfo?: any;
  11555. bbSize?: Vector3;
  11556. subDiv?: any;
  11557. useRightHandedSystem?: boolean;
  11558. depthSort?: boolean;
  11559. distanceTo?: Vector3;
  11560. depthSortedFacets?: any;
  11561. }): void;
  11562. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  11563. /**
  11564. * Creates a new VertexData from the imported parameters.
  11565. */
  11566. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  11567. }
  11568. }
  11569. declare module BABYLON {
  11570. class MeshBuilder {
  11571. private static updateSideOrientation(orientation?);
  11572. /**
  11573. * Creates a box mesh.
  11574. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  11575. * The parameter `size` sets the size (float) of each box side (default 1).
  11576. * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`).
  11577. * 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).
  11578. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  11579. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11580. * 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).
  11581. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11582. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11583. */
  11584. static CreateBox(name: string, options: {
  11585. size?: number;
  11586. width?: number;
  11587. height?: number;
  11588. depth?: number;
  11589. faceUV?: Vector4[];
  11590. faceColors?: Color4[];
  11591. sideOrientation?: number;
  11592. frontUVs?: Vector4;
  11593. backUVs?: Vector4;
  11594. updatable?: boolean;
  11595. }, scene?: Nullable<Scene>): Mesh;
  11596. /**
  11597. * Creates a sphere mesh.
  11598. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  11599. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  11600. * 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`).
  11601. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  11602. * 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
  11603. * 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).
  11604. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11605. * 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).
  11606. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11607. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11608. */
  11609. static CreateSphere(name: string, options: {
  11610. segments?: number;
  11611. diameter?: number;
  11612. diameterX?: number;
  11613. diameterY?: number;
  11614. diameterZ?: number;
  11615. arc?: number;
  11616. slice?: number;
  11617. sideOrientation?: number;
  11618. frontUVs?: Vector4;
  11619. backUVs?: Vector4;
  11620. updatable?: boolean;
  11621. }, scene: any): Mesh;
  11622. /**
  11623. * Creates a plane polygonal mesh. By default, this is a disc.
  11624. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#disc
  11625. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  11626. * 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.
  11627. * 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
  11628. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11629. * 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).
  11630. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11631. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11632. */
  11633. static CreateDisc(name: string, options: {
  11634. radius?: number;
  11635. tessellation?: number;
  11636. arc?: number;
  11637. updatable?: boolean;
  11638. sideOrientation?: number;
  11639. frontUVs?: Vector4;
  11640. backUVs?: Vector4;
  11641. }, scene?: Nullable<Scene>): Mesh;
  11642. /**
  11643. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  11644. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#icosphere
  11645. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  11646. * 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`).
  11647. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  11648. * 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.
  11649. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11650. * 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).
  11651. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11652. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11653. */
  11654. static CreateIcoSphere(name: string, options: {
  11655. radius?: number;
  11656. radiusX?: number;
  11657. radiusY?: number;
  11658. radiusZ?: number;
  11659. flat?: boolean;
  11660. subdivisions?: number;
  11661. sideOrientation?: number;
  11662. frontUVs?: Vector4;
  11663. backUVs?: Vector4;
  11664. updatable?: boolean;
  11665. }, scene: Scene): Mesh;
  11666. /**
  11667. * Creates a ribbon mesh.
  11668. * 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.
  11669. *
  11670. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  11671. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  11672. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  11673. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  11674. * 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.
  11675. * 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.
  11676. * 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
  11677. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11678. * 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).
  11679. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11680. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  11681. * 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.
  11682. * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values.
  11683. * 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
  11684. * if you set `closePath` to `true`, there's one extra vertex per path in the geometry.
  11685. * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time.
  11686. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11687. */
  11688. static CreateRibbon(name: string, options: {
  11689. pathArray: Vector3[][];
  11690. closeArray?: boolean;
  11691. closePath?: boolean;
  11692. offset?: number;
  11693. updatable?: boolean;
  11694. sideOrientation?: number;
  11695. frontUVs?: Vector4;
  11696. backUVs?: Vector4;
  11697. instance?: Mesh;
  11698. invertUV?: boolean;
  11699. uvs?: Vector2[];
  11700. colors?: Color4[];
  11701. }, scene?: Nullable<Scene>): Mesh;
  11702. /**
  11703. * Creates a cylinder or a cone mesh.
  11704. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  11705. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  11706. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  11707. * 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.
  11708. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  11709. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  11710. * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  11711. * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  11712. * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  11713. * 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).
  11714. * 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
  11715. * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  11716. * 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
  11717. * 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.
  11718. * If `enclose` is false, a ring surface is one element.
  11719. * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  11720. * 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
  11721. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11722. * 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).
  11723. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11724. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11725. */
  11726. static CreateCylinder(name: string, options: {
  11727. height?: number;
  11728. diameterTop?: number;
  11729. diameterBottom?: number;
  11730. diameter?: number;
  11731. tessellation?: number;
  11732. subdivisions?: number;
  11733. arc?: number;
  11734. faceColors?: Color4[];
  11735. faceUV?: Vector4[];
  11736. updatable?: boolean;
  11737. hasRings?: boolean;
  11738. enclose?: boolean;
  11739. sideOrientation?: number;
  11740. frontUVs?: Vector4;
  11741. backUVs?: Vector4;
  11742. }, scene: any): Mesh;
  11743. /**
  11744. * Creates a torus mesh.
  11745. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  11746. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  11747. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  11748. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  11749. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11750. * 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).
  11751. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11752. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11753. */
  11754. static CreateTorus(name: string, options: {
  11755. diameter?: number;
  11756. thickness?: number;
  11757. tessellation?: number;
  11758. updatable?: boolean;
  11759. sideOrientation?: number;
  11760. frontUVs?: Vector4;
  11761. backUVs?: Vector4;
  11762. }, scene: any): Mesh;
  11763. /**
  11764. * Creates a torus knot mesh.
  11765. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  11766. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  11767. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  11768. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  11769. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  11770. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11771. * 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).
  11772. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11773. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11774. */
  11775. static CreateTorusKnot(name: string, options: {
  11776. radius?: number;
  11777. tube?: number;
  11778. radialSegments?: number;
  11779. tubularSegments?: number;
  11780. p?: number;
  11781. q?: number;
  11782. updatable?: boolean;
  11783. sideOrientation?: number;
  11784. frontUVs?: Vector4;
  11785. backUVs?: Vector4;
  11786. }, scene: any): Mesh;
  11787. /**
  11788. * Creates a line system mesh.
  11789. * A line system is a pool of many lines gathered in a single mesh.
  11790. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#linesystem
  11791. * 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.
  11792. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function.
  11793. * The parameter `lines` is an array of lines, each line being an array of successive Vector3.
  11794. * 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
  11795. * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point.
  11796. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need the alpha blending (faster).
  11797. * 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
  11798. * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines.
  11799. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11800. */
  11801. static CreateLineSystem(name: string, options: {
  11802. lines: Vector3[][];
  11803. updatable: boolean;
  11804. instance: Nullable<LinesMesh>;
  11805. colors?: Nullable<Color4[][]>;
  11806. useVertexAlpha?: boolean;
  11807. }, scene: Nullable<Scene>): LinesMesh;
  11808. /**
  11809. * Creates a line mesh.
  11810. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lines
  11811. * 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.
  11812. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  11813. * The parameter `points` is an array successive Vector3.
  11814. * 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
  11815. * The optional parameter `colors` is an array of successive Color4, one per line point.
  11816. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need alpha blending (faster).
  11817. * When updating an instance, remember that only point positions can change, not the number of points.
  11818. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11819. */
  11820. static CreateLines(name: string, options: {
  11821. points: Vector3[];
  11822. updatable: boolean;
  11823. instance: Nullable<LinesMesh>;
  11824. colors?: Color4[];
  11825. useVertexAlpha?: boolean;
  11826. }, scene?: Nullable<Scene>): LinesMesh;
  11827. /**
  11828. * Creates a dashed line mesh.
  11829. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#dashed-lines
  11830. * 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.
  11831. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  11832. * The parameter `points` is an array successive Vector3.
  11833. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  11834. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  11835. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  11836. * 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
  11837. * When updating an instance, remember that only point positions can change, not the number of points.
  11838. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11839. */
  11840. static CreateDashedLines(name: string, options: {
  11841. points: Vector3[];
  11842. dashSize?: number;
  11843. gapSize?: number;
  11844. dashNb?: number;
  11845. updatable?: boolean;
  11846. instance?: LinesMesh;
  11847. }, scene?: Nullable<Scene>): LinesMesh;
  11848. /**
  11849. * Creates an extruded shape mesh.
  11850. * 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.
  11851. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#extruded-shapes
  11852. *
  11853. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  11854. * 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
  11855. * extruded along the Z axis.
  11856. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  11857. * 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.
  11858. * The parameter `scale` (float, default 1) is the value to scale the shape.
  11859. * 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
  11860. * 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
  11861. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  11862. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11863. * 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).
  11864. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11865. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  11866. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11867. */
  11868. static ExtrudeShape(name: string, options: {
  11869. shape: Vector3[];
  11870. path: Vector3[];
  11871. scale?: number;
  11872. rotation?: number;
  11873. cap?: number;
  11874. updatable?: boolean;
  11875. sideOrientation?: number;
  11876. frontUVs?: Vector4;
  11877. backUVs?: Vector4;
  11878. instance?: Mesh;
  11879. invertUV?: boolean;
  11880. }, scene?: Nullable<Scene>): Mesh;
  11881. /**
  11882. * Creates an custom extruded shape mesh.
  11883. * 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.
  11884. * tuto :http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#custom-extruded-shapes
  11885. *
  11886. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  11887. * 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
  11888. * extruded along the Z axis.
  11889. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  11890. * 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
  11891. * and the distance of this point from the begining of the path :
  11892. * ```javascript
  11893. * var rotationFunction = function(i, distance) {
  11894. * // do things
  11895. * return rotationValue; }
  11896. * ```
  11897. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  11898. * 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
  11899. * and the distance of this point from the begining of the path :
  11900. * ```javascript
  11901. * var scaleFunction = function(i, distance) {
  11902. * // do things
  11903. * return scaleValue;}
  11904. * ```
  11905. * It must returns a float value that will be the scale value applied to the shape on each path point.
  11906. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  11907. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  11908. * 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
  11909. * 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
  11910. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  11911. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11912. * 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).
  11913. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11914. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  11915. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11916. */
  11917. static ExtrudeShapeCustom(name: string, options: {
  11918. shape: Vector3[];
  11919. path: Vector3[];
  11920. scaleFunction?: any;
  11921. rotationFunction?: any;
  11922. ribbonCloseArray?: boolean;
  11923. ribbonClosePath?: boolean;
  11924. cap?: number;
  11925. updatable?: boolean;
  11926. sideOrientation?: number;
  11927. frontUVs?: Vector4;
  11928. backUVs?: Vector4;
  11929. instance?: Mesh;
  11930. invertUV?: boolean;
  11931. }, scene: Scene): Mesh;
  11932. /**
  11933. * Creates lathe mesh.
  11934. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  11935. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lathe
  11936. *
  11937. * 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
  11938. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  11939. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  11940. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  11941. * 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.
  11942. * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc".
  11943. * 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
  11944. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11945. * 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).
  11946. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11947. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  11948. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11949. */
  11950. static CreateLathe(name: string, options: {
  11951. shape: Vector3[];
  11952. radius?: number;
  11953. tessellation?: number;
  11954. arc?: number;
  11955. closed?: boolean;
  11956. updatable?: boolean;
  11957. sideOrientation?: number;
  11958. frontUVs?: Vector4;
  11959. backUVs?: Vector4;
  11960. cap?: number;
  11961. invertUV?: boolean;
  11962. }, scene: Scene): Mesh;
  11963. /**
  11964. * Creates a plane mesh.
  11965. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  11966. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  11967. * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`).
  11968. * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane.
  11969. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11970. * 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).
  11971. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11972. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11973. */
  11974. static CreatePlane(name: string, options: {
  11975. size?: number;
  11976. width?: number;
  11977. height?: number;
  11978. sideOrientation?: number;
  11979. frontUVs?: Vector4;
  11980. backUVs?: Vector4;
  11981. updatable?: boolean;
  11982. sourcePlane?: Plane;
  11983. }, scene: Scene): Mesh;
  11984. /**
  11985. * Creates a ground mesh.
  11986. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  11987. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  11988. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  11989. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11990. */
  11991. static CreateGround(name: string, options: {
  11992. width?: number;
  11993. height?: number;
  11994. subdivisions?: number;
  11995. subdivisionsX?: number;
  11996. subdivisionsY?: number;
  11997. updatable?: boolean;
  11998. }, scene: any): Mesh;
  11999. /**
  12000. * Creates a tiled ground mesh.
  12001. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  12002. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  12003. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  12004. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  12005. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  12006. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  12007. * numbers of subdivisions on the ground width and height of each tile.
  12008. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12009. */
  12010. static CreateTiledGround(name: string, options: {
  12011. xmin: number;
  12012. zmin: number;
  12013. xmax: number;
  12014. zmax: number;
  12015. subdivisions?: {
  12016. w: number;
  12017. h: number;
  12018. };
  12019. precision?: {
  12020. w: number;
  12021. h: number;
  12022. };
  12023. updatable?: boolean;
  12024. }, scene: Scene): Mesh;
  12025. /**
  12026. * Creates a ground mesh from a height map.
  12027. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  12028. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  12029. * The parameter `url` sets the URL of the height map image resource.
  12030. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  12031. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  12032. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  12033. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  12034. * 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.
  12035. * 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).
  12036. * This function is passed the newly built mesh :
  12037. * ```javascript
  12038. * function(mesh) { // do things
  12039. * return; }
  12040. * ```
  12041. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12042. */
  12043. static CreateGroundFromHeightMap(name: string, url: string, options: {
  12044. width?: number;
  12045. height?: number;
  12046. subdivisions?: number;
  12047. minHeight?: number;
  12048. maxHeight?: number;
  12049. colorFilter?: Color3;
  12050. updatable?: boolean;
  12051. onReady?: (mesh: GroundMesh) => void;
  12052. }, scene: Scene): GroundMesh;
  12053. /**
  12054. * Creates a polygon mesh.
  12055. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  12056. * 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.
  12057. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12058. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12059. * 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).
  12060. * Remember you can only change the shape positions, not their number when updating a polygon.
  12061. */
  12062. static CreatePolygon(name: string, options: {
  12063. shape: Vector3[];
  12064. holes?: Vector3[][];
  12065. depth?: number;
  12066. faceUV?: Vector4[];
  12067. faceColors?: Color4[];
  12068. updatable?: boolean;
  12069. sideOrientation?: number;
  12070. frontUVs?: Vector4;
  12071. backUVs?: Vector4;
  12072. }, scene: Scene): Mesh;
  12073. /**
  12074. * Creates an extruded polygon mesh, with depth in the Y direction.
  12075. * 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).
  12076. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  12077. */
  12078. static ExtrudePolygon(name: string, options: {
  12079. shape: Vector3[];
  12080. holes?: Vector3[][];
  12081. depth?: number;
  12082. faceUV?: Vector4[];
  12083. faceColors?: Color4[];
  12084. updatable?: boolean;
  12085. sideOrientation?: number;
  12086. frontUVs?: Vector4;
  12087. backUVs?: Vector4;
  12088. }, scene: Scene): Mesh;
  12089. /**
  12090. * Creates a tube mesh.
  12091. * 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.
  12092. *
  12093. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  12094. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  12095. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  12096. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  12097. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  12098. * 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.
  12099. * It must return a radius value (positive float) :
  12100. * ```javascript
  12101. * var radiusFunction = function(i, distance) {
  12102. * // do things
  12103. * return radius; }
  12104. * ```
  12105. * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc.
  12106. * 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
  12107. * 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
  12108. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12109. * 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).
  12110. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12111. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  12112. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12113. */
  12114. static CreateTube(name: string, options: {
  12115. path: Vector3[];
  12116. radius?: number;
  12117. tessellation?: number;
  12118. radiusFunction?: {
  12119. (i: number, distance: number): number;
  12120. };
  12121. cap?: number;
  12122. arc?: number;
  12123. updatable?: boolean;
  12124. sideOrientation?: number;
  12125. frontUVs?: Vector4;
  12126. backUVs?: Vector4;
  12127. instance?: Mesh;
  12128. invertUV?: boolean;
  12129. }, scene: Scene): Mesh;
  12130. /**
  12131. * Creates a polyhedron mesh.
  12132. *
  12133. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#polyhedron
  12134. * 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
  12135. * to choose the wanted type.
  12136. * The parameter `size` (positive float, default 1) sets the polygon size.
  12137. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  12138. * 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`.
  12139. * 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
  12140. * 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)`).
  12141. * 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
  12142. * 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.
  12143. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12144. * 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).
  12145. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12146. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12147. */
  12148. static CreatePolyhedron(name: string, options: {
  12149. type?: number;
  12150. size?: number;
  12151. sizeX?: number;
  12152. sizeY?: number;
  12153. sizeZ?: number;
  12154. custom?: any;
  12155. faceUV?: Vector4[];
  12156. faceColors?: Color4[];
  12157. flat?: boolean;
  12158. updatable?: boolean;
  12159. sideOrientation?: number;
  12160. frontUVs?: Vector4;
  12161. backUVs?: Vector4;
  12162. }, scene: Scene): Mesh;
  12163. /**
  12164. * Creates a decal mesh.
  12165. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#decals
  12166. * 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.
  12167. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  12168. * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates.
  12169. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  12170. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  12171. */
  12172. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  12173. position?: Vector3;
  12174. normal?: Vector3;
  12175. size?: Vector3;
  12176. angle?: number;
  12177. }): Mesh;
  12178. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  12179. }
  12180. }
  12181. declare module BABYLON {
  12182. class MeshLODLevel {
  12183. distance: number;
  12184. mesh: Mesh;
  12185. constructor(distance: number, mesh: Mesh);
  12186. }
  12187. }
  12188. declare module BABYLON {
  12189. /**
  12190. * A simplifier interface for future simplification implementations.
  12191. */
  12192. interface ISimplifier {
  12193. /**
  12194. * Simplification of a given mesh according to the given settings.
  12195. * Since this requires computation, it is assumed that the function runs async.
  12196. * @param settings The settings of the simplification, including quality and distance
  12197. * @param successCallback A callback that will be called after the mesh was simplified.
  12198. * @param errorCallback in case of an error, this callback will be called. optional.
  12199. */
  12200. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  12201. }
  12202. /**
  12203. * Expected simplification settings.
  12204. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  12205. */
  12206. interface ISimplificationSettings {
  12207. quality: number;
  12208. distance: number;
  12209. optimizeMesh?: boolean;
  12210. }
  12211. class SimplificationSettings implements ISimplificationSettings {
  12212. quality: number;
  12213. distance: number;
  12214. optimizeMesh: boolean | undefined;
  12215. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  12216. }
  12217. interface ISimplificationTask {
  12218. settings: Array<ISimplificationSettings>;
  12219. simplificationType: SimplificationType;
  12220. mesh: Mesh;
  12221. successCallback?: () => void;
  12222. parallelProcessing: boolean;
  12223. }
  12224. class SimplificationQueue {
  12225. private _simplificationArray;
  12226. running: boolean;
  12227. constructor();
  12228. addTask(task: ISimplificationTask): void;
  12229. executeNext(): void;
  12230. runSimplification(task: ISimplificationTask): void;
  12231. private getSimplifier(task);
  12232. }
  12233. /**
  12234. * The implemented types of simplification.
  12235. * At the moment only Quadratic Error Decimation is implemented.
  12236. */
  12237. enum SimplificationType {
  12238. QUADRATIC = 0,
  12239. }
  12240. class DecimationTriangle {
  12241. vertices: Array<DecimationVertex>;
  12242. normal: Vector3;
  12243. error: Array<number>;
  12244. deleted: boolean;
  12245. isDirty: boolean;
  12246. borderFactor: number;
  12247. deletePending: boolean;
  12248. originalOffset: number;
  12249. constructor(vertices: Array<DecimationVertex>);
  12250. }
  12251. class DecimationVertex {
  12252. position: Vector3;
  12253. id: number;
  12254. q: QuadraticMatrix;
  12255. isBorder: boolean;
  12256. triangleStart: number;
  12257. triangleCount: number;
  12258. originalOffsets: Array<number>;
  12259. constructor(position: Vector3, id: number);
  12260. updatePosition(newPosition: Vector3): void;
  12261. }
  12262. class QuadraticMatrix {
  12263. data: Array<number>;
  12264. constructor(data?: Array<number>);
  12265. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  12266. addInPlace(matrix: QuadraticMatrix): void;
  12267. addArrayInPlace(data: Array<number>): void;
  12268. add(matrix: QuadraticMatrix): QuadraticMatrix;
  12269. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  12270. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  12271. }
  12272. class Reference {
  12273. vertexId: number;
  12274. triangleId: number;
  12275. constructor(vertexId: number, triangleId: number);
  12276. }
  12277. /**
  12278. * An implementation of the Quadratic Error simplification algorithm.
  12279. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  12280. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  12281. * @author RaananW
  12282. */
  12283. class QuadraticErrorSimplification implements ISimplifier {
  12284. private _mesh;
  12285. private triangles;
  12286. private vertices;
  12287. private references;
  12288. private _reconstructedMesh;
  12289. syncIterations: number;
  12290. aggressiveness: number;
  12291. decimationIterations: number;
  12292. boundingBoxEpsilon: number;
  12293. constructor(_mesh: Mesh);
  12294. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  12295. private runDecimation(settings, submeshIndex, successCallback);
  12296. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  12297. private init(callback);
  12298. private reconstructMesh(submeshIndex);
  12299. private initDecimatedMesh();
  12300. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  12301. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  12302. private identifyBorder();
  12303. private updateMesh(identifyBorders?);
  12304. private vertexError(q, point);
  12305. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  12306. }
  12307. }
  12308. declare module BABYLON {
  12309. class Polygon {
  12310. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  12311. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  12312. static Parse(input: string): Vector2[];
  12313. static StartingAt(x: number, y: number): Path2;
  12314. }
  12315. class PolygonMeshBuilder {
  12316. private _points;
  12317. private _outlinepoints;
  12318. private _holes;
  12319. private _name;
  12320. private _scene;
  12321. private _epoints;
  12322. private _eholes;
  12323. private _addToepoint(points);
  12324. constructor(name: string, contours: Path2, scene: Scene);
  12325. constructor(name: string, contours: Vector2[], scene: Scene);
  12326. addHole(hole: Vector2[]): PolygonMeshBuilder;
  12327. build(updatable?: boolean, depth?: number): Mesh;
  12328. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  12329. }
  12330. }
  12331. declare module BABYLON {
  12332. class BaseSubMesh {
  12333. _materialDefines: Nullable<MaterialDefines>;
  12334. _materialEffect: Nullable<Effect>;
  12335. readonly effect: Nullable<Effect>;
  12336. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  12337. }
  12338. class SubMesh extends BaseSubMesh implements ICullable {
  12339. materialIndex: number;
  12340. verticesStart: number;
  12341. verticesCount: number;
  12342. indexStart: number;
  12343. indexCount: number;
  12344. linesIndexCount: number;
  12345. private _mesh;
  12346. private _renderingMesh;
  12347. private _boundingInfo;
  12348. private _linesIndexBuffer;
  12349. _lastColliderWorldVertices: Nullable<Vector3[]>;
  12350. _trianglePlanes: Plane[];
  12351. _lastColliderTransformMatrix: Matrix;
  12352. _renderId: number;
  12353. _alphaIndex: number;
  12354. _distanceToCamera: number;
  12355. _id: number;
  12356. private _currentMaterial;
  12357. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  12358. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  12359. readonly IsGlobal: boolean;
  12360. /**
  12361. * Returns the submesh BoudingInfo object.
  12362. */
  12363. getBoundingInfo(): BoundingInfo;
  12364. /**
  12365. * Sets the submesh BoundingInfo.
  12366. * Return the SubMesh.
  12367. */
  12368. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  12369. /**
  12370. * Returns the mesh of the current submesh.
  12371. */
  12372. getMesh(): AbstractMesh;
  12373. /**
  12374. * Returns the rendering mesh of the submesh.
  12375. */
  12376. getRenderingMesh(): Mesh;
  12377. /**
  12378. * Returns the submesh material.
  12379. */
  12380. getMaterial(): Nullable<Material>;
  12381. /**
  12382. * Sets a new updated BoundingInfo object to the submesh.
  12383. * Returns the SubMesh.
  12384. */
  12385. refreshBoundingInfo(): SubMesh;
  12386. _checkCollision(collider: Collider): boolean;
  12387. /**
  12388. * Updates the submesh BoundingInfo.
  12389. * Returns the Submesh.
  12390. */
  12391. updateBoundingInfo(world: Matrix): SubMesh;
  12392. /**
  12393. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  12394. * Boolean returned.
  12395. */
  12396. isInFrustum(frustumPlanes: Plane[]): boolean;
  12397. /**
  12398. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  12399. * Boolean returned.
  12400. */
  12401. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  12402. /**
  12403. * Renders the submesh.
  12404. * Returns it.
  12405. */
  12406. render(enableAlphaMode: boolean): SubMesh;
  12407. /**
  12408. * Returns a new Index Buffer.
  12409. * Type returned : WebGLBuffer.
  12410. */
  12411. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  12412. /**
  12413. * True is the passed Ray intersects the submesh bounding box.
  12414. * Boolean returned.
  12415. */
  12416. canIntersects(ray: Ray): boolean;
  12417. /**
  12418. * Returns an object IntersectionInfo.
  12419. */
  12420. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  12421. _rebuild(): void;
  12422. /**
  12423. * Creates a new Submesh from the passed Mesh.
  12424. */
  12425. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  12426. /**
  12427. * Disposes the Submesh.
  12428. * Returns nothing.
  12429. */
  12430. dispose(): void;
  12431. /**
  12432. * Creates a new Submesh from the passed parameters :
  12433. * - materialIndex (integer) : the index of the main mesh material.
  12434. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  12435. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  12436. * - mesh (Mesh) : the main mesh to create the submesh from.
  12437. * - renderingMesh (optional Mesh) : rendering mesh.
  12438. */
  12439. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  12440. }
  12441. }
  12442. declare module BABYLON {
  12443. class TransformNode extends Node {
  12444. static BILLBOARDMODE_NONE: number;
  12445. static BILLBOARDMODE_X: number;
  12446. static BILLBOARDMODE_Y: number;
  12447. static BILLBOARDMODE_Z: number;
  12448. static BILLBOARDMODE_ALL: number;
  12449. private _rotation;
  12450. private _rotationQuaternion;
  12451. protected _scaling: Vector3;
  12452. protected _isDirty: boolean;
  12453. private _transformToBoneReferal;
  12454. billboardMode: number;
  12455. scalingDeterminant: number;
  12456. infiniteDistance: boolean;
  12457. position: Vector3;
  12458. _poseMatrix: Matrix;
  12459. private _localWorld;
  12460. _worldMatrix: Matrix;
  12461. _worldMatrixDeterminant: number;
  12462. private _absolutePosition;
  12463. private _pivotMatrix;
  12464. private _pivotMatrixInverse;
  12465. private _postMultiplyPivotMatrix;
  12466. protected _isWorldMatrixFrozen: boolean;
  12467. /**
  12468. * An event triggered after the world matrix is updated
  12469. * @type {BABYLON.Observable}
  12470. */
  12471. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  12472. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  12473. /**
  12474. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  12475. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  12476. * Default : (0.0, 0.0, 0.0)
  12477. */
  12478. rotation: Vector3;
  12479. /**
  12480. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  12481. * Default : (1.0, 1.0, 1.0)
  12482. */
  12483. /**
  12484. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  12485. * Default : (1.0, 1.0, 1.0)
  12486. */
  12487. scaling: Vector3;
  12488. /**
  12489. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  12490. * It's null by default.
  12491. * 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)
  12492. */
  12493. rotationQuaternion: Nullable<Quaternion>;
  12494. /**
  12495. * Returns the latest update of the World matrix
  12496. * Returns a Matrix.
  12497. */
  12498. getWorldMatrix(): Matrix;
  12499. /**
  12500. * Returns the latest update of the World matrix determinant.
  12501. */
  12502. protected _getWorldMatrixDeterminant(): number;
  12503. /**
  12504. * Returns directly the latest state of the mesh World matrix.
  12505. * A Matrix is returned.
  12506. */
  12507. readonly worldMatrixFromCache: Matrix;
  12508. /**
  12509. * Copies the paramater passed Matrix into the mesh Pose matrix.
  12510. * Returns the AbstractMesh.
  12511. */
  12512. updatePoseMatrix(matrix: Matrix): TransformNode;
  12513. /**
  12514. * Returns the mesh Pose matrix.
  12515. * Returned object : Matrix
  12516. */
  12517. getPoseMatrix(): Matrix;
  12518. _isSynchronized(): boolean;
  12519. _initCache(): void;
  12520. markAsDirty(property: string): TransformNode;
  12521. /**
  12522. * Returns the current mesh absolute position.
  12523. * Retuns a Vector3.
  12524. */
  12525. readonly absolutePosition: Vector3;
  12526. /**
  12527. * Sets a new matrix to apply before all other transformation
  12528. * @param matrix defines the transform matrix
  12529. * @returns the current TransformNode
  12530. */
  12531. setPreTransformMatrix(matrix: Matrix): TransformNode;
  12532. /**
  12533. * Sets a new pivot matrix to the current node
  12534. * @param matrix defines the new pivot matrix to use
  12535. * @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
  12536. * @returns the current TransformNode
  12537. */
  12538. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  12539. /**
  12540. * Returns the mesh pivot matrix.
  12541. * Default : Identity.
  12542. * A Matrix is returned.
  12543. */
  12544. getPivotMatrix(): Matrix;
  12545. /**
  12546. * Prevents the World matrix to be computed any longer.
  12547. * Returns the AbstractMesh.
  12548. */
  12549. freezeWorldMatrix(): TransformNode;
  12550. /**
  12551. * Allows back the World matrix computation.
  12552. * Returns the AbstractMesh.
  12553. */
  12554. unfreezeWorldMatrix(): this;
  12555. /**
  12556. * True if the World matrix has been frozen.
  12557. * Returns a boolean.
  12558. */
  12559. readonly isWorldMatrixFrozen: boolean;
  12560. /**
  12561. * Retuns the mesh absolute position in the World.
  12562. * Returns a Vector3.
  12563. */
  12564. getAbsolutePosition(): Vector3;
  12565. /**
  12566. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  12567. * Returns the AbstractMesh.
  12568. */
  12569. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  12570. /**
  12571. * Sets the mesh position in its local space.
  12572. * Returns the AbstractMesh.
  12573. */
  12574. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  12575. /**
  12576. * Returns the mesh position in the local space from the current World matrix values.
  12577. * Returns a new Vector3.
  12578. */
  12579. getPositionExpressedInLocalSpace(): Vector3;
  12580. /**
  12581. * Translates the mesh along the passed Vector3 in its local space.
  12582. * Returns the AbstractMesh.
  12583. */
  12584. locallyTranslate(vector3: Vector3): TransformNode;
  12585. private static _lookAtVectorCache;
  12586. /**
  12587. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  12588. * @param targetPoint the position (must be in same space as current mesh) to look at
  12589. * @param yawCor optional yaw (y-axis) correction in radians
  12590. * @param pitchCor optional pitch (x-axis) correction in radians
  12591. * @param rollCor optional roll (z-axis) correction in radians
  12592. * @param space the choosen space of the target
  12593. * @returns the TransformNode.
  12594. */
  12595. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  12596. /**
  12597. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  12598. * This Vector3 is expressed in the World space.
  12599. */
  12600. getDirection(localAxis: Vector3): Vector3;
  12601. /**
  12602. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  12603. * localAxis is expressed in the mesh local space.
  12604. * result is computed in the Wordl space from the mesh World matrix.
  12605. * Returns the AbstractMesh.
  12606. */
  12607. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  12608. /**
  12609. * Sets a new pivot point to the current node
  12610. * @param point defines the new pivot point to use
  12611. * @param space defines if the point is in world or local space (local by default)
  12612. * @returns the current TransformNode
  12613. */
  12614. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  12615. /**
  12616. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  12617. */
  12618. getPivotPoint(): Vector3;
  12619. /**
  12620. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  12621. * Returns the AbstractMesh.
  12622. */
  12623. getPivotPointToRef(result: Vector3): TransformNode;
  12624. /**
  12625. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  12626. */
  12627. getAbsolutePivotPoint(): Vector3;
  12628. /**
  12629. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  12630. * Returns the AbstractMesh.
  12631. */
  12632. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  12633. /**
  12634. * Defines the passed node as the parent of the current node.
  12635. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  12636. * Returns the TransformNode.
  12637. */
  12638. setParent(node: Nullable<Node>): TransformNode;
  12639. private _nonUniformScaling;
  12640. readonly nonUniformScaling: boolean;
  12641. _updateNonUniformScalingState(value: boolean): boolean;
  12642. /**
  12643. * Attach the current TransformNode to another TransformNode associated with a bone
  12644. * @param bone Bone affecting the TransformNode
  12645. * @param affectedTransformNode TransformNode associated with the bone
  12646. */
  12647. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  12648. detachFromBone(): TransformNode;
  12649. private static _rotationAxisCache;
  12650. /**
  12651. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  12652. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  12653. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  12654. * The passed axis is also normalized.
  12655. * Returns the AbstractMesh.
  12656. */
  12657. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  12658. /**
  12659. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  12660. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  12661. * The passed axis is also normalized.
  12662. * Returns the AbstractMesh.
  12663. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  12664. */
  12665. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  12666. /**
  12667. * Translates the mesh along the axis vector for the passed distance in the given space.
  12668. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  12669. * Returns the AbstractMesh.
  12670. */
  12671. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  12672. /**
  12673. * Adds a rotation step to the mesh current rotation.
  12674. * x, y, z are Euler angles expressed in radians.
  12675. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  12676. * This means this rotation is made in the mesh local space only.
  12677. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  12678. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  12679. * ```javascript
  12680. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  12681. * ```
  12682. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  12683. * 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.
  12684. * Returns the AbstractMesh.
  12685. */
  12686. addRotation(x: number, y: number, z: number): TransformNode;
  12687. /**
  12688. * Computes the mesh World matrix and returns it.
  12689. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  12690. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  12691. * If the parameter `force`is set to `true`, the actual computation is done.
  12692. * Returns the mesh World Matrix.
  12693. */
  12694. computeWorldMatrix(force?: boolean): Matrix;
  12695. protected _afterComputeWorldMatrix(): void;
  12696. /**
  12697. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  12698. * @param func: callback function to add
  12699. *
  12700. * Returns the TransformNode.
  12701. */
  12702. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  12703. /**
  12704. * Removes a registered callback function.
  12705. * Returns the TransformNode.
  12706. */
  12707. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  12708. /**
  12709. * Clone the current transform node
  12710. * Returns the new transform node
  12711. * @param name Name of the new clone
  12712. * @param newParent New parent for the clone
  12713. * @param doNotCloneChildren Do not clone children hierarchy
  12714. */
  12715. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  12716. serialize(currentSerializationObject?: any): any;
  12717. /**
  12718. * Returns a new TransformNode object parsed from the source provided.
  12719. * The parameter `parsedMesh` is the source.
  12720. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  12721. */
  12722. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  12723. /**
  12724. * Disposes the TransformNode.
  12725. * By default, all the children are also disposed unless the parameter `doNotRecurse` is set to `true`.
  12726. * Returns nothing.
  12727. */
  12728. dispose(doNotRecurse?: boolean): void;
  12729. }
  12730. }
  12731. declare module BABYLON {
  12732. class VertexBuffer {
  12733. private _buffer;
  12734. private _kind;
  12735. private _offset;
  12736. private _size;
  12737. private _stride;
  12738. private _ownsBuffer;
  12739. constructor(engine: any, data: FloatArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number);
  12740. _rebuild(): void;
  12741. /**
  12742. * Returns the kind of the VertexBuffer (string).
  12743. */
  12744. getKind(): string;
  12745. /**
  12746. * Boolean : is the VertexBuffer updatable ?
  12747. */
  12748. isUpdatable(): boolean;
  12749. /**
  12750. * Returns an array of numbers or a Float32Array containing the VertexBuffer data.
  12751. */
  12752. getData(): Nullable<FloatArray>;
  12753. /**
  12754. * Returns the WebGLBuffer associated to the VertexBuffer.
  12755. */
  12756. getBuffer(): Nullable<WebGLBuffer>;
  12757. /**
  12758. * Returns the stride of the VertexBuffer (integer).
  12759. */
  12760. getStrideSize(): number;
  12761. /**
  12762. * Returns the offset (integer).
  12763. */
  12764. getOffset(): number;
  12765. /**
  12766. * Returns the VertexBuffer total size (integer).
  12767. */
  12768. getSize(): number;
  12769. /**
  12770. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  12771. */
  12772. getIsInstanced(): boolean;
  12773. /**
  12774. * Returns the instancing divisor, zero for non-instanced (integer).
  12775. */
  12776. getInstanceDivisor(): number;
  12777. /**
  12778. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  12779. * Returns the created WebGLBuffer.
  12780. */
  12781. create(data?: FloatArray): void;
  12782. /**
  12783. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  12784. * This function will create a new buffer if the current one is not updatable
  12785. * Returns the updated WebGLBuffer.
  12786. */
  12787. update(data: FloatArray): void;
  12788. /**
  12789. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  12790. * Returns the directly updated WebGLBuffer.
  12791. */
  12792. updateDirectly(data: Float32Array, offset: number): void;
  12793. /**
  12794. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  12795. */
  12796. dispose(): void;
  12797. private static _PositionKind;
  12798. private static _NormalKind;
  12799. private static _TangentKind;
  12800. private static _UVKind;
  12801. private static _UV2Kind;
  12802. private static _UV3Kind;
  12803. private static _UV4Kind;
  12804. private static _UV5Kind;
  12805. private static _UV6Kind;
  12806. private static _ColorKind;
  12807. private static _MatricesIndicesKind;
  12808. private static _MatricesWeightsKind;
  12809. private static _MatricesIndicesExtraKind;
  12810. private static _MatricesWeightsExtraKind;
  12811. static readonly PositionKind: string;
  12812. static readonly NormalKind: string;
  12813. static readonly TangentKind: string;
  12814. static readonly UVKind: string;
  12815. static readonly UV2Kind: string;
  12816. static readonly UV3Kind: string;
  12817. static readonly UV4Kind: string;
  12818. static readonly UV5Kind: string;
  12819. static readonly UV6Kind: string;
  12820. static readonly ColorKind: string;
  12821. static readonly MatricesIndicesKind: string;
  12822. static readonly MatricesWeightsKind: string;
  12823. static readonly MatricesIndicesExtraKind: string;
  12824. static readonly MatricesWeightsExtraKind: string;
  12825. }
  12826. }
  12827. declare module BABYLON {
  12828. class Scalar {
  12829. /**
  12830. * Two pi constants convenient for computation.
  12831. */
  12832. static TwoPi: number;
  12833. /**
  12834. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  12835. */
  12836. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  12837. /**
  12838. * Returns a string : the upper case translation of the number i to hexadecimal.
  12839. */
  12840. static ToHex(i: number): string;
  12841. /**
  12842. * Returns -1 if value is negative and +1 is value is positive.
  12843. * Returns the value itself if it's equal to zero.
  12844. */
  12845. static Sign(value: number): number;
  12846. /**
  12847. * Returns the value itself if it's between min and max.
  12848. * Returns min if the value is lower than min.
  12849. * Returns max if the value is greater than max.
  12850. */
  12851. static Clamp(value: number, min?: number, max?: number): number;
  12852. /**
  12853. * Returns the log2 of value.
  12854. */
  12855. static Log2(value: number): number;
  12856. /**
  12857. * Loops the value, so that it is never larger than length and never smaller than 0.
  12858. *
  12859. * This is similar to the modulo operator but it works with floating point numbers.
  12860. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  12861. * With t = 5 and length = 2.5, the result would be 0.0.
  12862. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  12863. */
  12864. static Repeat(value: number, length: number): number;
  12865. /**
  12866. * Normalize the value between 0.0 and 1.0 using min and max values
  12867. */
  12868. static Normalize(value: number, min: number, max: number): number;
  12869. /**
  12870. * Denormalize the value from 0.0 and 1.0 using min and max values
  12871. */
  12872. static Denormalize(normalized: number, min: number, max: number): number;
  12873. /**
  12874. * Calculates the shortest difference between two given angles given in degrees.
  12875. */
  12876. static DeltaAngle(current: number, target: number): number;
  12877. /**
  12878. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  12879. *
  12880. * The returned value will move back and forth between 0 and length
  12881. */
  12882. static PingPong(tx: number, length: number): number;
  12883. /**
  12884. * Interpolates between min and max with smoothing at the limits.
  12885. *
  12886. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  12887. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  12888. */
  12889. static SmoothStep(from: number, to: number, tx: number): number;
  12890. /**
  12891. * Moves a value current towards target.
  12892. *
  12893. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  12894. * Negative values of maxDelta pushes the value away from target.
  12895. */
  12896. static MoveTowards(current: number, target: number, maxDelta: number): number;
  12897. /**
  12898. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  12899. *
  12900. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  12901. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  12902. */
  12903. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  12904. /**
  12905. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  12906. */
  12907. static Lerp(start: number, end: number, amount: number): number;
  12908. /**
  12909. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  12910. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  12911. */
  12912. static LerpAngle(start: number, end: number, amount: number): number;
  12913. /**
  12914. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  12915. */
  12916. static InverseLerp(a: number, b: number, value: number): number;
  12917. /**
  12918. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  12919. */
  12920. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  12921. /**
  12922. * Returns a random float number between and min and max values
  12923. */
  12924. static RandomRange(min: number, max: number): number;
  12925. /**
  12926. * This function returns percentage of a number in a given range.
  12927. *
  12928. * RangeToPercent(40,20,60) will return 0.5 (50%)
  12929. * RangeToPercent(34,0,100) will return 0.34 (34%)
  12930. */
  12931. static RangeToPercent(number: number, min: number, max: number): number;
  12932. /**
  12933. * This function returns number that corresponds to the percentage in a given range.
  12934. *
  12935. * PercentToRange(0.34,0,100) will return 34.
  12936. */
  12937. static PercentToRange(percent: number, min: number, max: number): number;
  12938. /**
  12939. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  12940. * @param angle The angle to normalize in radian.
  12941. * @return The converted angle.
  12942. */
  12943. static NormalizeRadians(angle: number): number;
  12944. }
  12945. }
  12946. declare module BABYLON {
  12947. const ToGammaSpace: number;
  12948. const ToLinearSpace = 2.2;
  12949. const Epsilon = 0.001;
  12950. /**
  12951. * Class used to hold a RBG color
  12952. */
  12953. class Color3 {
  12954. /**
  12955. * Defines the red component (between 0 and 1, default is 0)
  12956. */
  12957. r: number;
  12958. /**
  12959. * Defines the green component (between 0 and 1, default is 0)
  12960. */
  12961. g: number;
  12962. /**
  12963. * Defines the blue component (between 0 and 1, default is 0)
  12964. */
  12965. b: number;
  12966. /**
  12967. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  12968. * @param r defines the red component (between 0 and 1, default is 0)
  12969. * @param g defines the green component (between 0 and 1, default is 0)
  12970. * @param b defines the blue component (between 0 and 1, default is 0)
  12971. */
  12972. constructor(
  12973. /**
  12974. * Defines the red component (between 0 and 1, default is 0)
  12975. */
  12976. r?: number,
  12977. /**
  12978. * Defines the green component (between 0 and 1, default is 0)
  12979. */
  12980. g?: number,
  12981. /**
  12982. * Defines the blue component (between 0 and 1, default is 0)
  12983. */
  12984. b?: number);
  12985. /**
  12986. * Creates a string with the Color3 current values
  12987. * @returns the string representation of the Color3 object
  12988. */
  12989. toString(): string;
  12990. /**
  12991. * Returns the string "Color3"
  12992. * @returns "Color3"
  12993. */
  12994. getClassName(): string;
  12995. /**
  12996. * Compute the Color3 hash code
  12997. * @returns an unique number that can be used to hash Color3 objects
  12998. */
  12999. getHashCode(): number;
  13000. /**
  13001. * Stores in the passed array from the passed starting index the red, green, blue values as successive elements
  13002. * @param array defines the array where to store the r,g,b components
  13003. * @param index defines an optional index in the target array to define where to start storing values
  13004. * @returns the current Color3 object
  13005. */
  13006. toArray(array: FloatArray, index?: number): Color3;
  13007. /**
  13008. * Returns a new {BABYLON.Color4} object from the current Color3 and the passed alpha
  13009. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  13010. * @returns a new {BABYLON.Color4} object
  13011. */
  13012. toColor4(alpha?: number): Color4;
  13013. /**
  13014. * Returns a new array populated with 3 numeric elements : red, green and blue values
  13015. * @returns the new array
  13016. */
  13017. asArray(): number[];
  13018. /**
  13019. * Returns the luminance value
  13020. * @returns a float value
  13021. */
  13022. toLuminance(): number;
  13023. /**
  13024. * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object
  13025. * @param otherColor defines the second operand
  13026. * @returns the new Color3 object
  13027. */
  13028. multiply(otherColor: Color3): Color3;
  13029. /**
  13030. * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result"
  13031. * @param otherColor defines the second operand
  13032. * @param result defines the Color3 object where to store the result
  13033. * @returns the current Color3
  13034. */
  13035. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  13036. /**
  13037. * Determines equality between Color3 objects
  13038. * @param otherColor defines the second operand
  13039. * @returns true if the rgb values are equal to the passed ones
  13040. */
  13041. equals(otherColor: Color3): boolean;
  13042. /**
  13043. * Determines equality between the current Color3 object and a set of r,b,g values
  13044. * @param r defines the red component to check
  13045. * @param g defines the green component to check
  13046. * @param b defines the blue component to check
  13047. * @returns true if the rgb values are equal to the passed ones
  13048. */
  13049. equalsFloats(r: number, g: number, b: number): boolean;
  13050. /**
  13051. * Multiplies in place each rgb value by scale
  13052. * @param scale defines the scaling factor
  13053. * @returns the updated Color3.
  13054. */
  13055. scale(scale: number): Color3;
  13056. /**
  13057. * Multiplies the rgb values by scale and stores the result into "result"
  13058. * @param scale defines the scaling factor
  13059. * @param result defines the Color3 object where to store the result
  13060. * @returns the unmodified current Color3.
  13061. */
  13062. scaleToRef(scale: number, result: Color3): Color3;
  13063. /**
  13064. * Clamps the rgb values by the min and max values and stores the result into "result"
  13065. * @param min defines minimum clamping value (default is 0)
  13066. * @param max defines maximum clamping value (default is 1)
  13067. * @param result defines color to store the result into
  13068. * @returns the original Color3
  13069. */
  13070. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  13071. /**
  13072. * Creates a new Color3 set with the added values of the current Color3 and of the passed one
  13073. * @param otherColor defines the second operand
  13074. * @returns the new Color3
  13075. */
  13076. add(otherColor: Color3): Color3;
  13077. /**
  13078. * Stores the result of the addition of the current Color3 and passed one rgb values into "result"
  13079. * @param otherColor defines the second operand
  13080. * @param result defines Color3 object to store the result into
  13081. * @returns the unmodified current Color3
  13082. */
  13083. addToRef(otherColor: Color3, result: Color3): Color3;
  13084. /**
  13085. * Returns a new Color3 set with the subtracted values of the passed one from the current Color3
  13086. * @param otherColor defines the second operand
  13087. * @returns the new Color3
  13088. */
  13089. subtract(otherColor: Color3): Color3;
  13090. /**
  13091. * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result"
  13092. * @param otherColor defines the second operand
  13093. * @param result defines Color3 object to store the result into
  13094. * @returns the unmodified current Color3
  13095. */
  13096. subtractToRef(otherColor: Color3, result: Color3): Color3;
  13097. /**
  13098. * Copy the current object
  13099. * @returns a new Color3 copied the current one
  13100. */
  13101. clone(): Color3;
  13102. /**
  13103. * Copies the rgb values from the source in the current Color3
  13104. * @param source defines the source Color3 object
  13105. * @returns the updated Color3 object
  13106. */
  13107. copyFrom(source: Color3): Color3;
  13108. /**
  13109. * Updates the Color3 rgb values from the passed floats
  13110. * @param r defines the red component to read from
  13111. * @param g defines the green component to read from
  13112. * @param b defines the blue component to read from
  13113. * @returns the current Color3 object
  13114. */
  13115. copyFromFloats(r: number, g: number, b: number): Color3;
  13116. /**
  13117. * Updates the Color3 rgb values from the passed floats
  13118. * @param r defines the red component to read from
  13119. * @param g defines the green component to read from
  13120. * @param b defines the blue component to read from
  13121. * @returns the current Color3 object
  13122. */
  13123. set(r: number, g: number, b: number): Color3;
  13124. /**
  13125. * Compute the Color3 hexadecimal code as a string
  13126. * @returns a string containing the hexadecimal representation of the Color3 object
  13127. */
  13128. toHexString(): string;
  13129. /**
  13130. * Computes a new Color3 converted from the current one to linear space
  13131. * @returns a new Color3 object
  13132. */
  13133. toLinearSpace(): Color3;
  13134. /**
  13135. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  13136. * @param convertedColor defines the Color3 object where to store the linear space version
  13137. * @returns the unmodified Color3
  13138. */
  13139. toLinearSpaceToRef(convertedColor: Color3): Color3;
  13140. /**
  13141. * Computes a new Color3 converted from the current one to gamma space
  13142. * @returns a new Color3 object
  13143. */
  13144. toGammaSpace(): Color3;
  13145. /**
  13146. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  13147. * @param convertedColor defines the Color3 object where to store the gamma space version
  13148. * @returns the unmodified Color3
  13149. */
  13150. toGammaSpaceToRef(convertedColor: Color3): Color3;
  13151. /**
  13152. * Creates a new Color3 from the string containing valid hexadecimal values
  13153. * @param hex defines a string containing valid hexadecimal values
  13154. * @returns a new Color3 object
  13155. */
  13156. static FromHexString(hex: string): Color3;
  13157. /**
  13158. * Creates a new Vector3 from the starting index of the passed array
  13159. * @param array defines the source array
  13160. * @param offset defines an offset in the source array
  13161. * @returns a new Color3 object
  13162. */
  13163. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  13164. /**
  13165. * Creates a new Color3 from integer values (< 256)
  13166. * @param r defines the red component to read from (value between 0 and 255)
  13167. * @param g defines the green component to read from (value between 0 and 255)
  13168. * @param b defines the blue component to read from (value between 0 and 255)
  13169. * @returns a new Color3 object
  13170. */
  13171. static FromInts(r: number, g: number, b: number): Color3;
  13172. /**
  13173. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  13174. * @param start defines the start Color3 value
  13175. * @param end defines the end Color3 value
  13176. * @param amount defines the gradient value between start and end
  13177. * @returns a new Color3 object
  13178. */
  13179. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  13180. /**
  13181. * Returns a Color3 value containing a red color
  13182. * @returns a new Color3 object
  13183. */
  13184. static Red(): Color3;
  13185. /**
  13186. * Returns a Color3 value containing a green color
  13187. * @returns a new Color3 object
  13188. */
  13189. static Green(): Color3;
  13190. /**
  13191. * Returns a Color3 value containing a blue color
  13192. * @returns a new Color3 object
  13193. */
  13194. static Blue(): Color3;
  13195. /**
  13196. * Returns a Color3 value containing a black color
  13197. * @returns a new Color3 object
  13198. */
  13199. static Black(): Color3;
  13200. /**
  13201. * Returns a Color3 value containing a white color
  13202. * @returns a new Color3 object
  13203. */
  13204. static White(): Color3;
  13205. /**
  13206. * Returns a Color3 value containing a purple color
  13207. * @returns a new Color3 object
  13208. */
  13209. static Purple(): Color3;
  13210. /**
  13211. * Returns a Color3 value containing a magenta color
  13212. * @returns a new Color3 object
  13213. */
  13214. static Magenta(): Color3;
  13215. /**
  13216. * Returns a Color3 value containing a yellow color
  13217. * @returns a new Color3 object
  13218. */
  13219. static Yellow(): Color3;
  13220. /**
  13221. * Returns a Color3 value containing a gray color
  13222. * @returns a new Color3 object
  13223. */
  13224. static Gray(): Color3;
  13225. /**
  13226. * Returns a Color3 value containing a teal color
  13227. * @returns a new Color3 object
  13228. */
  13229. static Teal(): Color3;
  13230. /**
  13231. * Returns a Color3 value containing a random color
  13232. * @returns a new Color3 object
  13233. */
  13234. static Random(): Color3;
  13235. }
  13236. /**
  13237. * Class used to hold a RBGA color
  13238. */
  13239. class Color4 {
  13240. /**
  13241. * Defines the red component (between 0 and 1, default is 0)
  13242. */
  13243. r: number;
  13244. /**
  13245. * Defines the green component (between 0 and 1, default is 0)
  13246. */
  13247. g: number;
  13248. /**
  13249. * Defines the blue component (between 0 and 1, default is 0)
  13250. */
  13251. b: number;
  13252. /**
  13253. * Defines the alpha component (between 0 and 1, default is 1)
  13254. */
  13255. a: number;
  13256. /**
  13257. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  13258. * @param r defines the red component (between 0 and 1, default is 0)
  13259. * @param g defines the green component (between 0 and 1, default is 0)
  13260. * @param b defines the blue component (between 0 and 1, default is 0)
  13261. * @param a defines the alpha component (between 0 and 1, default is 1)
  13262. */
  13263. constructor(
  13264. /**
  13265. * Defines the red component (between 0 and 1, default is 0)
  13266. */
  13267. r?: number,
  13268. /**
  13269. * Defines the green component (between 0 and 1, default is 0)
  13270. */
  13271. g?: number,
  13272. /**
  13273. * Defines the blue component (between 0 and 1, default is 0)
  13274. */
  13275. b?: number,
  13276. /**
  13277. * Defines the alpha component (between 0 and 1, default is 1)
  13278. */
  13279. a?: number);
  13280. /**
  13281. * Adds in place the passed Color4 values to the current Color4 object
  13282. * @param right defines the second operand
  13283. * @returns the current updated Color4 object
  13284. */
  13285. addInPlace(right: Color4): Color4;
  13286. /**
  13287. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  13288. * @returns the new array
  13289. */
  13290. asArray(): number[];
  13291. /**
  13292. * Stores from the starting index in the passed array the Color4 successive values
  13293. * @param array defines the array where to store the r,g,b components
  13294. * @param index defines an optional index in the target array to define where to start storing values
  13295. * @returns the current Color4 object
  13296. */
  13297. toArray(array: number[], index?: number): Color4;
  13298. /**
  13299. * Creates a new Color4 set with the added values of the current Color4 and of the passed one
  13300. * @param right defines the second operand
  13301. * @returns a new Color4 object
  13302. */
  13303. add(right: Color4): Color4;
  13304. /**
  13305. * Creates a new Color4 set with the subtracted values of the passed one from the current Color4
  13306. * @param right defines the second operand
  13307. * @returns a new Color4 object
  13308. */
  13309. subtract(right: Color4): Color4;
  13310. /**
  13311. * Subtracts the passed ones from the current Color4 values and stores the results in "result"
  13312. * @param right defines the second operand
  13313. * @param result defines the Color4 object where to store the result
  13314. * @returns the current Color4 object
  13315. */
  13316. subtractToRef(right: Color4, result: Color4): Color4;
  13317. /**
  13318. * Creates a new Color4 with the current Color4 values multiplied by scale
  13319. * @param scale defines the scaling factor to apply
  13320. * @returns a new Color4 object
  13321. */
  13322. scale(scale: number): Color4;
  13323. /**
  13324. * Multiplies the current Color4 values by scale and stores the result in "result"
  13325. * @param scale defines the scaling factor to apply
  13326. * @param result defines the Color4 object where to store the result
  13327. * @returns the current Color4.
  13328. */
  13329. scaleToRef(scale: number, result: Color4): Color4;
  13330. /**
  13331. * Clamps the rgb values by the min and max values and stores the result into "result"
  13332. * @param min defines minimum clamping value (default is 0)
  13333. * @param max defines maximum clamping value (default is 1)
  13334. * @param result defines color to store the result into.
  13335. * @returns the cuurent Color4
  13336. */
  13337. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  13338. /**
  13339. * Multipy an Color4 value by another and return a new Color4 object
  13340. * @param color defines the Color4 value to multiply by
  13341. * @returns a new Color4 object
  13342. */
  13343. multiply(color: Color4): Color4;
  13344. /**
  13345. * Multipy a Color4 value by another and push the result in a reference value
  13346. * @param color defines the Color4 value to multiply by
  13347. * @param result defines the Color4 to fill the result in
  13348. * @returns the result Color4
  13349. */
  13350. multiplyToRef(color: Color4, result: Color4): Color4;
  13351. /**
  13352. * Creates a string with the Color4 current values
  13353. * @returns the string representation of the Color4 object
  13354. */
  13355. toString(): string;
  13356. /**
  13357. * Returns the string "Color4"
  13358. * @returns "Color4"
  13359. */
  13360. getClassName(): string;
  13361. /**
  13362. * Compute the Color4 hash code
  13363. * @returns an unique number that can be used to hash Color4 objects
  13364. */
  13365. getHashCode(): number;
  13366. /**
  13367. * Creates a new Color4 copied from the current one
  13368. * @returns a new Color4 object
  13369. */
  13370. clone(): Color4;
  13371. /**
  13372. * Copies the passed Color4 values into the current one
  13373. * @param source defines the source Color4 object
  13374. * @returns the current updated Color4 object
  13375. */
  13376. copyFrom(source: Color4): Color4;
  13377. /**
  13378. * Copies the passed float values into the current one
  13379. * @param r defines the red component to read from
  13380. * @param g defines the green component to read from
  13381. * @param b defines the blue component to read from
  13382. * @param a defines the alpha component to read from
  13383. * @returns the current updated Color4 object
  13384. */
  13385. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  13386. /**
  13387. * Copies the passed float values into the current one
  13388. * @param r defines the red component to read from
  13389. * @param g defines the green component to read from
  13390. * @param b defines the blue component to read from
  13391. * @param a defines the alpha component to read from
  13392. * @returns the current updated Color4 object
  13393. */
  13394. set(r: number, g: number, b: number, a: number): Color4;
  13395. /**
  13396. * Compute the Color4 hexadecimal code as a string
  13397. * @returns a string containing the hexadecimal representation of the Color4 object
  13398. */
  13399. toHexString(): string;
  13400. /**
  13401. * Computes a new Color4 converted from the current one to linear space
  13402. * @returns a new Color4 object
  13403. */
  13404. toLinearSpace(): Color4;
  13405. /**
  13406. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  13407. * @param convertedColor defines the Color4 object where to store the linear space version
  13408. * @returns the unmodified Color4
  13409. */
  13410. toLinearSpaceToRef(convertedColor: Color4): Color4;
  13411. /**
  13412. * Computes a new Color4 converted from the current one to gamma space
  13413. * @returns a new Color4 object
  13414. */
  13415. toGammaSpace(): Color4;
  13416. /**
  13417. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  13418. * @param convertedColor defines the Color4 object where to store the gamma space version
  13419. * @returns the unmodified Color4
  13420. */
  13421. toGammaSpaceToRef(convertedColor: Color4): Color4;
  13422. /**
  13423. * Creates a new Color4 from the string containing valid hexadecimal values
  13424. * @param hex defines a string containing valid hexadecimal values
  13425. * @returns a new Color4 object
  13426. */
  13427. static FromHexString(hex: string): Color4;
  13428. /**
  13429. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  13430. * @param left defines the start value
  13431. * @param right defines the end value
  13432. * @param amount defines the gradient factor
  13433. * @returns a new Color4 object
  13434. */
  13435. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  13436. /**
  13437. * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  13438. * @param left defines the start value
  13439. * @param right defines the end value
  13440. * @param amount defines the gradient factor
  13441. * @param result defines the Color4 object where to store data
  13442. */
  13443. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  13444. /**
  13445. * Creates a new Color4 from the starting index element of the passed array
  13446. * @param array defines the source array to read from
  13447. * @param offset defines the offset in the source array
  13448. * @returns a new Color4 object
  13449. */
  13450. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  13451. /**
  13452. * Creates a new Color3 from integer values (< 256)
  13453. * @param r defines the red component to read from (value between 0 and 255)
  13454. * @param g defines the green component to read from (value between 0 and 255)
  13455. * @param b defines the blue component to read from (value between 0 and 255)
  13456. * @param a defines the alpha component to read from (value between 0 and 255)
  13457. * @returns a new Color3 object
  13458. */
  13459. static FromInts(r: number, g: number, b: number, a: number): Color4;
  13460. /**
  13461. * Check the content of a given array and convert it to an array containing RGBA data
  13462. * If the original array was already containing count * 4 values then it is returned directly
  13463. * @param colors defines the array to check
  13464. * @param count defines the number of RGBA data to expect
  13465. * @returns an array containing count * 4 values (RGBA)
  13466. */
  13467. static CheckColors4(colors: number[], count: number): number[];
  13468. }
  13469. class Vector2 {
  13470. x: number;
  13471. y: number;
  13472. /**
  13473. * Creates a new Vector2 from the passed x and y coordinates.
  13474. */
  13475. constructor(x: number, y: number);
  13476. /**
  13477. * Returns a string with the Vector2 coordinates.
  13478. */
  13479. toString(): string;
  13480. /**
  13481. * Returns the string "Vector2"
  13482. */
  13483. getClassName(): string;
  13484. /**
  13485. * Returns the Vector2 hash code as a number.
  13486. */
  13487. getHashCode(): number;
  13488. /**
  13489. * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index.
  13490. * Returns the Vector2.
  13491. */
  13492. toArray(array: FloatArray, index?: number): Vector2;
  13493. /**
  13494. * Returns a new array with 2 elements : the Vector2 coordinates.
  13495. */
  13496. asArray(): number[];
  13497. /**
  13498. * Sets the Vector2 coordinates with the passed Vector2 coordinates.
  13499. * Returns the updated Vector2.
  13500. */
  13501. copyFrom(source: Vector2): Vector2;
  13502. /**
  13503. * Sets the Vector2 coordinates with the passed floats.
  13504. * Returns the updated Vector2.
  13505. */
  13506. copyFromFloats(x: number, y: number): Vector2;
  13507. /**
  13508. * Sets the Vector2 coordinates with the passed floats.
  13509. * Returns the updated Vector2.
  13510. */
  13511. set(x: number, y: number): Vector2;
  13512. /**
  13513. * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates.
  13514. */
  13515. add(otherVector: Vector2): Vector2;
  13516. /**
  13517. * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates.
  13518. * Returns the Vector2.
  13519. */
  13520. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  13521. /**
  13522. * Set the Vector2 coordinates by adding the passed Vector2 coordinates.
  13523. * Returns the updated Vector2.
  13524. */
  13525. addInPlace(otherVector: Vector2): Vector2;
  13526. /**
  13527. * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates.
  13528. */
  13529. addVector3(otherVector: Vector3): Vector2;
  13530. /**
  13531. * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2.
  13532. */
  13533. subtract(otherVector: Vector2): Vector2;
  13534. /**
  13535. * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates.
  13536. * Returns the Vector2.
  13537. */
  13538. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  13539. /**
  13540. * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates.
  13541. * Returns the updated Vector2.
  13542. */
  13543. subtractInPlace(otherVector: Vector2): Vector2;
  13544. /**
  13545. * Multiplies in place the current Vector2 coordinates by the passed ones.
  13546. * Returns the updated Vector2.
  13547. */
  13548. multiplyInPlace(otherVector: Vector2): Vector2;
  13549. /**
  13550. * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates.
  13551. */
  13552. multiply(otherVector: Vector2): Vector2;
  13553. /**
  13554. * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates.
  13555. * Returns the Vector2.
  13556. */
  13557. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  13558. /**
  13559. * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats.
  13560. */
  13561. multiplyByFloats(x: number, y: number): Vector2;
  13562. /**
  13563. * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates.
  13564. */
  13565. divide(otherVector: Vector2): Vector2;
  13566. /**
  13567. * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates.
  13568. * Returns the Vector2.
  13569. */
  13570. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  13571. /**
  13572. * Divides the current Vector3 coordinates by the passed ones.
  13573. * Returns the updated Vector3.
  13574. */
  13575. divideInPlace(otherVector: Vector2): Vector2;
  13576. /**
  13577. * Returns a new Vector2 with current Vector2 negated coordinates.
  13578. */
  13579. negate(): Vector2;
  13580. /**
  13581. * Multiply the Vector2 coordinates by scale.
  13582. * Returns the updated Vector2.
  13583. */
  13584. scaleInPlace(scale: number): Vector2;
  13585. /**
  13586. * Returns a new Vector2 scaled by "scale" from the current Vector2.
  13587. */
  13588. scale(scale: number): Vector2;
  13589. /**
  13590. * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones.
  13591. */
  13592. equals(otherVector: Vector2): boolean;
  13593. /**
  13594. * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon.
  13595. */
  13596. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  13597. /**
  13598. * Returns the vector length (float).
  13599. */
  13600. length(): number;
  13601. /**
  13602. * Returns the vector squared length (float);
  13603. */
  13604. lengthSquared(): number;
  13605. /**
  13606. * Normalize the vector.
  13607. * Returns the updated Vector2.
  13608. */
  13609. normalize(): Vector2;
  13610. /**
  13611. * Returns a new Vector2 copied from the Vector2.
  13612. */
  13613. clone(): Vector2;
  13614. /**
  13615. * Returns a new Vector2(0, 0)
  13616. */
  13617. static Zero(): Vector2;
  13618. /**
  13619. * Returns a new Vector2(1, 1)
  13620. */
  13621. static One(): Vector2;
  13622. /**
  13623. * Returns a new Vector2 set from the passed index element of the passed array.
  13624. */
  13625. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  13626. /**
  13627. * Sets "result" from the passed index element of the passed array.
  13628. */
  13629. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  13630. /**
  13631. * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2.
  13632. */
  13633. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  13634. /**
  13635. * 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".
  13636. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  13637. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate.
  13638. */
  13639. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  13640. /**
  13641. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2".
  13642. */
  13643. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  13644. /**
  13645. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  13646. */
  13647. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  13648. /**
  13649. * Returns the dot product (float) of the vector "left" and the vector "right".
  13650. */
  13651. static Dot(left: Vector2, right: Vector2): number;
  13652. /**
  13653. * Returns a new Vector2 equal to the normalized passed vector.
  13654. */
  13655. static Normalize(vector: Vector2): Vector2;
  13656. /**
  13657. * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors.
  13658. */
  13659. static Minimize(left: Vector2, right: Vector2): Vector2;
  13660. /**
  13661. * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors.
  13662. */
  13663. static Maximize(left: Vector2, right: Vector2): Vector2;
  13664. /**
  13665. * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix.
  13666. */
  13667. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  13668. /**
  13669. * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates.
  13670. */
  13671. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  13672. /**
  13673. * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  13674. */
  13675. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  13676. /**
  13677. * Returns the distance (float) between the vectors "value1" and "value2".
  13678. */
  13679. static Distance(value1: Vector2, value2: Vector2): number;
  13680. /**
  13681. * Returns the squared distance (float) between the vectors "value1" and "value2".
  13682. */
  13683. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  13684. /**
  13685. * Returns a new Vecto2 located at the center of the vectors "value1" and "value2".
  13686. */
  13687. static Center(value1: Vector2, value2: Vector2): Vector2;
  13688. /**
  13689. * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  13690. */
  13691. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  13692. }
  13693. class Vector3 {
  13694. x: number;
  13695. y: number;
  13696. z: number;
  13697. /**
  13698. * Creates a new Vector3 object from the passed x, y, z (floats) coordinates.
  13699. * A Vector3 is the main object used in 3D geometry.
  13700. * It can represent etiher the coordinates of a point the space, either a direction.
  13701. */
  13702. constructor(x: number, y: number, z: number);
  13703. /**
  13704. * Returns a string with the Vector3 coordinates.
  13705. */
  13706. toString(): string;
  13707. /**
  13708. * Returns the string "Vector3"
  13709. */
  13710. getClassName(): string;
  13711. /**
  13712. * Returns the Vector hash code.
  13713. */
  13714. getHashCode(): number;
  13715. /**
  13716. * Returns a new array with three elements : the coordinates the Vector3.
  13717. */
  13718. asArray(): number[];
  13719. /**
  13720. * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3.
  13721. * Returns the Vector3.
  13722. */
  13723. toArray(array: FloatArray, index?: number): Vector3;
  13724. /**
  13725. * Returns a new Quaternion object, computed from the Vector3 coordinates.
  13726. */
  13727. toQuaternion(): Quaternion;
  13728. /**
  13729. * Adds the passed vector to the current Vector3.
  13730. * Returns the updated Vector3.
  13731. */
  13732. addInPlace(otherVector: Vector3): Vector3;
  13733. /**
  13734. * Returns a new Vector3, result of the addition the current Vector3 and the passed vector.
  13735. */
  13736. add(otherVector: Vector3): Vector3;
  13737. /**
  13738. * Adds the current Vector3 to the passed one and stores the result in the vector "result".
  13739. * Returns the current Vector3.
  13740. */
  13741. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  13742. /**
  13743. * Subtract the passed vector from the current Vector3.
  13744. * Returns the updated Vector3.
  13745. */
  13746. subtractInPlace(otherVector: Vector3): Vector3;
  13747. /**
  13748. * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3.
  13749. */
  13750. subtract(otherVector: Vector3): Vector3;
  13751. /**
  13752. * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result".
  13753. * Returns the current Vector3.
  13754. */
  13755. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  13756. /**
  13757. * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates.
  13758. */
  13759. subtractFromFloats(x: number, y: number, z: number): Vector3;
  13760. /**
  13761. * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result.
  13762. * Returns the current Vector3.
  13763. */
  13764. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  13765. /**
  13766. * Returns a new Vector3 set with the current Vector3 negated coordinates.
  13767. */
  13768. negate(): Vector3;
  13769. /**
  13770. * Multiplies the Vector3 coordinates by the float "scale".
  13771. * Returns the updated Vector3.
  13772. */
  13773. scaleInPlace(scale: number): Vector3;
  13774. /**
  13775. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale".
  13776. */
  13777. scale(scale: number): Vector3;
  13778. /**
  13779. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates.
  13780. * Returns the current Vector3.
  13781. */
  13782. scaleToRef(scale: number, result: Vector3): Vector3;
  13783. /**
  13784. * Boolean : True if the current Vector3 and the passed vector coordinates are strictly equal.
  13785. */
  13786. equals(otherVector: Vector3): boolean;
  13787. /**
  13788. * Boolean : True if the current Vector3 and the passed vector coordinates are distant less than epsilon.
  13789. */
  13790. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  13791. /**
  13792. * Boolean : True if the current Vector3 coordinate equal the passed floats.
  13793. */
  13794. equalsToFloats(x: number, y: number, z: number): boolean;
  13795. /**
  13796. * Muliplies the current Vector3 coordinates by the passed ones.
  13797. * Returns the updated Vector3.
  13798. */
  13799. multiplyInPlace(otherVector: Vector3): Vector3;
  13800. /**
  13801. * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector.
  13802. */
  13803. multiply(otherVector: Vector3): Vector3;
  13804. /**
  13805. * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result".
  13806. * Returns the current Vector3.
  13807. */
  13808. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  13809. /**
  13810. * Returns a new Vector3 set witth the result of the mulliplication of the current Vector3 coordinates by the passed floats.
  13811. */
  13812. multiplyByFloats(x: number, y: number, z: number): Vector3;
  13813. /**
  13814. * Returns a new Vector3 set witth the result of the division of the current Vector3 coordinates by the passed ones.
  13815. */
  13816. divide(otherVector: Vector3): Vector3;
  13817. /**
  13818. * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result".
  13819. * Returns the current Vector3.
  13820. */
  13821. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  13822. /**
  13823. * Divides the current Vector3 coordinates by the passed ones.
  13824. * Returns the updated Vector3.
  13825. */
  13826. divideInPlace(otherVector: Vector3): Vector3;
  13827. /**
  13828. * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones.
  13829. * Returns the updated Vector3.
  13830. */
  13831. MinimizeInPlace(other: Vector3): Vector3;
  13832. /**
  13833. * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones.
  13834. * Returns the updated Vector3.
  13835. */
  13836. MaximizeInPlace(other: Vector3): Vector3;
  13837. /**
  13838. * Return true is the vector is non uniform meaning x, y or z are not all the same.
  13839. */
  13840. readonly isNonUniform: boolean;
  13841. /**
  13842. * Returns the length of the Vector3 (float).
  13843. */
  13844. length(): number;
  13845. /**
  13846. * Returns the squared length of the Vector3 (float).
  13847. */
  13848. lengthSquared(): number;
  13849. /**
  13850. * Normalize the current Vector3.
  13851. * Returns the updated Vector3.
  13852. * /!\ In place operation.
  13853. */
  13854. normalize(): Vector3;
  13855. /**
  13856. * Normalize the current Vector3 to a new vector.
  13857. * @returns the new Vector3.
  13858. */
  13859. normalizeToNew(): Vector3;
  13860. /**
  13861. * Normalize the current Vector3 to the reference.
  13862. * @param the reference to update.
  13863. * @returns the updated Vector3.
  13864. */
  13865. normalizeToRef(reference: Vector3): Vector3;
  13866. /**
  13867. * Returns a new Vector3 copied from the current Vector3.
  13868. */
  13869. clone(): Vector3;
  13870. /**
  13871. * Copies the passed vector coordinates to the current Vector3 ones.
  13872. * Returns the updated Vector3.
  13873. */
  13874. copyFrom(source: Vector3): Vector3;
  13875. /**
  13876. * Copies the passed floats to the current Vector3 coordinates.
  13877. * Returns the updated Vector3.
  13878. */
  13879. copyFromFloats(x: number, y: number, z: number): Vector3;
  13880. /**
  13881. * Copies the passed floats to the current Vector3 coordinates.
  13882. * Returns the updated Vector3.
  13883. */
  13884. set(x: number, y: number, z: number): Vector3;
  13885. /**
  13886. *
  13887. */
  13888. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  13889. /**
  13890. * Get angle between two vectors.
  13891. * @param vector0 angle between vector0 and vector1
  13892. * @param vector1 angle between vector0 and vector1
  13893. * @param normal direction of the normal.
  13894. * @return the angle between vector0 and vector1.
  13895. */
  13896. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  13897. /**
  13898. * Returns a new Vector3 set from the index "offset" of the passed array.
  13899. */
  13900. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  13901. /**
  13902. * Returns a new Vector3 set from the index "offset" of the passed Float32Array.
  13903. * This function is deprecated. Use FromArray instead.
  13904. */
  13905. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  13906. /**
  13907. * Sets the passed vector "result" with the element values from the index "offset" of the passed array.
  13908. */
  13909. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  13910. /**
  13911. * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array.
  13912. * This function is deprecated. Use FromArrayToRef instead.
  13913. */
  13914. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  13915. /**
  13916. * Sets the passed vector "result" with the passed floats.
  13917. */
  13918. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  13919. /**
  13920. * Returns a new Vector3 set to (0.0, 0.0, 0.0).
  13921. */
  13922. static Zero(): Vector3;
  13923. /**
  13924. * Returns a new Vector3 set to (1.0, 1.0, 1.0).
  13925. */
  13926. static One(): Vector3;
  13927. /**
  13928. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  13929. */
  13930. static Up(): Vector3;
  13931. /**
  13932. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  13933. */
  13934. static Forward(): Vector3;
  13935. /**
  13936. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  13937. */
  13938. static Right(): Vector3;
  13939. /**
  13940. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  13941. */
  13942. static Left(): Vector3;
  13943. /**
  13944. * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector.
  13945. * This method computes tranformed coordinates only, not transformed direction vectors.
  13946. */
  13947. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  13948. /**
  13949. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector.
  13950. * This method computes tranformed coordinates only, not transformed direction vectors.
  13951. */
  13952. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  13953. /**
  13954. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z).
  13955. * This method computes tranformed coordinates only, not transformed direction vectors.
  13956. */
  13957. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  13958. /**
  13959. * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector.
  13960. * This methods computes transformed normalized direction vectors only.
  13961. */
  13962. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  13963. /**
  13964. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector.
  13965. * This methods computes transformed normalized direction vectors only.
  13966. */
  13967. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  13968. /**
  13969. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z).
  13970. * This methods computes transformed normalized direction vectors only.
  13971. */
  13972. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  13973. /**
  13974. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4".
  13975. */
  13976. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  13977. /**
  13978. * 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".
  13979. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one.
  13980. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one.
  13981. */
  13982. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  13983. /**
  13984. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2".
  13985. */
  13986. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  13987. /**
  13988. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end".
  13989. */
  13990. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  13991. /**
  13992. * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end".
  13993. */
  13994. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  13995. /**
  13996. * Returns the dot product (float) between the vectors "left" and "right".
  13997. */
  13998. static Dot(left: Vector3, right: Vector3): number;
  13999. /**
  14000. * Returns a new Vector3 as the cross product of the vectors "left" and "right".
  14001. * The cross product is then orthogonal to both "left" and "right".
  14002. */
  14003. static Cross(left: Vector3, right: Vector3): Vector3;
  14004. /**
  14005. * Sets the passed vector "result" with the cross product of "left" and "right".
  14006. * The cross product is then orthogonal to both "left" and "right".
  14007. */
  14008. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  14009. /**
  14010. * Returns a new Vector3 as the normalization of the passed vector.
  14011. */
  14012. static Normalize(vector: Vector3): Vector3;
  14013. /**
  14014. * Sets the passed vector "result" with the normalization of the passed first vector.
  14015. */
  14016. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  14017. private static _viewportMatrixCache;
  14018. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  14019. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  14020. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  14021. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  14022. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  14023. static Minimize(left: Vector3, right: Vector3): Vector3;
  14024. static Maximize(left: Vector3, right: Vector3): Vector3;
  14025. /**
  14026. * Returns the distance (float) between the vectors "value1" and "value2".
  14027. */
  14028. static Distance(value1: Vector3, value2: Vector3): number;
  14029. /**
  14030. * Returns the squared distance (float) between the vectors "value1" and "value2".
  14031. */
  14032. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  14033. /**
  14034. * Returns a new Vector3 located at the center between "value1" and "value2".
  14035. */
  14036. static Center(value1: Vector3, value2: Vector3): Vector3;
  14037. /**
  14038. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  14039. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  14040. * to something in order to rotate it from its local system to the given target system.
  14041. * Note : axis1, axis2 and axis3 are normalized during this operation.
  14042. * Returns a new Vector3.
  14043. */
  14044. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  14045. /**
  14046. * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3.
  14047. */
  14048. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  14049. }
  14050. class Vector4 {
  14051. x: number;
  14052. y: number;
  14053. z: number;
  14054. w: number;
  14055. /**
  14056. * Creates a Vector4 object from the passed floats.
  14057. */
  14058. constructor(x: number, y: number, z: number, w: number);
  14059. /**
  14060. * Returns the string with the Vector4 coordinates.
  14061. */
  14062. toString(): string;
  14063. /**
  14064. * Returns the string "Vector4".
  14065. */
  14066. getClassName(): string;
  14067. /**
  14068. * Returns the Vector4 hash code.
  14069. */
  14070. getHashCode(): number;
  14071. /**
  14072. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  14073. */
  14074. asArray(): number[];
  14075. /**
  14076. * Populates the passed array from the passed index with the Vector4 coordinates.
  14077. * Returns the Vector4.
  14078. */
  14079. toArray(array: FloatArray, index?: number): Vector4;
  14080. /**
  14081. * Adds the passed vector to the current Vector4.
  14082. * Returns the updated Vector4.
  14083. */
  14084. addInPlace(otherVector: Vector4): Vector4;
  14085. /**
  14086. * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one.
  14087. */
  14088. add(otherVector: Vector4): Vector4;
  14089. /**
  14090. * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one.
  14091. * Returns the current Vector4.
  14092. */
  14093. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  14094. /**
  14095. * Subtract in place the passed vector from the current Vector4.
  14096. * Returns the updated Vector4.
  14097. */
  14098. subtractInPlace(otherVector: Vector4): Vector4;
  14099. /**
  14100. * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4.
  14101. */
  14102. subtract(otherVector: Vector4): Vector4;
  14103. /**
  14104. * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4.
  14105. * Returns the current Vector4.
  14106. */
  14107. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  14108. /**
  14109. * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  14110. */
  14111. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  14112. /**
  14113. * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  14114. * Returns the current Vector4.
  14115. */
  14116. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  14117. /**
  14118. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  14119. */
  14120. negate(): Vector4;
  14121. /**
  14122. * Multiplies the current Vector4 coordinates by scale (float).
  14123. * Returns the updated Vector4.
  14124. */
  14125. scaleInPlace(scale: number): Vector4;
  14126. /**
  14127. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  14128. */
  14129. scale(scale: number): Vector4;
  14130. /**
  14131. * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float).
  14132. * Returns the current Vector4.
  14133. */
  14134. scaleToRef(scale: number, result: Vector4): Vector4;
  14135. /**
  14136. * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones.
  14137. */
  14138. equals(otherVector: Vector4): boolean;
  14139. /**
  14140. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones.
  14141. */
  14142. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  14143. /**
  14144. * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates.
  14145. */
  14146. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  14147. /**
  14148. * Multiplies in place the current Vector4 by the passed one.
  14149. * Returns the updated Vector4.
  14150. */
  14151. multiplyInPlace(otherVector: Vector4): Vector4;
  14152. /**
  14153. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one.
  14154. */
  14155. multiply(otherVector: Vector4): Vector4;
  14156. /**
  14157. * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one.
  14158. * Returns the current Vector4.
  14159. */
  14160. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  14161. /**
  14162. * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates.
  14163. */
  14164. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  14165. /**
  14166. * Returns a new Vector4 set with the division result of the current Vector4 by the passed one.
  14167. */
  14168. divide(otherVector: Vector4): Vector4;
  14169. /**
  14170. * Updates the passed vector "result" with the division result of the current Vector4 by the passed one.
  14171. * Returns the current Vector4.
  14172. */
  14173. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  14174. /**
  14175. * Divides the current Vector3 coordinates by the passed ones.
  14176. * Returns the updated Vector3.
  14177. */
  14178. divideInPlace(otherVector: Vector4): Vector4;
  14179. /**
  14180. * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones.
  14181. */
  14182. MinimizeInPlace(other: Vector4): Vector4;
  14183. /**
  14184. * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones.
  14185. */
  14186. MaximizeInPlace(other: Vector4): Vector4;
  14187. /**
  14188. * Returns the Vector4 length (float).
  14189. */
  14190. length(): number;
  14191. /**
  14192. * Returns the Vector4 squared length (float).
  14193. */
  14194. lengthSquared(): number;
  14195. /**
  14196. * Normalizes in place the Vector4.
  14197. * Returns the updated Vector4.
  14198. */
  14199. normalize(): Vector4;
  14200. /**
  14201. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  14202. */
  14203. toVector3(): Vector3;
  14204. /**
  14205. * Returns a new Vector4 copied from the current one.
  14206. */
  14207. clone(): Vector4;
  14208. /**
  14209. * Updates the current Vector4 with the passed one coordinates.
  14210. * Returns the updated Vector4.
  14211. */
  14212. copyFrom(source: Vector4): Vector4;
  14213. /**
  14214. * Updates the current Vector4 coordinates with the passed floats.
  14215. * Returns the updated Vector4.
  14216. */
  14217. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  14218. /**
  14219. * Updates the current Vector4 coordinates with the passed floats.
  14220. * Returns the updated Vector4.
  14221. */
  14222. set(x: number, y: number, z: number, w: number): Vector4;
  14223. /**
  14224. * Returns a new Vector4 set from the starting index of the passed array.
  14225. */
  14226. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  14227. /**
  14228. * Updates the passed vector "result" from the starting index of the passed array.
  14229. */
  14230. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  14231. /**
  14232. * Updates the passed vector "result" from the starting index of the passed Float32Array.
  14233. */
  14234. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  14235. /**
  14236. * Updates the passed vector "result" coordinates from the passed floats.
  14237. */
  14238. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  14239. /**
  14240. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  14241. */
  14242. static Zero(): Vector4;
  14243. /**
  14244. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  14245. */
  14246. static One(): Vector4;
  14247. /**
  14248. * Returns a new normalized Vector4 from the passed one.
  14249. */
  14250. static Normalize(vector: Vector4): Vector4;
  14251. /**
  14252. * Updates the passed vector "result" from the normalization of the passed one.
  14253. */
  14254. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  14255. static Minimize(left: Vector4, right: Vector4): Vector4;
  14256. static Maximize(left: Vector4, right: Vector4): Vector4;
  14257. /**
  14258. * Returns the distance (float) between the vectors "value1" and "value2".
  14259. */
  14260. static Distance(value1: Vector4, value2: Vector4): number;
  14261. /**
  14262. * Returns the squared distance (float) between the vectors "value1" and "value2".
  14263. */
  14264. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  14265. /**
  14266. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  14267. */
  14268. static Center(value1: Vector4, value2: Vector4): Vector4;
  14269. /**
  14270. * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector.
  14271. * This methods computes transformed normalized direction vectors only.
  14272. */
  14273. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  14274. /**
  14275. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector.
  14276. * This methods computes transformed normalized direction vectors only.
  14277. */
  14278. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  14279. /**
  14280. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w).
  14281. * This methods computes transformed normalized direction vectors only.
  14282. */
  14283. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  14284. }
  14285. interface ISize {
  14286. width: number;
  14287. height: number;
  14288. }
  14289. class Size implements ISize {
  14290. width: number;
  14291. height: number;
  14292. /**
  14293. * Creates a Size object from the passed width and height (floats).
  14294. */
  14295. constructor(width: number, height: number);
  14296. toString(): string;
  14297. /**
  14298. * Returns the string "Size"
  14299. */
  14300. getClassName(): string;
  14301. /**
  14302. * Returns the Size hash code.
  14303. */
  14304. getHashCode(): number;
  14305. /**
  14306. * Updates the current size from the passed one.
  14307. * Returns the updated Size.
  14308. */
  14309. copyFrom(src: Size): void;
  14310. /**
  14311. * Updates in place the current Size from the passed floats.
  14312. * Returns the updated Size.
  14313. */
  14314. copyFromFloats(width: number, height: number): Size;
  14315. /**
  14316. * Updates in place the current Size from the passed floats.
  14317. * Returns the updated Size.
  14318. */
  14319. set(width: number, height: number): Size;
  14320. /**
  14321. * Returns a new Size set with the multiplication result of the current Size and the passed floats.
  14322. */
  14323. multiplyByFloats(w: number, h: number): Size;
  14324. /**
  14325. * Returns a new Size copied from the passed one.
  14326. */
  14327. clone(): Size;
  14328. /**
  14329. * Boolean : True if the current Size and the passed one width and height are strictly equal.
  14330. */
  14331. equals(other: Size): boolean;
  14332. /**
  14333. * Returns the surface of the Size : width * height (float).
  14334. */
  14335. readonly surface: number;
  14336. /**
  14337. * Returns a new Size set to (0.0, 0.0)
  14338. */
  14339. static Zero(): Size;
  14340. /**
  14341. * Returns a new Size set as the addition result of the current Size and the passed one.
  14342. */
  14343. add(otherSize: Size): Size;
  14344. /**
  14345. * Returns a new Size set as the subtraction result of the passed one from the current Size.
  14346. */
  14347. subtract(otherSize: Size): Size;
  14348. /**
  14349. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  14350. */
  14351. static Lerp(start: Size, end: Size, amount: number): Size;
  14352. }
  14353. class Quaternion {
  14354. x: number;
  14355. y: number;
  14356. z: number;
  14357. w: number;
  14358. /**
  14359. * Creates a new Quaternion from the passed floats.
  14360. */
  14361. constructor(x?: number, y?: number, z?: number, w?: number);
  14362. /**
  14363. * Returns a string with the Quaternion coordinates.
  14364. */
  14365. toString(): string;
  14366. /**
  14367. * Returns the string "Quaternion".
  14368. */
  14369. getClassName(): string;
  14370. /**
  14371. * Returns the Quaternion hash code.
  14372. */
  14373. getHashCode(): number;
  14374. /**
  14375. * Returns a new array populated with 4 elements : the Quaternion coordinates.
  14376. */
  14377. asArray(): number[];
  14378. /**
  14379. * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal.
  14380. */
  14381. equals(otherQuaternion: Quaternion): boolean;
  14382. /**
  14383. * Returns a new Quaternion copied from the current one.
  14384. */
  14385. clone(): Quaternion;
  14386. /**
  14387. * Updates the current Quaternion from the passed one coordinates.
  14388. * Returns the updated Quaterion.
  14389. */
  14390. copyFrom(other: Quaternion): Quaternion;
  14391. /**
  14392. * Updates the current Quaternion from the passed float coordinates.
  14393. * Returns the updated Quaterion.
  14394. */
  14395. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  14396. /**
  14397. * Updates the current Quaternion from the passed float coordinates.
  14398. * Returns the updated Quaterion.
  14399. */
  14400. set(x: number, y: number, z: number, w: number): Quaternion;
  14401. /**
  14402. * Returns a new Quaternion as the addition result of the passed one and the current Quaternion.
  14403. */
  14404. add(other: Quaternion): Quaternion;
  14405. /**
  14406. * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion.
  14407. */
  14408. subtract(other: Quaternion): Quaternion;
  14409. /**
  14410. * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale".
  14411. */
  14412. scale(value: number): Quaternion;
  14413. /**
  14414. * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1".
  14415. */
  14416. multiply(q1: Quaternion): Quaternion;
  14417. /**
  14418. * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1".
  14419. * Returns the current Quaternion.
  14420. */
  14421. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  14422. /**
  14423. * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1".
  14424. * Returns the updated Quaternion.
  14425. */
  14426. multiplyInPlace(q1: Quaternion): Quaternion;
  14427. /**
  14428. * Sets the passed "ref" with the conjugation of the current Quaternion.
  14429. * Returns the current Quaternion.
  14430. */
  14431. conjugateToRef(ref: Quaternion): Quaternion;
  14432. /**
  14433. * Conjugates in place the current Quaternion.
  14434. * Returns the updated Quaternion.
  14435. */
  14436. conjugateInPlace(): Quaternion;
  14437. /**
  14438. * Returns a new Quaternion as the conjugate of the current Quaternion.
  14439. */
  14440. conjugate(): Quaternion;
  14441. /**
  14442. * Returns the Quaternion length (float).
  14443. */
  14444. length(): number;
  14445. /**
  14446. * Normalize in place the current Quaternion.
  14447. * Returns the updated Quaternion.
  14448. */
  14449. normalize(): Quaternion;
  14450. /**
  14451. * Returns a new Vector3 set with the Euler angles translated from the current Quaternion.
  14452. */
  14453. toEulerAngles(order?: string): Vector3;
  14454. /**
  14455. * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion.
  14456. * Returns the current Quaternion.
  14457. */
  14458. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  14459. /**
  14460. * Updates the passed rotation matrix with the current Quaternion values.
  14461. * Returns the current Quaternion.
  14462. */
  14463. toRotationMatrix(result: Matrix): Quaternion;
  14464. /**
  14465. * Updates the current Quaternion from the passed rotation matrix values.
  14466. * Returns the updated Quaternion.
  14467. */
  14468. fromRotationMatrix(matrix: Matrix): Quaternion;
  14469. /**
  14470. * Returns a new Quaternion set from the passed rotation matrix values.
  14471. */
  14472. static FromRotationMatrix(matrix: Matrix): Quaternion;
  14473. /**
  14474. * Updates the passed quaternion "result" with the passed rotation matrix values.
  14475. */
  14476. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  14477. /**
  14478. * Returns a new Quaternion set to (0.0, 0.0, 0.0).
  14479. */
  14480. static Zero(): Quaternion;
  14481. /**
  14482. * Returns a new Quaternion as the inverted current Quaternion.
  14483. */
  14484. static Inverse(q: Quaternion): Quaternion;
  14485. /**
  14486. * Returns the identity Quaternion.
  14487. */
  14488. static Identity(): Quaternion;
  14489. static IsIdentity(quaternion: Quaternion): boolean;
  14490. /**
  14491. * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float).
  14492. */
  14493. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  14494. /**
  14495. * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float).
  14496. */
  14497. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  14498. /**
  14499. * Retuns a new Quaternion set from the starting index of the passed array.
  14500. */
  14501. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  14502. /**
  14503. * Returns a new Quaternion set from the passed Euler float angles (y, x, z).
  14504. */
  14505. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  14506. /**
  14507. * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z).
  14508. */
  14509. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  14510. /**
  14511. * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation
  14512. */
  14513. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  14514. /**
  14515. * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation
  14516. */
  14517. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  14518. /**
  14519. * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  14520. * cf to Vector3.RotationFromAxis() documentation.
  14521. * Note : axis1, axis2 and axis3 are normalized during this operation.
  14522. */
  14523. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion;
  14524. /**
  14525. * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  14526. * cf to Vector3.RotationFromAxis() documentation.
  14527. * Note : axis1, axis2 and axis3 are normalized during this operation.
  14528. */
  14529. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  14530. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  14531. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  14532. /**
  14533. * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2".
  14534. */
  14535. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  14536. }
  14537. class Matrix {
  14538. private static _tempQuaternion;
  14539. private static _xAxis;
  14540. private static _yAxis;
  14541. private static _zAxis;
  14542. private static _updateFlagSeed;
  14543. private static _identityReadOnly;
  14544. private _isIdentity;
  14545. private _isIdentityDirty;
  14546. updateFlag: number;
  14547. m: Float32Array;
  14548. _markAsUpdated(): void;
  14549. constructor();
  14550. /**
  14551. * Boolean : True is the matrix is the identity matrix
  14552. */
  14553. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  14554. /**
  14555. * Returns the matrix determinant (float).
  14556. */
  14557. determinant(): number;
  14558. /**
  14559. * Returns the matrix underlying array.
  14560. */
  14561. toArray(): Float32Array;
  14562. /**
  14563. * Returns the matrix underlying array.
  14564. */
  14565. asArray(): Float32Array;
  14566. /**
  14567. * Inverts in place the Matrix.
  14568. * Returns the Matrix inverted.
  14569. */
  14570. invert(): Matrix;
  14571. /**
  14572. * Sets all the matrix elements to zero.
  14573. * Returns the Matrix.
  14574. */
  14575. reset(): Matrix;
  14576. /**
  14577. * Returns a new Matrix as the addition result of the current Matrix and the passed one.
  14578. */
  14579. add(other: Matrix): Matrix;
  14580. /**
  14581. * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one.
  14582. * Returns the Matrix.
  14583. */
  14584. addToRef(other: Matrix, result: Matrix): Matrix;
  14585. /**
  14586. * Adds in place the passed matrix to the current Matrix.
  14587. * Returns the updated Matrix.
  14588. */
  14589. addToSelf(other: Matrix): Matrix;
  14590. /**
  14591. * Sets the passed matrix with the current inverted Matrix.
  14592. * Returns the unmodified current Matrix.
  14593. */
  14594. invertToRef(other: Matrix): Matrix;
  14595. /**
  14596. * Inserts the translation vector (using 3 x floats) in the current Matrix.
  14597. * Returns the updated Matrix.
  14598. */
  14599. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  14600. /**
  14601. * Inserts the translation vector in the current Matrix.
  14602. * Returns the updated Matrix.
  14603. */
  14604. setTranslation(vector3: Vector3): Matrix;
  14605. /**
  14606. * Returns a new Vector3 as the extracted translation from the Matrix.
  14607. */
  14608. getTranslation(): Vector3;
  14609. /**
  14610. * Fill a Vector3 with the extracted translation from the Matrix.
  14611. */
  14612. getTranslationToRef(result: Vector3): Matrix;
  14613. /**
  14614. * Remove rotation and scaling part from the Matrix.
  14615. * Returns the updated Matrix.
  14616. */
  14617. removeRotationAndScaling(): Matrix;
  14618. /**
  14619. * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one.
  14620. */
  14621. multiply(other: Matrix): Matrix;
  14622. /**
  14623. * Updates the current Matrix from the passed one values.
  14624. * Returns the updated Matrix.
  14625. */
  14626. copyFrom(other: Matrix): Matrix;
  14627. /**
  14628. * Populates the passed array from the starting index with the Matrix values.
  14629. * Returns the Matrix.
  14630. */
  14631. copyToArray(array: Float32Array, offset?: number): Matrix;
  14632. /**
  14633. * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one.
  14634. */
  14635. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  14636. /**
  14637. * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one.
  14638. */
  14639. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  14640. /**
  14641. * Boolean : True is the current Matrix and the passed one values are strictly equal.
  14642. */
  14643. equals(value: Matrix): boolean;
  14644. /**
  14645. * Returns a new Matrix from the current Matrix.
  14646. */
  14647. clone(): Matrix;
  14648. /**
  14649. * Returns the string "Matrix"
  14650. */
  14651. getClassName(): string;
  14652. /**
  14653. * Returns the Matrix hash code.
  14654. */
  14655. getHashCode(): number;
  14656. /**
  14657. * Decomposes the current Matrix into :
  14658. * - a scale vector3 passed as a reference to update,
  14659. * - a rotation quaternion passed as a reference to update,
  14660. * - a translation vector3 passed as a reference to update.
  14661. * Returns the true if operation was successful.
  14662. */
  14663. decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean;
  14664. /**
  14665. * Returns a new Matrix as the extracted rotation matrix from the current one.
  14666. */
  14667. getRotationMatrix(): Matrix;
  14668. /**
  14669. * Extracts the rotation matrix from the current one and sets it as the passed "result".
  14670. * Returns the current Matrix.
  14671. */
  14672. getRotationMatrixToRef(result: Matrix): Matrix;
  14673. /**
  14674. * Returns a new Matrix set from the starting index of the passed array.
  14675. */
  14676. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  14677. /**
  14678. * Sets the passed "result" matrix from the starting index of the passed array.
  14679. */
  14680. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  14681. /**
  14682. * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale".
  14683. */
  14684. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  14685. /**
  14686. * Sets the passed matrix "result" with the 16 passed floats.
  14687. */
  14688. 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;
  14689. /**
  14690. * Returns the index-th row of the current matrix as a new Vector4.
  14691. */
  14692. getRow(index: number): Nullable<Vector4>;
  14693. /**
  14694. * Sets the index-th row of the current matrix with the passed Vector4 values.
  14695. * Returns the updated Matrix.
  14696. */
  14697. setRow(index: number, row: Vector4): Matrix;
  14698. /**
  14699. * Compute the transpose of the matrix.
  14700. * Returns a new Matrix.
  14701. */
  14702. transpose(): Matrix;
  14703. /**
  14704. * Compute the transpose of the matrix.
  14705. * Returns the current matrix.
  14706. */
  14707. transposeToRef(result: Matrix): Matrix;
  14708. /**
  14709. * Sets the index-th row of the current matrix with the passed 4 x float values.
  14710. * Returns the updated Matrix.
  14711. */
  14712. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  14713. /**
  14714. * Static identity matrix to be used as readonly matrix
  14715. * Must not be updated.
  14716. */
  14717. static readonly IdentityReadOnly: Matrix;
  14718. /**
  14719. * Returns a new Matrix set from the 16 passed floats.
  14720. */
  14721. 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;
  14722. /**
  14723. * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  14724. */
  14725. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  14726. /**
  14727. * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  14728. */
  14729. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  14730. /**
  14731. * Returns a new indentity Matrix.
  14732. */
  14733. static Identity(): Matrix;
  14734. /**
  14735. * Sets the passed "result" as an identity matrix.
  14736. */
  14737. static IdentityToRef(result: Matrix): void;
  14738. /**
  14739. * Returns a new zero Matrix.
  14740. */
  14741. static Zero(): Matrix;
  14742. /**
  14743. * Returns a new rotation matrix for "angle" radians around the X axis.
  14744. */
  14745. static RotationX(angle: number): Matrix;
  14746. /**
  14747. * Returns a new Matrix as the passed inverted one.
  14748. */
  14749. static Invert(source: Matrix): Matrix;
  14750. /**
  14751. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis.
  14752. */
  14753. static RotationXToRef(angle: number, result: Matrix): void;
  14754. /**
  14755. * Returns a new rotation matrix for "angle" radians around the Y axis.
  14756. */
  14757. static RotationY(angle: number): Matrix;
  14758. /**
  14759. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis.
  14760. */
  14761. static RotationYToRef(angle: number, result: Matrix): void;
  14762. /**
  14763. * Returns a new rotation matrix for "angle" radians around the Z axis.
  14764. */
  14765. static RotationZ(angle: number): Matrix;
  14766. /**
  14767. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis.
  14768. */
  14769. static RotationZToRef(angle: number, result: Matrix): void;
  14770. /**
  14771. * Returns a new rotation matrix for "angle" radians around the passed axis.
  14772. */
  14773. static RotationAxis(axis: Vector3, angle: number): Matrix;
  14774. /**
  14775. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis.
  14776. */
  14777. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  14778. /**
  14779. * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z).
  14780. */
  14781. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  14782. /**
  14783. * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z).
  14784. */
  14785. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  14786. /**
  14787. * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z).
  14788. */
  14789. static Scaling(x: number, y: number, z: number): Matrix;
  14790. /**
  14791. * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z).
  14792. */
  14793. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  14794. /**
  14795. * Returns a new Matrix as a translation matrix from the passed floats (x, y, z).
  14796. */
  14797. static Translation(x: number, y: number, z: number): Matrix;
  14798. /**
  14799. * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z).
  14800. */
  14801. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  14802. /**
  14803. * Returns a new Matrix whose values are the interpolated values for "gradien" (float) between the ones of the matrices "startValue" and "endValue".
  14804. */
  14805. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  14806. /**
  14807. * Returns a new Matrix whose values are computed by :
  14808. * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices,
  14809. * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end,
  14810. * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices.
  14811. */
  14812. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  14813. /**
  14814. * 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".
  14815. * This methods works for a Left-Handed system.
  14816. */
  14817. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  14818. /**
  14819. * 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".
  14820. * This methods works for a Left-Handed system.
  14821. */
  14822. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  14823. /**
  14824. * 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".
  14825. * This methods works for a Right-Handed system.
  14826. */
  14827. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  14828. /**
  14829. * 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".
  14830. * This methods works for a Left-Handed system.
  14831. */
  14832. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  14833. /**
  14834. * 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.
  14835. */
  14836. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  14837. /**
  14838. * 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.
  14839. */
  14840. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  14841. /**
  14842. * 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.
  14843. */
  14844. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  14845. /**
  14846. * 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.
  14847. */
  14848. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  14849. /**
  14850. * 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.
  14851. */
  14852. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  14853. /**
  14854. * 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.
  14855. */
  14856. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  14857. /**
  14858. * 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.
  14859. */
  14860. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  14861. /**
  14862. * 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.
  14863. */
  14864. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  14865. /**
  14866. * 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.
  14867. */
  14868. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  14869. /**
  14870. * 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.
  14871. */
  14872. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  14873. /**
  14874. * 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.
  14875. */
  14876. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  14877. /**
  14878. * 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.
  14879. */
  14880. static PerspectiveFovWebVRToRef(fov: {
  14881. upDegrees: number;
  14882. downDegrees: number;
  14883. leftDegrees: number;
  14884. rightDegrees: number;
  14885. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  14886. /**
  14887. * Returns the final transformation matrix : world * view * projection * viewport
  14888. */
  14889. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  14890. /**
  14891. * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix.
  14892. */
  14893. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  14894. /**
  14895. * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix.
  14896. */
  14897. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  14898. /**
  14899. * Compute the transpose of the passed Matrix.
  14900. * Returns a new Matrix.
  14901. */
  14902. static Transpose(matrix: Matrix): Matrix;
  14903. /**
  14904. * Compute the transpose of the passed Matrix and store it in the result matrix.
  14905. */
  14906. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  14907. /**
  14908. * Returns a new Matrix as the reflection matrix across the passed plane.
  14909. */
  14910. static Reflection(plane: Plane): Matrix;
  14911. /**
  14912. * Sets the passed matrix "result" as the reflection matrix across the passed plane.
  14913. */
  14914. static ReflectionToRef(plane: Plane, result: Matrix): void;
  14915. /**
  14916. * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis.
  14917. */
  14918. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  14919. /**
  14920. * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion.
  14921. */
  14922. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  14923. }
  14924. class Plane {
  14925. normal: Vector3;
  14926. d: number;
  14927. /**
  14928. * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  14929. */
  14930. constructor(a: number, b: number, c: number, d: number);
  14931. /**
  14932. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  14933. */
  14934. asArray(): number[];
  14935. /**
  14936. * Returns a new plane copied from the current Plane.
  14937. */
  14938. clone(): Plane;
  14939. /**
  14940. * Returns the string "Plane".
  14941. */
  14942. getClassName(): string;
  14943. /**
  14944. * Returns the Plane hash code.
  14945. */
  14946. getHashCode(): number;
  14947. /**
  14948. * Normalize the current Plane in place.
  14949. * Returns the updated Plane.
  14950. */
  14951. normalize(): Plane;
  14952. /**
  14953. * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix.
  14954. */
  14955. transform(transformation: Matrix): Plane;
  14956. /**
  14957. * Returns the dot product (float) of the point coordinates and the plane normal.
  14958. */
  14959. dotCoordinate(point: Vector3): number;
  14960. /**
  14961. * Updates the current Plane from the plane defined by the three passed points.
  14962. * Returns the updated Plane.
  14963. */
  14964. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  14965. /**
  14966. * Boolean : True is the vector "direction" is the same side than the plane normal.
  14967. */
  14968. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  14969. /**
  14970. * Returns the signed distance (float) from the passed point to the Plane.
  14971. */
  14972. signedDistanceTo(point: Vector3): number;
  14973. /**
  14974. * Returns a new Plane from the passed array.
  14975. */
  14976. static FromArray(array: ArrayLike<number>): Plane;
  14977. /**
  14978. * Returns a new Plane defined by the three passed points.
  14979. */
  14980. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  14981. /**
  14982. * Returns a new Plane the normal vector to this plane at the passed origin point.
  14983. * Note : the vector "normal" is updated because normalized.
  14984. */
  14985. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  14986. /**
  14987. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point.
  14988. */
  14989. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  14990. }
  14991. class Viewport {
  14992. x: number;
  14993. y: number;
  14994. width: number;
  14995. height: number;
  14996. /**
  14997. * Creates a Viewport object located at (x, y) and sized (width, height).
  14998. */
  14999. constructor(x: number, y: number, width: number, height: number);
  15000. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  15001. /**
  15002. * Returns a new Viewport copied from the current one.
  15003. */
  15004. clone(): Viewport;
  15005. }
  15006. class Frustum {
  15007. /**
  15008. * Returns a new array of 6 Frustum planes computed by the passed transformation matrix.
  15009. */
  15010. static GetPlanes(transform: Matrix): Plane[];
  15011. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15012. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15013. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15014. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15015. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15016. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  15017. /**
  15018. * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix.
  15019. */
  15020. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  15021. }
  15022. enum Space {
  15023. LOCAL = 0,
  15024. WORLD = 1,
  15025. BONE = 2,
  15026. }
  15027. class Axis {
  15028. static X: Vector3;
  15029. static Y: Vector3;
  15030. static Z: Vector3;
  15031. }
  15032. class BezierCurve {
  15033. /**
  15034. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats.
  15035. */
  15036. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  15037. }
  15038. enum Orientation {
  15039. CW = 0,
  15040. CCW = 1,
  15041. }
  15042. class Angle {
  15043. private _radians;
  15044. /**
  15045. * Creates an Angle object of "radians" radians (float).
  15046. */
  15047. constructor(radians: number);
  15048. /**
  15049. * Returns the Angle value in degrees (float).
  15050. */
  15051. degrees: () => number;
  15052. /**
  15053. * Returns the Angle value in radians (float).
  15054. */
  15055. radians: () => number;
  15056. /**
  15057. * Returns a new Angle object valued with the angle value in radians between the two passed vectors.
  15058. */
  15059. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  15060. /**
  15061. * Returns a new Angle object from the passed float in radians.
  15062. */
  15063. static FromRadians(radians: number): Angle;
  15064. /**
  15065. * Returns a new Angle object from the passed float in degrees.
  15066. */
  15067. static FromDegrees(degrees: number): Angle;
  15068. }
  15069. class Arc2 {
  15070. startPoint: Vector2;
  15071. midPoint: Vector2;
  15072. endPoint: Vector2;
  15073. centerPoint: Vector2;
  15074. radius: number;
  15075. angle: Angle;
  15076. startAngle: Angle;
  15077. orientation: Orientation;
  15078. /**
  15079. * Creates an Arc object from the three passed points : start, middle and end.
  15080. */
  15081. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  15082. }
  15083. class Path2 {
  15084. private _points;
  15085. private _length;
  15086. closed: boolean;
  15087. /**
  15088. * Creates a Path2 object from the starting 2D coordinates x and y.
  15089. */
  15090. constructor(x: number, y: number);
  15091. /**
  15092. * Adds a new segment until the passed coordinates (x, y) to the current Path2.
  15093. * Returns the updated Path2.
  15094. */
  15095. addLineTo(x: number, y: number): Path2;
  15096. /**
  15097. * 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.
  15098. * Returns the updated Path2.
  15099. */
  15100. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  15101. /**
  15102. * Closes the Path2.
  15103. * Returns the Path2.
  15104. */
  15105. close(): Path2;
  15106. /**
  15107. * Returns the Path2 total length (float).
  15108. */
  15109. length(): number;
  15110. /**
  15111. * Returns the Path2 internal array of points.
  15112. */
  15113. getPoints(): Vector2[];
  15114. /**
  15115. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  15116. */
  15117. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  15118. /**
  15119. * Returns a new Path2 starting at the coordinates (x, y).
  15120. */
  15121. static StartingAt(x: number, y: number): Path2;
  15122. }
  15123. class Path3D {
  15124. path: Vector3[];
  15125. private _curve;
  15126. private _distances;
  15127. private _tangents;
  15128. private _normals;
  15129. private _binormals;
  15130. private _raw;
  15131. /**
  15132. * new Path3D(path, normal, raw)
  15133. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  15134. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  15135. * path : an array of Vector3, the curve axis of the Path3D
  15136. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  15137. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  15138. */
  15139. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  15140. /**
  15141. * Returns the Path3D array of successive Vector3 designing its curve.
  15142. */
  15143. getCurve(): Vector3[];
  15144. /**
  15145. * Returns an array populated with tangent vectors on each Path3D curve point.
  15146. */
  15147. getTangents(): Vector3[];
  15148. /**
  15149. * Returns an array populated with normal vectors on each Path3D curve point.
  15150. */
  15151. getNormals(): Vector3[];
  15152. /**
  15153. * Returns an array populated with binormal vectors on each Path3D curve point.
  15154. */
  15155. getBinormals(): Vector3[];
  15156. /**
  15157. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  15158. */
  15159. getDistances(): number[];
  15160. /**
  15161. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  15162. * Returns the same object updated.
  15163. */
  15164. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  15165. private _compute(firstNormal);
  15166. private _getFirstNonNullVector(index);
  15167. private _getLastNonNullVector(index);
  15168. private _normalVector(v0, vt, va);
  15169. }
  15170. class Curve3 {
  15171. private _points;
  15172. private _length;
  15173. /**
  15174. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  15175. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  15176. * @param v1 (Vector3) the control point
  15177. * @param v2 (Vector3) the end point of the Quadratic Bezier
  15178. * @param nbPoints (integer) the wanted number of points in the curve
  15179. */
  15180. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  15181. /**
  15182. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  15183. * @param v0 (Vector3) the origin point of the Cubic Bezier
  15184. * @param v1 (Vector3) the first control point
  15185. * @param v2 (Vector3) the second control point
  15186. * @param v3 (Vector3) the end point of the Cubic Bezier
  15187. * @param nbPoints (integer) the wanted number of points in the curve
  15188. */
  15189. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  15190. /**
  15191. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  15192. * @param p1 (Vector3) the origin point of the Hermite Spline
  15193. * @param t1 (Vector3) the tangent vector at the origin point
  15194. * @param p2 (Vector3) the end point of the Hermite Spline
  15195. * @param t2 (Vector3) the tangent vector at the end point
  15196. * @param nbPoints (integer) the wanted number of points in the curve
  15197. */
  15198. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  15199. /**
  15200. * Returns a Curve3 object along a CatmullRom Spline curve :
  15201. * @param points (array of Vector3) the points the spline must pass through. At least, four points required.
  15202. * @param nbPoints (integer) the wanted number of points between each curve control points.
  15203. */
  15204. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3;
  15205. /**
  15206. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  15207. * A Curve3 is designed from a series of successive Vector3.
  15208. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  15209. */
  15210. constructor(points: Vector3[]);
  15211. /**
  15212. * Returns the Curve3 stored array of successive Vector3
  15213. */
  15214. getPoints(): Vector3[];
  15215. /**
  15216. * Returns the computed length (float) of the curve.
  15217. */
  15218. length(): number;
  15219. /**
  15220. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  15221. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  15222. * curveA and curveB keep unchanged.
  15223. */
  15224. continue(curve: Curve3): Curve3;
  15225. private _computeLength(path);
  15226. }
  15227. class PositionNormalVertex {
  15228. position: Vector3;
  15229. normal: Vector3;
  15230. constructor(position?: Vector3, normal?: Vector3);
  15231. clone(): PositionNormalVertex;
  15232. }
  15233. class PositionNormalTextureVertex {
  15234. position: Vector3;
  15235. normal: Vector3;
  15236. uv: Vector2;
  15237. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  15238. clone(): PositionNormalTextureVertex;
  15239. }
  15240. class Tmp {
  15241. static Color3: Color3[];
  15242. static Vector2: Vector2[];
  15243. static Vector3: Vector3[];
  15244. static Vector4: Vector4[];
  15245. static Quaternion: Quaternion[];
  15246. static Matrix: Matrix[];
  15247. }
  15248. }
  15249. declare module BABYLON {
  15250. class SphericalPolynomial {
  15251. x: Vector3;
  15252. y: Vector3;
  15253. z: Vector3;
  15254. xx: Vector3;
  15255. yy: Vector3;
  15256. zz: Vector3;
  15257. xy: Vector3;
  15258. yz: Vector3;
  15259. zx: Vector3;
  15260. addAmbient(color: Color3): void;
  15261. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  15262. scale(scale: number): void;
  15263. }
  15264. class SphericalHarmonics {
  15265. L00: Vector3;
  15266. L1_1: Vector3;
  15267. L10: Vector3;
  15268. L11: Vector3;
  15269. L2_2: Vector3;
  15270. L2_1: Vector3;
  15271. L20: Vector3;
  15272. L21: Vector3;
  15273. L22: Vector3;
  15274. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  15275. scale(scale: number): void;
  15276. convertIncidentRadianceToIrradiance(): void;
  15277. convertIrradianceToLambertianRadiance(): void;
  15278. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  15279. }
  15280. }
  15281. declare module BABYLON {
  15282. class MorphTarget {
  15283. name: string;
  15284. animations: Animation[];
  15285. private _positions;
  15286. private _normals;
  15287. private _tangents;
  15288. private _influence;
  15289. onInfluenceChanged: Observable<boolean>;
  15290. influence: number;
  15291. constructor(name: string, influence?: number);
  15292. readonly hasPositions: boolean;
  15293. readonly hasNormals: boolean;
  15294. readonly hasTangents: boolean;
  15295. setPositions(data: Nullable<FloatArray>): void;
  15296. getPositions(): Nullable<FloatArray>;
  15297. setNormals(data: Nullable<FloatArray>): void;
  15298. getNormals(): Nullable<FloatArray>;
  15299. setTangents(data: Nullable<FloatArray>): void;
  15300. getTangents(): Nullable<FloatArray>;
  15301. /**
  15302. * Serializes the current target into a Serialization object.
  15303. * Returns the serialized object.
  15304. */
  15305. serialize(): any;
  15306. static Parse(serializationObject: any): MorphTarget;
  15307. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  15308. }
  15309. }
  15310. declare module BABYLON {
  15311. class MorphTargetManager {
  15312. private _targets;
  15313. private _targetObservable;
  15314. private _activeTargets;
  15315. private _scene;
  15316. private _influences;
  15317. private _supportsNormals;
  15318. private _supportsTangents;
  15319. private _vertexCount;
  15320. private _uniqueId;
  15321. private _tempInfluences;
  15322. constructor(scene?: Nullable<Scene>);
  15323. readonly uniqueId: number;
  15324. readonly vertexCount: number;
  15325. readonly supportsNormals: boolean;
  15326. readonly supportsTangents: boolean;
  15327. readonly numTargets: number;
  15328. readonly numInfluencers: number;
  15329. readonly influences: Float32Array;
  15330. getActiveTarget(index: number): MorphTarget;
  15331. getTarget(index: number): MorphTarget;
  15332. addTarget(target: MorphTarget): void;
  15333. removeTarget(target: MorphTarget): void;
  15334. /**
  15335. * Serializes the current manager into a Serialization object.
  15336. * Returns the serialized object.
  15337. */
  15338. serialize(): any;
  15339. private _syncActiveTargets(needUpdate);
  15340. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  15341. }
  15342. }
  15343. declare module BABYLON {
  15344. interface PhysicsImpostorJoint {
  15345. mainImpostor: PhysicsImpostor;
  15346. connectedImpostor: PhysicsImpostor;
  15347. joint: PhysicsJoint;
  15348. }
  15349. class PhysicsEngine {
  15350. private _physicsPlugin;
  15351. gravity: Vector3;
  15352. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  15353. setGravity(gravity: Vector3): void;
  15354. /**
  15355. * Set the time step of the physics engine.
  15356. * default is 1/60.
  15357. * To slow it down, enter 1/600 for example.
  15358. * To speed it up, 1/30
  15359. * @param {number} newTimeStep the new timestep to apply to this world.
  15360. */
  15361. setTimeStep(newTimeStep?: number): void;
  15362. /**
  15363. * Get the time step of the physics engine.
  15364. */
  15365. getTimeStep(): number;
  15366. dispose(): void;
  15367. getPhysicsPluginName(): string;
  15368. static Epsilon: number;
  15369. private _impostors;
  15370. private _joints;
  15371. /**
  15372. * Adding a new impostor for the impostor tracking.
  15373. * This will be done by the impostor itself.
  15374. * @param {PhysicsImpostor} impostor the impostor to add
  15375. */
  15376. addImpostor(impostor: PhysicsImpostor): void;
  15377. /**
  15378. * Remove an impostor from the engine.
  15379. * This impostor and its mesh will not longer be updated by the physics engine.
  15380. * @param {PhysicsImpostor} impostor the impostor to remove
  15381. */
  15382. removeImpostor(impostor: PhysicsImpostor): void;
  15383. /**
  15384. * Add a joint to the physics engine
  15385. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  15386. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  15387. * @param {PhysicsJoint} the joint that will connect both impostors.
  15388. */
  15389. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  15390. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  15391. /**
  15392. * Called by the scene. no need to call it.
  15393. */
  15394. _step(delta: number): void;
  15395. getPhysicsPlugin(): IPhysicsEnginePlugin;
  15396. getImpostors(): Array<PhysicsImpostor>;
  15397. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  15398. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  15399. }
  15400. interface IPhysicsEnginePlugin {
  15401. world: any;
  15402. name: string;
  15403. setGravity(gravity: Vector3): void;
  15404. setTimeStep(timeStep: number): void;
  15405. getTimeStep(): number;
  15406. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  15407. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  15408. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  15409. generatePhysicsBody(impostor: PhysicsImpostor): void;
  15410. removePhysicsBody(impostor: PhysicsImpostor): void;
  15411. generateJoint(joint: PhysicsImpostorJoint): void;
  15412. removeJoint(joint: PhysicsImpostorJoint): void;
  15413. isSupported(): boolean;
  15414. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  15415. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  15416. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  15417. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  15418. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  15419. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  15420. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  15421. getBodyMass(impostor: PhysicsImpostor): number;
  15422. getBodyFriction(impostor: PhysicsImpostor): number;
  15423. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  15424. getBodyRestitution(impostor: PhysicsImpostor): number;
  15425. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  15426. sleepBody(impostor: PhysicsImpostor): void;
  15427. wakeUpBody(impostor: PhysicsImpostor): void;
  15428. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  15429. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  15430. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  15431. getRadius(impostor: PhysicsImpostor): number;
  15432. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  15433. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  15434. dispose(): void;
  15435. }
  15436. }
  15437. declare module BABYLON {
  15438. class PhysicsHelper {
  15439. private _scene;
  15440. private _physicsEngine;
  15441. constructor(scene: Scene);
  15442. /**
  15443. * @param {Vector3} origin the origin of the explosion
  15444. * @param {number} radius the explosion radius
  15445. * @param {number} strength the explosion strength
  15446. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  15447. */
  15448. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  15449. /**
  15450. * @param {Vector3} origin the origin of the explosion
  15451. * @param {number} radius the explosion radius
  15452. * @param {number} strength the explosion strength
  15453. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  15454. */
  15455. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  15456. /**
  15457. * @param {Vector3} origin the origin of the explosion
  15458. * @param {number} radius the explosion radius
  15459. * @param {number} strength the explosion strength
  15460. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  15461. */
  15462. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  15463. /**
  15464. * @param {Vector3} origin the origin of the updraft
  15465. * @param {number} radius the radius of the updraft
  15466. * @param {number} strength the strength of the updraft
  15467. * @param {number} height the height of the updraft
  15468. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  15469. */
  15470. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  15471. /**
  15472. * @param {Vector3} origin the of the vortex
  15473. * @param {number} radius the radius of the vortex
  15474. * @param {number} strength the strength of the vortex
  15475. * @param {number} height the height of the vortex
  15476. */
  15477. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  15478. }
  15479. /***** Radial explosion *****/
  15480. class PhysicsRadialExplosionEvent {
  15481. private _scene;
  15482. private _sphere;
  15483. private _sphereOptions;
  15484. private _rays;
  15485. private _dataFetched;
  15486. constructor(scene: Scene);
  15487. /**
  15488. * Returns the data related to the radial explosion event (sphere & rays).
  15489. * @returns {PhysicsRadialExplosionEventData}
  15490. */
  15491. getData(): PhysicsRadialExplosionEventData;
  15492. /**
  15493. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  15494. * @param impostor
  15495. * @param {Vector3} origin the origin of the explosion
  15496. * @param {number} radius the explosion radius
  15497. * @param {number} strength the explosion strength
  15498. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  15499. * @returns {Nullable<PhysicsForceAndContactPoint>}
  15500. */
  15501. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  15502. /**
  15503. * Disposes the sphere.
  15504. * @param {bolean} force
  15505. */
  15506. dispose(force?: boolean): void;
  15507. /*** Helpers ***/
  15508. private _prepareSphere();
  15509. private _intersectsWithSphere(impostor, origin, radius);
  15510. }
  15511. /***** Gravitational Field *****/
  15512. class PhysicsGravitationalFieldEvent {
  15513. private _physicsHelper;
  15514. private _scene;
  15515. private _origin;
  15516. private _radius;
  15517. private _strength;
  15518. private _falloff;
  15519. private _tickCallback;
  15520. private _sphere;
  15521. private _dataFetched;
  15522. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  15523. /**
  15524. * Returns the data related to the gravitational field event (sphere).
  15525. * @returns {PhysicsGravitationalFieldEventData}
  15526. */
  15527. getData(): PhysicsGravitationalFieldEventData;
  15528. /**
  15529. * Enables the gravitational field.
  15530. */
  15531. enable(): void;
  15532. /**
  15533. * Disables the gravitational field.
  15534. */
  15535. disable(): void;
  15536. /**
  15537. * Disposes the sphere.
  15538. * @param {bolean} force
  15539. */
  15540. dispose(force?: boolean): void;
  15541. private _tick();
  15542. }
  15543. /***** Updraft *****/
  15544. class PhysicsUpdraftEvent {
  15545. private _scene;
  15546. private _origin;
  15547. private _radius;
  15548. private _strength;
  15549. private _height;
  15550. private _updraftMode;
  15551. private _physicsEngine;
  15552. private _originTop;
  15553. private _originDirection;
  15554. private _tickCallback;
  15555. private _cylinder;
  15556. private _cylinderPosition;
  15557. private _dataFetched;
  15558. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  15559. /**
  15560. * Returns the data related to the updraft event (cylinder).
  15561. * @returns {PhysicsUpdraftEventData}
  15562. */
  15563. getData(): PhysicsUpdraftEventData;
  15564. /**
  15565. * Enables the updraft.
  15566. */
  15567. enable(): void;
  15568. /**
  15569. * Disables the cortex.
  15570. */
  15571. disable(): void;
  15572. /**
  15573. * Disposes the sphere.
  15574. * @param {bolean} force
  15575. */
  15576. dispose(force?: boolean): void;
  15577. private getImpostorForceAndContactPoint(impostor);
  15578. private _tick();
  15579. /*** Helpers ***/
  15580. private _prepareCylinder();
  15581. private _intersectsWithCylinder(impostor);
  15582. }
  15583. /***** Vortex *****/
  15584. class PhysicsVortexEvent {
  15585. private _scene;
  15586. private _origin;
  15587. private _radius;
  15588. private _strength;
  15589. private _height;
  15590. private _physicsEngine;
  15591. private _originTop;
  15592. private _centripetalForceThreshold;
  15593. private _updraftMultiplier;
  15594. private _tickCallback;
  15595. private _cylinder;
  15596. private _cylinderPosition;
  15597. private _dataFetched;
  15598. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  15599. /**
  15600. * Returns the data related to the vortex event (cylinder).
  15601. * @returns {PhysicsVortexEventData}
  15602. */
  15603. getData(): PhysicsVortexEventData;
  15604. /**
  15605. * Enables the vortex.
  15606. */
  15607. enable(): void;
  15608. /**
  15609. * Disables the cortex.
  15610. */
  15611. disable(): void;
  15612. /**
  15613. * Disposes the sphere.
  15614. * @param {bolean} force
  15615. */
  15616. dispose(force?: boolean): void;
  15617. private getImpostorForceAndContactPoint(impostor);
  15618. private _tick();
  15619. /*** Helpers ***/
  15620. private _prepareCylinder();
  15621. private _intersectsWithCylinder(impostor);
  15622. }
  15623. /***** Enums *****/
  15624. /**
  15625. * The strenght of the force in correspondence to the distance of the affected object
  15626. */
  15627. enum PhysicsRadialImpulseFalloff {
  15628. Constant = 0,
  15629. Linear = 1,
  15630. }
  15631. /**
  15632. * The strenght of the force in correspondence to the distance of the affected object
  15633. */
  15634. enum PhysicsUpdraftMode {
  15635. Center = 0,
  15636. Perpendicular = 1,
  15637. }
  15638. /***** Data interfaces *****/
  15639. interface PhysicsForceAndContactPoint {
  15640. force: Vector3;
  15641. contactPoint: Vector3;
  15642. }
  15643. interface PhysicsRadialExplosionEventData {
  15644. sphere: Mesh;
  15645. rays: Array<Ray>;
  15646. }
  15647. interface PhysicsGravitationalFieldEventData {
  15648. sphere: Mesh;
  15649. }
  15650. interface PhysicsUpdraftEventData {
  15651. cylinder: Mesh;
  15652. }
  15653. interface PhysicsVortexEventData {
  15654. cylinder: Mesh;
  15655. }
  15656. }
  15657. declare module BABYLON {
  15658. interface PhysicsImpostorParameters {
  15659. mass: number;
  15660. friction?: number;
  15661. restitution?: number;
  15662. nativeOptions?: any;
  15663. ignoreParent?: boolean;
  15664. disableBidirectionalTransformation?: boolean;
  15665. }
  15666. interface IPhysicsEnabledObject {
  15667. position: Vector3;
  15668. rotationQuaternion: Nullable<Quaternion>;
  15669. scaling: Vector3;
  15670. rotation?: Vector3;
  15671. parent?: any;
  15672. getBoundingInfo(): BoundingInfo;
  15673. computeWorldMatrix(force: boolean): Matrix;
  15674. getWorldMatrix?(): Matrix;
  15675. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  15676. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  15677. getIndices?(): Nullable<IndicesArray>;
  15678. getScene?(): Scene;
  15679. getAbsolutePosition(): Vector3;
  15680. getAbsolutePivotPoint(): Vector3;
  15681. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15682. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15683. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15684. getClassName(): string;
  15685. }
  15686. class PhysicsImpostor {
  15687. object: IPhysicsEnabledObject;
  15688. type: number;
  15689. private _options;
  15690. private _scene;
  15691. static DEFAULT_OBJECT_SIZE: Vector3;
  15692. static IDENTITY_QUATERNION: Quaternion;
  15693. private _physicsEngine;
  15694. private _physicsBody;
  15695. private _bodyUpdateRequired;
  15696. private _onBeforePhysicsStepCallbacks;
  15697. private _onAfterPhysicsStepCallbacks;
  15698. private _onPhysicsCollideCallbacks;
  15699. private _deltaPosition;
  15700. private _deltaRotation;
  15701. private _deltaRotationConjugated;
  15702. private _parent;
  15703. private _isDisposed;
  15704. private static _tmpVecs;
  15705. private static _tmpQuat;
  15706. readonly isDisposed: boolean;
  15707. mass: number;
  15708. friction: number;
  15709. restitution: number;
  15710. uniqueId: number;
  15711. private _joints;
  15712. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  15713. /**
  15714. * This function will completly initialize this impostor.
  15715. * It will create a new body - but only if this mesh has no parent.
  15716. * If it has, this impostor will not be used other than to define the impostor
  15717. * of the child mesh.
  15718. */
  15719. _init(): void;
  15720. private _getPhysicsParent();
  15721. /**
  15722. * Should a new body be generated.
  15723. */
  15724. isBodyInitRequired(): boolean;
  15725. setScalingUpdated(updated: boolean): void;
  15726. /**
  15727. * Force a regeneration of this or the parent's impostor's body.
  15728. * Use under cautious - This will remove all joints already implemented.
  15729. */
  15730. forceUpdate(): void;
  15731. /**
  15732. * Gets the body that holds this impostor. Either its own, or its parent.
  15733. */
  15734. /**
  15735. * Set the physics body. Used mainly by the physics engine/plugin
  15736. */
  15737. physicsBody: any;
  15738. parent: Nullable<PhysicsImpostor>;
  15739. resetUpdateFlags(): void;
  15740. getObjectExtendSize(): Vector3;
  15741. getObjectCenter(): Vector3;
  15742. /**
  15743. * Get a specific parametes from the options parameter.
  15744. */
  15745. getParam(paramName: string): any;
  15746. /**
  15747. * Sets a specific parameter in the options given to the physics plugin
  15748. */
  15749. setParam(paramName: string, value: number): void;
  15750. /**
  15751. * Specifically change the body's mass option. Won't recreate the physics body object
  15752. */
  15753. setMass(mass: number): void;
  15754. getLinearVelocity(): Nullable<Vector3>;
  15755. setLinearVelocity(velocity: Nullable<Vector3>): void;
  15756. getAngularVelocity(): Nullable<Vector3>;
  15757. setAngularVelocity(velocity: Nullable<Vector3>): void;
  15758. /**
  15759. * Execute a function with the physics plugin native code.
  15760. * Provide a function the will have two variables - the world object and the physics body object.
  15761. */
  15762. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  15763. /**
  15764. * Register a function that will be executed before the physics world is stepping forward.
  15765. */
  15766. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  15767. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  15768. /**
  15769. * Register a function that will be executed after the physics step
  15770. */
  15771. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  15772. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  15773. /**
  15774. * register a function that will be executed when this impostor collides against a different body.
  15775. */
  15776. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  15777. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  15778. private _tmpQuat;
  15779. private _tmpQuat2;
  15780. getParentsRotation(): Quaternion;
  15781. /**
  15782. * this function is executed by the physics engine.
  15783. */
  15784. beforeStep: () => void;
  15785. /**
  15786. * this function is executed by the physics engine.
  15787. */
  15788. afterStep: () => void;
  15789. /**
  15790. * Legacy collision detection event support
  15791. */
  15792. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  15793. onCollide: (e: {
  15794. body: any;
  15795. }) => void;
  15796. /**
  15797. * Apply a force
  15798. */
  15799. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  15800. /**
  15801. * Apply an impulse
  15802. */
  15803. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  15804. /**
  15805. * A help function to create a joint.
  15806. */
  15807. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  15808. /**
  15809. * Add a joint to this impostor with a different impostor.
  15810. */
  15811. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  15812. /**
  15813. * Will keep this body still, in a sleep mode.
  15814. */
  15815. sleep(): PhysicsImpostor;
  15816. /**
  15817. * Wake the body up.
  15818. */
  15819. wakeUp(): PhysicsImpostor;
  15820. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  15821. dispose(): void;
  15822. setDeltaPosition(position: Vector3): void;
  15823. setDeltaRotation(rotation: Quaternion): void;
  15824. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  15825. getRadius(): number;
  15826. /**
  15827. * Sync a bone with this impostor
  15828. * @param bone The bone to sync to the impostor.
  15829. * @param boneMesh The mesh that the bone is influencing.
  15830. * @param jointPivot The pivot of the joint / bone in local space.
  15831. * @param distToJoint Optional distance from the impostor to the joint.
  15832. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  15833. */
  15834. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  15835. /**
  15836. * Sync impostor to a bone
  15837. * @param bone The bone that the impostor will be synced to.
  15838. * @param boneMesh The mesh that the bone is influencing.
  15839. * @param jointPivot The pivot of the joint / bone in local space.
  15840. * @param distToJoint Optional distance from the impostor to the joint.
  15841. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  15842. * @param boneAxis Optional vector3 axis the bone is aligned with
  15843. */
  15844. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  15845. static NoImpostor: number;
  15846. static SphereImpostor: number;
  15847. static BoxImpostor: number;
  15848. static PlaneImpostor: number;
  15849. static MeshImpostor: number;
  15850. static CylinderImpostor: number;
  15851. static ParticleImpostor: number;
  15852. static HeightmapImpostor: number;
  15853. }
  15854. }
  15855. declare module BABYLON {
  15856. interface PhysicsJointData {
  15857. mainPivot?: Vector3;
  15858. connectedPivot?: Vector3;
  15859. mainAxis?: Vector3;
  15860. connectedAxis?: Vector3;
  15861. collision?: boolean;
  15862. nativeParams?: any;
  15863. }
  15864. /**
  15865. * This is a holder class for the physics joint created by the physics plugin.
  15866. * It holds a set of functions to control the underlying joint.
  15867. */
  15868. class PhysicsJoint {
  15869. type: number;
  15870. jointData: PhysicsJointData;
  15871. private _physicsJoint;
  15872. protected _physicsPlugin: IPhysicsEnginePlugin;
  15873. constructor(type: number, jointData: PhysicsJointData);
  15874. physicsJoint: any;
  15875. physicsPlugin: IPhysicsEnginePlugin;
  15876. /**
  15877. * Execute a function that is physics-plugin specific.
  15878. * @param {Function} func the function that will be executed.
  15879. * It accepts two parameters: the physics world and the physics joint.
  15880. */
  15881. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  15882. static DistanceJoint: number;
  15883. static HingeJoint: number;
  15884. static BallAndSocketJoint: number;
  15885. static WheelJoint: number;
  15886. static SliderJoint: number;
  15887. static PrismaticJoint: number;
  15888. static UniversalJoint: number;
  15889. static Hinge2Joint: number;
  15890. static PointToPointJoint: number;
  15891. static SpringJoint: number;
  15892. static LockJoint: number;
  15893. }
  15894. /**
  15895. * A class representing a physics distance joint.
  15896. */
  15897. class DistanceJoint extends PhysicsJoint {
  15898. constructor(jointData: DistanceJointData);
  15899. /**
  15900. * Update the predefined distance.
  15901. */
  15902. updateDistance(maxDistance: number, minDistance?: number): void;
  15903. }
  15904. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  15905. constructor(type: number, jointData: PhysicsJointData);
  15906. /**
  15907. * Set the motor values.
  15908. * Attention, this function is plugin specific. Engines won't react 100% the same.
  15909. * @param {number} force the force to apply
  15910. * @param {number} maxForce max force for this motor.
  15911. */
  15912. setMotor(force?: number, maxForce?: number): void;
  15913. /**
  15914. * Set the motor's limits.
  15915. * Attention, this function is plugin specific. Engines won't react 100% the same.
  15916. */
  15917. setLimit(upperLimit: number, lowerLimit?: number): void;
  15918. }
  15919. /**
  15920. * This class represents a single hinge physics joint
  15921. */
  15922. class HingeJoint extends MotorEnabledJoint {
  15923. constructor(jointData: PhysicsJointData);
  15924. /**
  15925. * Set the motor values.
  15926. * Attention, this function is plugin specific. Engines won't react 100% the same.
  15927. * @param {number} force the force to apply
  15928. * @param {number} maxForce max force for this motor.
  15929. */
  15930. setMotor(force?: number, maxForce?: number): void;
  15931. /**
  15932. * Set the motor's limits.
  15933. * Attention, this function is plugin specific. Engines won't react 100% the same.
  15934. */
  15935. setLimit(upperLimit: number, lowerLimit?: number): void;
  15936. }
  15937. /**
  15938. * This class represents a dual hinge physics joint (same as wheel joint)
  15939. */
  15940. class Hinge2Joint extends MotorEnabledJoint {
  15941. constructor(jointData: PhysicsJointData);
  15942. /**
  15943. * Set the motor values.
  15944. * Attention, this function is plugin specific. Engines won't react 100% the same.
  15945. * @param {number} force the force to apply
  15946. * @param {number} maxForce max force for this motor.
  15947. * @param {motorIndex} the motor's index, 0 or 1.
  15948. */
  15949. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  15950. /**
  15951. * Set the motor limits.
  15952. * Attention, this function is plugin specific. Engines won't react 100% the same.
  15953. * @param {number} upperLimit the upper limit
  15954. * @param {number} lowerLimit lower limit
  15955. * @param {motorIndex} the motor's index, 0 or 1.
  15956. */
  15957. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  15958. }
  15959. interface IMotorEnabledJoint {
  15960. physicsJoint: any;
  15961. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  15962. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  15963. }
  15964. interface DistanceJointData extends PhysicsJointData {
  15965. maxDistance: number;
  15966. }
  15967. interface SpringJointData extends PhysicsJointData {
  15968. length: number;
  15969. stiffness: number;
  15970. damping: number;
  15971. }
  15972. }
  15973. declare module BABYLON {
  15974. /**
  15975. * Particle emitter emitting particles from the inside of a box.
  15976. * It emits the particles randomly between 2 given directions.
  15977. */
  15978. class BoxParticleEmitter implements IParticleEmitterType {
  15979. private _particleSystem;
  15980. /**
  15981. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15982. */
  15983. /**
  15984. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15985. */
  15986. direction1: Vector3;
  15987. /**
  15988. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15989. */
  15990. /**
  15991. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15992. */
  15993. direction2: Vector3;
  15994. /**
  15995. * 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.
  15996. */
  15997. /**
  15998. * 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.
  15999. */
  16000. minEmitBox: Vector3;
  16001. /**
  16002. * 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.
  16003. */
  16004. /**
  16005. * 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.
  16006. */
  16007. maxEmitBox: Vector3;
  16008. /**
  16009. * Creates a new instance of @see BoxParticleEmitter
  16010. * @param _particleSystem the particle system associated with the emitter
  16011. */
  16012. constructor(_particleSystem: ParticleSystem);
  16013. /**
  16014. * Called by the particle System when the direction is computed for the created particle.
  16015. * @param emitPower is the power of the particle (speed)
  16016. * @param worldMatrix is the world matrix of the particle system
  16017. * @param directionToUpdate is the direction vector to update with the result
  16018. * @param particle is the particle we are computed the direction for
  16019. */
  16020. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16021. /**
  16022. * Called by the particle System when the position is computed for the created particle.
  16023. * @param worldMatrix is the world matrix of the particle system
  16024. * @param positionToUpdate is the position vector to update with the result
  16025. * @param particle is the particle we are computed the position for
  16026. */
  16027. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16028. /**
  16029. * Clones the current emitter and returns a copy of it
  16030. * @returns the new emitter
  16031. */
  16032. clone(): BoxParticleEmitter;
  16033. }
  16034. }
  16035. declare module BABYLON {
  16036. /**
  16037. * Particle emitter emitting particles from the inside of a cone.
  16038. * It emits the particles alongside the cone volume from the base to the particle.
  16039. * The emission direction might be randomized.
  16040. */
  16041. class ConeParticleEmitter implements IParticleEmitterType {
  16042. /**
  16043. * The radius of the emission cone.
  16044. */
  16045. angle: number;
  16046. /**
  16047. * The cone base angle.
  16048. */
  16049. directionRandomizer: number;
  16050. private _radius;
  16051. private _height;
  16052. /**
  16053. * Gets the radius of the emission cone.
  16054. */
  16055. /**
  16056. * Sets the radius of the emission cone.
  16057. */
  16058. radius: number;
  16059. /**
  16060. * Creates a new instance of @see ConeParticleEmitter
  16061. * @param radius the radius of the emission cone
  16062. * @param angles the cone base angle
  16063. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16064. */
  16065. constructor(radius: number,
  16066. /**
  16067. * The radius of the emission cone.
  16068. */
  16069. angle: number,
  16070. /**
  16071. * The cone base angle.
  16072. */
  16073. directionRandomizer?: number);
  16074. /**
  16075. * Called by the particle System when the direction is computed for the created particle.
  16076. * @param emitPower is the power of the particle (speed)
  16077. * @param worldMatrix is the world matrix of the particle system
  16078. * @param directionToUpdate is the direction vector to update with the result
  16079. * @param particle is the particle we are computed the direction for
  16080. */
  16081. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16082. /**
  16083. * Called by the particle System when the position is computed for the created particle.
  16084. * @param worldMatrix is the world matrix of the particle system
  16085. * @param positionToUpdate is the position vector to update with the result
  16086. * @param particle is the particle we are computed the position for
  16087. */
  16088. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16089. /**
  16090. * Clones the current emitter and returns a copy of it
  16091. * @returns the new emitter
  16092. */
  16093. clone(): ConeParticleEmitter;
  16094. }
  16095. }
  16096. declare module BABYLON {
  16097. /**
  16098. * This represents a GPU particle system in Babylon.
  16099. * This os the fastest particle system in Babylon as it uses the GPU to update the individual particle data.
  16100. */
  16101. class GPUParticleSystem implements IDisposable, IParticleSystem {
  16102. /**
  16103. * The id of the Particle system.
  16104. */
  16105. id: string;
  16106. /**
  16107. * The friendly name of the Particle system.
  16108. */
  16109. name: string;
  16110. /**
  16111. * The emitter represents the Mesh or position we are attaching the particle system to.
  16112. */
  16113. emitter: Nullable<AbstractMesh | Vector3>;
  16114. /**
  16115. * The rendering group used by the Particle system to chose when to render.
  16116. */
  16117. renderingGroupId: number;
  16118. /**
  16119. * The layer mask we are rendering the particles through.
  16120. */
  16121. layerMask: number;
  16122. private _capacity;
  16123. private _renderEffect;
  16124. private _updateEffect;
  16125. private _updateBuffer;
  16126. private _updateVAO;
  16127. private _updateVertexBuffers;
  16128. private _renderBuffer;
  16129. private _renderVAO;
  16130. private _renderVertexBuffers;
  16131. private _sourceVAO;
  16132. private _targetVAO;
  16133. private _sourceBuffer;
  16134. private _targetBuffer;
  16135. private _scene;
  16136. private _engine;
  16137. private _currentRenderId;
  16138. private _started;
  16139. /**
  16140. * An event triggered when the system is disposed.
  16141. */
  16142. onDisposeObservable: Observable<GPUParticleSystem>;
  16143. /**
  16144. * Gets Wether the system has been started.
  16145. * @returns True if it has been started, otherwise false.
  16146. */
  16147. isStarted(): boolean;
  16148. /**
  16149. * Starts the particle system and begins to emit.
  16150. */
  16151. start(): void;
  16152. /**
  16153. * Stops the particle system.
  16154. */
  16155. stop(): void;
  16156. /**
  16157. * Instantiates a GPU particle system.
  16158. * 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.
  16159. * @param name The name of the particle system
  16160. * @param capacity The max number of particles alive at the same time
  16161. * @param scene The scene the particle system belongs to
  16162. */
  16163. constructor(name: string, capacity: number, scene: Scene);
  16164. /**
  16165. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16166. */
  16167. animate(): void;
  16168. private _initialize();
  16169. /**
  16170. * Renders the particle system in its current state.
  16171. * @returns the current number of particles.
  16172. */
  16173. render(): number;
  16174. /**
  16175. * Rebuilds the particle system
  16176. */
  16177. rebuild(): void;
  16178. /**
  16179. * Disposes the particle system and free the associated resources.
  16180. */
  16181. dispose(): void;
  16182. /**
  16183. * Clones the particle system.
  16184. * @param name The name of the cloned object
  16185. * @param newEmitter The new emitter to use
  16186. * @returns the cloned particle system
  16187. */
  16188. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  16189. /**
  16190. * Serializes the particle system to a JSON object.
  16191. * @returns the JSON object
  16192. */
  16193. serialize(): any;
  16194. }
  16195. }
  16196. declare module BABYLON {
  16197. /**
  16198. * Particle emitter represents a volume emitting particles.
  16199. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16200. */
  16201. interface IParticleEmitterType {
  16202. /**
  16203. * Called by the particle System when the direction is computed for the created particle.
  16204. * @param emitPower is the power of the particle (speed)
  16205. * @param worldMatrix is the world matrix of the particle system
  16206. * @param directionToUpdate is the direction vector to update with the result
  16207. * @param particle is the particle we are computed the direction for
  16208. */
  16209. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16210. /**
  16211. * Called by the particle System when the position is computed for the created particle.
  16212. * @param worldMatrix is the world matrix of the particle system
  16213. * @param positionToUpdate is the position vector to update with the result
  16214. * @param particle is the particle we are computed the position for
  16215. */
  16216. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16217. /**
  16218. * Clones the current emitter and returns a copy of it
  16219. * @returns the new emitter
  16220. */
  16221. clone(): IParticleEmitterType;
  16222. }
  16223. }
  16224. declare module BABYLON {
  16225. /**
  16226. * A particle represents one of the element emitted by a particle system.
  16227. * This is mainly define by its coordinates, direction, velocity and age.
  16228. */
  16229. class Particle {
  16230. private particleSystem;
  16231. /**
  16232. * The world position of the particle in the scene.
  16233. */
  16234. position: Vector3;
  16235. /**
  16236. * The world direction of the particle in the scene.
  16237. */
  16238. direction: Vector3;
  16239. /**
  16240. * The color of the particle.
  16241. */
  16242. color: Color4;
  16243. /**
  16244. * The color change of the particle per step.
  16245. */
  16246. colorStep: Color4;
  16247. /**
  16248. * Defines how long will the life of the particle be.
  16249. */
  16250. lifeTime: number;
  16251. /**
  16252. * The current age of the particle.
  16253. */
  16254. age: number;
  16255. /**
  16256. * The current size of the particle.
  16257. */
  16258. size: number;
  16259. /**
  16260. * The current angle of the particle.
  16261. */
  16262. angle: number;
  16263. /**
  16264. * Defines how fast is the angle changing.
  16265. */
  16266. angularSpeed: number;
  16267. /**
  16268. * Defines the cell index used by the particle to be rendered from a sprite.
  16269. */
  16270. cellIndex: number;
  16271. private _currentFrameCounter;
  16272. /**
  16273. * Creates a new instance of @see Particle
  16274. * @param particleSystem the particle system the particle belongs to
  16275. */
  16276. constructor(particleSystem: ParticleSystem);
  16277. /**
  16278. * Defines how the sprite cell index is updated for the particle. This is
  16279. * defined as a callback.
  16280. */
  16281. updateCellIndex: (scaledUpdateSpeed: number) => void;
  16282. private updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  16283. private updateCellIndexWithCustomSpeed();
  16284. /**
  16285. * Copy the properties of particle to another one.
  16286. * @param other the particle to copy the information to.
  16287. */
  16288. copyTo(other: Particle): void;
  16289. }
  16290. }
  16291. declare module BABYLON {
  16292. /**
  16293. * Interface representing a particle system in Babylon.
  16294. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16295. * A particle system represents a way to manage particles (@see Particle) from their emission to their animation and rendering.
  16296. */
  16297. interface IParticleSystem {
  16298. /**
  16299. * The id of the Particle system.
  16300. */
  16301. id: string;
  16302. /**
  16303. * The name of the Particle system.
  16304. */
  16305. name: string;
  16306. /**
  16307. * The emitter represents the Mesh or position we are attaching the particle system to.
  16308. */
  16309. emitter: Nullable<AbstractMesh | Vector3>;
  16310. /**
  16311. * The rendering group used by the Particle system to chose when to render.
  16312. */
  16313. renderingGroupId: number;
  16314. /**
  16315. * The layer mask we are rendering the particles through.
  16316. */
  16317. layerMask: number;
  16318. /**
  16319. * Gets if the particle system has been started.
  16320. * @return true if the system has been started, otherwise false.
  16321. */
  16322. isStarted(): boolean;
  16323. /**
  16324. * Animates the particle system for this frame.
  16325. */
  16326. animate(): void;
  16327. /**
  16328. * Renders the particle system in its current state.
  16329. * @returns the current number of particles.
  16330. */
  16331. render(): number;
  16332. /**
  16333. * Dispose the particle system and frees its associated resources.
  16334. */
  16335. dispose(): void;
  16336. /**
  16337. * Clones the particle system.
  16338. * @param name The name of the cloned object
  16339. * @param newEmitter The new emitter to use
  16340. * @returns the cloned particle system
  16341. */
  16342. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16343. /**
  16344. * Serializes the particle system to a JSON object.
  16345. * @returns the JSON object
  16346. */
  16347. serialize(): any;
  16348. /**
  16349. * Rebuild the particle system
  16350. */
  16351. rebuild(): void;
  16352. }
  16353. /**
  16354. * This represents a particle system in Babylon.
  16355. * 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.
  16356. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16357. * @example https://doc.babylonjs.com/babylon101/particles
  16358. */
  16359. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16360. /**
  16361. * Source color is added to the destination color without alpha affecting the result.
  16362. */
  16363. static BLENDMODE_ONEONE: number;
  16364. /**
  16365. * Blend current color and particle color using particle’s alpha.
  16366. */
  16367. static BLENDMODE_STANDARD: number;
  16368. /**
  16369. * List of animations used by the particle system.
  16370. */
  16371. animations: Animation[];
  16372. /**
  16373. * The id of the Particle system.
  16374. */
  16375. id: string;
  16376. /**
  16377. * The friendly name of the Particle system.
  16378. */
  16379. name: string;
  16380. /**
  16381. * The rendering group used by the Particle system to chose when to render.
  16382. */
  16383. renderingGroupId: number;
  16384. /**
  16385. * The emitter represents the Mesh or position we are attaching the particle system to.
  16386. */
  16387. emitter: Nullable<AbstractMesh | Vector3>;
  16388. /**
  16389. * The density of particles, the rate of particle flow
  16390. */
  16391. emitRate: number;
  16392. /**
  16393. * If you want to launch only a few particles at once, that can be done, as well.
  16394. */
  16395. manualEmitCount: number;
  16396. /**
  16397. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16398. */
  16399. updateSpeed: number;
  16400. /**
  16401. * The amount of time the particle system is running (depends of the overall speed above).
  16402. */
  16403. targetStopDuration: number;
  16404. /**
  16405. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16406. */
  16407. disposeOnStop: boolean;
  16408. /**
  16409. * Minimum power of emitting particles.
  16410. */
  16411. minEmitPower: number;
  16412. /**
  16413. * Maximum power of emitting particles.
  16414. */
  16415. maxEmitPower: number;
  16416. /**
  16417. * Minimum life time of emitting particles.
  16418. */
  16419. minLifeTime: number;
  16420. /**
  16421. * Maximum life time of emitting particles.
  16422. */
  16423. maxLifeTime: number;
  16424. /**
  16425. * Minimum Size of emitting particles.
  16426. */
  16427. minSize: number;
  16428. /**
  16429. * Maximum Size of emitting particles.
  16430. */
  16431. maxSize: number;
  16432. /**
  16433. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16434. */
  16435. minAngularSpeed: number;
  16436. /**
  16437. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16438. */
  16439. maxAngularSpeed: number;
  16440. /**
  16441. * The texture used to render each particle. (this can be a spritesheet)
  16442. */
  16443. particleTexture: Nullable<Texture>;
  16444. /**
  16445. * The layer mask we are rendering the particles through.
  16446. */
  16447. layerMask: number;
  16448. /**
  16449. * This can help using your own shader to render the particle system.
  16450. * The according effect will be created
  16451. */
  16452. customShader: any;
  16453. /**
  16454. * By default particle system starts as soon as they are created. This prevents the
  16455. * automatic start to happen and let you decide when to start emitting particles.
  16456. */
  16457. preventAutoStart: boolean;
  16458. /**
  16459. * This function can be defined to provide custom update for active particles.
  16460. * This function will be called instead of regular update (age, position, color, etc.).
  16461. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16462. */
  16463. updateFunction: (particles: Particle[]) => void;
  16464. /**
  16465. * Callback triggered when the particle animation is ending.
  16466. */
  16467. onAnimationEnd: Nullable<() => void>;
  16468. /**
  16469. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16470. */
  16471. blendMode: number;
  16472. /**
  16473. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16474. * to override the particles.
  16475. */
  16476. forceDepthWrite: boolean;
  16477. /**
  16478. * You can use gravity if you want to give an orientation to your particles.
  16479. */
  16480. gravity: Vector3;
  16481. /**
  16482. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16483. */
  16484. direction1: Vector3;
  16485. /**
  16486. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16487. */
  16488. direction2: Vector3;
  16489. /**
  16490. * 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.
  16491. */
  16492. minEmitBox: Vector3;
  16493. /**
  16494. * 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.
  16495. */
  16496. maxEmitBox: Vector3;
  16497. /**
  16498. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16499. */
  16500. color1: Color4;
  16501. /**
  16502. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16503. */
  16504. color2: Color4;
  16505. /**
  16506. * Color the particle will have at the end of its lifetime.
  16507. */
  16508. colorDead: Color4;
  16509. /**
  16510. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  16511. */
  16512. textureMask: Color4;
  16513. /**
  16514. * The particle emitter type defines the emitter used by the particle system.
  16515. * It can be for example box, sphere, or cone...
  16516. */
  16517. particleEmitterType: IParticleEmitterType;
  16518. /**
  16519. * This function can be defined to specify initial direction for every new particle.
  16520. * It by default use the emitterType defined function.
  16521. */
  16522. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16523. /**
  16524. * This function can be defined to specify initial position for every new particle.
  16525. * It by default use the emitterType defined function.
  16526. */
  16527. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16528. /**
  16529. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  16530. */
  16531. spriteCellLoop: boolean;
  16532. /**
  16533. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  16534. */
  16535. spriteCellChangeSpeed: number;
  16536. /**
  16537. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  16538. */
  16539. startSpriteCellID: number;
  16540. /**
  16541. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  16542. */
  16543. endSpriteCellID: number;
  16544. /**
  16545. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  16546. */
  16547. spriteCellWidth: number;
  16548. /**
  16549. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  16550. */
  16551. spriteCellHeight: number;
  16552. /**
  16553. * An event triggered when the system is disposed.
  16554. */
  16555. onDisposeObservable: Observable<ParticleSystem>;
  16556. private _onDisposeObserver;
  16557. /**
  16558. * Sets a callback that will be triggered when the system is disposed.
  16559. */
  16560. onDispose: () => void;
  16561. /**
  16562. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  16563. */
  16564. readonly isAnimationSheetEnabled: Boolean;
  16565. private _particles;
  16566. private _epsilon;
  16567. private _capacity;
  16568. private _scene;
  16569. private _stockParticles;
  16570. private _newPartsExcess;
  16571. private _vertexData;
  16572. private _vertexBuffer;
  16573. private _vertexBuffers;
  16574. private _indexBuffer;
  16575. private _effect;
  16576. private _customEffect;
  16577. private _cachedDefines;
  16578. private _scaledColorStep;
  16579. private _colorDiff;
  16580. private _scaledDirection;
  16581. private _scaledGravity;
  16582. private _currentRenderId;
  16583. private _alive;
  16584. private _started;
  16585. private _stopped;
  16586. private _actualFrame;
  16587. private _scaledUpdateSpeed;
  16588. private _vertexBufferSize;
  16589. private _isAnimationSheetEnabled;
  16590. /**
  16591. * Instantiates a particle system.
  16592. * 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.
  16593. * @param name The name of the particle system
  16594. * @param capacity The max number of particles alive at the same time
  16595. * @param scene The scene the particle system belongs to
  16596. * @param customEffect a custom effect used to change the way particles are rendered by default
  16597. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16598. * @param epsilon Offset used to render the particles
  16599. */
  16600. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16601. private _createIndexBuffer();
  16602. /**
  16603. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16604. * Its lifetime will start back at 0.
  16605. * @param particle The particle to recycle
  16606. */
  16607. recycleParticle(particle: Particle): void;
  16608. /**
  16609. * Gets the maximum number of particles active at the same time.
  16610. * @returns The max number of active particles.
  16611. */
  16612. getCapacity(): number;
  16613. /**
  16614. * Gets Wether there are still active particles in the system.
  16615. * @returns True if it is alive, otherwise false.
  16616. */
  16617. isAlive(): boolean;
  16618. /**
  16619. * Gets Wether the system has been started.
  16620. * @returns True if it has been started, otherwise false.
  16621. */
  16622. isStarted(): boolean;
  16623. /**
  16624. * Starts the particle system and begins to emit.
  16625. */
  16626. start(): void;
  16627. /**
  16628. * Stops the particle system.
  16629. */
  16630. stop(): void;
  16631. /**
  16632. * @ignore (for internal use only)
  16633. */
  16634. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16635. /**
  16636. * @ignore (for internal use only)
  16637. */
  16638. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16639. private _update(newParticles);
  16640. private _getEffect();
  16641. /**
  16642. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16643. */
  16644. animate(): void;
  16645. private _appendParticleVertexes;
  16646. private _appenedParticleVertexesWithSheet(offset, particle);
  16647. private _appenedParticleVertexesNoSheet(offset, particle);
  16648. /**
  16649. * Rebuilds the particle system.
  16650. */
  16651. rebuild(): void;
  16652. /**
  16653. * Renders the particle system in its current state.
  16654. * @returns the current number of particles.
  16655. */
  16656. render(): number;
  16657. /**
  16658. * Disposes the particle system and free the associated resources.
  16659. */
  16660. dispose(): void;
  16661. /**
  16662. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  16663. * @param radius The radius of the sphere to emit from
  16664. * @returns the emitter
  16665. */
  16666. createSphereEmitter(radius?: number): SphereParticleEmitter;
  16667. /**
  16668. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  16669. * @param radius The radius of the sphere to emit from
  16670. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16671. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16672. * @returns the emitter
  16673. */
  16674. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16675. /**
  16676. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  16677. * @param radius The radius of the cone to emit from
  16678. * @param angle The base angle of the cone
  16679. * @returns the emitter
  16680. */
  16681. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16682. /**
  16683. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16684. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16685. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16686. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16687. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16688. * @returns the emitter
  16689. */
  16690. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16691. /**
  16692. * Clones the particle system.
  16693. * @param name The name of the cloned object
  16694. * @param newEmitter The new emitter to use
  16695. * @returns the cloned particle system
  16696. */
  16697. clone(name: string, newEmitter: any): ParticleSystem;
  16698. /**
  16699. * Serializes the particle system to a JSON object.
  16700. * @returns the JSON object
  16701. */
  16702. serialize(): any;
  16703. /**
  16704. * Parses a JSON object to create a particle system.
  16705. * @param parsedParticleSystem The JSON object to parse
  16706. * @param scene The scene to create the particle system in
  16707. * @param rootUrl The root url to use to load external dependencies like texture
  16708. * @returns the Parsed particle system
  16709. */
  16710. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  16711. }
  16712. }
  16713. declare module BABYLON {
  16714. /**
  16715. * Represents one particle of a solid particle system.
  16716. * @see SolidParticleSystem
  16717. */
  16718. class SolidParticle {
  16719. /**
  16720. * particle global index
  16721. */
  16722. idx: number;
  16723. /**
  16724. * The color of the particle
  16725. */
  16726. color: Nullable<Color4>;
  16727. /**
  16728. * The world space position of the particle.
  16729. */
  16730. position: Vector3;
  16731. /**
  16732. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  16733. */
  16734. rotation: Vector3;
  16735. /**
  16736. * The world space rotation quaternion of the particle.
  16737. */
  16738. rotationQuaternion: Nullable<Quaternion>;
  16739. /**
  16740. * The scaling of the particle.
  16741. */
  16742. scaling: Vector3;
  16743. /**
  16744. * The uvs of the particle.
  16745. */
  16746. uvs: Vector4;
  16747. /**
  16748. * The current speed of the particle.
  16749. */
  16750. velocity: Vector3;
  16751. /**
  16752. * The pivot point in the particle local space.
  16753. */
  16754. pivot: Vector3;
  16755. /**
  16756. * Is the particle active or not ?
  16757. */
  16758. alive: boolean;
  16759. /**
  16760. * Is the particle visible or not ?
  16761. */
  16762. isVisible: boolean;
  16763. /**
  16764. * Index of this particle in the global "positions" array (Internal use)
  16765. */
  16766. _pos: number;
  16767. /**
  16768. * Index of this particle in the global "indices" array (Internal use)
  16769. */
  16770. _ind: number;
  16771. /**
  16772. * ModelShape of this particle (Internal use)
  16773. */
  16774. _model: ModelShape;
  16775. /**
  16776. * ModelShape id of this particle
  16777. */
  16778. shapeId: number;
  16779. /**
  16780. * Index of the particle in its shape id (Internal use)
  16781. */
  16782. idxInShape: number;
  16783. /**
  16784. * Reference to the shape model BoundingInfo object (Internal use)
  16785. */
  16786. _modelBoundingInfo: BoundingInfo;
  16787. /**
  16788. * Particle BoundingInfo object (Internal use)
  16789. */
  16790. _boundingInfo: BoundingInfo;
  16791. /**
  16792. * Reference to the SPS what the particle belongs to (Internal use)
  16793. */
  16794. _sps: SolidParticleSystem;
  16795. /**
  16796. * Still set as invisible in order to skip useless computations (Internal use)
  16797. */
  16798. _stillInvisible: boolean;
  16799. /**
  16800. * Last computed particle rotation matrix
  16801. */
  16802. _rotationMatrix: number[];
  16803. /**
  16804. * Creates a Solid Particle object.
  16805. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  16806. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  16807. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  16808. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  16809. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  16810. * @param shapeId (integer) is the model shape identifier in the SPS.
  16811. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  16812. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  16813. */
  16814. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  16815. /**
  16816. * Legacy support, changed scale to scaling
  16817. */
  16818. /**
  16819. * Legacy support, changed scale to scaling
  16820. */
  16821. scale: Vector3;
  16822. /**
  16823. * Legacy support, changed quaternion to rotationQuaternion
  16824. */
  16825. /**
  16826. * Legacy support, changed quaternion to rotationQuaternion
  16827. */
  16828. quaternion: Nullable<Quaternion>;
  16829. /**
  16830. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  16831. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  16832. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  16833. * @returns true if it intersects
  16834. */
  16835. intersectsMesh(target: Mesh | SolidParticle): boolean;
  16836. }
  16837. /**
  16838. * Represents the shape of the model used by one particle of a solid particle system.
  16839. * SPS internal tool, don't use it manually.
  16840. * @see SolidParticleSystem
  16841. */
  16842. class ModelShape {
  16843. /**
  16844. * The shape id.
  16845. */
  16846. shapeID: number;
  16847. /**
  16848. * flat array of model positions (internal use)
  16849. */
  16850. _shape: Vector3[];
  16851. /**
  16852. * flat array of model UVs (internal use)
  16853. */
  16854. _shapeUV: number[];
  16855. /**
  16856. * length of the shape in the model indices array (internal use)
  16857. */
  16858. _indicesLength: number;
  16859. /**
  16860. * Custom position function (internal use)
  16861. */
  16862. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  16863. /**
  16864. * Custom vertex function (internal use)
  16865. */
  16866. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  16867. /**
  16868. * 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.
  16869. * SPS internal tool, don't use it manually.
  16870. * @ignore
  16871. */
  16872. 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>);
  16873. }
  16874. /**
  16875. * Represents a Depth Sorted Particle in the solid particle system.
  16876. * @see SolidParticleSystem
  16877. */
  16878. class DepthSortedParticle {
  16879. /**
  16880. * Index of the particle in the "indices" array
  16881. */
  16882. ind: number;
  16883. /**
  16884. * Length of the particle shape in the "indices" array
  16885. */
  16886. indicesLength: number;
  16887. /**
  16888. * Squared distance from the particle to the camera
  16889. */
  16890. sqDistance: number;
  16891. }
  16892. }
  16893. declare module BABYLON {
  16894. /**
  16895. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  16896. *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.
  16897. * The SPS is also a particle system. It provides some methods to manage the particles.
  16898. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  16899. *
  16900. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  16901. */
  16902. class SolidParticleSystem implements IDisposable {
  16903. /**
  16904. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  16905. * Example : var p = SPS.particles[i];
  16906. */
  16907. particles: SolidParticle[];
  16908. /**
  16909. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  16910. */
  16911. nbParticles: number;
  16912. /**
  16913. * If the particles must ever face the camera (default false). Useful for planar particles.
  16914. */
  16915. billboard: boolean;
  16916. /**
  16917. * Recompute normals when adding a shape
  16918. */
  16919. recomputeNormals: boolean;
  16920. /**
  16921. * This a counter ofr your own usage. It's not set by any SPS functions.
  16922. */
  16923. counter: number;
  16924. /**
  16925. * The SPS name. This name is also given to the underlying mesh.
  16926. */
  16927. name: string;
  16928. /**
  16929. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  16930. */
  16931. mesh: Mesh;
  16932. /**
  16933. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  16934. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  16935. */
  16936. vars: any;
  16937. /**
  16938. * This array is populated when the SPS is set as 'pickable'.
  16939. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  16940. * Each element of this array is an object `{idx: int, faceId: int}`.
  16941. * `idx` is the picked particle index in the `SPS.particles` array
  16942. * `faceId` is the picked face index counted within this particle.
  16943. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  16944. */
  16945. pickedParticles: {
  16946. idx: number;
  16947. faceId: number;
  16948. }[];
  16949. /**
  16950. * This array is populated when `enableDepthSort` is set to true.
  16951. * Each element of this array is an instance of the class DepthSortedParticle.
  16952. */
  16953. depthSortedParticles: DepthSortedParticle[];
  16954. /**
  16955. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  16956. */
  16957. _bSphereOnly: boolean;
  16958. /**
  16959. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  16960. */
  16961. _bSphereRadiusFactor: number;
  16962. private _scene;
  16963. private _positions;
  16964. private _indices;
  16965. private _normals;
  16966. private _colors;
  16967. private _uvs;
  16968. private _indices32;
  16969. private _positions32;
  16970. private _normals32;
  16971. private _fixedNormal32;
  16972. private _colors32;
  16973. private _uvs32;
  16974. private _index;
  16975. private _updatable;
  16976. private _pickable;
  16977. private _isVisibilityBoxLocked;
  16978. private _alwaysVisible;
  16979. private _depthSort;
  16980. private _shapeCounter;
  16981. private _copy;
  16982. private _shape;
  16983. private _shapeUV;
  16984. private _color;
  16985. private _computeParticleColor;
  16986. private _computeParticleTexture;
  16987. private _computeParticleRotation;
  16988. private _computeParticleVertex;
  16989. private _computeBoundingBox;
  16990. private _depthSortParticles;
  16991. private _cam_axisZ;
  16992. private _cam_axisY;
  16993. private _cam_axisX;
  16994. private _axisZ;
  16995. private _camera;
  16996. private _particle;
  16997. private _camDir;
  16998. private _camInvertedPosition;
  16999. private _rotMatrix;
  17000. private _invertMatrix;
  17001. private _rotated;
  17002. private _quaternion;
  17003. private _vertex;
  17004. private _normal;
  17005. private _yaw;
  17006. private _pitch;
  17007. private _roll;
  17008. private _halfroll;
  17009. private _halfpitch;
  17010. private _halfyaw;
  17011. private _sinRoll;
  17012. private _cosRoll;
  17013. private _sinPitch;
  17014. private _cosPitch;
  17015. private _sinYaw;
  17016. private _cosYaw;
  17017. private _mustUnrotateFixedNormals;
  17018. private _minimum;
  17019. private _maximum;
  17020. private _minBbox;
  17021. private _maxBbox;
  17022. private _particlesIntersect;
  17023. private _depthSortFunction;
  17024. private _needs32Bits;
  17025. /**
  17026. * Creates a SPS (Solid Particle System) object.
  17027. * @param name (String) is the SPS name, this will be the underlying mesh name.
  17028. * @param scene (Scene) is the scene in which the SPS is added.
  17029. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  17030. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  17031. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  17032. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  17033. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  17034. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  17035. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  17036. */
  17037. constructor(name: string, scene: Scene, options?: {
  17038. updatable?: boolean;
  17039. isPickable?: boolean;
  17040. enableDepthSort?: boolean;
  17041. particleIntersection?: boolean;
  17042. boundingSphereOnly?: boolean;
  17043. bSphereRadiusFactor?: number;
  17044. });
  17045. /**
  17046. * Builds the SPS underlying mesh. Returns a standard Mesh.
  17047. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  17048. * @returns the created mesh
  17049. */
  17050. buildMesh(): Mesh;
  17051. /**
  17052. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  17053. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  17054. * Thus the particles generated from `digest()` have their property `position` set yet.
  17055. * @param mesh ( Mesh ) is the mesh to be digested
  17056. * @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
  17057. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  17058. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  17059. * @returns the current SPS
  17060. */
  17061. digest(mesh: Mesh, options?: {
  17062. facetNb?: number;
  17063. number?: number;
  17064. delta?: number;
  17065. }): SolidParticleSystem;
  17066. private _unrotateFixedNormals();
  17067. private _resetCopy();
  17068. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  17069. private _posToShape(positions);
  17070. private _uvsToShapeUV(uvs);
  17071. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  17072. /**
  17073. * Adds some particles to the SPS from the model shape. Returns the shape id.
  17074. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  17075. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  17076. * @param nb (positive integer) the number of particles to be created from this model
  17077. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  17078. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  17079. * @returns the number of shapes in the system
  17080. */
  17081. addShape(mesh: Mesh, nb: number, options?: {
  17082. positionFunction?: any;
  17083. vertexFunction?: any;
  17084. }): number;
  17085. private _rebuildParticle(particle);
  17086. /**
  17087. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  17088. * @returns the SPS.
  17089. */
  17090. rebuildMesh(): SolidParticleSystem;
  17091. /**
  17092. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  17093. * This method calls `updateParticle()` for each particle of the SPS.
  17094. * For an animated SPS, it is usually called within the render loop.
  17095. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  17096. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  17097. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  17098. * @returns the SPS.
  17099. */
  17100. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  17101. private _quaternionRotationYPR();
  17102. private _quaternionToRotationMatrix();
  17103. /**
  17104. * Disposes the SPS.
  17105. */
  17106. dispose(): void;
  17107. /**
  17108. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  17109. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  17110. * @returns the SPS.
  17111. */
  17112. refreshVisibleSize(): SolidParticleSystem;
  17113. /**
  17114. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  17115. * @param size the size (float) of the visibility box
  17116. * note : this doesn't lock the SPS mesh bounding box.
  17117. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  17118. */
  17119. setVisibilityBox(size: number): void;
  17120. /**
  17121. * Gets whether the SPS as always visible or not
  17122. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  17123. */
  17124. /**
  17125. * Sets the SPS as always visible or not
  17126. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  17127. */
  17128. isAlwaysVisible: boolean;
  17129. /**
  17130. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  17131. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  17132. */
  17133. /**
  17134. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  17135. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  17136. */
  17137. isVisibilityBoxLocked: boolean;
  17138. /**
  17139. * Gets if `setParticles()` computes the particle rotations or not.
  17140. * Default value : true. The SPS is faster when it's set to false.
  17141. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  17142. */
  17143. /**
  17144. * Tells to `setParticles()` to compute the particle rotations or not.
  17145. * Default value : true. The SPS is faster when it's set to false.
  17146. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  17147. */
  17148. computeParticleRotation: boolean;
  17149. /**
  17150. * Gets if `setParticles()` computes the particle colors or not.
  17151. * Default value : true. The SPS is faster when it's set to false.
  17152. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  17153. */
  17154. /**
  17155. * Tells to `setParticles()` to compute the particle colors or not.
  17156. * Default value : true. The SPS is faster when it's set to false.
  17157. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  17158. */
  17159. computeParticleColor: boolean;
  17160. /**
  17161. * Gets if `setParticles()` computes the particle textures or not.
  17162. * Default value : true. The SPS is faster when it's set to false.
  17163. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  17164. */
  17165. computeParticleTexture: boolean;
  17166. /**
  17167. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  17168. * Default value : false. The SPS is faster when it's set to false.
  17169. * Note : the particle custom vertex positions aren't stored values.
  17170. */
  17171. /**
  17172. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  17173. * Default value : false. The SPS is faster when it's set to false.
  17174. * Note : the particle custom vertex positions aren't stored values.
  17175. */
  17176. computeParticleVertex: boolean;
  17177. /**
  17178. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  17179. */
  17180. /**
  17181. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  17182. */
  17183. computeBoundingBox: boolean;
  17184. /**
  17185. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  17186. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  17187. * Default : `true`
  17188. */
  17189. /**
  17190. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  17191. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  17192. * Default : `true`
  17193. */
  17194. depthSortParticles: boolean;
  17195. /**
  17196. * This function does nothing. It may be overwritten to set all the particle first values.
  17197. * The SPS doesn't call this function, you may have to call it by your own.
  17198. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  17199. */
  17200. initParticles(): void;
  17201. /**
  17202. * This function does nothing. It may be overwritten to recycle a particle.
  17203. * The SPS doesn't call this function, you may have to call it by your own.
  17204. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  17205. * @param particle The particle to recycle
  17206. * @returns the recycled particle
  17207. */
  17208. recycleParticle(particle: SolidParticle): SolidParticle;
  17209. /**
  17210. * Updates a particle : this function should be overwritten by the user.
  17211. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  17212. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  17213. * @example : just set a particle position or velocity and recycle conditions
  17214. * @param particle The particle to update
  17215. * @returns the updated particle
  17216. */
  17217. updateParticle(particle: SolidParticle): SolidParticle;
  17218. /**
  17219. * Updates a vertex of a particle : it can be overwritten by the user.
  17220. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  17221. * @param particle the current particle
  17222. * @param vertex the current index of the current particle
  17223. * @param pt the index of the current vertex in the particle shape
  17224. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  17225. * @example : just set a vertex particle position
  17226. * @returns the updated vertex
  17227. */
  17228. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  17229. /**
  17230. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  17231. * This does nothing and may be overwritten by the user.
  17232. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  17233. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  17234. * @param update the boolean update value actually passed to setParticles()
  17235. */
  17236. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  17237. /**
  17238. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  17239. * This will be passed three parameters.
  17240. * This does nothing and may be overwritten by the user.
  17241. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  17242. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  17243. * @param update the boolean update value actually passed to setParticles()
  17244. */
  17245. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  17246. }
  17247. }
  17248. declare module BABYLON {
  17249. /**
  17250. * Particle emitter emitting particles from the inside of a sphere.
  17251. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17252. */
  17253. class SphereParticleEmitter implements IParticleEmitterType {
  17254. /**
  17255. * The radius of the emission sphere.
  17256. */
  17257. radius: number;
  17258. /**
  17259. * How much to randomize the particle direction [0-1].
  17260. */
  17261. directionRandomizer: number;
  17262. /**
  17263. * Creates a new instance of @see SphereParticleEmitter
  17264. * @param radius the radius of the emission sphere
  17265. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17266. */
  17267. constructor(
  17268. /**
  17269. * The radius of the emission sphere.
  17270. */
  17271. radius: number,
  17272. /**
  17273. * How much to randomize the particle direction [0-1].
  17274. */
  17275. directionRandomizer?: number);
  17276. /**
  17277. * Called by the particle System when the direction is computed for the created particle.
  17278. * @param emitPower is the power of the particle (speed)
  17279. * @param worldMatrix is the world matrix of the particle system
  17280. * @param directionToUpdate is the direction vector to update with the result
  17281. * @param particle is the particle we are computed the direction for
  17282. */
  17283. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17284. /**
  17285. * Called by the particle System when the position is computed for the created particle.
  17286. * @param worldMatrix is the world matrix of the particle system
  17287. * @param positionToUpdate is the position vector to update with the result
  17288. * @param particle is the particle we are computed the position for
  17289. */
  17290. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17291. /**
  17292. * Clones the current emitter and returns a copy of it
  17293. * @returns the new emitter
  17294. */
  17295. clone(): SphereParticleEmitter;
  17296. }
  17297. /**
  17298. * Particle emitter emitting particles from the inside of a sphere.
  17299. * It emits the particles randomly between two vectors.
  17300. */
  17301. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17302. /**
  17303. * The min limit of the emission direction.
  17304. */
  17305. direction1: Vector3;
  17306. /**
  17307. * The max limit of the emission direction.
  17308. */
  17309. direction2: Vector3;
  17310. /**
  17311. * Creates a new instance of @see SphereDirectedParticleEmitter
  17312. * @param radius the radius of the emission sphere
  17313. * @param direction1 the min limit of the emission direction
  17314. * @param direction2 the max limit of the emission direction
  17315. */
  17316. constructor(radius: number,
  17317. /**
  17318. * The min limit of the emission direction.
  17319. */
  17320. direction1: Vector3,
  17321. /**
  17322. * The max limit of the emission direction.
  17323. */
  17324. direction2: Vector3);
  17325. /**
  17326. * Called by the particle System when the direction is computed for the created particle.
  17327. * @param emitPower is the power of the particle (speed)
  17328. * @param worldMatrix is the world matrix of the particle system
  17329. * @param directionToUpdate is the direction vector to update with the result
  17330. * @param particle is the particle we are computed the direction for
  17331. */
  17332. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17333. /**
  17334. * Clones the current emitter and returns a copy of it
  17335. * @returns the new emitter
  17336. */
  17337. clone(): SphereDirectedParticleEmitter;
  17338. }
  17339. }
  17340. declare module BABYLON {
  17341. class ReflectionProbe {
  17342. name: string;
  17343. private _scene;
  17344. private _renderTargetTexture;
  17345. private _projectionMatrix;
  17346. private _viewMatrix;
  17347. private _target;
  17348. private _add;
  17349. private _attachedMesh;
  17350. invertYAxis: boolean;
  17351. position: Vector3;
  17352. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  17353. samples: number;
  17354. refreshRate: number;
  17355. getScene(): Scene;
  17356. readonly cubeTexture: RenderTargetTexture;
  17357. readonly renderList: Nullable<AbstractMesh[]>;
  17358. attachToMesh(mesh: AbstractMesh): void;
  17359. /**
  17360. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17361. *
  17362. * @param renderingGroupId The rendering group id corresponding to its index
  17363. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17364. */
  17365. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17366. dispose(): void;
  17367. }
  17368. }
  17369. declare module BABYLON {
  17370. class BoundingBoxRenderer {
  17371. frontColor: Color3;
  17372. backColor: Color3;
  17373. showBackLines: boolean;
  17374. renderList: SmartArray<BoundingBox>;
  17375. private _scene;
  17376. private _colorShader;
  17377. private _vertexBuffers;
  17378. private _indexBuffer;
  17379. constructor(scene: Scene);
  17380. private _prepareRessources();
  17381. private _createIndexBuffer();
  17382. _rebuild(): void;
  17383. reset(): void;
  17384. render(): void;
  17385. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  17386. dispose(): void;
  17387. }
  17388. }
  17389. declare module BABYLON {
  17390. class DepthRenderer {
  17391. private _scene;
  17392. private _depthMap;
  17393. private _effect;
  17394. private _cachedDefines;
  17395. constructor(scene: Scene, type?: number);
  17396. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17397. getDepthMap(): RenderTargetTexture;
  17398. dispose(): void;
  17399. }
  17400. }
  17401. declare module BABYLON {
  17402. class EdgesRenderer {
  17403. edgesWidthScalerForOrthographic: number;
  17404. edgesWidthScalerForPerspective: number;
  17405. private _source;
  17406. private _linesPositions;
  17407. private _linesNormals;
  17408. private _linesIndices;
  17409. private _epsilon;
  17410. private _indicesCount;
  17411. private _lineShader;
  17412. private _ib;
  17413. private _buffers;
  17414. private _checkVerticesInsteadOfIndices;
  17415. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17416. private _prepareRessources();
  17417. _rebuild(): void;
  17418. dispose(): void;
  17419. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  17420. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  17421. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  17422. _generateEdgesLines(): void;
  17423. render(): void;
  17424. }
  17425. }
  17426. declare module BABYLON {
  17427. /**
  17428. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  17429. */
  17430. class GeometryBufferRenderer {
  17431. private _scene;
  17432. private _multiRenderTarget;
  17433. private _ratio;
  17434. private _enablePosition;
  17435. protected _effect: Effect;
  17436. protected _cachedDefines: string;
  17437. /**
  17438. * Set the render list (meshes to be rendered) used in the G buffer.
  17439. */
  17440. renderList: Mesh[];
  17441. /**
  17442. * Gets wether or not G buffer are supported by the running hardware.
  17443. * This requires draw buffer supports
  17444. */
  17445. readonly isSupported: boolean;
  17446. /**
  17447. * Gets wether or not position are enabled for the G buffer.
  17448. */
  17449. /**
  17450. * Sets wether or not position are enabled for the G buffer.
  17451. */
  17452. enablePosition: boolean;
  17453. /**
  17454. * Gets the scene associated with the buffer.
  17455. */
  17456. readonly scene: Scene;
  17457. /**
  17458. * Gets the ratio used by the buffer during its creation.
  17459. * How big is the buffer related to the main canvas.
  17460. */
  17461. readonly ratio: number;
  17462. /**
  17463. * Creates a new G Buffer for the scene. @see GeometryBufferRenderer
  17464. * @param scene The scene the buffer belongs to
  17465. * @param ratio How big is the buffer related to the main canvas.
  17466. */
  17467. constructor(scene: Scene, ratio?: number);
  17468. /**
  17469. * Checks wether everything is ready to render a submesh to the G buffer.
  17470. * @param subMesh the submesh to check readiness for
  17471. * @param useInstances is the mesh drawn using instance or not
  17472. * @returns true if ready otherwise false
  17473. */
  17474. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17475. /**
  17476. * Gets the current underlying G Buffer.
  17477. * @returns the buffer
  17478. */
  17479. getGBuffer(): MultiRenderTarget;
  17480. /**
  17481. * Gets the number of samples used to render the buffer (anti aliasing).
  17482. */
  17483. /**
  17484. * Sets the number of samples used to render the buffer (anti aliasing).
  17485. */
  17486. samples: number;
  17487. /**
  17488. * Disposes the renderer and frees up associated resources.
  17489. */
  17490. dispose(): void;
  17491. protected _createRenderTargets(): void;
  17492. }
  17493. }
  17494. declare module BABYLON {
  17495. class OutlineRenderer {
  17496. private _scene;
  17497. private _effect;
  17498. private _cachedDefines;
  17499. zOffset: number;
  17500. constructor(scene: Scene);
  17501. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  17502. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17503. }
  17504. }
  17505. declare module BABYLON {
  17506. class RenderingGroup {
  17507. index: number;
  17508. private _scene;
  17509. private _opaqueSubMeshes;
  17510. private _transparentSubMeshes;
  17511. private _alphaTestSubMeshes;
  17512. private _depthOnlySubMeshes;
  17513. private _particleSystems;
  17514. private _spriteManagers;
  17515. private _opaqueSortCompareFn;
  17516. private _alphaTestSortCompareFn;
  17517. private _transparentSortCompareFn;
  17518. private _renderOpaque;
  17519. private _renderAlphaTest;
  17520. private _renderTransparent;
  17521. private _edgesRenderers;
  17522. onBeforeTransparentRendering: () => void;
  17523. /**
  17524. * Set the opaque sort comparison function.
  17525. * If null the sub meshes will be render in the order they were created
  17526. */
  17527. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17528. /**
  17529. * Set the alpha test sort comparison function.
  17530. * If null the sub meshes will be render in the order they were created
  17531. */
  17532. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17533. /**
  17534. * Set the transparent sort comparison function.
  17535. * If null the sub meshes will be render in the order they were created
  17536. */
  17537. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17538. /**
  17539. * Creates a new rendering group.
  17540. * @param index The rendering group index
  17541. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17542. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17543. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17544. */
  17545. 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>);
  17546. /**
  17547. * Render all the sub meshes contained in the group.
  17548. * @param customRenderFunction Used to override the default render behaviour of the group.
  17549. * @returns true if rendered some submeshes.
  17550. */
  17551. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17552. /**
  17553. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17554. * @param subMeshes The submeshes to render
  17555. */
  17556. private renderOpaqueSorted(subMeshes);
  17557. /**
  17558. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17559. * @param subMeshes The submeshes to render
  17560. */
  17561. private renderAlphaTestSorted(subMeshes);
  17562. /**
  17563. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17564. * @param subMeshes The submeshes to render
  17565. */
  17566. private renderTransparentSorted(subMeshes);
  17567. /**
  17568. * Renders the submeshes in a specified order.
  17569. * @param subMeshes The submeshes to sort before render
  17570. * @param sortCompareFn The comparison function use to sort
  17571. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17572. * @param transparent Specifies to activate blending if true
  17573. */
  17574. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  17575. /**
  17576. * Renders the submeshes in the order they were dispatched (no sort applied).
  17577. * @param subMeshes The submeshes to render
  17578. */
  17579. private static renderUnsorted(subMeshes);
  17580. /**
  17581. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17582. * are rendered back to front if in the same alpha index.
  17583. *
  17584. * @param a The first submesh
  17585. * @param b The second submesh
  17586. * @returns The result of the comparison
  17587. */
  17588. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17589. /**
  17590. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17591. * are rendered back to front.
  17592. *
  17593. * @param a The first submesh
  17594. * @param b The second submesh
  17595. * @returns The result of the comparison
  17596. */
  17597. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17598. /**
  17599. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17600. * are rendered front to back (prevent overdraw).
  17601. *
  17602. * @param a The first submesh
  17603. * @param b The second submesh
  17604. * @returns The result of the comparison
  17605. */
  17606. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17607. /**
  17608. * Resets the different lists of submeshes to prepare a new frame.
  17609. */
  17610. prepare(): void;
  17611. dispose(): void;
  17612. /**
  17613. * Inserts the submesh in its correct queue depending on its material.
  17614. * @param subMesh The submesh to dispatch
  17615. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17616. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17617. */
  17618. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17619. dispatchSprites(spriteManager: SpriteManager): void;
  17620. dispatchParticles(particleSystem: IParticleSystem): void;
  17621. private _renderParticles(activeMeshes);
  17622. private _renderSprites();
  17623. }
  17624. }
  17625. declare module BABYLON {
  17626. class RenderingManager {
  17627. /**
  17628. * The max id used for rendering groups (not included)
  17629. */
  17630. static MAX_RENDERINGGROUPS: number;
  17631. /**
  17632. * The min id used for rendering groups (included)
  17633. */
  17634. static MIN_RENDERINGGROUPS: number;
  17635. /**
  17636. * Used to globally prevent autoclearing scenes.
  17637. */
  17638. static AUTOCLEAR: boolean;
  17639. private _scene;
  17640. private _renderingGroups;
  17641. private _depthStencilBufferAlreadyCleaned;
  17642. private _autoClearDepthStencil;
  17643. private _customOpaqueSortCompareFn;
  17644. private _customAlphaTestSortCompareFn;
  17645. private _customTransparentSortCompareFn;
  17646. private _renderinGroupInfo;
  17647. constructor(scene: Scene);
  17648. private _clearDepthStencilBuffer(depth?, stencil?);
  17649. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17650. reset(): void;
  17651. dispose(): void;
  17652. private _prepareRenderingGroup(renderingGroupId);
  17653. dispatchSprites(spriteManager: SpriteManager): void;
  17654. dispatchParticles(particleSystem: IParticleSystem): void;
  17655. /**
  17656. * @param subMesh The submesh to dispatch
  17657. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17658. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17659. */
  17660. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17661. /**
  17662. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17663. * This allowed control for front to back rendering or reversly depending of the special needs.
  17664. *
  17665. * @param renderingGroupId The rendering group id corresponding to its index
  17666. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17667. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17668. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17669. */
  17670. 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;
  17671. /**
  17672. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17673. *
  17674. * @param renderingGroupId The rendering group id corresponding to its index
  17675. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17676. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17677. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17678. */
  17679. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17680. }
  17681. }
  17682. declare module BABYLON {
  17683. class AnaglyphPostProcess extends PostProcess {
  17684. private _passedProcess;
  17685. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  17686. }
  17687. }
  17688. declare module BABYLON {
  17689. class BlackAndWhitePostProcess extends PostProcess {
  17690. degree: number;
  17691. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  17692. }
  17693. }
  17694. declare module BABYLON {
  17695. /**
  17696. * The Blur Post Process which blurs an image based on a kernel and direction.
  17697. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  17698. */
  17699. class BlurPostProcess extends PostProcess {
  17700. /** The direction in which to blur the image. */ direction: Vector2;
  17701. protected _kernel: number;
  17702. protected _idealKernel: number;
  17703. protected _packedFloat: boolean;
  17704. protected _staticDefines: string;
  17705. /**
  17706. * Gets the length in pixels of the blur sample region
  17707. */
  17708. /**
  17709. * Sets the length in pixels of the blur sample region
  17710. */
  17711. kernel: number;
  17712. /**
  17713. * Gets wether or not the blur is unpacking/repacking floats
  17714. */
  17715. /**
  17716. * Sets wether or not the blur needs to unpack/repack floats
  17717. */
  17718. packedFloat: boolean;
  17719. /**
  17720. * Creates a new instance of @see BlurPostProcess
  17721. * @param name The name of the effect.
  17722. * @param direction The direction in which to blur the image.
  17723. * @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.
  17724. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17725. * @param camera The camera to apply the render pass to.
  17726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17727. * @param engine The engine which the post process will be applied. (default: current engine)
  17728. * @param reusable If the post process can be reused on the same frame. (default: false)
  17729. * @param textureType Type of textures used when performing the post process. (default: 0)
  17730. */
  17731. 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);
  17732. protected _updateParameters(): void;
  17733. /**
  17734. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  17735. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  17736. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  17737. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  17738. * The gaps between physical kernels are compensated for in the weighting of the samples
  17739. * @param idealKernel Ideal blur kernel.
  17740. * @return Nearest best kernel.
  17741. */
  17742. protected _nearestBestKernel(idealKernel: number): number;
  17743. /**
  17744. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  17745. * @param x The point on the Gaussian distribution to sample.
  17746. * @return the value of the Gaussian function at x.
  17747. */
  17748. protected _gaussianWeight(x: number): number;
  17749. /**
  17750. * Generates a string that can be used as a floating point number in GLSL.
  17751. * @param x Value to print.
  17752. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  17753. * @return GLSL float string.
  17754. */
  17755. protected _glslFloat(x: number, decimalFigures?: number): string;
  17756. }
  17757. }
  17758. declare module BABYLON {
  17759. /**
  17760. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  17761. */
  17762. class CircleOfConfusionPostProcess extends PostProcess {
  17763. /**
  17764. * 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.
  17765. */
  17766. lensSize: number;
  17767. /**
  17768. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  17769. */
  17770. fStop: number;
  17771. /**
  17772. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  17773. */
  17774. focusDistance: number;
  17775. /**
  17776. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  17777. */
  17778. focalLength: number;
  17779. /**
  17780. * Creates a new instance of @see CircleOfConfusionPostProcess
  17781. * @param name The name of the effect.
  17782. * @param scene The scene the effect belongs to.
  17783. * @param depthTexture The depth texture of the scene to compute the circle of confusion.
  17784. * @param options The required width/height ratio to downsize to before computing the render pass.
  17785. * @param camera The camera to apply the render pass to.
  17786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17787. * @param engine The engine which the post process will be applied. (default: current engine)
  17788. * @param reusable If the post process can be reused on the same frame. (default: false)
  17789. * @param textureType Type of textures used when performing the post process. (default: 0)
  17790. */
  17791. constructor(name: string, scene: Scene, depthTexture: RenderTargetTexture, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  17792. }
  17793. }
  17794. declare module BABYLON {
  17795. class ColorCorrectionPostProcess extends PostProcess {
  17796. private _colorTableTexture;
  17797. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  17798. }
  17799. }
  17800. declare module BABYLON {
  17801. class ConvolutionPostProcess extends PostProcess {
  17802. kernel: number[];
  17803. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  17804. static EdgeDetect0Kernel: number[];
  17805. static EdgeDetect1Kernel: number[];
  17806. static EdgeDetect2Kernel: number[];
  17807. static SharpenKernel: number[];
  17808. static EmbossKernel: number[];
  17809. static GaussianKernel: number[];
  17810. }
  17811. }
  17812. declare module BABYLON {
  17813. /**
  17814. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  17815. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  17816. * based on samples that have a large difference in distance than the center pixel.
  17817. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  17818. */
  17819. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  17820. direction: Vector2;
  17821. /**
  17822. * Creates a new instance of @see CircleOfConfusionPostProcess
  17823. * @param name The name of the effect.
  17824. * @param scene The scene the effect belongs to.
  17825. * @param direction The direction the blur should be applied.
  17826. * @param kernel The size of the kernel used to blur.
  17827. * @param options The required width/height ratio to downsize to before computing the render pass.
  17828. * @param camera The camera to apply the render pass to.
  17829. * @param depthMap The depth map to be used to avoid blurring accross edges
  17830. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  17831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17832. * @param engine The engine which the post process will be applied. (default: current engine)
  17833. * @param reusable If the post process can be reused on the same frame. (default: false)
  17834. * @param textureType Type of textures used when performing the post process. (default: 0)
  17835. */
  17836. constructor(name: string, scene: Scene, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, depthMap: RenderTargetTexture, imageToBlur?: Nullable<PostProcess>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  17837. }
  17838. }
  17839. declare module BABYLON {
  17840. /**
  17841. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  17842. */
  17843. class DepthOfFieldEffect extends PostProcessRenderEffect {
  17844. private _depthOfFieldPass;
  17845. private _circleOfConfusion;
  17846. private _depthOfFieldBlurX;
  17847. private _depthOfFieldBlurY;
  17848. private _depthOfFieldMerge;
  17849. /**
  17850. * The size of the kernel to be used for the blur
  17851. */
  17852. kernelSize: number;
  17853. /**
  17854. * The focal the length of the camera used in the effect
  17855. */
  17856. focalLength: number;
  17857. /**
  17858. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  17859. */
  17860. fStop: number;
  17861. /**
  17862. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  17863. */
  17864. focusDistance: number;
  17865. /**
  17866. * 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.
  17867. */
  17868. lensSize: number;
  17869. /**
  17870. * Creates a new instance of @see DepthOfFieldEffect
  17871. * @param scene The scene the effect belongs to.
  17872. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  17873. */
  17874. constructor(scene: Scene, pipelineTextureType?: number);
  17875. /**
  17876. * Disposes each of the internal effects for a given camera.
  17877. * @param camera The camera to dispose the effect on.
  17878. */
  17879. disposeEffects(camera: Camera): void;
  17880. }
  17881. }
  17882. declare module BABYLON {
  17883. /**
  17884. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  17885. */
  17886. class DepthOfFieldMergePostProcess extends PostProcess {
  17887. /**
  17888. * Creates a new instance of @see CircleOfConfusionPostProcess
  17889. * @param name The name of the effect.
  17890. * @param original The non-blurred image to be modified
  17891. * @param circleOfConfusion The circle of confusion post process that will determine how blurred each pixel should become.
  17892. * @param options The required width/height ratio to downsize to before computing the render pass.
  17893. * @param camera The camera to apply the render pass to.
  17894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17895. * @param engine The engine which the post process will be applied. (default: current engine)
  17896. * @param reusable If the post process can be reused on the same frame. (default: false)
  17897. * @param textureType Type of textures used when performing the post process. (default: 0)
  17898. */
  17899. constructor(name: string, original: PostProcess, circleOfConfusion: PostProcess, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  17900. }
  17901. }
  17902. declare module BABYLON {
  17903. class DisplayPassPostProcess extends PostProcess {
  17904. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  17905. }
  17906. }
  17907. declare module BABYLON {
  17908. class FilterPostProcess extends PostProcess {
  17909. kernelMatrix: Matrix;
  17910. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  17911. }
  17912. }
  17913. declare module BABYLON {
  17914. class FxaaPostProcess extends PostProcess {
  17915. texelWidth: number;
  17916. texelHeight: number;
  17917. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  17918. }
  17919. }
  17920. declare module BABYLON {
  17921. class HighlightsPostProcess extends PostProcess {
  17922. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  17923. }
  17924. }
  17925. declare module BABYLON {
  17926. class ImageProcessingPostProcess extends PostProcess {
  17927. /**
  17928. * Default configuration related to image processing available in the PBR Material.
  17929. */
  17930. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17931. /**
  17932. * Gets the image processing configuration used either in this material.
  17933. */
  17934. /**
  17935. * Sets the Default image processing configuration used either in the this material.
  17936. *
  17937. * If sets to null, the scene one is in use.
  17938. */
  17939. imageProcessingConfiguration: ImageProcessingConfiguration;
  17940. /**
  17941. * Keep track of the image processing observer to allow dispose and replace.
  17942. */
  17943. private _imageProcessingObserver;
  17944. /**
  17945. * Attaches a new image processing configuration to the PBR Material.
  17946. * @param configuration
  17947. */
  17948. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  17949. /**
  17950. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17951. */
  17952. /**
  17953. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17954. */
  17955. colorCurves: Nullable<ColorCurves>;
  17956. /**
  17957. * Gets wether the color curves effect is enabled.
  17958. */
  17959. /**
  17960. * Sets wether the color curves effect is enabled.
  17961. */
  17962. colorCurvesEnabled: boolean;
  17963. /**
  17964. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17965. */
  17966. /**
  17967. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17968. */
  17969. colorGradingTexture: Nullable<BaseTexture>;
  17970. /**
  17971. * Gets wether the color grading effect is enabled.
  17972. */
  17973. /**
  17974. * Gets wether the color grading effect is enabled.
  17975. */
  17976. colorGradingEnabled: boolean;
  17977. /**
  17978. * Gets exposure used in the effect.
  17979. */
  17980. /**
  17981. * Sets exposure used in the effect.
  17982. */
  17983. exposure: number;
  17984. /**
  17985. * Gets wether tonemapping is enabled or not.
  17986. */
  17987. /**
  17988. * Sets wether tonemapping is enabled or not
  17989. */
  17990. toneMappingEnabled: boolean;
  17991. /**
  17992. * Gets contrast used in the effect.
  17993. */
  17994. /**
  17995. * Sets contrast used in the effect.
  17996. */
  17997. contrast: number;
  17998. /**
  17999. * Gets Vignette stretch size.
  18000. */
  18001. /**
  18002. * Sets Vignette stretch size.
  18003. */
  18004. vignetteStretch: number;
  18005. /**
  18006. * Gets Vignette centre X Offset.
  18007. */
  18008. /**
  18009. * Sets Vignette centre X Offset.
  18010. */
  18011. vignetteCentreX: number;
  18012. /**
  18013. * Gets Vignette centre Y Offset.
  18014. */
  18015. /**
  18016. * Sets Vignette centre Y Offset.
  18017. */
  18018. vignetteCentreY: number;
  18019. /**
  18020. * Gets Vignette weight or intensity of the vignette effect.
  18021. */
  18022. /**
  18023. * Sets Vignette weight or intensity of the vignette effect.
  18024. */
  18025. vignetteWeight: number;
  18026. /**
  18027. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18028. * if vignetteEnabled is set to true.
  18029. */
  18030. /**
  18031. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18032. * if vignetteEnabled is set to true.
  18033. */
  18034. vignetteColor: Color4;
  18035. /**
  18036. * Gets Camera field of view used by the Vignette effect.
  18037. */
  18038. /**
  18039. * Sets Camera field of view used by the Vignette effect.
  18040. */
  18041. vignetteCameraFov: number;
  18042. /**
  18043. * Gets the vignette blend mode allowing different kind of effect.
  18044. */
  18045. /**
  18046. * Sets the vignette blend mode allowing different kind of effect.
  18047. */
  18048. vignetteBlendMode: number;
  18049. /**
  18050. * Gets wether the vignette effect is enabled.
  18051. */
  18052. /**
  18053. * Sets wether the vignette effect is enabled.
  18054. */
  18055. vignetteEnabled: boolean;
  18056. private _fromLinearSpace;
  18057. /**
  18058. * Gets wether the input of the processing is in Gamma or Linear Space.
  18059. */
  18060. /**
  18061. * Sets wether the input of the processing is in Gamma or Linear Space.
  18062. */
  18063. fromLinearSpace: boolean;
  18064. /**
  18065. * Defines cache preventing GC.
  18066. */
  18067. private _defines;
  18068. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18069. getClassName(): string;
  18070. protected _updateParameters(): void;
  18071. dispose(camera?: Camera): void;
  18072. }
  18073. }
  18074. declare module BABYLON {
  18075. class PassPostProcess extends PostProcess {
  18076. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  18077. }
  18078. }
  18079. declare module BABYLON {
  18080. type PostProcessOptions = {
  18081. width: number;
  18082. height: number;
  18083. };
  18084. /**
  18085. * PostProcess can be used to apply a shader to a texture after it has been rendered
  18086. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18087. */
  18088. class PostProcess {
  18089. /** Name of the PostProcess. */ name: string;
  18090. /**
  18091. * Width of the texture to apply the post process on
  18092. */
  18093. width: number;
  18094. /**
  18095. * Height of the texture to apply the post process on
  18096. */
  18097. height: number;
  18098. /**
  18099. * Sampling mode used by the shader
  18100. * See https://doc.babylonjs.com/classes/3.1/texture
  18101. */
  18102. renderTargetSamplingMode: number;
  18103. /**
  18104. * Clear color to use when screen clearing
  18105. */
  18106. clearColor: Color4;
  18107. /**
  18108. * If the buffer needs to be cleared before applying the post process. (default: true)
  18109. * Should be set to false if shader will overwrite all previous pixels.
  18110. */
  18111. autoClear: boolean;
  18112. /**
  18113. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  18114. */
  18115. alphaMode: number;
  18116. /**
  18117. * Sets the setAlphaBlendConstants of the babylon engine
  18118. */
  18119. alphaConstants: Color4;
  18120. /**
  18121. * Animations to be used for the post processing
  18122. */
  18123. animations: Animation[];
  18124. /**
  18125. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  18126. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18127. */
  18128. enablePixelPerfectMode: boolean;
  18129. /**
  18130. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18131. */
  18132. scaleMode: number;
  18133. /**
  18134. * Force textures to be a power of two (default: false)
  18135. */
  18136. alwaysForcePOT: boolean;
  18137. /**
  18138. * Number of sample textures (default: 1)
  18139. */
  18140. samples: number;
  18141. /**
  18142. * Modify the scale of the post process to be the same as the viewport (default: false)
  18143. */
  18144. adaptScaleToCurrentViewport: boolean;
  18145. private _camera;
  18146. private _scene;
  18147. private _engine;
  18148. private _options;
  18149. private _reusable;
  18150. private _textureType;
  18151. /**
  18152. * Smart array of input and output textures for the post process.
  18153. */
  18154. _textures: SmartArray<InternalTexture>;
  18155. /**
  18156. * The index in _textures that corresponds to the output texture.
  18157. */
  18158. _currentRenderTextureInd: number;
  18159. private _effect;
  18160. private _samplers;
  18161. private _fragmentUrl;
  18162. private _vertexUrl;
  18163. private _parameters;
  18164. private _scaleRatio;
  18165. protected _indexParameters: any;
  18166. private _shareOutputWithPostProcess;
  18167. private _texelSize;
  18168. private _forcedOutputTexture;
  18169. /**
  18170. * An event triggered when the postprocess is activated.
  18171. * @type {BABYLON.Observable}
  18172. */
  18173. onActivateObservable: Observable<Camera>;
  18174. private _onActivateObserver;
  18175. /**
  18176. * A function that is added to the onActivateObservable
  18177. */
  18178. onActivate: Nullable<(camera: Camera) => void>;
  18179. /**
  18180. * An event triggered when the postprocess changes its size.
  18181. * @type {BABYLON.Observable}
  18182. */
  18183. onSizeChangedObservable: Observable<PostProcess>;
  18184. private _onSizeChangedObserver;
  18185. /**
  18186. * A function that is added to the onSizeChangedObservable
  18187. */
  18188. onSizeChanged: (postProcess: PostProcess) => void;
  18189. /**
  18190. * An event triggered when the postprocess applies its effect.
  18191. * @type {BABYLON.Observable}
  18192. */
  18193. onApplyObservable: Observable<Effect>;
  18194. private _onApplyObserver;
  18195. /**
  18196. * A function that is added to the onApplyObservable
  18197. */
  18198. onApply: (effect: Effect) => void;
  18199. /**
  18200. * An event triggered before rendering the postprocess
  18201. * @type {BABYLON.Observable}
  18202. */
  18203. onBeforeRenderObservable: Observable<Effect>;
  18204. private _onBeforeRenderObserver;
  18205. /**
  18206. * A function that is added to the onBeforeRenderObservable
  18207. */
  18208. onBeforeRender: (effect: Effect) => void;
  18209. /**
  18210. * An event triggered after rendering the postprocess
  18211. * @type {BABYLON.Observable}
  18212. */
  18213. onAfterRenderObservable: Observable<Effect>;
  18214. private _onAfterRenderObserver;
  18215. /**
  18216. * A function that is added to the onAfterRenderObservable
  18217. */
  18218. onAfterRender: (efect: Effect) => void;
  18219. /**
  18220. * The resulting output of the post process.
  18221. */
  18222. outputTexture: InternalTexture;
  18223. /**
  18224. * Gets the camera which post process is applied to.
  18225. * @returns The camera the post process is applied to.
  18226. */
  18227. getCamera(): Camera;
  18228. /**
  18229. * Gets the texel size of the postprocess.
  18230. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18231. */
  18232. readonly texelSize: Vector2;
  18233. /**
  18234. * Creates a new instance of @see PostProcess
  18235. * @param name The name of the PostProcess.
  18236. * @param fragmentUrl The url of the fragment shader to be used.
  18237. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18238. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18239. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18240. * @param camera The camera to apply the render pass to.
  18241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18242. * @param engine The engine which the post process will be applied. (default: current engine)
  18243. * @param reusable If the post process can be reused on the same frame. (default: false)
  18244. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18245. * @param textureType Type of textures used when performing the post process. (default: 0)
  18246. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18247. * @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
  18248. * @param blockCompilation If the shader should be compiled imediatly. (default: false)
  18249. */
  18250. 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);
  18251. /**
  18252. * Gets the engine which this post process belongs to.
  18253. * @returns The engine the post process was enabled with.
  18254. */
  18255. getEngine(): Engine;
  18256. /**
  18257. * The effect that is created when initializing the post process.
  18258. * @returns The created effect corrisponding the the postprocess.
  18259. */
  18260. getEffect(): Effect;
  18261. /**
  18262. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18263. * @param postProcess The post process to share the output with.
  18264. * @returns This post process.
  18265. */
  18266. shareOutputWith(postProcess: PostProcess): PostProcess;
  18267. /**
  18268. * Updates the effect with the current post process compile time values and recompiles the shader.
  18269. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18270. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18271. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18272. * @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
  18273. * @param onCompiled Called when the shader has been compiled.
  18274. * @param onError Called if there is an error when compiling a shader.
  18275. */
  18276. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18277. /**
  18278. * The post process is reusable if it can be used multiple times within one frame.
  18279. * @returns If the post process is reusable
  18280. */
  18281. isReusable(): boolean;
  18282. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18283. markTextureDirty(): void;
  18284. /**
  18285. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18286. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18287. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18288. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18289. */
  18290. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): void;
  18291. /**
  18292. * If the post process is supported.
  18293. */
  18294. readonly isSupported: boolean;
  18295. /**
  18296. * The aspect ratio of the output texture.
  18297. */
  18298. readonly aspectRatio: number;
  18299. /**
  18300. * Get a value indicating if the post-process is ready to be used
  18301. * @returns true if the post-process is ready (shader is compiled)
  18302. */
  18303. isReady(): boolean;
  18304. /**
  18305. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18306. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  18307. */
  18308. apply(): Nullable<Effect>;
  18309. private _disposeTextures();
  18310. /**
  18311. * Disposes the post process.
  18312. * @param camera The camera to dispose the post process on.
  18313. */
  18314. dispose(camera?: Camera): void;
  18315. }
  18316. }
  18317. declare module BABYLON {
  18318. /**
  18319. * PostProcessManager is used to manage one or more post processes or post process pipelines
  18320. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18321. */
  18322. class PostProcessManager {
  18323. private _scene;
  18324. private _indexBuffer;
  18325. private _vertexBuffers;
  18326. /**
  18327. * Creates a new instance of @see PostProcess
  18328. * @param scene The scene that the post process is associated with.
  18329. */
  18330. constructor(scene: Scene);
  18331. private _prepareBuffers();
  18332. private _buildIndexBuffer();
  18333. /**
  18334. * Rebuilds the vertex buffers of the manager.
  18335. */
  18336. _rebuild(): void;
  18337. /**
  18338. * Prepares a frame to be run through a post process.
  18339. * @param sourceTexture The input texture to the post procesess. (default: null)
  18340. * @param postProcesses An array of post processes to be run. (default: null)
  18341. * @returns True if the post processes were able to be run.
  18342. */
  18343. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  18344. /**
  18345. * Manually render a set of post processes to a texture.
  18346. * @param postProcesses An array of post processes to be run.
  18347. * @param targetTexture The target texture to render to.
  18348. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  18349. */
  18350. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  18351. /**
  18352. * Finalize the result of the output of the postprocesses.
  18353. * @param doNotPresent If true the result will not be displayed to the screen.
  18354. * @param targetTexture The target texture to render to.
  18355. * @param faceIndex The index of the face to bind the target texture to.
  18356. * @param postProcesses The array of post processes to render.
  18357. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  18358. */
  18359. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: PostProcess[], forceFullscreenViewport?: boolean): void;
  18360. /**
  18361. * Disposes of the post process manager.
  18362. */
  18363. dispose(): void;
  18364. }
  18365. }
  18366. declare module BABYLON {
  18367. class RefractionPostProcess extends PostProcess {
  18368. color: Color3;
  18369. depth: number;
  18370. colorLevel: number;
  18371. private _refRexture;
  18372. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  18373. dispose(camera: Camera): void;
  18374. }
  18375. }
  18376. declare module BABYLON {
  18377. class StereoscopicInterlacePostProcess extends PostProcess {
  18378. private _stepSize;
  18379. private _passedProcess;
  18380. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  18381. }
  18382. }
  18383. declare module BABYLON {
  18384. enum TonemappingOperator {
  18385. Hable = 0,
  18386. Reinhard = 1,
  18387. HejiDawson = 2,
  18388. Photographic = 3,
  18389. }
  18390. class TonemapPostProcess extends PostProcess {
  18391. private _operator;
  18392. exposureAdjustment: number;
  18393. constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  18394. }
  18395. }
  18396. declare module BABYLON {
  18397. class VolumetricLightScatteringPostProcess extends PostProcess {
  18398. private _volumetricLightScatteringPass;
  18399. private _volumetricLightScatteringRTT;
  18400. private _viewPort;
  18401. private _screenCoordinates;
  18402. private _cachedDefines;
  18403. /**
  18404. * If not undefined, the mesh position is computed from the attached node position
  18405. * @type {{position: Vector3}}
  18406. */
  18407. attachedNode: {
  18408. position: Vector3;
  18409. };
  18410. /**
  18411. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  18412. * @type {Vector3}
  18413. */
  18414. customMeshPosition: Vector3;
  18415. /**
  18416. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  18417. * @type {boolean}
  18418. */
  18419. useCustomMeshPosition: boolean;
  18420. /**
  18421. * If the post-process should inverse the light scattering direction
  18422. * @type {boolean}
  18423. */
  18424. invert: boolean;
  18425. /**
  18426. * The internal mesh used by the post-process
  18427. * @type {boolean}
  18428. */
  18429. mesh: Mesh;
  18430. useDiffuseColor: boolean;
  18431. /**
  18432. * Array containing the excluded meshes not rendered in the internal pass
  18433. */
  18434. excludedMeshes: AbstractMesh[];
  18435. /**
  18436. * Controls the overall intensity of the post-process
  18437. * @type {number}
  18438. */
  18439. exposure: number;
  18440. /**
  18441. * Dissipates each sample's contribution in range [0, 1]
  18442. * @type {number}
  18443. */
  18444. decay: number;
  18445. /**
  18446. * Controls the overall intensity of each sample
  18447. * @type {number}
  18448. */
  18449. weight: number;
  18450. /**
  18451. * Controls the density of each sample
  18452. * @type {number}
  18453. */
  18454. density: number;
  18455. /**
  18456. * @constructor
  18457. * @param {string} name - The post-process name
  18458. * @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)
  18459. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  18460. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  18461. * @param {number} samples - The post-process quality, default 100
  18462. * @param {number} samplingMode - The post-process filtering mode
  18463. * @param {BABYLON.Engine} engine - The babylon engine
  18464. * @param {boolean} reusable - If the post-process is reusable
  18465. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  18466. */
  18467. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  18468. getClassName(): string;
  18469. private _isReady(subMesh, useInstances);
  18470. /**
  18471. * Sets the new light position for light scattering effect
  18472. * @param {BABYLON.Vector3} The new custom light position
  18473. */
  18474. setCustomMeshPosition(position: Vector3): void;
  18475. /**
  18476. * Returns the light position for light scattering effect
  18477. * @return {BABYLON.Vector3} The custom light position
  18478. */
  18479. getCustomMeshPosition(): Vector3;
  18480. /**
  18481. * Disposes the internal assets and detaches the post-process from the camera
  18482. */
  18483. dispose(camera: Camera): void;
  18484. /**
  18485. * Returns the render target texture used by the post-process
  18486. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  18487. */
  18488. getPass(): RenderTargetTexture;
  18489. private _meshExcluded(mesh);
  18490. private _createPass(scene, ratio);
  18491. private _updateMeshScreenCoordinates(scene);
  18492. /**
  18493. * Creates a default mesh for the Volumeric Light Scattering post-process
  18494. * @param {string} The mesh name
  18495. * @param {BABYLON.Scene} The scene where to create the mesh
  18496. * @return {BABYLON.Mesh} the default mesh
  18497. */
  18498. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  18499. }
  18500. }
  18501. declare module BABYLON {
  18502. class VRDistortionCorrectionPostProcess extends PostProcess {
  18503. aspectRatio: number;
  18504. private _isRightEye;
  18505. private _distortionFactors;
  18506. private _postProcessScaleFactor;
  18507. private _lensCenterOffset;
  18508. private _scaleIn;
  18509. private _scaleFactor;
  18510. private _lensCenter;
  18511. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  18512. }
  18513. }
  18514. declare module BABYLON {
  18515. class Sprite {
  18516. name: string;
  18517. position: Vector3;
  18518. color: Color4;
  18519. width: number;
  18520. height: number;
  18521. angle: number;
  18522. cellIndex: number;
  18523. invertU: number;
  18524. invertV: number;
  18525. disposeWhenFinishedAnimating: boolean;
  18526. animations: Animation[];
  18527. isPickable: boolean;
  18528. actionManager: ActionManager;
  18529. private _animationStarted;
  18530. private _loopAnimation;
  18531. private _fromIndex;
  18532. private _toIndex;
  18533. private _delay;
  18534. private _direction;
  18535. private _manager;
  18536. private _time;
  18537. private _onAnimationEnd;
  18538. size: number;
  18539. constructor(name: string, manager: SpriteManager);
  18540. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18541. stopAnimation(): void;
  18542. _animate(deltaTime: number): void;
  18543. dispose(): void;
  18544. }
  18545. }
  18546. declare module BABYLON {
  18547. class SpriteManager {
  18548. name: string;
  18549. sprites: Sprite[];
  18550. renderingGroupId: number;
  18551. layerMask: number;
  18552. fogEnabled: boolean;
  18553. isPickable: boolean;
  18554. cellWidth: number;
  18555. cellHeight: number;
  18556. /**
  18557. * An event triggered when the manager is disposed.
  18558. * @type {BABYLON.Observable}
  18559. */
  18560. onDisposeObservable: Observable<SpriteManager>;
  18561. private _onDisposeObserver;
  18562. onDispose: () => void;
  18563. private _capacity;
  18564. private _spriteTexture;
  18565. private _epsilon;
  18566. private _scene;
  18567. private _vertexData;
  18568. private _buffer;
  18569. private _vertexBuffers;
  18570. private _indexBuffer;
  18571. private _effectBase;
  18572. private _effectFog;
  18573. texture: Texture;
  18574. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  18575. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  18576. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  18577. render(): void;
  18578. dispose(): void;
  18579. }
  18580. }
  18581. declare module BABYLON {
  18582. class _AlphaState {
  18583. private _isAlphaBlendDirty;
  18584. private _isBlendFunctionParametersDirty;
  18585. private _isBlendEquationParametersDirty;
  18586. private _isBlendConstantsDirty;
  18587. private _alphaBlend;
  18588. private _blendFunctionParameters;
  18589. private _blendEquationParameters;
  18590. private _blendConstants;
  18591. /**
  18592. * Initializes the state.
  18593. */
  18594. constructor();
  18595. readonly isDirty: boolean;
  18596. alphaBlend: boolean;
  18597. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  18598. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  18599. setAlphaEquationParameters(rgb: number, alpha: number): void;
  18600. reset(): void;
  18601. apply(gl: WebGLRenderingContext): void;
  18602. }
  18603. }
  18604. declare module BABYLON {
  18605. class _DepthCullingState {
  18606. private _isDepthTestDirty;
  18607. private _isDepthMaskDirty;
  18608. private _isDepthFuncDirty;
  18609. private _isCullFaceDirty;
  18610. private _isCullDirty;
  18611. private _isZOffsetDirty;
  18612. private _isFrontFaceDirty;
  18613. private _depthTest;
  18614. private _depthMask;
  18615. private _depthFunc;
  18616. private _cull;
  18617. private _cullFace;
  18618. private _zOffset;
  18619. private _frontFace;
  18620. /**
  18621. * Initializes the state.
  18622. */
  18623. constructor();
  18624. readonly isDirty: boolean;
  18625. zOffset: number;
  18626. cullFace: Nullable<number>;
  18627. cull: Nullable<boolean>;
  18628. depthFunc: Nullable<number>;
  18629. depthMask: boolean;
  18630. depthTest: boolean;
  18631. frontFace: Nullable<number>;
  18632. reset(): void;
  18633. apply(gl: WebGLRenderingContext): void;
  18634. }
  18635. }
  18636. declare module BABYLON {
  18637. class _StencilState {
  18638. private _isStencilTestDirty;
  18639. private _isStencilMaskDirty;
  18640. private _isStencilFuncDirty;
  18641. private _isStencilOpDirty;
  18642. private _stencilTest;
  18643. private _stencilMask;
  18644. private _stencilFunc;
  18645. private _stencilFuncRef;
  18646. private _stencilFuncMask;
  18647. private _stencilOpStencilFail;
  18648. private _stencilOpDepthFail;
  18649. private _stencilOpStencilDepthPass;
  18650. readonly isDirty: boolean;
  18651. stencilFunc: number;
  18652. stencilFuncRef: number;
  18653. stencilFuncMask: number;
  18654. stencilOpStencilFail: number;
  18655. stencilOpDepthFail: number;
  18656. stencilOpStencilDepthPass: number;
  18657. stencilMask: number;
  18658. stencilTest: boolean;
  18659. constructor();
  18660. reset(): void;
  18661. apply(gl: WebGLRenderingContext): void;
  18662. }
  18663. }
  18664. declare module BABYLON {
  18665. class AndOrNotEvaluator {
  18666. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  18667. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  18668. private static _SimplifyNegation(booleanString);
  18669. }
  18670. }
  18671. declare module BABYLON {
  18672. /**
  18673. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  18674. */
  18675. enum AssetTaskState {
  18676. /**
  18677. * Initialization
  18678. */
  18679. INIT = 0,
  18680. /**
  18681. * Running
  18682. */
  18683. RUNNING = 1,
  18684. /**
  18685. * Done
  18686. */
  18687. DONE = 2,
  18688. /**
  18689. * Error
  18690. */
  18691. ERROR = 3,
  18692. }
  18693. /**
  18694. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  18695. */
  18696. abstract class AbstractAssetTask {
  18697. /**
  18698. * Task name
  18699. */ name: string;
  18700. /**
  18701. * Callback called when the task is successful
  18702. */
  18703. onSuccess: (task: any) => void;
  18704. /**
  18705. * Callback called when the task is successful
  18706. */
  18707. onError: (task: any, message?: string, exception?: any) => void;
  18708. /**
  18709. * Creates a new {BABYLON.AssetsManager}
  18710. * @param name defines the name of the task
  18711. */
  18712. constructor(
  18713. /**
  18714. * Task name
  18715. */ name: string);
  18716. private _isCompleted;
  18717. private _taskState;
  18718. private _errorObject;
  18719. /**
  18720. * Get if the task is completed
  18721. */
  18722. readonly isCompleted: boolean;
  18723. /**
  18724. * Gets the current state of the task
  18725. */
  18726. readonly taskState: AssetTaskState;
  18727. /**
  18728. * Gets the current error object (if task is in error)
  18729. */
  18730. readonly errorObject: {
  18731. message?: string;
  18732. exception?: any;
  18733. };
  18734. /**
  18735. * Internal only
  18736. * @ignore
  18737. */
  18738. _setErrorObject(message?: string, exception?: any): void;
  18739. /**
  18740. * Execute the current task
  18741. * @param scene defines the scene where you want your assets to be loaded
  18742. * @param onSuccess is a callback called when the task is successfully executed
  18743. * @param onError is a callback called if an error occurs
  18744. */
  18745. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  18746. /**
  18747. * Execute the current task
  18748. * @param scene defines the scene where you want your assets to be loaded
  18749. * @param onSuccess is a callback called when the task is successfully executed
  18750. * @param onError is a callback called if an error occurs
  18751. */
  18752. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  18753. private onErrorCallback(onError, message?, exception?);
  18754. private onDoneCallback(onSuccess, onError);
  18755. }
  18756. /**
  18757. * Define the interface used by progress events raised during assets loading
  18758. */
  18759. interface IAssetsProgressEvent {
  18760. /**
  18761. * Defines the number of remaining tasks to process
  18762. */
  18763. remainingCount: number;
  18764. /**
  18765. * Defines the total number of tasks
  18766. */
  18767. totalCount: number;
  18768. /**
  18769. * Defines the task that was just processed
  18770. */
  18771. task: AbstractAssetTask;
  18772. }
  18773. /**
  18774. * Class used to share progress information about assets loading
  18775. */
  18776. class AssetsProgressEvent implements IAssetsProgressEvent {
  18777. /**
  18778. * Defines the number of remaining tasks to process
  18779. */
  18780. remainingCount: number;
  18781. /**
  18782. * Defines the total number of tasks
  18783. */
  18784. totalCount: number;
  18785. /**
  18786. * Defines the task that was just processed
  18787. */
  18788. task: AbstractAssetTask;
  18789. /**
  18790. * Creates a {BABYLON.AssetsProgressEvent}
  18791. * @param remainingCount defines the number of remaining tasks to process
  18792. * @param totalCount defines the total number of tasks
  18793. * @param task defines the task that was just processed
  18794. */
  18795. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  18796. }
  18797. /**
  18798. * Define a task used by {BABYLON.AssetsManager} to load meshes
  18799. */
  18800. class MeshAssetTask extends AbstractAssetTask {
  18801. /**
  18802. * Defines the name of the task
  18803. */
  18804. name: string;
  18805. /**
  18806. * Defines the list of mesh's names you want to load
  18807. */
  18808. meshesNames: any;
  18809. /**
  18810. * Defines the root url to use as a base to load your meshes and associated resources
  18811. */
  18812. rootUrl: string;
  18813. /**
  18814. * Defines the filename of the scene to load from
  18815. */
  18816. sceneFilename: string;
  18817. /**
  18818. * Gets the list of loaded meshes
  18819. */
  18820. loadedMeshes: Array<AbstractMesh>;
  18821. /**
  18822. * Gets the list of loaded particle systems
  18823. */
  18824. loadedParticleSystems: Array<ParticleSystem>;
  18825. /**
  18826. * Gets the list of loaded skeletons
  18827. */
  18828. loadedSkeletons: Array<Skeleton>;
  18829. /**
  18830. * Callback called when the task is successful
  18831. */
  18832. onSuccess: (task: MeshAssetTask) => void;
  18833. /**
  18834. * Callback called when the task is successful
  18835. */
  18836. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  18837. /**
  18838. * Creates a new {BABYLON.MeshAssetTask}
  18839. * @param name defines the name of the task
  18840. * @param meshesNames defines the list of mesh's names you want to load
  18841. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  18842. * @param sceneFilename defines the filename of the scene to load from
  18843. */
  18844. constructor(
  18845. /**
  18846. * Defines the name of the task
  18847. */
  18848. name: string,
  18849. /**
  18850. * Defines the list of mesh's names you want to load
  18851. */
  18852. meshesNames: any,
  18853. /**
  18854. * Defines the root url to use as a base to load your meshes and associated resources
  18855. */
  18856. rootUrl: string,
  18857. /**
  18858. * Defines the filename of the scene to load from
  18859. */
  18860. sceneFilename: string);
  18861. /**
  18862. * Execute the current task
  18863. * @param scene defines the scene where you want your assets to be loaded
  18864. * @param onSuccess is a callback called when the task is successfully executed
  18865. * @param onError is a callback called if an error occurs
  18866. */
  18867. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  18868. }
  18869. /**
  18870. * Define a task used by {BABYLON.AssetsManager} to load text content
  18871. */
  18872. class TextFileAssetTask extends AbstractAssetTask {
  18873. /**
  18874. * Defines the name of the task
  18875. */
  18876. name: string;
  18877. /**
  18878. * Defines the location of the file to load
  18879. */
  18880. url: string;
  18881. /**
  18882. * Gets the loaded text string
  18883. */
  18884. text: string;
  18885. /**
  18886. * Callback called when the task is successful
  18887. */
  18888. onSuccess: (task: TextFileAssetTask) => void;
  18889. /**
  18890. * Callback called when the task is successful
  18891. */
  18892. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  18893. /**
  18894. * Creates a new TextFileAssetTask object
  18895. * @param name defines the name of the task
  18896. * @param url defines the location of the file to load
  18897. */
  18898. constructor(
  18899. /**
  18900. * Defines the name of the task
  18901. */
  18902. name: string,
  18903. /**
  18904. * Defines the location of the file to load
  18905. */
  18906. url: string);
  18907. /**
  18908. * Execute the current task
  18909. * @param scene defines the scene where you want your assets to be loaded
  18910. * @param onSuccess is a callback called when the task is successfully executed
  18911. * @param onError is a callback called if an error occurs
  18912. */
  18913. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  18914. }
  18915. /**
  18916. * Define a task used by {BABYLON.AssetsManager} to load binary data
  18917. */
  18918. class BinaryFileAssetTask extends AbstractAssetTask {
  18919. /**
  18920. * Defines the name of the task
  18921. */
  18922. name: string;
  18923. /**
  18924. * Defines the location of the file to load
  18925. */
  18926. url: string;
  18927. /**
  18928. * Gets the lodaded data (as an array buffer)
  18929. */
  18930. data: ArrayBuffer;
  18931. /**
  18932. * Callback called when the task is successful
  18933. */
  18934. onSuccess: (task: BinaryFileAssetTask) => void;
  18935. /**
  18936. * Callback called when the task is successful
  18937. */
  18938. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  18939. /**
  18940. * Creates a new BinaryFileAssetTask object
  18941. * @param name defines the name of the new task
  18942. * @param url defines the location of the file to load
  18943. */
  18944. constructor(
  18945. /**
  18946. * Defines the name of the task
  18947. */
  18948. name: string,
  18949. /**
  18950. * Defines the location of the file to load
  18951. */
  18952. url: string);
  18953. /**
  18954. * Execute the current task
  18955. * @param scene defines the scene where you want your assets to be loaded
  18956. * @param onSuccess is a callback called when the task is successfully executed
  18957. * @param onError is a callback called if an error occurs
  18958. */
  18959. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  18960. }
  18961. /**
  18962. * Define a task used by {BABYLON.AssetsManager} to load images
  18963. */
  18964. class ImageAssetTask extends AbstractAssetTask {
  18965. /**
  18966. * Defines the name of the task
  18967. */
  18968. name: string;
  18969. /**
  18970. * Defines the location of the image to load
  18971. */
  18972. url: string;
  18973. /**
  18974. * Gets the loaded images
  18975. */
  18976. image: HTMLImageElement;
  18977. /**
  18978. * Callback called when the task is successful
  18979. */
  18980. onSuccess: (task: ImageAssetTask) => void;
  18981. /**
  18982. * Callback called when the task is successful
  18983. */
  18984. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  18985. /**
  18986. * Creates a new ImageAssetTask
  18987. * @param name defines the name of the task
  18988. * @param url defines the location of the image to load
  18989. */
  18990. constructor(
  18991. /**
  18992. * Defines the name of the task
  18993. */
  18994. name: string,
  18995. /**
  18996. * Defines the location of the image to load
  18997. */
  18998. url: string);
  18999. /**
  19000. * Execute the current task
  19001. * @param scene defines the scene where you want your assets to be loaded
  19002. * @param onSuccess is a callback called when the task is successfully executed
  19003. * @param onError is a callback called if an error occurs
  19004. */
  19005. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  19006. }
  19007. /**
  19008. * Defines the interface used by texture loading tasks
  19009. */
  19010. interface ITextureAssetTask<TEX extends BaseTexture> {
  19011. /**
  19012. * Gets the loaded texture
  19013. */
  19014. texture: TEX;
  19015. }
  19016. /**
  19017. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  19018. */
  19019. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  19020. /**
  19021. * Defines the name of the task
  19022. */
  19023. name: string;
  19024. /**
  19025. * Defines the location of the file to load
  19026. */
  19027. url: string;
  19028. /**
  19029. * Defines if mipmap should not be generated (default is false)
  19030. */
  19031. noMipmap: boolean | undefined;
  19032. /**
  19033. * Defines if texture must be inverted on Y axis (default is false)
  19034. */
  19035. invertY: boolean | undefined;
  19036. /**
  19037. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  19038. */
  19039. samplingMode: number;
  19040. /**
  19041. * Gets the loaded texture
  19042. */
  19043. texture: Texture;
  19044. /**
  19045. * Callback called when the task is successful
  19046. */
  19047. onSuccess: (task: TextureAssetTask) => void;
  19048. /**
  19049. * Callback called when the task is successful
  19050. */
  19051. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  19052. /**
  19053. * Creates a new TextureAssetTask object
  19054. * @param name defines the name of the task
  19055. * @param url defines the location of the file to load
  19056. * @param noMipmap defines if mipmap should not be generated (default is false)
  19057. * @param invertY defines if texture must be inverted on Y axis (default is false)
  19058. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  19059. */
  19060. constructor(
  19061. /**
  19062. * Defines the name of the task
  19063. */
  19064. name: string,
  19065. /**
  19066. * Defines the location of the file to load
  19067. */
  19068. url: string,
  19069. /**
  19070. * Defines if mipmap should not be generated (default is false)
  19071. */
  19072. noMipmap?: boolean | undefined,
  19073. /**
  19074. * Defines if texture must be inverted on Y axis (default is false)
  19075. */
  19076. invertY?: boolean | undefined,
  19077. /**
  19078. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  19079. */
  19080. samplingMode?: number);
  19081. /**
  19082. * Execute the current task
  19083. * @param scene defines the scene where you want your assets to be loaded
  19084. * @param onSuccess is a callback called when the task is successfully executed
  19085. * @param onError is a callback called if an error occurs
  19086. */
  19087. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  19088. }
  19089. /**
  19090. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  19091. */
  19092. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  19093. /**
  19094. * Defines the name of the task
  19095. */
  19096. name: string;
  19097. /**
  19098. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  19099. */
  19100. url: string;
  19101. /**
  19102. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  19103. */
  19104. extensions: string[] | undefined;
  19105. /**
  19106. * Defines if mipmaps should not be generated (default is false)
  19107. */
  19108. noMipmap: boolean | undefined;
  19109. /**
  19110. * Defines the explicit list of files (undefined by default)
  19111. */
  19112. files: string[] | undefined;
  19113. /**
  19114. * Gets the loaded texture
  19115. */
  19116. texture: CubeTexture;
  19117. /**
  19118. * Callback called when the task is successful
  19119. */
  19120. onSuccess: (task: CubeTextureAssetTask) => void;
  19121. /**
  19122. * Callback called when the task is successful
  19123. */
  19124. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  19125. /**
  19126. * Creates a new CubeTextureAssetTask
  19127. * @param name defines the name of the task
  19128. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  19129. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  19130. * @param noMipmap defines if mipmaps should not be generated (default is false)
  19131. * @param files defines the explicit list of files (undefined by default)
  19132. */
  19133. constructor(
  19134. /**
  19135. * Defines the name of the task
  19136. */
  19137. name: string,
  19138. /**
  19139. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  19140. */
  19141. url: string,
  19142. /**
  19143. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  19144. */
  19145. extensions?: string[] | undefined,
  19146. /**
  19147. * Defines if mipmaps should not be generated (default is false)
  19148. */
  19149. noMipmap?: boolean | undefined,
  19150. /**
  19151. * Defines the explicit list of files (undefined by default)
  19152. */
  19153. files?: string[] | undefined);
  19154. /**
  19155. * Execute the current task
  19156. * @param scene defines the scene where you want your assets to be loaded
  19157. * @param onSuccess is a callback called when the task is successfully executed
  19158. * @param onError is a callback called if an error occurs
  19159. */
  19160. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  19161. }
  19162. /**
  19163. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  19164. */
  19165. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  19166. /**
  19167. * Defines the name of the task
  19168. */
  19169. name: string;
  19170. /**
  19171. * Defines the location of the file to load
  19172. */
  19173. url: string;
  19174. /**
  19175. * 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.
  19176. */
  19177. size: number | undefined;
  19178. /**
  19179. * Defines if mipmaps should not be generated (default is false)
  19180. */
  19181. noMipmap: boolean;
  19182. /**
  19183. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  19184. */
  19185. generateHarmonics: boolean;
  19186. /**
  19187. * 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)
  19188. */
  19189. useInGammaSpace: boolean;
  19190. /**
  19191. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  19192. */
  19193. usePMREMGenerator: boolean;
  19194. /**
  19195. * Gets the loaded texture
  19196. */
  19197. texture: HDRCubeTexture;
  19198. /**
  19199. * Callback called when the task is successful
  19200. */
  19201. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  19202. /**
  19203. * Callback called when the task is successful
  19204. */
  19205. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  19206. /**
  19207. * Creates a new HDRCubeTextureAssetTask object
  19208. * @param name defines the name of the task
  19209. * @param url defines the location of the file to load
  19210. * @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.
  19211. * @param noMipmap defines if mipmaps should not be generated (default is false)
  19212. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  19213. * @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)
  19214. * @param usePMREMGenerator specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  19215. */
  19216. constructor(
  19217. /**
  19218. * Defines the name of the task
  19219. */
  19220. name: string,
  19221. /**
  19222. * Defines the location of the file to load
  19223. */
  19224. url: string,
  19225. /**
  19226. * 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.
  19227. */
  19228. size?: number | undefined,
  19229. /**
  19230. * Defines if mipmaps should not be generated (default is false)
  19231. */
  19232. noMipmap?: boolean,
  19233. /**
  19234. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  19235. */
  19236. generateHarmonics?: boolean,
  19237. /**
  19238. * 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)
  19239. */
  19240. useInGammaSpace?: boolean,
  19241. /**
  19242. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  19243. */
  19244. usePMREMGenerator?: boolean);
  19245. /**
  19246. * Execute the current task
  19247. * @param scene defines the scene where you want your assets to be loaded
  19248. * @param onSuccess is a callback called when the task is successfully executed
  19249. * @param onError is a callback called if an error occurs
  19250. */
  19251. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  19252. }
  19253. /**
  19254. * This class can be used to easily import assets into a scene
  19255. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  19256. */
  19257. class AssetsManager {
  19258. private _scene;
  19259. private _isLoading;
  19260. protected _tasks: AbstractAssetTask[];
  19261. protected _waitingTasksCount: number;
  19262. protected _totalTasksCount: number;
  19263. /**
  19264. * Callback called when all tasks are processed
  19265. */
  19266. onFinish: (tasks: AbstractAssetTask[]) => void;
  19267. /**
  19268. * Callback called when a task is successful
  19269. */
  19270. onTaskSuccess: (task: AbstractAssetTask) => void;
  19271. /**
  19272. * Callback called when a task had an error
  19273. */
  19274. onTaskError: (task: AbstractAssetTask) => void;
  19275. /**
  19276. * Callback called when a task is done (whatever the result is)
  19277. */
  19278. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  19279. /**
  19280. * Observable called when all tasks are processed
  19281. */
  19282. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  19283. /**
  19284. * Observable called when a task had an error
  19285. */
  19286. onTaskErrorObservable: Observable<AbstractAssetTask>;
  19287. /**
  19288. * Observable called when a task is successful
  19289. */
  19290. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  19291. /**
  19292. * Observable called when a task is done (whatever the result is)
  19293. */
  19294. onProgressObservable: Observable<IAssetsProgressEvent>;
  19295. /**
  19296. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  19297. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  19298. */
  19299. useDefaultLoadingScreen: boolean;
  19300. /**
  19301. * Creates a new AssetsManager
  19302. * @param scene defines the scene to work on
  19303. */
  19304. constructor(scene: Scene);
  19305. /**
  19306. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  19307. * @param taskName defines the name of the new task
  19308. * @param meshesNames defines the name of meshes to load
  19309. * @param rootUrl defines the root url to use to locate files
  19310. * @param sceneFilename defines the filename of the scene file
  19311. * @returns a new {BABYLON.MeshAssetTask} object
  19312. */
  19313. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  19314. /**
  19315. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  19316. * @param taskName defines the name of the new task
  19317. * @param url defines the url of the file to load
  19318. * @returns a new {BABYLON.TextFileAssetTask} object
  19319. */
  19320. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  19321. /**
  19322. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  19323. * @param taskName defines the name of the new task
  19324. * @param url defines the url of the file to load
  19325. * @returns a new {BABYLON.BinaryFileAssetTask} object
  19326. */
  19327. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  19328. /**
  19329. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  19330. * @param taskName defines the name of the new task
  19331. * @param url defines the url of the file to load
  19332. * @returns a new {BABYLON.ImageAssetTask} object
  19333. */
  19334. addImageTask(taskName: string, url: string): ImageAssetTask;
  19335. /**
  19336. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  19337. * @param taskName defines the name of the new task
  19338. * @param url defines the url of the file to load
  19339. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  19340. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  19341. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  19342. * @returns a new {BABYLON.TextureAssetTask} object
  19343. */
  19344. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  19345. /**
  19346. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  19347. * @param taskName defines the name of the new task
  19348. * @param url defines the url of the file to load
  19349. * @param extensions defines the extension to use to load the cube map (can be null)
  19350. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  19351. * @param files defines the list of files to load (can be null)
  19352. * @returns a new {BABYLON.CubeTextureAssetTask} object
  19353. */
  19354. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  19355. /**
  19356. *
  19357. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  19358. * @param taskName defines the name of the new task
  19359. * @param url defines the url of the file to load
  19360. * @param size defines the size you want for the cubemap (can be null)
  19361. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  19362. * @param generateHarmonics defines if you want to automatically generate (true by default)
  19363. * @param useInGammaSpace defines if the texture must be considered in gamma space (false by default)
  19364. * @param usePMREMGenerator is a reserved parameter and must be set to false or ignored
  19365. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  19366. */
  19367. addHDRCubeTextureTask(taskName: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean): HDRCubeTextureAssetTask;
  19368. private _decreaseWaitingTasksCount(task);
  19369. private _runTask(task);
  19370. /**
  19371. * Reset the {BABYLON.AssetsManager} and remove all tasks
  19372. * @return the current instance of the {BABYLON.AssetsManager}
  19373. */
  19374. reset(): AssetsManager;
  19375. /**
  19376. * Start the loading process
  19377. * @return the current instance of the {BABYLON.AssetsManager}
  19378. */
  19379. load(): AssetsManager;
  19380. }
  19381. }
  19382. declare module BABYLON {
  19383. class Database {
  19384. private callbackManifestChecked;
  19385. private currentSceneUrl;
  19386. private db;
  19387. private _enableSceneOffline;
  19388. private _enableTexturesOffline;
  19389. private manifestVersionFound;
  19390. private mustUpdateRessources;
  19391. private hasReachedQuota;
  19392. private isSupported;
  19393. private idbFactory;
  19394. static IsUASupportingBlobStorage: boolean;
  19395. static IDBStorageEnabled: boolean;
  19396. readonly enableSceneOffline: boolean;
  19397. readonly enableTexturesOffline: boolean;
  19398. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any);
  19399. static parseURL: (url: string) => string;
  19400. static ReturnFullUrlLocation: (url: string) => string;
  19401. checkManifestFile(): void;
  19402. openAsync(successCallback: () => void, errorCallback: () => void): void;
  19403. loadImageFromDB(url: string, image: HTMLImageElement): void;
  19404. private _loadImageFromDBAsync(url, image, notInDBCallback);
  19405. private _saveImageIntoDBAsync(url, image);
  19406. private _checkVersionFromDB(url, versionLoaded);
  19407. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  19408. private _saveVersionIntoDBAsync(url, callback);
  19409. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  19410. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  19411. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  19412. }
  19413. }
  19414. declare module BABYLON {
  19415. interface DDSInfo {
  19416. width: number;
  19417. height: number;
  19418. mipmapCount: number;
  19419. isFourCC: boolean;
  19420. isRGB: boolean;
  19421. isLuminance: boolean;
  19422. isCube: boolean;
  19423. isCompressed: boolean;
  19424. dxgiFormat: number;
  19425. textureType: number;
  19426. }
  19427. class DDSTools {
  19428. static StoreLODInAlphaChannel: boolean;
  19429. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  19430. private static _FloatView;
  19431. private static _Int32View;
  19432. private static _ToHalfFloat(value);
  19433. private static _FromHalfFloat(value);
  19434. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  19435. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  19436. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  19437. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  19438. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  19439. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  19440. private static _ExtractLongWordOrder(value);
  19441. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  19442. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  19443. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  19444. }
  19445. }
  19446. declare module BABYLON {
  19447. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  19448. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  19449. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  19450. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  19451. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  19452. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  19453. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  19454. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  19455. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  19456. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  19457. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  19458. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  19459. class SerializationHelper {
  19460. static Serialize<T>(entity: T, serializationObject?: any): any;
  19461. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  19462. static Clone<T>(creationFunction: () => T, source: T): T;
  19463. static Instanciate<T>(creationFunction: () => T, source: T): T;
  19464. }
  19465. }
  19466. declare module Earcut {
  19467. /**
  19468. * The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
  19469. * @param data is a flat array of vertice coordinates like [x0, y0, x1, y1, x2, y2, ...].
  19470. * @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).
  19471. * @param dim is the number of coordinates per vertice in the input array (2 by default).
  19472. */
  19473. function earcut(data: number[], holeIndices: number[], dim: number): Array<number>;
  19474. /**
  19475. * return a percentage difference between the polygon area and its triangulation area;
  19476. * used to verify correctness of triangulation
  19477. */
  19478. function deviation(data: number[], holeIndices: number[], dim: number, triangles: number[]): number;
  19479. /**
  19480. * turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
  19481. */
  19482. function flatten(data: number[][][]): {
  19483. vertices: number[];
  19484. holes: number[];
  19485. dimensions: number;
  19486. };
  19487. }
  19488. declare module BABYLON {
  19489. class FilesInput {
  19490. static FilesToLoad: {
  19491. [key: string]: File;
  19492. };
  19493. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  19494. private _engine;
  19495. private _currentScene;
  19496. private _sceneLoadedCallback;
  19497. private _progressCallback;
  19498. private _additionalRenderLoopLogicCallback;
  19499. private _textureLoadingCallback;
  19500. private _startingProcessingFilesCallback;
  19501. private _onReloadCallback;
  19502. private _errorCallback;
  19503. private _elementToMonitor;
  19504. private _sceneFileToLoad;
  19505. private _filesToLoad;
  19506. 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);
  19507. private _dragEnterHandler;
  19508. private _dragOverHandler;
  19509. private _dropHandler;
  19510. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  19511. dispose(): void;
  19512. private renderFunction();
  19513. private drag(e);
  19514. private drop(eventDrop);
  19515. private _traverseFolder(folder, files, remaining, callback);
  19516. private _processFiles(files);
  19517. loadFiles(event: any): void;
  19518. private _processReload();
  19519. reload(): void;
  19520. }
  19521. }
  19522. declare module BABYLON {
  19523. /**
  19524. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  19525. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  19526. */
  19527. class KhronosTextureContainer {
  19528. arrayBuffer: any;
  19529. static HEADER_LEN: number;
  19530. static COMPRESSED_2D: number;
  19531. static COMPRESSED_3D: number;
  19532. static TEX_2D: number;
  19533. static TEX_3D: number;
  19534. glType: number;
  19535. glTypeSize: number;
  19536. glFormat: number;
  19537. glInternalFormat: number;
  19538. glBaseInternalFormat: number;
  19539. pixelWidth: number;
  19540. pixelHeight: number;
  19541. pixelDepth: number;
  19542. numberOfArrayElements: number;
  19543. numberOfFaces: number;
  19544. numberOfMipmapLevels: number;
  19545. bytesOfKeyValueData: number;
  19546. loadType: number;
  19547. /**
  19548. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  19549. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  19550. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  19551. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  19552. */
  19553. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  19554. switchEndainness(val: number): number;
  19555. /**
  19556. * It is assumed that the texture has already been created & is currently bound
  19557. */
  19558. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  19559. private _upload2DCompressedLevels(gl, loadMipmaps);
  19560. }
  19561. }
  19562. declare module BABYLON {
  19563. /**
  19564. * A class serves as a medium between the observable and its observers
  19565. */
  19566. class EventState {
  19567. /**
  19568. * Create a new EventState
  19569. * @param mask defines the mask associated with this state
  19570. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  19571. * @param target defines the original target of the state
  19572. * @param currentTarget defines the current target of the state
  19573. */
  19574. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  19575. /**
  19576. * Initialize the current event state
  19577. * @param mask defines the mask associated with this state
  19578. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  19579. * @param target defines the original target of the state
  19580. * @param currentTarget defines the current target of the state
  19581. * @returns the current event state
  19582. */
  19583. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  19584. /**
  19585. * An Observer can set this property to true to prevent subsequent observers of being notified
  19586. */
  19587. skipNextObservers: boolean;
  19588. /**
  19589. * Get the mask value that were used to trigger the event corresponding to this EventState object
  19590. */
  19591. mask: number;
  19592. /**
  19593. * The object that originally notified the event
  19594. */
  19595. target?: any;
  19596. /**
  19597. * The current object in the bubbling phase
  19598. */
  19599. currentTarget?: any;
  19600. /**
  19601. * This will be populated with the return value of the last function that was executed.
  19602. * If it is the first function in the callback chain it will be the event data.
  19603. */
  19604. lastReturnValue?: any;
  19605. }
  19606. /**
  19607. * Represent an Observer registered to a given Observable object.
  19608. */
  19609. class Observer<T> {
  19610. /**
  19611. * Defines the callback to call when the observer is notified
  19612. */
  19613. callback: (eventData: T, eventState: EventState) => void;
  19614. /**
  19615. * Defines the mask of the observer (used to filter notifications)
  19616. */
  19617. mask: number;
  19618. /**
  19619. * Defines the current scope used to restore the JS context
  19620. */
  19621. scope: any;
  19622. /**
  19623. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  19624. */
  19625. unregisterOnNextCall: boolean;
  19626. /**
  19627. * Creates a new observer
  19628. * @param callback defines the callback to call when the observer is notified
  19629. * @param mask defines the mask of the observer (used to filter notifications)
  19630. * @param scope defines the current scope used to restore the JS context
  19631. */
  19632. constructor(
  19633. /**
  19634. * Defines the callback to call when the observer is notified
  19635. */
  19636. callback: (eventData: T, eventState: EventState) => void,
  19637. /**
  19638. * Defines the mask of the observer (used to filter notifications)
  19639. */
  19640. mask: number,
  19641. /**
  19642. * Defines the current scope used to restore the JS context
  19643. */
  19644. scope?: any);
  19645. }
  19646. /**
  19647. * Represent a list of observers registered to multiple Observables object.
  19648. */
  19649. class MultiObserver<T> {
  19650. private _observers;
  19651. private _observables;
  19652. /**
  19653. * Release associated resources
  19654. */
  19655. dispose(): void;
  19656. /**
  19657. * Raise a callback when one of the observable will notify
  19658. * @param observables defines a list of observables to watch
  19659. * @param callback defines the callback to call on notification
  19660. * @param mask defines the mask used to filter notifications
  19661. * @param scope defines the current scope used to restore the JS context
  19662. * @returns the new MultiObserver
  19663. */
  19664. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  19665. }
  19666. /**
  19667. * The Observable class is a simple implementation of the Observable pattern.
  19668. * 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.
  19669. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  19670. * 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).
  19671. * 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.
  19672. */
  19673. class Observable<T> {
  19674. private _observers;
  19675. private _eventState;
  19676. private _onObserverAdded;
  19677. /**
  19678. * Creates a new observable
  19679. * @param onObserverAdded defines a callback to call when a new observer is added
  19680. */
  19681. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  19682. /**
  19683. * Create a new Observer with the specified callback
  19684. * @param callback the callback that will be executed for that Observer
  19685. * @param mask the mask used to filter observers
  19686. * @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.
  19687. * @param scope optional scope for the callback to be called from
  19688. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  19689. * @returns the new observer created for the callback
  19690. */
  19691. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  19692. /**
  19693. * Remove an Observer from the Observable object
  19694. * @param observer the instance of the Observer to remove
  19695. * @returns false if it doesn't belong to this Observable
  19696. */
  19697. remove(observer: Nullable<Observer<T>>): boolean;
  19698. /**
  19699. * Remove a callback from the Observable object
  19700. * @param callback the callback to remove
  19701. * @param scope optional scope. If used only the callbacks with this scope will be removed
  19702. * @returns false if it doesn't belong to this Observable
  19703. */
  19704. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  19705. private _deferUnregister(observer);
  19706. /**
  19707. * Notify all Observers by calling their respective callback with the given data
  19708. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  19709. * @param eventData defines the data to send to all observers
  19710. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  19711. * @param target defines the original target of the state
  19712. * @param currentTarget defines the current target of the state
  19713. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  19714. */
  19715. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  19716. /**
  19717. * Calling this will execute each callback, expecting it to be a promise or return a value.
  19718. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  19719. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  19720. * and it is crucial that all callbacks will be executed.
  19721. * The order of the callbacks is kept, callbacks are not executed parallel.
  19722. *
  19723. * @param eventData The data to be sent to each callback
  19724. * @param mask is used to filter observers defaults to -1
  19725. * @param target defines the callback target (see EventState)
  19726. * @param currentTarget defines he current object in the bubbling phase
  19727. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  19728. */
  19729. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  19730. /**
  19731. * Notify a specific observer
  19732. * @param observer defines the observer to notify
  19733. * @param eventData defines the data to be sent to each callback
  19734. * @param mask is used to filter observers defaults to -1
  19735. */
  19736. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  19737. /**
  19738. * Gets a boolean indicating if the observable has at least one observer
  19739. * @returns true is the Observable has at least one Observer registered
  19740. */
  19741. hasObservers(): boolean;
  19742. /**
  19743. * Clear the list of observers
  19744. */
  19745. clear(): void;
  19746. /**
  19747. * Clone the current observable
  19748. * @returns a new observable
  19749. */
  19750. clone(): Observable<T>;
  19751. /**
  19752. * Does this observable handles observer registered with a given mask
  19753. * @param mask defines the mask to be tested
  19754. * @return whether or not one observer registered with the given mask is handeled
  19755. **/
  19756. hasSpecificMask(mask?: number): boolean;
  19757. }
  19758. }
  19759. declare module BABYLON {
  19760. /**
  19761. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  19762. */
  19763. class PerformanceMonitor {
  19764. private _enabled;
  19765. private _rollingFrameTime;
  19766. private _lastFrameTimeMs;
  19767. /**
  19768. * constructor
  19769. * @param frameSampleSize The number of samples required to saturate the sliding window
  19770. */
  19771. constructor(frameSampleSize?: number);
  19772. /**
  19773. * Samples current frame
  19774. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  19775. */
  19776. sampleFrame(timeMs?: number): void;
  19777. /**
  19778. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  19779. * @return Average frame time in milliseconds
  19780. */
  19781. readonly averageFrameTime: number;
  19782. /**
  19783. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  19784. * @return Frame time variance in milliseconds squared
  19785. */
  19786. readonly averageFrameTimeVariance: number;
  19787. /**
  19788. * Returns the frame time of the most recent frame
  19789. * @return Frame time in milliseconds
  19790. */
  19791. readonly instantaneousFrameTime: number;
  19792. /**
  19793. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  19794. * @return Framerate in frames per second
  19795. */
  19796. readonly averageFPS: number;
  19797. /**
  19798. * Returns the average framerate in frames per second using the most recent frame time
  19799. * @return Framerate in frames per second
  19800. */
  19801. readonly instantaneousFPS: number;
  19802. /**
  19803. * Returns true if enough samples have been taken to completely fill the sliding window
  19804. * @return true if saturated
  19805. */
  19806. readonly isSaturated: boolean;
  19807. /**
  19808. * Enables contributions to the sliding window sample set
  19809. */
  19810. enable(): void;
  19811. /**
  19812. * Disables contributions to the sliding window sample set
  19813. * Samples will not be interpolated over the disabled period
  19814. */
  19815. disable(): void;
  19816. /**
  19817. * Returns true if sampling is enabled
  19818. * @return true if enabled
  19819. */
  19820. readonly isEnabled: boolean;
  19821. /**
  19822. * Resets performance monitor
  19823. */
  19824. reset(): void;
  19825. }
  19826. /**
  19827. * RollingAverage
  19828. *
  19829. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  19830. */
  19831. class RollingAverage {
  19832. /**
  19833. * Current average
  19834. */
  19835. average: number;
  19836. /**
  19837. * Current variance
  19838. */
  19839. variance: number;
  19840. protected _samples: Array<number>;
  19841. protected _sampleCount: number;
  19842. protected _pos: number;
  19843. protected _m2: number;
  19844. /**
  19845. * constructor
  19846. * @param length The number of samples required to saturate the sliding window
  19847. */
  19848. constructor(length: number);
  19849. /**
  19850. * Adds a sample to the sample set
  19851. * @param v The sample value
  19852. */
  19853. add(v: number): void;
  19854. /**
  19855. * Returns previously added values or null if outside of history or outside the sliding window domain
  19856. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  19857. * @return Value previously recorded with add() or null if outside of range
  19858. */
  19859. history(i: number): number;
  19860. /**
  19861. * Returns true if enough samples have been taken to completely fill the sliding window
  19862. * @return true if sample-set saturated
  19863. */
  19864. isSaturated(): boolean;
  19865. /**
  19866. * Resets the rolling average (equivalent to 0 samples taken so far)
  19867. */
  19868. reset(): void;
  19869. /**
  19870. * Wraps a value around the sample range boundaries
  19871. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  19872. * @return Wrapped position in sample range
  19873. */
  19874. protected _wrapPosition(i: number): number;
  19875. }
  19876. }
  19877. declare module BABYLON {
  19878. /**
  19879. * Helper class that provides a small promise polyfill
  19880. */
  19881. class PromisePolyfill {
  19882. /**
  19883. * Static function used to check if the polyfill is required
  19884. * If this is the case then the function will inject the polyfill to window.Promise
  19885. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  19886. */
  19887. static Apply(force?: boolean): void;
  19888. }
  19889. }
  19890. declare module BABYLON {
  19891. /**
  19892. * Defines the root class used to create scene optimization to use with SceneOptimizer
  19893. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  19894. */
  19895. class SceneOptimization {
  19896. /**
  19897. * Defines the priority of this optimization (0 by default which means first in the list)
  19898. */
  19899. priority: number;
  19900. /**
  19901. * Gets a string describing the action executed by the current optimization
  19902. * @returns description string
  19903. */
  19904. getDescription(): string;
  19905. /**
  19906. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  19907. * @param scene defines the current scene where to apply this optimization
  19908. * @param optimizer defines the current optimizer
  19909. * @returns true if everything that can be done was applied
  19910. */
  19911. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  19912. /**
  19913. * Creates the SceneOptimization object
  19914. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  19915. * @param desc defines the description associated with the optimization
  19916. */
  19917. constructor(
  19918. /**
  19919. * Defines the priority of this optimization (0 by default which means first in the list)
  19920. */
  19921. priority?: number);
  19922. }
  19923. /**
  19924. * Defines an optimization used to reduce the size of render target textures
  19925. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  19926. */
  19927. class TextureOptimization extends SceneOptimization {
  19928. /**
  19929. * Defines the priority of this optimization (0 by default which means first in the list)
  19930. */
  19931. priority: number;
  19932. /**
  19933. * 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
  19934. */
  19935. maximumSize: number;
  19936. /**
  19937. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  19938. */
  19939. step: number;
  19940. /**
  19941. * Gets a string describing the action executed by the current optimization
  19942. * @returns description string
  19943. */
  19944. getDescription(): string;
  19945. /**
  19946. * Creates the TextureOptimization object
  19947. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  19948. * @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
  19949. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  19950. */
  19951. constructor(
  19952. /**
  19953. * Defines the priority of this optimization (0 by default which means first in the list)
  19954. */
  19955. priority?: number,
  19956. /**
  19957. * 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
  19958. */
  19959. maximumSize?: number,
  19960. /**
  19961. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  19962. */
  19963. step?: number);
  19964. /**
  19965. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  19966. * @param scene defines the current scene where to apply this optimization
  19967. * @param optimizer defines the current optimizer
  19968. * @returns true if everything that can be done was applied
  19969. */
  19970. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  19971. }
  19972. /**
  19973. * Defines an optimization used to increase or decrease the rendering resolution
  19974. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  19975. */
  19976. class HardwareScalingOptimization extends SceneOptimization {
  19977. /**
  19978. * Defines the priority of this optimization (0 by default which means first in the list)
  19979. */
  19980. priority: number;
  19981. /**
  19982. * Defines the maximum scale to use (2 by default)
  19983. */
  19984. maximumScale: number;
  19985. /**
  19986. * Defines the step to use between two passes (0.5 by default)
  19987. */
  19988. step: number;
  19989. private _currentScale;
  19990. private _directionOffset;
  19991. /**
  19992. * Gets a string describing the action executed by the current optimization
  19993. * @return description string
  19994. */
  19995. getDescription(): string;
  19996. /**
  19997. * Creates the HardwareScalingOptimization object
  19998. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  19999. * @param maximumScale defines the maximum scale to use (2 by default)
  20000. * @param step defines the step to use between two passes (0.5 by default)
  20001. */
  20002. constructor(
  20003. /**
  20004. * Defines the priority of this optimization (0 by default which means first in the list)
  20005. */
  20006. priority?: number,
  20007. /**
  20008. * Defines the maximum scale to use (2 by default)
  20009. */
  20010. maximumScale?: number,
  20011. /**
  20012. * Defines the step to use between two passes (0.5 by default)
  20013. */
  20014. step?: number);
  20015. /**
  20016. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  20017. * @param scene defines the current scene where to apply this optimization
  20018. * @param optimizer defines the current optimizer
  20019. * @returns true if everything that can be done was applied
  20020. */
  20021. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  20022. }
  20023. /**
  20024. * Defines an optimization used to remove shadows
  20025. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  20026. */
  20027. class ShadowsOptimization extends SceneOptimization {
  20028. /**
  20029. * Gets a string describing the action executed by the current optimization
  20030. * @return description string
  20031. */
  20032. getDescription(): string;
  20033. /**
  20034. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  20035. * @param scene defines the current scene where to apply this optimization
  20036. * @param optimizer defines the current optimizer
  20037. * @returns true if everything that can be done was applied
  20038. */
  20039. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  20040. }
  20041. /**
  20042. * Defines an optimization used to turn post-processes off
  20043. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  20044. */
  20045. class PostProcessesOptimization extends SceneOptimization {
  20046. /**
  20047. * Gets a string describing the action executed by the current optimization
  20048. * @return description string
  20049. */
  20050. getDescription(): string;
  20051. /**
  20052. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  20053. * @param scene defines the current scene where to apply this optimization
  20054. * @param optimizer defines the current optimizer
  20055. * @returns true if everything that can be done was applied
  20056. */
  20057. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  20058. }
  20059. /**
  20060. * Defines an optimization used to turn lens flares off
  20061. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  20062. */
  20063. class LensFlaresOptimization extends SceneOptimization {
  20064. /**
  20065. * Gets a string describing the action executed by the current optimization
  20066. * @return description string
  20067. */
  20068. getDescription(): string;
  20069. /**
  20070. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  20071. * @param scene defines the current scene where to apply this optimization
  20072. * @param optimizer defines the current optimizer
  20073. * @returns true if everything that can be done was applied
  20074. */
  20075. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  20076. }
  20077. /**
  20078. * Defines an optimization based on user defined callback.
  20079. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  20080. */
  20081. class CustomOptimization extends SceneOptimization {
  20082. /**
  20083. * Callback called to apply the custom optimization.
  20084. */
  20085. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  20086. /**
  20087. * Callback called to get custom description
  20088. */
  20089. onGetDescription: () => string;
  20090. /**
  20091. * Gets a string describing the action executed by the current optimization
  20092. * @returns description string
  20093. */
  20094. getDescription(): string;
  20095. /**
  20096. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  20097. * @param scene defines the current scene where to apply this optimization
  20098. * @param optimizer defines the current optimizer
  20099. * @returns true if everything that can be done was applied
  20100. */
  20101. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  20102. }
  20103. /**
  20104. * Defines an optimization used to turn particles off
  20105. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  20106. */
  20107. class ParticlesOptimization extends SceneOptimization {
  20108. /**
  20109. * Gets a string describing the action executed by the current optimization
  20110. * @return description string
  20111. */
  20112. getDescription(): string;
  20113. /**
  20114. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  20115. * @param scene defines the current scene where to apply this optimization
  20116. * @param optimizer defines the current optimizer
  20117. * @returns true if everything that can be done was applied
  20118. */
  20119. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  20120. }
  20121. /**
  20122. * Defines an optimization used to turn render targets off
  20123. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  20124. */
  20125. class RenderTargetsOptimization extends SceneOptimization {
  20126. /**
  20127. * Gets a string describing the action executed by the current optimization
  20128. * @return description string
  20129. */
  20130. getDescription(): string;
  20131. /**
  20132. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  20133. * @param scene defines the current scene where to apply this optimization
  20134. * @param optimizer defines the current optimizer
  20135. * @returns true if everything that can be done was applied
  20136. */
  20137. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  20138. }
  20139. /**
  20140. * Defines an optimization used to merge meshes with compatible materials
  20141. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  20142. */
  20143. class MergeMeshesOptimization extends SceneOptimization {
  20144. private static _UpdateSelectionTree;
  20145. /**
  20146. * Gets or sets a boolean which defines if optimization octree has to be updated
  20147. */
  20148. /**
  20149. * Gets or sets a boolean which defines if optimization octree has to be updated
  20150. */
  20151. static UpdateSelectionTree: boolean;
  20152. /**
  20153. * Gets a string describing the action executed by the current optimization
  20154. * @return description string
  20155. */
  20156. getDescription(): string;
  20157. private _canBeMerged;
  20158. /**
  20159. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  20160. * @param scene defines the current scene where to apply this optimization
  20161. * @param optimizer defines the current optimizer
  20162. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  20163. * @returns true if everything that can be done was applied
  20164. */
  20165. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  20166. }
  20167. /**
  20168. * Defines a list of options used by SceneOptimizer
  20169. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  20170. */
  20171. class SceneOptimizerOptions {
  20172. /**
  20173. * Defines the target frame rate to reach (60 by default)
  20174. */
  20175. targetFrameRate: number;
  20176. /**
  20177. * Defines the interval between two checkes (2000ms by default)
  20178. */
  20179. trackerDuration: number;
  20180. /**
  20181. * Gets the list of optimizations to apply
  20182. */
  20183. optimizations: SceneOptimization[];
  20184. /**
  20185. * Creates a new list of options used by SceneOptimizer
  20186. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  20187. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  20188. */
  20189. constructor(
  20190. /**
  20191. * Defines the target frame rate to reach (60 by default)
  20192. */
  20193. targetFrameRate?: number,
  20194. /**
  20195. * Defines the interval between two checkes (2000ms by default)
  20196. */
  20197. trackerDuration?: number);
  20198. /**
  20199. * Add a new optimization
  20200. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  20201. * @returns the current SceneOptimizerOptions
  20202. */
  20203. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  20204. /**
  20205. * Add a new custom optimization
  20206. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  20207. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  20208. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  20209. * @returns the current SceneOptimizerOptions
  20210. */
  20211. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  20212. /**
  20213. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  20214. * @param targetFrameRate defines the target frame rate (60 by default)
  20215. * @returns a SceneOptimizerOptions object
  20216. */
  20217. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  20218. /**
  20219. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  20220. * @param targetFrameRate defines the target frame rate (60 by default)
  20221. * @returns a SceneOptimizerOptions object
  20222. */
  20223. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  20224. /**
  20225. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  20226. * @param targetFrameRate defines the target frame rate (60 by default)
  20227. * @returns a SceneOptimizerOptions object
  20228. */
  20229. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  20230. }
  20231. /**
  20232. * Class used to run optimizations in order to reach a target frame rate
  20233. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  20234. */
  20235. class SceneOptimizer implements IDisposable {
  20236. private _isRunning;
  20237. private _options;
  20238. private _scene;
  20239. private _currentPriorityLevel;
  20240. private _targetFrameRate;
  20241. private _trackerDuration;
  20242. private _currentFrameRate;
  20243. private _sceneDisposeObserver;
  20244. private _improvementMode;
  20245. /**
  20246. * Defines an observable called when the optimizer reaches the target frame rate
  20247. */
  20248. onSuccessObservable: Observable<SceneOptimizer>;
  20249. /**
  20250. * Defines an observable called when the optimizer enables an optimization
  20251. */
  20252. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  20253. /**
  20254. * Defines an observable called when the optimizer is not able to reach the target frame rate
  20255. */
  20256. onFailureObservable: Observable<SceneOptimizer>;
  20257. /**
  20258. * Gets a boolean indicating if the optimizer is in improvement mode
  20259. */
  20260. readonly isInImprovementMode: boolean;
  20261. /**
  20262. * Gets the current priority level (0 at start)
  20263. */
  20264. readonly currentPriorityLevel: number;
  20265. /**
  20266. * Gets the current frame rate checked by the SceneOptimizer
  20267. */
  20268. readonly currentFrameRate: number;
  20269. /**
  20270. * Gets or sets the current target frame rate (60 by default)
  20271. */
  20272. /**
  20273. * Gets or sets the current target frame rate (60 by default)
  20274. */
  20275. targetFrameRate: number;
  20276. /**
  20277. * Gets or sets the current interval between two checks (every 2000ms by default)
  20278. */
  20279. /**
  20280. * Gets or sets the current interval between two checks (every 2000ms by default)
  20281. */
  20282. trackerDuration: number;
  20283. /**
  20284. * Gets the list of active optimizations
  20285. */
  20286. readonly optimizations: SceneOptimization[];
  20287. /**
  20288. * Creates a new SceneOptimizer
  20289. * @param scene defines the scene to work on
  20290. * @param options defines the options to use with the SceneOptimizer
  20291. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  20292. * @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)
  20293. */
  20294. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  20295. /**
  20296. * Stops the current optimizer
  20297. */
  20298. stop(): void;
  20299. /**
  20300. * Reset the optimizer to initial step (current priority level = 0)
  20301. */
  20302. reset(): void;
  20303. /**
  20304. * Start the optimizer. By default it will try to reach a specific framerate
  20305. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  20306. */
  20307. start(): void;
  20308. private _checkCurrentState();
  20309. /**
  20310. * Release all resources
  20311. */
  20312. dispose(): void;
  20313. /**
  20314. * Helper function to create a SceneOptimizer with one single line of code
  20315. * @param scene defines the scene to work on
  20316. * @param options defines the options to use with the SceneOptimizer
  20317. * @param onSuccess defines a callback to call on success
  20318. * @param onFailure defines a callback to call on failure
  20319. * @returns the new SceneOptimizer object
  20320. */
  20321. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  20322. }
  20323. }
  20324. declare module BABYLON {
  20325. class SceneSerializer {
  20326. static ClearCache(): void;
  20327. static Serialize(scene: Scene): any;
  20328. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  20329. }
  20330. }
  20331. declare module BABYLON {
  20332. class SmartArray<T> {
  20333. data: Array<T>;
  20334. length: number;
  20335. protected _id: number;
  20336. [index: number]: T;
  20337. constructor(capacity: number);
  20338. push(value: T): void;
  20339. forEach(func: (content: T) => void): void;
  20340. sort(compareFn: (a: T, b: T) => number): void;
  20341. reset(): void;
  20342. dispose(): void;
  20343. concat(array: any): void;
  20344. indexOf(value: T): number;
  20345. contains(value: T): boolean;
  20346. private static _GlobalId;
  20347. }
  20348. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  20349. private _duplicateId;
  20350. [index: number]: T;
  20351. push(value: T): void;
  20352. pushNoDuplicate(value: T): boolean;
  20353. reset(): void;
  20354. concatWithNoDuplicate(array: any): void;
  20355. }
  20356. }
  20357. declare module BABYLON {
  20358. /**
  20359. * This class implement a typical dictionary using a string as key and the generic type T as value.
  20360. * The underlying implementation relies on an associative array to ensure the best performances.
  20361. * The value can be anything including 'null' but except 'undefined'
  20362. */
  20363. class StringDictionary<T> {
  20364. /**
  20365. * This will clear this dictionary and copy the content from the 'source' one.
  20366. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  20367. * @param source the dictionary to take the content from and copy to this dictionary
  20368. */
  20369. copyFrom(source: StringDictionary<T>): void;
  20370. /**
  20371. * Get a value based from its key
  20372. * @param key the given key to get the matching value from
  20373. * @return the value if found, otherwise undefined is returned
  20374. */
  20375. get(key: string): T | undefined;
  20376. /**
  20377. * Get a value from its key or add it if it doesn't exist.
  20378. * This method will ensure you that a given key/data will be present in the dictionary.
  20379. * @param key the given key to get the matching value from
  20380. * @param factory the factory that will create the value if the key is not present in the dictionary.
  20381. * The factory will only be invoked if there's no data for the given key.
  20382. * @return the value corresponding to the key.
  20383. */
  20384. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  20385. /**
  20386. * Get a value from its key if present in the dictionary otherwise add it
  20387. * @param key the key to get the value from
  20388. * @param val if there's no such key/value pair in the dictionary add it with this value
  20389. * @return the value corresponding to the key
  20390. */
  20391. getOrAdd(key: string, val: T): T;
  20392. /**
  20393. * Check if there's a given key in the dictionary
  20394. * @param key the key to check for
  20395. * @return true if the key is present, false otherwise
  20396. */
  20397. contains(key: string): boolean;
  20398. /**
  20399. * Add a new key and its corresponding value
  20400. * @param key the key to add
  20401. * @param value the value corresponding to the key
  20402. * @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
  20403. */
  20404. add(key: string, value: T): boolean;
  20405. set(key: string, value: T): boolean;
  20406. /**
  20407. * Get the element of the given key and remove it from the dictionary
  20408. * @param key
  20409. */
  20410. getAndRemove(key: string): Nullable<T>;
  20411. /**
  20412. * Remove a key/value from the dictionary.
  20413. * @param key the key to remove
  20414. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  20415. */
  20416. remove(key: string): boolean;
  20417. /**
  20418. * Clear the whole content of the dictionary
  20419. */
  20420. clear(): void;
  20421. readonly count: number;
  20422. /**
  20423. * Execute a callback on each key/val of the dictionary.
  20424. * Note that you can remove any element in this dictionary in the callback implementation
  20425. * @param callback the callback to execute on a given key/value pair
  20426. */
  20427. forEach(callback: (key: string, val: T) => void): void;
  20428. /**
  20429. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  20430. * If the callback returns null or undefined the method will iterate to the next key/value pair
  20431. * Note that you can remove any element in this dictionary in the callback implementation
  20432. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  20433. */
  20434. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  20435. private _count;
  20436. private _data;
  20437. }
  20438. }
  20439. declare module BABYLON {
  20440. class Tags {
  20441. static EnableFor(obj: any): void;
  20442. static DisableFor(obj: any): void;
  20443. static HasTags(obj: any): boolean;
  20444. static GetTags(obj: any, asString?: boolean): any;
  20445. static AddTagsTo(obj: any, tagsString: string): void;
  20446. static _AddTagTo(obj: any, tag: string): void;
  20447. static RemoveTagsFrom(obj: any, tagsString: string): void;
  20448. static _RemoveTagFrom(obj: any, tag: string): void;
  20449. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  20450. }
  20451. }
  20452. declare module BABYLON {
  20453. class TextureTools {
  20454. /**
  20455. * Uses the GPU to create a copy texture rescaled at a given size
  20456. * @param texture Texture to copy from
  20457. * @param width Desired width
  20458. * @param height Desired height
  20459. * @return Generated texture
  20460. */
  20461. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  20462. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20463. private static _environmentBRDFBase64Texture;
  20464. }
  20465. }
  20466. declare module BABYLON {
  20467. class TGATools {
  20468. private static _TYPE_INDEXED;
  20469. private static _TYPE_RGB;
  20470. private static _TYPE_GREY;
  20471. private static _TYPE_RLE_INDEXED;
  20472. private static _TYPE_RLE_RGB;
  20473. private static _TYPE_RLE_GREY;
  20474. private static _ORIGIN_MASK;
  20475. private static _ORIGIN_SHIFT;
  20476. private static _ORIGIN_BL;
  20477. private static _ORIGIN_BR;
  20478. private static _ORIGIN_UL;
  20479. private static _ORIGIN_UR;
  20480. static GetTGAHeader(data: Uint8Array): any;
  20481. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  20482. 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;
  20483. 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;
  20484. 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;
  20485. 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;
  20486. 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;
  20487. 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;
  20488. }
  20489. }
  20490. declare module BABYLON {
  20491. interface IAnimatable {
  20492. animations: Array<Animation>;
  20493. }
  20494. class LoadFileError extends Error {
  20495. request: XMLHttpRequest | undefined;
  20496. private static _setPrototypeOf;
  20497. constructor(message: string, request?: XMLHttpRequest | undefined);
  20498. }
  20499. class RetryStrategy {
  20500. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  20501. }
  20502. interface IFileRequest {
  20503. /**
  20504. * Raised when the request is complete (success or error).
  20505. */
  20506. onCompleteObservable: Observable<IFileRequest>;
  20507. /**
  20508. * Aborts the request for a file.
  20509. */
  20510. abort: () => void;
  20511. }
  20512. class Tools {
  20513. static BaseUrl: string;
  20514. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  20515. /**
  20516. * Default behaviour for cors in the application.
  20517. * It can be a string if the expected behavior is identical in the entire app.
  20518. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  20519. */
  20520. static CorsBehavior: string | ((url: string | string[]) => string);
  20521. static UseFallbackTexture: boolean;
  20522. /**
  20523. * Use this object to register external classes like custom textures or material
  20524. * to allow the laoders to instantiate them
  20525. */
  20526. static RegisteredExternalClasses: {
  20527. [key: string]: Object;
  20528. };
  20529. static fallbackTexture: string;
  20530. /**
  20531. * Interpolates between a and b via alpha
  20532. * @param a The lower value (returned when alpha = 0)
  20533. * @param b The upper value (returned when alpha = 1)
  20534. * @param alpha The interpolation-factor
  20535. * @return The mixed value
  20536. */
  20537. static Mix(a: number, b: number, alpha: number): number;
  20538. static Instantiate(className: string): any;
  20539. /**
  20540. * Provides a slice function that will work even on IE
  20541. * @param data defines the array to slice
  20542. * @returns the new sliced array
  20543. */
  20544. static Slice(data: FloatArray): FloatArray;
  20545. static SetImmediate(action: () => void): void;
  20546. static IsExponentOfTwo(value: number): boolean;
  20547. /**
  20548. * Find the next highest power of two.
  20549. * @param x Number to start search from.
  20550. * @return Next highest power of two.
  20551. */
  20552. static CeilingPOT(x: number): number;
  20553. /**
  20554. * Find the next lowest power of two.
  20555. * @param x Number to start search from.
  20556. * @return Next lowest power of two.
  20557. */
  20558. static FloorPOT(x: number): number;
  20559. /**
  20560. * Find the nearest power of two.
  20561. * @param x Number to start search from.
  20562. * @return Next nearest power of two.
  20563. */
  20564. static NearestPOT(x: number): number;
  20565. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  20566. static GetFilename(path: string): string;
  20567. /**
  20568. * Extracts the "folder" part of a path (everything before the filename).
  20569. * @param uri The URI to extract the info from
  20570. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  20571. * @returns The "folder" part of the path
  20572. */
  20573. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  20574. static GetDOMTextContent(element: HTMLElement): string;
  20575. static ToDegrees(angle: number): number;
  20576. static ToRadians(angle: number): number;
  20577. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  20578. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  20579. minimum: Vector3;
  20580. maximum: Vector3;
  20581. };
  20582. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  20583. minimum: Vector3;
  20584. maximum: Vector3;
  20585. };
  20586. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  20587. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  20588. minimum: Vector2;
  20589. maximum: Vector2;
  20590. };
  20591. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  20592. static GetPointerPrefix(): string;
  20593. /**
  20594. * @param func - the function to be called
  20595. * @param requester - the object that will request the next frame. Falls back to window.
  20596. */
  20597. static QueueNewFrame(func: () => void, requester?: any): number;
  20598. static RequestFullscreen(element: HTMLElement): void;
  20599. static ExitFullscreen(): void;
  20600. static SetCorsBehavior(url: string | string[], element: {
  20601. crossOrigin: string | null;
  20602. }): void;
  20603. static CleanUrl(url: string): string;
  20604. static PreprocessUrl: (url: string) => string;
  20605. static LoadImage(url: any, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  20606. 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;
  20607. /**
  20608. * Load a script (identified by an url). When the url returns, the
  20609. * content of this file is added into a new script element, attached to the DOM (body element)
  20610. */
  20611. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  20612. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (this: MSBaseReader, ev: ProgressEvent) => any): IFileRequest;
  20613. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (this: MSBaseReader, ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  20614. static FileAsURL(content: string): string;
  20615. static Format(value: number, decimals?: number): string;
  20616. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  20617. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  20618. static IsEmpty(obj: any): boolean;
  20619. static RegisterTopRootEvents(events: {
  20620. name: string;
  20621. handler: Nullable<(e: FocusEvent) => any>;
  20622. }[]): void;
  20623. static UnregisterTopRootEvents(events: {
  20624. name: string;
  20625. handler: Nullable<(e: FocusEvent) => any>;
  20626. }[]): void;
  20627. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  20628. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  20629. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  20630. /**
  20631. * Generates an image screenshot from the specified camera.
  20632. *
  20633. * @param engine The engine to use for rendering
  20634. * @param camera The camera to use for rendering
  20635. * @param size This parameter can be set to a single number or to an object with the
  20636. * following (optional) properties: precision, width, height. If a single number is passed,
  20637. * it will be used for both width and height. If an object is passed, the screenshot size
  20638. * will be derived from the parameters. The precision property is a multiplier allowing
  20639. * rendering at a higher or lower resolution.
  20640. * @param successCallback The callback receives a single parameter which contains the
  20641. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  20642. * src parameter of an <img> to display it.
  20643. * @param mimeType The MIME type of the screenshot image (default: image/png).
  20644. * Check your browser for supported MIME types.
  20645. * @param samples Texture samples (default: 1)
  20646. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  20647. * @param fileName A name for for the downloaded file.
  20648. * @constructor
  20649. */
  20650. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  20651. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  20652. /**
  20653. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20654. * Be aware Math.random() could cause collisions, but:
  20655. * "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"
  20656. */
  20657. static RandomId(): string;
  20658. /**
  20659. * Test if the given uri is a base64 string.
  20660. * @param uri The uri to test
  20661. * @return True if the uri is a base64 string or false otherwise.
  20662. */
  20663. static IsBase64(uri: string): boolean;
  20664. /**
  20665. * Decode the given base64 uri.
  20666. * @param uri The uri to decode
  20667. * @return The decoded base64 data.
  20668. */
  20669. static DecodeBase64(uri: string): ArrayBuffer;
  20670. private static _NoneLogLevel;
  20671. private static _MessageLogLevel;
  20672. private static _WarningLogLevel;
  20673. private static _ErrorLogLevel;
  20674. private static _LogCache;
  20675. static errorsCount: number;
  20676. static OnNewCacheEntry: (entry: string) => void;
  20677. static readonly NoneLogLevel: number;
  20678. static readonly MessageLogLevel: number;
  20679. static readonly WarningLogLevel: number;
  20680. static readonly ErrorLogLevel: number;
  20681. static readonly AllLogLevel: number;
  20682. private static _AddLogEntry(entry);
  20683. private static _FormatMessage(message);
  20684. private static _LogDisabled(message);
  20685. private static _LogEnabled(message);
  20686. private static _WarnDisabled(message);
  20687. private static _WarnEnabled(message);
  20688. private static _ErrorDisabled(message);
  20689. private static _ErrorEnabled(message);
  20690. static Log: (message: string) => void;
  20691. static Warn: (message: string) => void;
  20692. static Error: (message: string) => void;
  20693. static readonly LogCache: string;
  20694. static ClearLogCache(): void;
  20695. static LogLevels: number;
  20696. static IsWindowObjectExist(): boolean;
  20697. private static _PerformanceNoneLogLevel;
  20698. private static _PerformanceUserMarkLogLevel;
  20699. private static _PerformanceConsoleLogLevel;
  20700. private static _performance;
  20701. static readonly PerformanceNoneLogLevel: number;
  20702. static readonly PerformanceUserMarkLogLevel: number;
  20703. static readonly PerformanceConsoleLogLevel: number;
  20704. static PerformanceLogLevel: number;
  20705. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  20706. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  20707. static _StartUserMark(counterName: string, condition?: boolean): void;
  20708. static _EndUserMark(counterName: string, condition?: boolean): void;
  20709. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  20710. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  20711. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  20712. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  20713. static readonly Now: number;
  20714. /**
  20715. * This method will return the name of the class used to create the instance of the given object.
  20716. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  20717. * @param object the object to get the class name from
  20718. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  20719. */
  20720. static GetClassName(object: any, isType?: boolean): string;
  20721. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  20722. /**
  20723. * This method will return the name of the full name of the class, including its owning module (if any).
  20724. * 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).
  20725. * @param object the object to get the class name from
  20726. * @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.
  20727. */
  20728. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  20729. /**
  20730. * 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.
  20731. * @param array
  20732. */
  20733. static arrayOrStringFeeder(array: any): (i: number) => number;
  20734. /**
  20735. * Compute the hashCode of a stream of number
  20736. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  20737. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  20738. * @return the hash code computed
  20739. */
  20740. static hashCodeFromStream(feeder: (index: number) => number): number;
  20741. }
  20742. /**
  20743. * This class is used to track a performance counter which is number based.
  20744. * The user has access to many properties which give statistics of different nature
  20745. *
  20746. * The implementer can track two kinds of Performance Counter: time and count
  20747. * 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.
  20748. * 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.
  20749. */
  20750. class PerfCounter {
  20751. static Enabled: boolean;
  20752. /**
  20753. * Returns the smallest value ever
  20754. */
  20755. readonly min: number;
  20756. /**
  20757. * Returns the biggest value ever
  20758. */
  20759. readonly max: number;
  20760. /**
  20761. * Returns the average value since the performance counter is running
  20762. */
  20763. readonly average: number;
  20764. /**
  20765. * Returns the average value of the last second the counter was monitored
  20766. */
  20767. readonly lastSecAverage: number;
  20768. /**
  20769. * Returns the current value
  20770. */
  20771. readonly current: number;
  20772. readonly total: number;
  20773. readonly count: number;
  20774. constructor();
  20775. /**
  20776. * Call this method to start monitoring a new frame.
  20777. * 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.
  20778. */
  20779. fetchNewFrame(): void;
  20780. /**
  20781. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  20782. * @param newCount the count value to add to the monitored count
  20783. * @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.
  20784. */
  20785. addCount(newCount: number, fetchResult: boolean): void;
  20786. /**
  20787. * Start monitoring this performance counter
  20788. */
  20789. beginMonitoring(): void;
  20790. /**
  20791. * Compute the time lapsed since the previous beginMonitoring() call.
  20792. * @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
  20793. */
  20794. endMonitoring(newFrame?: boolean): void;
  20795. private _fetchResult();
  20796. private _startMonitoringTime;
  20797. private _min;
  20798. private _max;
  20799. private _average;
  20800. private _current;
  20801. private _totalValueCount;
  20802. private _totalAccumulated;
  20803. private _lastSecAverage;
  20804. private _lastSecAccumulated;
  20805. private _lastSecTime;
  20806. private _lastSecValueCount;
  20807. }
  20808. /**
  20809. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  20810. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  20811. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  20812. * @param name The name of the class, case should be preserved
  20813. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  20814. */
  20815. function className(name: string, module?: string): (target: Object) => void;
  20816. /**
  20817. * An implementation of a loop for asynchronous functions.
  20818. */
  20819. class AsyncLoop {
  20820. iterations: number;
  20821. private _fn;
  20822. private _successCallback;
  20823. index: number;
  20824. private _done;
  20825. /**
  20826. * Constroctor.
  20827. * @param iterations the number of iterations.
  20828. * @param _fn the function to run each iteration
  20829. * @param _successCallback the callback that will be called upon succesful execution
  20830. * @param offset starting offset.
  20831. */
  20832. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  20833. /**
  20834. * Execute the next iteration. Must be called after the last iteration was finished.
  20835. */
  20836. executeNext(): void;
  20837. /**
  20838. * Break the loop and run the success callback.
  20839. */
  20840. breakLoop(): void;
  20841. /**
  20842. * Helper function
  20843. */
  20844. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  20845. /**
  20846. * A for-loop that will run a given number of iterations synchronous and the rest async.
  20847. * @param iterations total number of iterations
  20848. * @param syncedIterations number of synchronous iterations in each async iteration.
  20849. * @param fn the function to call each iteration.
  20850. * @param callback a success call back that will be called when iterating stops.
  20851. * @param breakFunction a break condition (optional)
  20852. * @param timeout timeout settings for the setTimeout function. default - 0.
  20853. * @constructor
  20854. */
  20855. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  20856. }
  20857. }
  20858. declare module BABYLON {
  20859. enum JoystickAxis {
  20860. X = 0,
  20861. Y = 1,
  20862. Z = 2,
  20863. }
  20864. class VirtualJoystick {
  20865. reverseLeftRight: boolean;
  20866. reverseUpDown: boolean;
  20867. deltaPosition: Vector3;
  20868. pressed: boolean;
  20869. private static _globalJoystickIndex;
  20870. private static vjCanvas;
  20871. private static vjCanvasContext;
  20872. private static vjCanvasWidth;
  20873. private static vjCanvasHeight;
  20874. private static halfWidth;
  20875. private _action;
  20876. private _axisTargetedByLeftAndRight;
  20877. private _axisTargetedByUpAndDown;
  20878. private _joystickSensibility;
  20879. private _inversedSensibility;
  20880. private _joystickPointerID;
  20881. private _joystickColor;
  20882. private _joystickPointerPos;
  20883. private _joystickPreviousPointerPos;
  20884. private _joystickPointerStartPos;
  20885. private _deltaJoystickVector;
  20886. private _leftJoystick;
  20887. private _touches;
  20888. private _onPointerDownHandlerRef;
  20889. private _onPointerMoveHandlerRef;
  20890. private _onPointerUpHandlerRef;
  20891. private _onResize;
  20892. constructor(leftJoystick?: boolean);
  20893. setJoystickSensibility(newJoystickSensibility: number): void;
  20894. private _onPointerDown(e);
  20895. private _onPointerMove(e);
  20896. private _onPointerUp(e);
  20897. /**
  20898. * Change the color of the virtual joystick
  20899. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  20900. */
  20901. setJoystickColor(newColor: string): void;
  20902. setActionOnTouch(action: () => any): void;
  20903. setAxisForLeftRight(axis: JoystickAxis): void;
  20904. setAxisForUpDown(axis: JoystickAxis): void;
  20905. private _drawVirtualJoystick();
  20906. releaseCanvas(): void;
  20907. }
  20908. }
  20909. declare module BABYLON {
  20910. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  20911. readonly name: string;
  20912. private _zoomStopsAnimation;
  20913. private _idleRotationSpeed;
  20914. private _idleRotationWaitTime;
  20915. private _idleRotationSpinupTime;
  20916. /**
  20917. * Gets the flag that indicates if user zooming should stop animation.
  20918. */
  20919. /**
  20920. * Sets the flag that indicates if user zooming should stop animation.
  20921. */
  20922. zoomStopsAnimation: boolean;
  20923. /**
  20924. * Gets the default speed at which the camera rotates around the model.
  20925. */
  20926. /**
  20927. * Sets the default speed at which the camera rotates around the model.
  20928. */
  20929. idleRotationSpeed: number;
  20930. /**
  20931. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  20932. */
  20933. /**
  20934. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  20935. */
  20936. idleRotationWaitTime: number;
  20937. /**
  20938. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  20939. */
  20940. /**
  20941. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  20942. */
  20943. idleRotationSpinupTime: number;
  20944. /**
  20945. * Gets a value indicating if the camera is currently rotating because of this behavior
  20946. */
  20947. readonly rotationInProgress: boolean;
  20948. private _onPrePointerObservableObserver;
  20949. private _onAfterCheckInputsObserver;
  20950. private _attachedCamera;
  20951. private _isPointerDown;
  20952. private _lastFrameTime;
  20953. private _lastInteractionTime;
  20954. private _cameraRotationSpeed;
  20955. init(): void;
  20956. attach(camera: ArcRotateCamera): void;
  20957. detach(): void;
  20958. /**
  20959. * Returns true if user is scrolling.
  20960. * @return true if user is scrolling.
  20961. */
  20962. private _userIsZooming();
  20963. private _lastFrameRadius;
  20964. private _shouldAnimationStopForInteraction();
  20965. /**
  20966. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  20967. */
  20968. private _applyUserInteraction();
  20969. private _userIsMoving();
  20970. }
  20971. }
  20972. declare module BABYLON {
  20973. /**
  20974. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  20975. */
  20976. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  20977. readonly name: string;
  20978. /**
  20979. * The easing function used by animations
  20980. */
  20981. static EasingFunction: BackEase;
  20982. /**
  20983. * The easing mode used by animations
  20984. */
  20985. static EasingMode: number;
  20986. /**
  20987. * The duration of the animation, in milliseconds
  20988. */
  20989. transitionDuration: number;
  20990. /**
  20991. * Length of the distance animated by the transition when lower radius is reached
  20992. */
  20993. lowerRadiusTransitionRange: number;
  20994. /**
  20995. * Length of the distance animated by the transition when upper radius is reached
  20996. */
  20997. upperRadiusTransitionRange: number;
  20998. private _autoTransitionRange;
  20999. /**
  21000. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  21001. */
  21002. /**
  21003. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  21004. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  21005. */
  21006. autoTransitionRange: boolean;
  21007. private _attachedCamera;
  21008. private _onAfterCheckInputsObserver;
  21009. private _onMeshTargetChangedObserver;
  21010. init(): void;
  21011. attach(camera: ArcRotateCamera): void;
  21012. detach(): void;
  21013. private _radiusIsAnimating;
  21014. private _radiusBounceTransition;
  21015. private _animatables;
  21016. private _cachedWheelPrecision;
  21017. /**
  21018. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  21019. * @param radiusLimit The limit to check against.
  21020. * @return Bool to indicate if at limit.
  21021. */
  21022. private _isRadiusAtLimit(radiusLimit);
  21023. /**
  21024. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  21025. * @param radiusDelta The delta by which to animate to. Can be negative.
  21026. */
  21027. private _applyBoundRadiusAnimation(radiusDelta);
  21028. /**
  21029. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  21030. */
  21031. protected _clearAnimationLocks(): void;
  21032. /**
  21033. * Stops and removes all animations that have been applied to the camera
  21034. */
  21035. stopAllAnimations(): void;
  21036. }
  21037. }
  21038. declare module BABYLON {
  21039. class FramingBehavior implements Behavior<ArcRotateCamera> {
  21040. readonly name: string;
  21041. private _mode;
  21042. private _radiusScale;
  21043. private _positionScale;
  21044. private _defaultElevation;
  21045. private _elevationReturnTime;
  21046. private _elevationReturnWaitTime;
  21047. private _zoomStopsAnimation;
  21048. private _framingTime;
  21049. /**
  21050. * The easing function used by animations
  21051. */
  21052. static EasingFunction: ExponentialEase;
  21053. /**
  21054. * The easing mode used by animations
  21055. */
  21056. static EasingMode: number;
  21057. /**
  21058. * Gets current mode used by the behavior.
  21059. */
  21060. /**
  21061. * Sets the current mode used by the behavior
  21062. */
  21063. mode: number;
  21064. /**
  21065. * Gets the scale applied to the radius
  21066. */
  21067. /**
  21068. * Sets the scale applied to the radius (1 by default)
  21069. */
  21070. radiusScale: number;
  21071. /**
  21072. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  21073. */
  21074. /**
  21075. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  21076. */
  21077. positionScale: number;
  21078. /**
  21079. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  21080. * behaviour is triggered, in radians.
  21081. */
  21082. /**
  21083. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  21084. * behaviour is triggered, in radians.
  21085. */
  21086. defaultElevation: number;
  21087. /**
  21088. * Gets the time (in milliseconds) taken to return to the default beta position.
  21089. * Negative value indicates camera should not return to default.
  21090. */
  21091. /**
  21092. * Sets the time (in milliseconds) taken to return to the default beta position.
  21093. * Negative value indicates camera should not return to default.
  21094. */
  21095. elevationReturnTime: number;
  21096. /**
  21097. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  21098. */
  21099. /**
  21100. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  21101. */
  21102. elevationReturnWaitTime: number;
  21103. /**
  21104. * Gets the flag that indicates if user zooming should stop animation.
  21105. */
  21106. /**
  21107. * Sets the flag that indicates if user zooming should stop animation.
  21108. */
  21109. zoomStopsAnimation: boolean;
  21110. /**
  21111. * Gets the transition time when framing the mesh, in milliseconds
  21112. */
  21113. /**
  21114. * Sets the transition time when framing the mesh, in milliseconds
  21115. */
  21116. framingTime: number;
  21117. private _onPrePointerObservableObserver;
  21118. private _onAfterCheckInputsObserver;
  21119. private _onMeshTargetChangedObserver;
  21120. private _attachedCamera;
  21121. private _isPointerDown;
  21122. private _lastInteractionTime;
  21123. init(): void;
  21124. attach(camera: ArcRotateCamera): void;
  21125. detach(): void;
  21126. private _animatables;
  21127. private _betaIsAnimating;
  21128. private _betaTransition;
  21129. private _radiusTransition;
  21130. private _vectorTransition;
  21131. /**
  21132. * Targets the given mesh and updates zoom level accordingly.
  21133. * @param mesh The mesh to target.
  21134. * @param radius Optional. If a cached radius position already exists, overrides default.
  21135. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  21136. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  21137. * @param onAnimationEnd Callback triggered at the end of the framing animation
  21138. */
  21139. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  21140. /**
  21141. * Targets the given mesh with its children and updates zoom level accordingly.
  21142. * @param mesh The mesh to target.
  21143. * @param radius Optional. If a cached radius position already exists, overrides default.
  21144. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  21145. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  21146. * @param onAnimationEnd Callback triggered at the end of the framing animation
  21147. */
  21148. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  21149. /**
  21150. * Targets the given meshes with their children and updates zoom level accordingly.
  21151. * @param meshes The mesh to target.
  21152. * @param radius Optional. If a cached radius position already exists, overrides default.
  21153. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  21154. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  21155. * @param onAnimationEnd Callback triggered at the end of the framing animation
  21156. */
  21157. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  21158. /**
  21159. * Targets the given mesh and updates zoom level accordingly.
  21160. * @param mesh The mesh to target.
  21161. * @param radius Optional. If a cached radius position already exists, overrides default.
  21162. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  21163. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  21164. * @param onAnimationEnd Callback triggered at the end of the framing animation
  21165. */
  21166. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  21167. /**
  21168. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  21169. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  21170. * frustum width.
  21171. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  21172. * to fully enclose the mesh in the viewing frustum.
  21173. */
  21174. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  21175. /**
  21176. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  21177. * is automatically returned to its default position (expected to be above ground plane).
  21178. */
  21179. private _maintainCameraAboveGround();
  21180. /**
  21181. * Returns the frustum slope based on the canvas ratio and camera FOV
  21182. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  21183. */
  21184. private _getFrustumSlope();
  21185. /**
  21186. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  21187. */
  21188. private _clearAnimationLocks();
  21189. /**
  21190. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  21191. */
  21192. private _applyUserInteraction();
  21193. /**
  21194. * Stops and removes all animations that have been applied to the camera
  21195. */
  21196. stopAllAnimations(): void;
  21197. /**
  21198. * Gets a value indicating if the user is moving the camera
  21199. */
  21200. readonly isUserIsMoving: boolean;
  21201. /**
  21202. * The camera can move all the way towards the mesh.
  21203. */
  21204. static IgnoreBoundsSizeMode: number;
  21205. /**
  21206. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  21207. */
  21208. static FitFrustumSidesMode: number;
  21209. }
  21210. }
  21211. declare module BABYLON {
  21212. interface IOctreeContainer<T> {
  21213. blocks: Array<OctreeBlock<T>>;
  21214. }
  21215. class Octree<T> {
  21216. maxDepth: number;
  21217. blocks: Array<OctreeBlock<T>>;
  21218. dynamicContent: T[];
  21219. private _maxBlockCapacity;
  21220. private _selectionContent;
  21221. private _creationFunc;
  21222. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  21223. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  21224. addMesh(entry: T): void;
  21225. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  21226. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  21227. intersectsRay(ray: Ray): SmartArray<T>;
  21228. 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;
  21229. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  21230. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  21231. }
  21232. }
  21233. declare module BABYLON {
  21234. class OctreeBlock<T> {
  21235. entries: T[];
  21236. blocks: Array<OctreeBlock<T>>;
  21237. private _depth;
  21238. private _maxDepth;
  21239. private _capacity;
  21240. private _minPoint;
  21241. private _maxPoint;
  21242. private _boundingVectors;
  21243. private _creationFunc;
  21244. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  21245. readonly capacity: number;
  21246. readonly minPoint: Vector3;
  21247. readonly maxPoint: Vector3;
  21248. addEntry(entry: T): void;
  21249. addEntries(entries: T[]): void;
  21250. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  21251. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  21252. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  21253. createInnerBlocks(): void;
  21254. }
  21255. }
  21256. declare module BABYLON {
  21257. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  21258. camera: ArcRotateCamera;
  21259. gamepad: Nullable<Gamepad>;
  21260. private _onGamepadConnectedObserver;
  21261. private _onGamepadDisconnectedObserver;
  21262. gamepadRotationSensibility: number;
  21263. gamepadMoveSensibility: number;
  21264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  21265. detachControl(element: Nullable<HTMLElement>): void;
  21266. checkInputs(): void;
  21267. getClassName(): string;
  21268. getSimpleName(): string;
  21269. }
  21270. }
  21271. declare module BABYLON {
  21272. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  21273. camera: ArcRotateCamera;
  21274. private _keys;
  21275. keysUp: number[];
  21276. keysDown: number[];
  21277. keysLeft: number[];
  21278. keysRight: number[];
  21279. keysReset: number[];
  21280. panningSensibility: number;
  21281. zoomingSensibility: number;
  21282. useAltToZoom: boolean;
  21283. private _ctrlPressed;
  21284. private _altPressed;
  21285. private _onCanvasBlurObserver;
  21286. private _onKeyboardObserver;
  21287. private _engine;
  21288. private _scene;
  21289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  21290. detachControl(element: Nullable<HTMLElement>): void;
  21291. checkInputs(): void;
  21292. getClassName(): string;
  21293. getSimpleName(): string;
  21294. }
  21295. }
  21296. declare module BABYLON {
  21297. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  21298. camera: ArcRotateCamera;
  21299. private _wheel;
  21300. private _observer;
  21301. wheelPrecision: number;
  21302. /**
  21303. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  21304. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  21305. */
  21306. wheelDeltaPercentage: number;
  21307. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  21308. detachControl(element: Nullable<HTMLElement>): void;
  21309. getClassName(): string;
  21310. getSimpleName(): string;
  21311. }
  21312. }
  21313. declare module BABYLON {
  21314. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  21315. camera: ArcRotateCamera;
  21316. buttons: number[];
  21317. angularSensibilityX: number;
  21318. angularSensibilityY: number;
  21319. pinchPrecision: number;
  21320. /**
  21321. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  21322. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  21323. */
  21324. pinchDeltaPercentage: number;
  21325. panningSensibility: number;
  21326. multiTouchPanning: boolean;
  21327. multiTouchPanAndZoom: boolean;
  21328. private _isPanClick;
  21329. pinchInwards: boolean;
  21330. private _pointerInput;
  21331. private _observer;
  21332. private _onMouseMove;
  21333. private _onGestureStart;
  21334. private _onGesture;
  21335. private _MSGestureHandler;
  21336. private _onLostFocus;
  21337. private _onContextMenu;
  21338. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  21339. detachControl(element: Nullable<HTMLElement>): void;
  21340. getClassName(): string;
  21341. getSimpleName(): string;
  21342. }
  21343. }
  21344. declare module BABYLON {
  21345. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  21346. camera: ArcRotateCamera;
  21347. alphaCorrection: number;
  21348. betaCorrection: number;
  21349. gammaCorrection: number;
  21350. private _alpha;
  21351. private _gamma;
  21352. private _dirty;
  21353. private _deviceOrientationHandler;
  21354. constructor();
  21355. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  21356. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  21357. checkInputs(): void;
  21358. detachControl(element: Nullable<HTMLElement>): void;
  21359. getClassName(): string;
  21360. getSimpleName(): string;
  21361. }
  21362. }
  21363. declare module BABYLON {
  21364. /**
  21365. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  21366. * Screen rotation is taken into account.
  21367. */
  21368. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  21369. private _camera;
  21370. private _screenOrientationAngle;
  21371. private _constantTranform;
  21372. private _screenQuaternion;
  21373. private _alpha;
  21374. private _beta;
  21375. private _gamma;
  21376. constructor();
  21377. camera: FreeCamera;
  21378. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  21379. private _orientationChanged;
  21380. private _deviceOrientation;
  21381. detachControl(element: Nullable<HTMLElement>): void;
  21382. checkInputs(): void;
  21383. getClassName(): string;
  21384. getSimpleName(): string;
  21385. }
  21386. }
  21387. declare module BABYLON {
  21388. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  21389. camera: FreeCamera;
  21390. gamepad: Nullable<Gamepad>;
  21391. private _onGamepadConnectedObserver;
  21392. private _onGamepadDisconnectedObserver;
  21393. gamepadAngularSensibility: number;
  21394. gamepadMoveSensibility: number;
  21395. private _cameraTransform;
  21396. private _deltaTransform;
  21397. private _vector3;
  21398. private _vector2;
  21399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  21400. detachControl(element: Nullable<HTMLElement>): void;
  21401. checkInputs(): void;
  21402. getClassName(): string;
  21403. getSimpleName(): string;
  21404. }
  21405. }
  21406. declare module BABYLON {
  21407. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  21408. camera: FreeCamera;
  21409. private _keys;
  21410. private _onCanvasBlurObserver;
  21411. private _onKeyboardObserver;
  21412. private _engine;
  21413. private _scene;
  21414. keysUp: number[];
  21415. keysDown: number[];
  21416. keysLeft: number[];
  21417. keysRight: number[];
  21418. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  21419. detachControl(element: Nullable<HTMLElement>): void;
  21420. checkInputs(): void;
  21421. getClassName(): string;
  21422. _onLostFocus(e: FocusEvent): void;
  21423. getSimpleName(): string;
  21424. }
  21425. }
  21426. declare module BABYLON {
  21427. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  21428. touchEnabled: boolean;
  21429. camera: FreeCamera;
  21430. buttons: number[];
  21431. angularSensibility: number;
  21432. private _pointerInput;
  21433. private _onMouseMove;
  21434. private _observer;
  21435. private previousPosition;
  21436. constructor(touchEnabled?: boolean);
  21437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  21438. detachControl(element: Nullable<HTMLElement>): void;
  21439. getClassName(): string;
  21440. getSimpleName(): string;
  21441. }
  21442. }
  21443. declare module BABYLON {
  21444. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  21445. camera: FreeCamera;
  21446. private _offsetX;
  21447. private _offsetY;
  21448. private _pointerPressed;
  21449. private _pointerInput;
  21450. private _observer;
  21451. private _onLostFocus;
  21452. touchAngularSensibility: number;
  21453. touchMoveSensibility: number;
  21454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  21455. detachControl(element: Nullable<HTMLElement>): void;
  21456. checkInputs(): void;
  21457. getClassName(): string;
  21458. getSimpleName(): string;
  21459. }
  21460. }
  21461. declare module BABYLON {
  21462. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  21463. camera: FreeCamera;
  21464. private _leftjoystick;
  21465. private _rightjoystick;
  21466. getLeftJoystick(): VirtualJoystick;
  21467. getRightJoystick(): VirtualJoystick;
  21468. checkInputs(): void;
  21469. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  21470. detachControl(element: Nullable<HTMLElement>): void;
  21471. getClassName(): string;
  21472. getSimpleName(): string;
  21473. }
  21474. }
  21475. declare module BABYLON {
  21476. class VRCameraMetrics {
  21477. hResolution: number;
  21478. vResolution: number;
  21479. hScreenSize: number;
  21480. vScreenSize: number;
  21481. vScreenCenter: number;
  21482. eyeToScreenDistance: number;
  21483. lensSeparationDistance: number;
  21484. interpupillaryDistance: number;
  21485. distortionK: number[];
  21486. chromaAbCorrection: number[];
  21487. postProcessScaleFactor: number;
  21488. lensCenterOffset: number;
  21489. compensateDistortion: boolean;
  21490. readonly aspectRatio: number;
  21491. readonly aspectRatioFov: number;
  21492. readonly leftHMatrix: Matrix;
  21493. readonly rightHMatrix: Matrix;
  21494. readonly leftPreViewMatrix: Matrix;
  21495. readonly rightPreViewMatrix: Matrix;
  21496. static GetDefault(): VRCameraMetrics;
  21497. }
  21498. }
  21499. declare module BABYLON {
  21500. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  21501. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  21502. getClassName(): string;
  21503. }
  21504. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  21505. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  21506. getClassName(): string;
  21507. }
  21508. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  21509. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  21510. getClassName(): string;
  21511. }
  21512. }
  21513. declare module BABYLON {
  21514. /**
  21515. * Options to modify the vr teleportation behavior.
  21516. */
  21517. interface VRTeleportationOptions {
  21518. /**
  21519. * The name of the mesh which should be used as the teleportation floor. (default: null)
  21520. */
  21521. floorMeshName?: string;
  21522. /**
  21523. * A list of meshes to be used as the teleportation floor. (default: empty)
  21524. */
  21525. floorMeshes?: Mesh[];
  21526. }
  21527. /**
  21528. * Options to modify the vr experience helper's behavior.
  21529. */
  21530. interface VRExperienceHelperOptions extends WebVROptions {
  21531. /**
  21532. * Create a DeviceOrientationCamera to be used as your out of vr camera.
  21533. */
  21534. createDeviceOrientationCamera?: boolean;
  21535. /**
  21536. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found.
  21537. */
  21538. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  21539. }
  21540. /**
  21541. * Helps to quickly add VR support to an existing scene.
  21542. * See http://doc.babylonjs.com/how_to/webvr_helper
  21543. */
  21544. class VRExperienceHelper {
  21545. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  21546. private _scene;
  21547. private _position;
  21548. private _btnVR;
  21549. private _btnVRDisplayed;
  21550. private _webVRsupported;
  21551. private _webVRready;
  21552. private _webVRrequesting;
  21553. private _webVRpresenting;
  21554. private _fullscreenVRpresenting;
  21555. private _canvas;
  21556. private _webVRCamera;
  21557. private _vrDeviceOrientationCamera;
  21558. private _deviceOrientationCamera;
  21559. private _existingCamera;
  21560. private _onKeyDown;
  21561. private _onVrDisplayPresentChange;
  21562. private _onVRDisplayChanged;
  21563. private _onVRRequestPresentStart;
  21564. private _onVRRequestPresentComplete;
  21565. /**
  21566. * Observable raised when entering VR.
  21567. */
  21568. onEnteringVRObservable: Observable<VRExperienceHelper>;
  21569. /**
  21570. * Observable raised when exiting VR.
  21571. */
  21572. onExitingVRObservable: Observable<VRExperienceHelper>;
  21573. /**
  21574. * Observable raised when controller mesh is loaded.
  21575. */
  21576. onControllerMeshLoadedObservable: Observable<WebVRController>;
  21577. /** Return this.onEnteringVRObservable
  21578. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  21579. */
  21580. readonly onEnteringVR: Observable<VRExperienceHelper>;
  21581. /** Return this.onExitingVRObservable
  21582. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  21583. */
  21584. readonly onExitingVR: Observable<VRExperienceHelper>;
  21585. /** Return this.onControllerMeshLoadedObservable
  21586. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  21587. */
  21588. readonly onControllerMeshLoaded: Observable<WebVRController>;
  21589. private _rayLength;
  21590. private _useCustomVRButton;
  21591. private _teleportationRequested;
  21592. private _teleportationEnabledOnLeftController;
  21593. private _teleportationEnabledOnRightController;
  21594. private _interactionsEnabledOnLeftController;
  21595. private _interactionsEnabledOnRightController;
  21596. private _leftControllerReady;
  21597. private _rightControllerReady;
  21598. private _floorMeshName;
  21599. private _floorMeshesCollection;
  21600. private _teleportationAllowed;
  21601. private _rotationAllowed;
  21602. private _teleportationRequestInitiated;
  21603. private _teleportationBackRequestInitiated;
  21604. private teleportBackwardsVector;
  21605. private _rotationRightAsked;
  21606. private _rotationLeftAsked;
  21607. private _teleportationTarget;
  21608. private _isDefaultTeleportationTarget;
  21609. private _postProcessMove;
  21610. private _passProcessMove;
  21611. private _teleportationFillColor;
  21612. private _teleportationBorderColor;
  21613. private _rotationAngle;
  21614. private _haloCenter;
  21615. private _gazeTracker;
  21616. private _padSensibilityUp;
  21617. private _padSensibilityDown;
  21618. private _leftLaserPointer;
  21619. private _rightLaserPointer;
  21620. private _currentMeshSelected;
  21621. /**
  21622. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  21623. */
  21624. onNewMeshSelected: Observable<AbstractMesh>;
  21625. /**
  21626. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  21627. */
  21628. onNewMeshPicked: Observable<PickingInfo>;
  21629. private _circleEase;
  21630. /**
  21631. * Observable raised before camera teleportation
  21632. */
  21633. onBeforeCameraTeleport: Observable<Vector3>;
  21634. /**
  21635. * Observable raised after camera teleportation
  21636. */
  21637. onAfterCameraTeleport: Observable<Vector3>;
  21638. /**
  21639. * Observable raised when current selected mesh gets unselected
  21640. */
  21641. onSelectedMeshUnselected: Observable<AbstractMesh>;
  21642. private _raySelectionPredicate;
  21643. /**
  21644. * To be optionaly changed by user to define custom ray selection
  21645. */
  21646. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  21647. /**
  21648. * To be optionaly changed by user to define custom selection logic (after ray selection)
  21649. */
  21650. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  21651. /**
  21652. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  21653. */
  21654. teleportationEnabled: boolean;
  21655. private _currentHit;
  21656. private _pointerDownOnMeshAsked;
  21657. private _isActionableMesh;
  21658. private _defaultHeight;
  21659. private _teleportationInitialized;
  21660. private _interactionsEnabled;
  21661. private _interactionsRequested;
  21662. private _displayGaze;
  21663. private _displayLaserPointer;
  21664. private _dpadPressed;
  21665. /**
  21666. * The mesh used to display where the user is going to teleport.
  21667. */
  21668. /**
  21669. * Sets the mesh to be used to display where the user is going to teleport.
  21670. */
  21671. teleportationTarget: Mesh;
  21672. /**
  21673. * If the ray of the gaze should be displayed.
  21674. */
  21675. /**
  21676. * Sets if the ray of the gaze should be displayed.
  21677. */
  21678. displayGaze: boolean;
  21679. /**
  21680. * If the ray of the LaserPointer should be displayed.
  21681. */
  21682. /**
  21683. * Sets if the ray of the LaserPointer should be displayed.
  21684. */
  21685. displayLaserPointer: boolean;
  21686. /**
  21687. * The deviceOrientationCamera used as the camera when not in VR.
  21688. */
  21689. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  21690. /**
  21691. * Based on the current WebVR support, returns the current VR camera used.
  21692. */
  21693. readonly currentVRCamera: Nullable<Camera>;
  21694. /**
  21695. * The webVRCamera which is used when in VR.
  21696. */
  21697. readonly webVRCamera: WebVRFreeCamera;
  21698. /**
  21699. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  21700. */
  21701. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  21702. /**
  21703. * Instantiates a VRExperienceHelper.
  21704. * Helps to quickly add VR support to an existing scene.
  21705. * @param scene The scene the VRExperienceHelper belongs to.
  21706. * @param webVROptions Options to modify the vr experience helper's behavior.
  21707. */
  21708. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  21709. private _onDefaultMeshLoaded(webVRController);
  21710. private _onResize;
  21711. private _onFullscreenChange;
  21712. /**
  21713. * Gets a value indicating if we are currently in VR mode.
  21714. */
  21715. readonly isInVRMode: boolean;
  21716. private onVrDisplayPresentChange();
  21717. private onVRDisplayChanged(eventArgs);
  21718. private moveButtonToBottomRight();
  21719. private displayVRButton();
  21720. private updateButtonVisibility();
  21721. /**
  21722. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  21723. * Otherwise, will use the fullscreen API.
  21724. */
  21725. enterVR(): void;
  21726. /**
  21727. * Attempt to exit VR, or fullscreen.
  21728. */
  21729. exitVR(): void;
  21730. /**
  21731. * The position of the vr experience helper.
  21732. */
  21733. /**
  21734. * Sets the position of the vr experience helper.
  21735. */
  21736. position: Vector3;
  21737. /**
  21738. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  21739. */
  21740. enableInteractions(): void;
  21741. private beforeRender;
  21742. private _isTeleportationFloor(mesh);
  21743. /**
  21744. * Adds a floor mesh to be used for teleportation.
  21745. * @param floorMesh the mesh to be used for teleportation.
  21746. */
  21747. addFloorMesh(floorMesh: Mesh): void;
  21748. /**
  21749. * Removes a floor mesh from being used for teleportation.
  21750. * @param floorMesh the mesh to be removed.
  21751. */
  21752. removeFloorMesh(floorMesh: Mesh): void;
  21753. /**
  21754. * Enables interactions and teleportation using the VR controllers and gaze.
  21755. * @param vrTeleportationOptions options to modify teleportation behavior.
  21756. */
  21757. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  21758. private _onNewGamepadConnected;
  21759. private _tryEnableInteractionOnController;
  21760. private _onNewGamepadDisconnected;
  21761. private _enableInteractionOnController(webVRController);
  21762. private _checkTeleportWithRay(stateObject, webVRController?);
  21763. private _selectionPointerDown();
  21764. private _selectionPointerUp();
  21765. private _checkRotate(stateObject);
  21766. private _checkTeleportBackwards(stateObject);
  21767. private _enableTeleportationOnController(webVRController);
  21768. private _createGazeTracker();
  21769. private _createTeleportationCircles();
  21770. private _displayTeleportationTarget();
  21771. private _hideTeleportationTarget();
  21772. private _rotateCamera(right);
  21773. private _moveTeleportationSelectorTo(hit);
  21774. private _workingVector;
  21775. private _workingQuaternion;
  21776. private _workingMatrix;
  21777. private _teleportCamera(location?);
  21778. private _castRayAndSelectObject();
  21779. private _notifySelectedMeshUnselected();
  21780. /**
  21781. * Sets the color of the laser ray from the vr controllers.
  21782. * @param color new color for the ray.
  21783. */
  21784. changeLaserColor(color: Color3): void;
  21785. /**
  21786. * Sets the color of the ray from the vr headsets gaze.
  21787. * @param color new color for the ray.
  21788. */
  21789. changeGazeColor(color: Color3): void;
  21790. /**
  21791. * Exits VR and disposes of the vr experience helper
  21792. */
  21793. dispose(): void;
  21794. /**
  21795. * Gets the name of the VRExperienceHelper class
  21796. * @returns "VRExperienceHelper"
  21797. */
  21798. getClassName(): string;
  21799. }
  21800. }
  21801. declare var HMDVRDevice: any;
  21802. declare var VRDisplay: any;
  21803. declare var VRFrameData: any;
  21804. declare module BABYLON {
  21805. /**
  21806. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  21807. * IMPORTANT!! The data is right-hand data.
  21808. * @export
  21809. * @interface DevicePose
  21810. */
  21811. interface DevicePose {
  21812. /**
  21813. * The position of the device, values in array are [x,y,z].
  21814. */
  21815. readonly position?: Float32Array;
  21816. /**
  21817. * The linearVelocity of the device, values in array are [x,y,z].
  21818. */
  21819. readonly linearVelocity?: Float32Array;
  21820. /**
  21821. * The linearAcceleration of the device, values in array are [x,y,z].
  21822. */
  21823. readonly linearAcceleration?: Float32Array;
  21824. /**
  21825. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  21826. */
  21827. readonly orientation?: Float32Array;
  21828. /**
  21829. * The angularVelocity of the device, values in array are [x,y,z].
  21830. */
  21831. readonly angularVelocity?: Float32Array;
  21832. /**
  21833. * The angularAcceleration of the device, values in array are [x,y,z].
  21834. */
  21835. readonly angularAcceleration?: Float32Array;
  21836. }
  21837. /**
  21838. * Interface representing a pose controlled object in Babylon.
  21839. * A pose controlled object has both regular pose values as well as pose values
  21840. * from an external device such as a VR head mounted display
  21841. */
  21842. interface PoseControlled {
  21843. /**
  21844. * The position of the object in babylon space.
  21845. */
  21846. position: Vector3;
  21847. /**
  21848. * The rotation quaternion of the object in babylon space.
  21849. */
  21850. rotationQuaternion: Quaternion;
  21851. /**
  21852. * The position of the device in babylon space.
  21853. */
  21854. devicePosition?: Vector3;
  21855. /**
  21856. * The rotation quaternion of the device in babylon space.
  21857. */
  21858. deviceRotationQuaternion: Quaternion;
  21859. /**
  21860. * The raw pose coming from the device.
  21861. */
  21862. rawPose: Nullable<DevicePose>;
  21863. /**
  21864. * The scale of the device to be used when translating from device space to babylon space.
  21865. */
  21866. deviceScaleFactor: number;
  21867. /**
  21868. * Updates the poseControlled values based on the input device pose.
  21869. * @param poseData the pose data to update the object with
  21870. */
  21871. updateFromDevice(poseData: DevicePose): void;
  21872. }
  21873. /**
  21874. * Set of options to customize the webVRCamera
  21875. */
  21876. interface WebVROptions {
  21877. /**
  21878. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  21879. */
  21880. trackPosition?: boolean;
  21881. /**
  21882. * Sets the scale of the vrDevice in babylon space. (default: 1)
  21883. */
  21884. positionScale?: number;
  21885. /**
  21886. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  21887. */
  21888. displayName?: string;
  21889. /**
  21890. * Should the native controller meshes be initialized. (default: true)
  21891. */
  21892. controllerMeshes?: boolean;
  21893. /**
  21894. * Creating a default HemiLight only on controllers. (default: true)
  21895. */
  21896. defaultLightingOnControllers?: boolean;
  21897. /**
  21898. * If you don't want to use the default VR button of the helper. (default: false)
  21899. */
  21900. useCustomVRButton?: boolean;
  21901. /**
  21902. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  21903. */
  21904. customVRButton?: HTMLButtonElement;
  21905. /**
  21906. * To change the length of the ray for gaze/controllers. (default: 100)
  21907. */
  21908. rayLength?: number;
  21909. /**
  21910. * To change the default offset from the ground to account for user's height. (default: 1.7)
  21911. */
  21912. defaultHeight?: number;
  21913. }
  21914. /**
  21915. * This represents a WebVR camera.
  21916. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  21917. * @example http://doc.babylonjs.com/how_to/webvr_camera
  21918. */
  21919. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  21920. private webVROptions;
  21921. /**
  21922. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  21923. */
  21924. _vrDevice: any;
  21925. /**
  21926. * The rawPose of the vrDevice.
  21927. */
  21928. rawPose: Nullable<DevicePose>;
  21929. private _onVREnabled;
  21930. private _specsVersion;
  21931. private _attached;
  21932. private _frameData;
  21933. protected _descendants: Array<Node>;
  21934. private _deviceRoomPosition;
  21935. private _deviceRoomRotationQuaternion;
  21936. private _standingMatrix;
  21937. /**
  21938. * Represents device position in babylon space.
  21939. */
  21940. devicePosition: Vector3;
  21941. /**
  21942. * Represents device rotation in babylon space.
  21943. */
  21944. deviceRotationQuaternion: Quaternion;
  21945. /**
  21946. * The scale of the device to be used when translating from device space to babylon space.
  21947. */
  21948. deviceScaleFactor: number;
  21949. private _deviceToWorld;
  21950. private _worldToDevice;
  21951. /**
  21952. * References to the webVR controllers for the vrDevice.
  21953. */
  21954. controllers: Array<WebVRController>;
  21955. /**
  21956. * Emits an event when a controller is attached.
  21957. */
  21958. onControllersAttachedObservable: Observable<WebVRController[]>;
  21959. /**
  21960. * Emits an event when a controller's mesh has been loaded;
  21961. */
  21962. onControllerMeshLoadedObservable: Observable<WebVRController>;
  21963. /**
  21964. * If the rig cameras be used as parent instead of this camera.
  21965. */
  21966. rigParenting: boolean;
  21967. private _lightOnControllers;
  21968. private _defaultHeight?;
  21969. /**
  21970. * Instantiates a WebVRFreeCamera.
  21971. * @param name The name of the WebVRFreeCamera
  21972. * @param position The starting anchor position for the camera
  21973. * @param scene The scene the camera belongs to
  21974. * @param webVROptions a set of customizable options for the webVRCamera
  21975. */
  21976. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  21977. /**
  21978. * Gets the device distance from the ground.
  21979. * @returns the distance from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  21980. */
  21981. deviceDistanceToRoomGround(): number;
  21982. /**
  21983. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  21984. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  21985. */
  21986. useStandingMatrix(callback?: (bool: boolean) => void): void;
  21987. /**
  21988. * Disposes the camera
  21989. */
  21990. dispose(): void;
  21991. /**
  21992. * Gets a vrController by name.
  21993. * @param name The name of the controller to retreive
  21994. * @returns the controller matching the name specified or null if not found
  21995. */
  21996. getControllerByName(name: string): Nullable<WebVRController>;
  21997. private _leftController;
  21998. /**
  21999. * The controller corrisponding to the users left hand.
  22000. */
  22001. readonly leftController: Nullable<WebVRController>;
  22002. private _rightController;
  22003. /**
  22004. * The controller corrisponding to the users right hand.
  22005. */
  22006. readonly rightController: Nullable<WebVRController>;
  22007. /**
  22008. * Casts a ray forward from the vrCamera's gaze.
  22009. * @param length Length of the ray (default: 100)
  22010. * @returns the ray corrisponding to the gaze
  22011. */
  22012. getForwardRay(length?: number): Ray;
  22013. /**
  22014. * Updates the camera based on device's frame data
  22015. */
  22016. _checkInputs(): void;
  22017. /**
  22018. * Updates the poseControlled values based on the input device pose.
  22019. * @param poseData Pose coming from the device
  22020. */
  22021. updateFromDevice(poseData: DevicePose): void;
  22022. /**
  22023. * WebVR's attach control will start broadcasting frames to the device.
  22024. * Note that in certain browsers (chrome for example) this function must be called
  22025. * within a user-interaction callback. Example:
  22026. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  22027. *
  22028. * @param element html element to attach the vrDevice to
  22029. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  22030. */
  22031. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  22032. /**
  22033. * Detaches the camera from the html element and disables VR
  22034. *
  22035. * @param element html element to detach from
  22036. */
  22037. detachControl(element: HTMLElement): void;
  22038. /**
  22039. * @returns the name of this class
  22040. */
  22041. getClassName(): string;
  22042. /**
  22043. * Calls resetPose on the vrDisplay
  22044. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  22045. */
  22046. resetToCurrentRotation(): void;
  22047. /**
  22048. * Updates the rig cameras (left and right eye)
  22049. */
  22050. _updateRigCameras(): void;
  22051. private _workingVector;
  22052. private _oneVector;
  22053. private _workingMatrix;
  22054. private updateCacheCalled;
  22055. /**
  22056. * Updates the cached values of the camera
  22057. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  22058. */
  22059. _updateCache(ignoreParentClass?: boolean): void;
  22060. /**
  22061. * Updates the current device position and rotation in the babylon world
  22062. */
  22063. update(): void;
  22064. /**
  22065. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  22066. * @returns an identity matrix
  22067. */
  22068. _getViewMatrix(): Matrix;
  22069. /**
  22070. * This function is called by the two RIG cameras.
  22071. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  22072. */
  22073. protected _getWebVRViewMatrix(): Matrix;
  22074. protected _getWebVRProjectionMatrix(): Matrix;
  22075. private _onGamepadConnectedObserver;
  22076. private _onGamepadDisconnectedObserver;
  22077. /**
  22078. * Initializes the controllers and their meshes
  22079. */
  22080. initControllers(): void;
  22081. }
  22082. }
  22083. declare module BABYLON {
  22084. class GearVRController extends WebVRController {
  22085. static MODEL_BASE_URL: string;
  22086. static MODEL_FILENAME: string;
  22087. static readonly GAMEPAD_ID_PREFIX: string;
  22088. private readonly _buttonIndexToObservableNameMap;
  22089. constructor(vrGamepad: any);
  22090. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  22091. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  22092. }
  22093. }
  22094. declare module BABYLON {
  22095. class GenericController extends WebVRController {
  22096. static readonly MODEL_BASE_URL: string;
  22097. static readonly MODEL_FILENAME: string;
  22098. constructor(vrGamepad: any);
  22099. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  22100. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  22101. }
  22102. }
  22103. declare module BABYLON {
  22104. class OculusTouchController extends WebVRController {
  22105. static MODEL_BASE_URL: string;
  22106. static MODEL_LEFT_FILENAME: string;
  22107. static MODEL_RIGHT_FILENAME: string;
  22108. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  22109. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  22110. constructor(vrGamepad: any);
  22111. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  22112. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  22113. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  22114. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  22115. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  22116. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  22117. }
  22118. }
  22119. declare module BABYLON {
  22120. enum PoseEnabledControllerType {
  22121. VIVE = 0,
  22122. OCULUS = 1,
  22123. WINDOWS = 2,
  22124. GEAR_VR = 3,
  22125. GENERIC = 4,
  22126. }
  22127. interface MutableGamepadButton {
  22128. value: number;
  22129. touched: boolean;
  22130. pressed: boolean;
  22131. }
  22132. interface ExtendedGamepadButton extends GamepadButton {
  22133. readonly pressed: boolean;
  22134. readonly touched: boolean;
  22135. readonly value: number;
  22136. }
  22137. class PoseEnabledControllerHelper {
  22138. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | GenericController;
  22139. }
  22140. class PoseEnabledController extends Gamepad implements PoseControlled {
  22141. private _deviceRoomPosition;
  22142. private _deviceRoomRotationQuaternion;
  22143. devicePosition: Vector3;
  22144. deviceRotationQuaternion: Quaternion;
  22145. deviceScaleFactor: number;
  22146. position: Vector3;
  22147. rotationQuaternion: Quaternion;
  22148. controllerType: PoseEnabledControllerType;
  22149. private _calculatedPosition;
  22150. private _calculatedRotation;
  22151. rawPose: DevicePose;
  22152. _mesh: Nullable<AbstractMesh>;
  22153. private _poseControlledCamera;
  22154. private _leftHandSystemQuaternion;
  22155. _deviceToWorld: Matrix;
  22156. constructor(browserGamepad: any);
  22157. private _workingMatrix;
  22158. update(): void;
  22159. updateFromDevice(poseData: DevicePose): void;
  22160. attachToMesh(mesh: AbstractMesh): void;
  22161. attachToPoseControlledCamera(camera: TargetCamera): void;
  22162. dispose(): void;
  22163. readonly mesh: Nullable<AbstractMesh>;
  22164. getForwardRay(length?: number): Ray;
  22165. }
  22166. }
  22167. declare module BABYLON {
  22168. class ViveController extends WebVRController {
  22169. static MODEL_BASE_URL: string;
  22170. static MODEL_FILENAME: string;
  22171. constructor(vrGamepad: any);
  22172. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  22173. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  22174. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  22175. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  22176. /**
  22177. * Vive mapping:
  22178. * 0: touchpad
  22179. * 1: trigger
  22180. * 2: left AND right buttons
  22181. * 3: menu button
  22182. */
  22183. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  22184. }
  22185. }
  22186. declare module BABYLON {
  22187. abstract class WebVRController extends PoseEnabledController {
  22188. protected _defaultModel: AbstractMesh;
  22189. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  22190. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  22191. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  22192. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  22193. onPadValuesChangedObservable: Observable<StickValues>;
  22194. protected _buttons: Array<MutableGamepadButton>;
  22195. private _onButtonStateChange;
  22196. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  22197. pad: StickValues;
  22198. hand: string;
  22199. readonly defaultModel: AbstractMesh;
  22200. constructor(vrGamepad: any);
  22201. update(): void;
  22202. protected abstract handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  22203. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  22204. private _setButtonValue(newState, currentState, buttonIndex);
  22205. private _changes;
  22206. private _checkChanges(newState, currentState);
  22207. dispose(): void;
  22208. }
  22209. }
  22210. declare module BABYLON {
  22211. class WindowsMotionController extends WebVRController {
  22212. static MODEL_BASE_URL: string;
  22213. static MODEL_LEFT_FILENAME: string;
  22214. static MODEL_RIGHT_FILENAME: string;
  22215. static readonly GAMEPAD_ID_PREFIX: string;
  22216. private static readonly GAMEPAD_ID_PATTERN;
  22217. private _loadedMeshInfo;
  22218. private readonly _mapping;
  22219. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  22220. onTrackpadValuesChangedObservable: Observable<StickValues>;
  22221. trackpad: StickValues;
  22222. constructor(vrGamepad: any);
  22223. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  22224. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  22225. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  22226. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  22227. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  22228. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  22229. /**
  22230. * Called once per frame by the engine.
  22231. */
  22232. update(): void;
  22233. /**
  22234. * Called once for each button that changed state since the last frame
  22235. * @param buttonIdx Which button index changed
  22236. * @param state New state of the button
  22237. * @param changes Which properties on the state changed since last frame
  22238. */
  22239. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  22240. protected lerpButtonTransform(buttonName: string, buttonValue: number): void;
  22241. protected lerpAxisTransform(axis: number, axisValue: number): void;
  22242. /**
  22243. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  22244. * @param scene scene in which to add meshes
  22245. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  22246. */
  22247. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  22248. /**
  22249. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  22250. * can be transformed by button presses and axes values, based on this._mapping.
  22251. *
  22252. * @param scene scene in which the meshes exist
  22253. * @param meshes list of meshes that make up the controller model to process
  22254. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  22255. */
  22256. private processModel(scene, meshes);
  22257. private createMeshInfo(rootNode);
  22258. getForwardRay(length?: number): Ray;
  22259. dispose(): void;
  22260. }
  22261. }
  22262. declare module BABYLON {
  22263. /**
  22264. * Interface to implement to create a shadow generator compatible with BJS.
  22265. */
  22266. interface IShadowGenerator {
  22267. /**
  22268. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  22269. * @returns The render target texture if present otherwise, null
  22270. */
  22271. getShadowMap(): Nullable<RenderTargetTexture>;
  22272. /**
  22273. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  22274. * @returns The render target texture if the shadow map is present otherwise, null
  22275. */
  22276. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  22277. /**
  22278. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  22279. * @param subMesh The submesh we want to render in the shadow map
  22280. * @param useInstances Defines wether will draw in the map using instances
  22281. * @returns true if ready otherwise, false
  22282. */
  22283. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22284. /**
  22285. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  22286. * @param defines Defines of the material we want to update
  22287. * @param lightIndex Index of the light in the enabled light list of the material
  22288. */
  22289. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  22290. /**
  22291. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  22292. * defined in the generator but impacting the effect).
  22293. * It implies the unifroms available on the materials are the standard BJS ones.
  22294. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  22295. * @param effect The effect we are binfing the information for
  22296. */
  22297. bindShadowLight(lightIndex: string, effect: Effect): void;
  22298. /**
  22299. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  22300. * (eq to shadow prjection matrix * light transform matrix)
  22301. * @returns The transform matrix used to create the shadow map
  22302. */
  22303. getTransformMatrix(): Matrix;
  22304. /**
  22305. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  22306. * Cube and 2D textures for instance.
  22307. */
  22308. recreateShadowMap(): void;
  22309. /**
  22310. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  22311. * @param onCompiled Callback triggered at the and of the effects compilation
  22312. * @param options Sets of optional options forcing the compilation with different modes
  22313. */
  22314. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  22315. useInstances: boolean;
  22316. }>): void;
  22317. /**
  22318. * Serializes the shadow generator setup to a json object.
  22319. * @returns The serialized JSON object
  22320. */
  22321. serialize(): any;
  22322. /**
  22323. * Disposes the Shadow map and related Textures and effects.
  22324. */
  22325. dispose(): void;
  22326. }
  22327. /**
  22328. * Default implementation of @see IShadowGenerator.
  22329. * This is the main object responsible of generating shadows in the framework.
  22330. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  22331. */
  22332. class ShadowGenerator implements IShadowGenerator {
  22333. private static _FILTER_NONE;
  22334. private static _FILTER_EXPONENTIALSHADOWMAP;
  22335. private static _FILTER_POISSONSAMPLING;
  22336. private static _FILTER_BLUREXPONENTIALSHADOWMAP;
  22337. private static _FILTER_CLOSEEXPONENTIALSHADOWMAP;
  22338. private static _FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  22339. /**
  22340. * Shadow generator mode None: no filtering applied.
  22341. */
  22342. static readonly FILTER_NONE: number;
  22343. /**
  22344. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  22345. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  22346. */
  22347. static readonly FILTER_POISSONSAMPLING: number;
  22348. /**
  22349. * Shadow generator mode ESM: Exponential Shadow Mapping.
  22350. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  22351. */
  22352. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  22353. /**
  22354. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  22355. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  22356. */
  22357. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  22358. /**
  22359. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  22360. * edge artifacts on steep falloff.
  22361. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  22362. */
  22363. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  22364. /**
  22365. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  22366. * edge artifacts on steep falloff.
  22367. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  22368. */
  22369. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  22370. private _bias;
  22371. /**
  22372. * Gets the bias: offset applied on the depth preventing acnea.
  22373. */
  22374. /**
  22375. * Sets the bias: offset applied on the depth preventing acnea.
  22376. */
  22377. bias: number;
  22378. private _blurBoxOffset;
  22379. /**
  22380. * Gets the blur box offset: offset applied during the blur pass.
  22381. * Only usefull if useKernelBlur = false
  22382. */
  22383. /**
  22384. * Sets the blur box offset: offset applied during the blur pass.
  22385. * Only usefull if useKernelBlur = false
  22386. */
  22387. blurBoxOffset: number;
  22388. private _blurScale;
  22389. /**
  22390. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  22391. * 2 means half of the size.
  22392. */
  22393. /**
  22394. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  22395. * 2 means half of the size.
  22396. */
  22397. blurScale: number;
  22398. private _blurKernel;
  22399. /**
  22400. * Gets the blur kernel: kernel size of the blur pass.
  22401. * Only usefull if useKernelBlur = true
  22402. */
  22403. /**
  22404. * Sets the blur kernel: kernel size of the blur pass.
  22405. * Only usefull if useKernelBlur = true
  22406. */
  22407. blurKernel: number;
  22408. private _useKernelBlur;
  22409. /**
  22410. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  22411. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  22412. */
  22413. /**
  22414. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  22415. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  22416. */
  22417. useKernelBlur: boolean;
  22418. private _depthScale;
  22419. /**
  22420. * Gets the depth scale used in ESM mode.
  22421. */
  22422. /**
  22423. * Sets the depth scale used in ESM mode.
  22424. * This can override the scale stored on the light.
  22425. */
  22426. depthScale: number;
  22427. private _filter;
  22428. /**
  22429. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  22430. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  22431. */
  22432. /**
  22433. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  22434. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  22435. */
  22436. filter: number;
  22437. /**
  22438. * Gets if the current filter is set to Poisson Sampling aka PCF.
  22439. */
  22440. /**
  22441. * Sets the current filter to Poisson Sampling aka PCF.
  22442. */
  22443. usePoissonSampling: boolean;
  22444. /**
  22445. * Gets if the current filter is set to VSM.
  22446. * DEPRECATED. Should use useExponentialShadowMap instead.
  22447. */
  22448. /**
  22449. * Sets the current filter is to VSM.
  22450. * DEPRECATED. Should use useExponentialShadowMap instead.
  22451. */
  22452. useVarianceShadowMap: boolean;
  22453. /**
  22454. * Gets if the current filter is set to blurred VSM.
  22455. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  22456. */
  22457. /**
  22458. * Sets the current filter is to blurred VSM.
  22459. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  22460. */
  22461. useBlurVarianceShadowMap: boolean;
  22462. /**
  22463. * Gets if the current filter is set to ESM.
  22464. */
  22465. /**
  22466. * Sets the current filter is to ESM.
  22467. */
  22468. useExponentialShadowMap: boolean;
  22469. /**
  22470. * Gets if the current filter is set to filtered ESM.
  22471. */
  22472. /**
  22473. * Gets if the current filter is set to filtered ESM.
  22474. */
  22475. useBlurExponentialShadowMap: boolean;
  22476. /**
  22477. * Gets if the current filter is set to "close ESM" (using the inverse of the
  22478. * exponential to prevent steep falloff artifacts).
  22479. */
  22480. /**
  22481. * Sets the current filter to "close ESM" (using the inverse of the
  22482. * exponential to prevent steep falloff artifacts).
  22483. */
  22484. useCloseExponentialShadowMap: boolean;
  22485. /**
  22486. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  22487. * exponential to prevent steep falloff artifacts).
  22488. */
  22489. /**
  22490. * Sets the current filter to fileterd "close ESM" (using the inverse of the
  22491. * exponential to prevent steep falloff artifacts).
  22492. */
  22493. useBlurCloseExponentialShadowMap: boolean;
  22494. private _darkness;
  22495. /**
  22496. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  22497. * 0 means strongest and 1 would means no shadow.
  22498. * @returns the darkness.
  22499. */
  22500. getDarkness(): number;
  22501. /**
  22502. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  22503. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  22504. * @returns the shadow generator allowing fluent coding.
  22505. */
  22506. setDarkness(darkness: number): ShadowGenerator;
  22507. private _transparencyShadow;
  22508. /**
  22509. * Sets the ability to have transparent shadow (boolean).
  22510. * @param transparent True if transparent else False
  22511. * @returns the shadow generator allowing fluent coding
  22512. */
  22513. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  22514. private _shadowMap;
  22515. private _shadowMap2;
  22516. /**
  22517. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  22518. * @returns The render target texture if present otherwise, null
  22519. */
  22520. getShadowMap(): Nullable<RenderTargetTexture>;
  22521. /**
  22522. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  22523. * @returns The render target texture if the shadow map is present otherwise, null
  22524. */
  22525. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  22526. /**
  22527. * Helper function to add a mesh and its descendants to the list of shadow casters.
  22528. * @param mesh Mesh to add
  22529. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  22530. * @returns the Shadow Generator itself
  22531. */
  22532. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  22533. /**
  22534. * Helper function to remove a mesh and its descendants from the list of shadow casters
  22535. * @param mesh Mesh to remove
  22536. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  22537. * @returns the Shadow Generator itself
  22538. */
  22539. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  22540. /**
  22541. * Controls the extent to which the shadows fade out at the edge of the frustum
  22542. * Used only by directionals and spots
  22543. */
  22544. frustumEdgeFalloff: number;
  22545. private _light;
  22546. /**
  22547. * Returns the associated light object.
  22548. * @returns the light generating the shadow
  22549. */
  22550. getLight(): IShadowLight;
  22551. /**
  22552. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  22553. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  22554. * It might on the other hand introduce peter panning.
  22555. */
  22556. forceBackFacesOnly: boolean;
  22557. private _scene;
  22558. private _lightDirection;
  22559. private _effect;
  22560. private _viewMatrix;
  22561. private _projectionMatrix;
  22562. private _transformMatrix;
  22563. private _cachedPosition;
  22564. private _cachedDirection;
  22565. private _cachedDefines;
  22566. private _currentRenderID;
  22567. private _boxBlurPostprocess;
  22568. private _kernelBlurXPostprocess;
  22569. private _kernelBlurYPostprocess;
  22570. private _blurPostProcesses;
  22571. private _mapSize;
  22572. private _currentFaceIndex;
  22573. private _currentFaceIndexCache;
  22574. private _textureType;
  22575. private _defaultTextureMatrix;
  22576. /**
  22577. * Creates a ShadowGenerator object.
  22578. * A ShadowGenerator is the required tool to use the shadows.
  22579. * Each light casting shadows needs to use its own ShadowGenerator.
  22580. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  22581. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  22582. * @param light The light object generating the shadows.
  22583. * @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.
  22584. */
  22585. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  22586. private _initializeGenerator();
  22587. private _initializeShadowMap();
  22588. private _initializeBlurRTTAndPostProcesses();
  22589. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  22590. private _renderSubMeshForShadowMap(subMesh);
  22591. private _applyFilterValues();
  22592. /**
  22593. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  22594. * @param onCompiled Callback triggered at the and of the effects compilation
  22595. * @param options Sets of optional options forcing the compilation with different modes
  22596. */
  22597. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  22598. useInstances: boolean;
  22599. }>): void;
  22600. /**
  22601. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  22602. * @param subMesh The submesh we want to render in the shadow map
  22603. * @param useInstances Defines wether will draw in the map using instances
  22604. * @returns true if ready otherwise, false
  22605. */
  22606. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22607. /**
  22608. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  22609. * @param defines Defines of the material we want to update
  22610. * @param lightIndex Index of the light in the enabled light list of the material
  22611. */
  22612. prepareDefines(defines: any, lightIndex: number): void;
  22613. /**
  22614. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  22615. * defined in the generator but impacting the effect).
  22616. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  22617. * @param effect The effect we are binfing the information for
  22618. */
  22619. bindShadowLight(lightIndex: string, effect: Effect): void;
  22620. /**
  22621. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  22622. * (eq to shadow prjection matrix * light transform matrix)
  22623. * @returns The transform matrix used to create the shadow map
  22624. */
  22625. getTransformMatrix(): Matrix;
  22626. /**
  22627. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  22628. * Cube and 2D textures for instance.
  22629. */
  22630. recreateShadowMap(): void;
  22631. private _disposeBlurPostProcesses();
  22632. private _disposeRTTandPostProcesses();
  22633. /**
  22634. * Disposes the ShadowGenerator.
  22635. * Returns nothing.
  22636. */
  22637. dispose(): void;
  22638. /**
  22639. * Serializes the shadow generator setup to a json object.
  22640. * @returns The serialized JSON object
  22641. */
  22642. serialize(): any;
  22643. /**
  22644. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  22645. * @param parsedShadowGenerator The JSON object to parse
  22646. * @param scene The scene to create the shadow map for
  22647. * @returns The parsed shadow generator
  22648. */
  22649. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  22650. }
  22651. }
  22652. declare module BABYLON {
  22653. }
  22654. declare module BABYLON {
  22655. /**
  22656. * Background material used to create an efficient environement around your scene.
  22657. */
  22658. class BackgroundMaterial extends PushMaterial {
  22659. /**
  22660. * Standard reflectance value at parallel view angle.
  22661. */
  22662. static StandardReflectance0: number;
  22663. /**
  22664. * Standard reflectance value at grazing angle.
  22665. */
  22666. static StandardReflectance90: number;
  22667. protected _primaryColor: Color3;
  22668. /**
  22669. * Key light Color (multiply against the R channel of the environement texture)
  22670. */
  22671. primaryColor: Color3;
  22672. protected _primaryLevel: float;
  22673. /**
  22674. * Key light Level (allowing HDR output of the background)
  22675. */
  22676. primaryLevel: float;
  22677. protected _secondaryColor: Color3;
  22678. /**
  22679. * Secondary light Color (multiply against the G channel of the environement texture)
  22680. */
  22681. secondaryColor: Color3;
  22682. protected _secondaryLevel: float;
  22683. /**
  22684. * Secondary light Level (allowing HDR output of the background)
  22685. */
  22686. secondaryLevel: float;
  22687. protected _tertiaryColor: Color3;
  22688. /**
  22689. * Tertiary light Color (multiply against the B channel of the environement texture)
  22690. */
  22691. tertiaryColor: Color3;
  22692. protected _tertiaryLevel: float;
  22693. /**
  22694. * Tertiary light Level (allowing HDR output of the background)
  22695. */
  22696. tertiaryLevel: float;
  22697. protected _reflectionTexture: Nullable<BaseTexture>;
  22698. /**
  22699. * Reflection Texture used in the material.
  22700. * Should be author in a specific way for the best result (refer to the documentation).
  22701. */
  22702. reflectionTexture: Nullable<BaseTexture>;
  22703. protected _reflectionBlur: float;
  22704. /**
  22705. * Reflection Texture level of blur.
  22706. *
  22707. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  22708. * texture twice.
  22709. */
  22710. reflectionBlur: float;
  22711. protected _diffuseTexture: Nullable<BaseTexture>;
  22712. /**
  22713. * Diffuse Texture used in the material.
  22714. * Should be author in a specific way for the best result (refer to the documentation).
  22715. */
  22716. diffuseTexture: Nullable<BaseTexture>;
  22717. protected _shadowLights: Nullable<IShadowLight[]>;
  22718. /**
  22719. * Specify the list of lights casting shadow on the material.
  22720. * All scene shadow lights will be included if null.
  22721. */
  22722. shadowLights: Nullable<IShadowLight[]>;
  22723. protected _shadowBlurScale: int;
  22724. /**
  22725. * For the lights having a blurred shadow generator, this can add a second blur pass in order to reach
  22726. * soft lighting on the background.
  22727. */
  22728. shadowBlurScale: int;
  22729. protected _shadowLevel: float;
  22730. /**
  22731. * Helps adjusting the shadow to a softer level if required.
  22732. * 0 means black shadows and 1 means no shadows.
  22733. */
  22734. shadowLevel: float;
  22735. protected _sceneCenter: Vector3;
  22736. /**
  22737. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  22738. * It is usually zero but might be interesting to modify according to your setup.
  22739. */
  22740. sceneCenter: Vector3;
  22741. protected _opacityFresnel: boolean;
  22742. /**
  22743. * This helps specifying that the material is falling off to the sky box at grazing angle.
  22744. * This helps ensuring a nice transition when the camera goes under the ground.
  22745. */
  22746. opacityFresnel: boolean;
  22747. protected _reflectionFresnel: boolean;
  22748. /**
  22749. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  22750. * This helps adding a mirror texture on the ground.
  22751. */
  22752. reflectionFresnel: boolean;
  22753. protected _reflectionFalloffDistance: number;
  22754. /**
  22755. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  22756. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  22757. */
  22758. reflectionFalloffDistance: number;
  22759. protected _reflectionAmount: number;
  22760. /**
  22761. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  22762. */
  22763. reflectionAmount: number;
  22764. protected _reflectionReflectance0: number;
  22765. /**
  22766. * This specifies the weight of the reflection at grazing angle.
  22767. */
  22768. reflectionReflectance0: number;
  22769. protected _reflectionReflectance90: number;
  22770. /**
  22771. * This specifies the weight of the reflection at a perpendicular point of view.
  22772. */
  22773. reflectionReflectance90: number;
  22774. /**
  22775. * Sets the reflection reflectance fresnel values according to the default standard
  22776. * empirically know to work well :-)
  22777. */
  22778. reflectionStandardFresnelWeight: number;
  22779. protected _useRGBColor: boolean;
  22780. /**
  22781. * Helps to directly use the maps channels instead of their level.
  22782. */
  22783. useRGBColor: boolean;
  22784. protected _enableNoise: boolean;
  22785. /**
  22786. * This helps reducing the banding effect that could occur on the background.
  22787. */
  22788. enableNoise: boolean;
  22789. private _maxSimultaneousLights;
  22790. /**
  22791. * Number of Simultaneous lights allowed on the material.
  22792. */
  22793. maxSimultaneousLights: int;
  22794. /**
  22795. * Default configuration related to image processing available in the Background Material.
  22796. */
  22797. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22798. /**
  22799. * Keep track of the image processing observer to allow dispose and replace.
  22800. */
  22801. private _imageProcessingObserver;
  22802. /**
  22803. * Attaches a new image processing configuration to the PBR Material.
  22804. * @param configuration (if null the scene configuration will be use)
  22805. */
  22806. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22807. /**
  22808. * Gets the image processing configuration used either in this material.
  22809. */
  22810. /**
  22811. * Sets the Default image processing configuration used either in the this material.
  22812. *
  22813. * If sets to null, the scene one is in use.
  22814. */
  22815. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  22816. /**
  22817. * Gets wether the color curves effect is enabled.
  22818. */
  22819. /**
  22820. * Sets wether the color curves effect is enabled.
  22821. */
  22822. cameraColorCurvesEnabled: boolean;
  22823. /**
  22824. * Gets wether the color grading effect is enabled.
  22825. */
  22826. /**
  22827. * Gets wether the color grading effect is enabled.
  22828. */
  22829. cameraColorGradingEnabled: boolean;
  22830. /**
  22831. * Gets wether tonemapping is enabled or not.
  22832. */
  22833. /**
  22834. * Sets wether tonemapping is enabled or not
  22835. */
  22836. cameraToneMappingEnabled: boolean;
  22837. /**
  22838. * The camera exposure used on this material.
  22839. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22840. * This corresponds to a photographic exposure.
  22841. */
  22842. /**
  22843. * The camera exposure used on this material.
  22844. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22845. * This corresponds to a photographic exposure.
  22846. */
  22847. cameraExposure: float;
  22848. /**
  22849. * Gets The camera contrast used on this material.
  22850. */
  22851. /**
  22852. * Sets The camera contrast used on this material.
  22853. */
  22854. cameraContrast: float;
  22855. /**
  22856. * Gets the Color Grading 2D Lookup Texture.
  22857. */
  22858. /**
  22859. * Sets the Color Grading 2D Lookup Texture.
  22860. */
  22861. cameraColorGradingTexture: Nullable<BaseTexture>;
  22862. /**
  22863. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22864. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22865. * 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;
  22866. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22867. */
  22868. /**
  22869. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22870. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22871. * 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;
  22872. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22873. */
  22874. cameraColorCurves: Nullable<ColorCurves>;
  22875. private _renderTargets;
  22876. private _reflectionControls;
  22877. /**
  22878. * Instantiates a Background Material in the given scene
  22879. * @param name The friendly name of the material
  22880. * @param scene The scene to add the material to
  22881. */
  22882. constructor(name: string, scene: Scene);
  22883. /**
  22884. * The entire material has been created in order to prevent overdraw.
  22885. * @returns false
  22886. */
  22887. needAlphaTesting(): boolean;
  22888. /**
  22889. * The entire material has been created in order to prevent overdraw.
  22890. * @returns true if blending is enable
  22891. */
  22892. needAlphaBlending(): boolean;
  22893. /**
  22894. * Checks wether the material is ready to be rendered for a given mesh.
  22895. * @param mesh The mesh to render
  22896. * @param subMesh The submesh to check against
  22897. * @param useInstances Specify wether or not the material is used with instances
  22898. * @returns true if all the dependencies are ready (Textures, Effects...)
  22899. */
  22900. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22901. /**
  22902. * Build the uniform buffer used in the material.
  22903. */
  22904. buildUniformLayout(): void;
  22905. /**
  22906. * Unbind the material.
  22907. */
  22908. unbind(): void;
  22909. /**
  22910. * Bind only the world matrix to the material.
  22911. * @param world The world matrix to bind.
  22912. */
  22913. bindOnlyWorldMatrix(world: Matrix): void;
  22914. /**
  22915. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  22916. * @param world The world matrix to bind.
  22917. * @param subMesh The submesh to bind for.
  22918. */
  22919. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22920. /**
  22921. * Dispose the material.
  22922. * @param forceDisposeEffect Force disposal of the associated effect.
  22923. * @param forceDisposeTextures Force disposal of the associated textures.
  22924. */
  22925. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22926. /**
  22927. * Clones the material.
  22928. * @param name The cloned name.
  22929. * @returns The cloned material.
  22930. */
  22931. clone(name: string): BackgroundMaterial;
  22932. /**
  22933. * Serializes the current material to its JSON representation.
  22934. * @returns The JSON representation.
  22935. */
  22936. serialize(): any;
  22937. /**
  22938. * Gets the class name of the material
  22939. * @returns "BackgroundMaterial"
  22940. */
  22941. getClassName(): string;
  22942. /**
  22943. * Parse a JSON input to create back a background material.
  22944. * @param source The JSON data to parse
  22945. * @param scene The scene to create the parsed material in
  22946. * @param rootUrl The root url of the assets the material depends upon
  22947. * @returns the instantiated BackgroundMaterial.
  22948. */
  22949. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  22950. }
  22951. }
  22952. declare module BABYLON {
  22953. /**
  22954. * The Physically based material base class of BJS.
  22955. *
  22956. * This offers the main features of a standard PBR material.
  22957. * For more information, please refer to the documentation :
  22958. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  22959. */
  22960. abstract class PBRBaseMaterial extends PushMaterial {
  22961. /**
  22962. * Intensity of the direct lights e.g. the four lights available in your scene.
  22963. * This impacts both the direct diffuse and specular highlights.
  22964. */
  22965. protected _directIntensity: number;
  22966. /**
  22967. * Intensity of the emissive part of the material.
  22968. * This helps controlling the emissive effect without modifying the emissive color.
  22969. */
  22970. protected _emissiveIntensity: number;
  22971. /**
  22972. * Intensity of the environment e.g. how much the environment will light the object
  22973. * either through harmonics for rough material or through the refelction for shiny ones.
  22974. */
  22975. protected _environmentIntensity: number;
  22976. /**
  22977. * This is a special control allowing the reduction of the specular highlights coming from the
  22978. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22979. */
  22980. protected _specularIntensity: number;
  22981. private _lightingInfos;
  22982. /**
  22983. * Debug Control allowing disabling the bump map on this material.
  22984. */
  22985. protected _disableBumpMap: boolean;
  22986. /**
  22987. * AKA Diffuse Texture in standard nomenclature.
  22988. */
  22989. protected _albedoTexture: BaseTexture;
  22990. /**
  22991. * AKA Occlusion Texture in other nomenclature.
  22992. */
  22993. protected _ambientTexture: BaseTexture;
  22994. /**
  22995. * AKA Occlusion Texture Intensity in other nomenclature.
  22996. */
  22997. protected _ambientTextureStrength: number;
  22998. protected _opacityTexture: BaseTexture;
  22999. protected _reflectionTexture: BaseTexture;
  23000. protected _refractionTexture: BaseTexture;
  23001. protected _emissiveTexture: BaseTexture;
  23002. /**
  23003. * AKA Specular texture in other nomenclature.
  23004. */
  23005. protected _reflectivityTexture: BaseTexture;
  23006. /**
  23007. * Used to switch from specular/glossiness to metallic/roughness workflow.
  23008. */
  23009. protected _metallicTexture: BaseTexture;
  23010. /**
  23011. * Specifies the metallic scalar of the metallic/roughness workflow.
  23012. * Can also be used to scale the metalness values of the metallic texture.
  23013. */
  23014. protected _metallic: number;
  23015. /**
  23016. * Specifies the roughness scalar of the metallic/roughness workflow.
  23017. * Can also be used to scale the roughness values of the metallic texture.
  23018. */
  23019. protected _roughness: number;
  23020. /**
  23021. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  23022. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  23023. */
  23024. protected _microSurfaceTexture: BaseTexture;
  23025. protected _bumpTexture: BaseTexture;
  23026. protected _lightmapTexture: BaseTexture;
  23027. protected _ambientColor: Color3;
  23028. /**
  23029. * AKA Diffuse Color in other nomenclature.
  23030. */
  23031. protected _albedoColor: Color3;
  23032. /**
  23033. * AKA Specular Color in other nomenclature.
  23034. */
  23035. protected _reflectivityColor: Color3;
  23036. protected _reflectionColor: Color3;
  23037. protected _emissiveColor: Color3;
  23038. /**
  23039. * AKA Glossiness in other nomenclature.
  23040. */
  23041. protected _microSurface: number;
  23042. /**
  23043. * source material index of refraction (IOR)' / 'destination material IOR.
  23044. */
  23045. protected _indexOfRefraction: number;
  23046. /**
  23047. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  23048. */
  23049. protected _invertRefractionY: boolean;
  23050. /**
  23051. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  23052. * Materials half opaque for instance using refraction could benefit from this control.
  23053. */
  23054. protected _linkRefractionWithTransparency: boolean;
  23055. protected _useLightmapAsShadowmap: boolean;
  23056. /**
  23057. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  23058. * makes the reflect vector face the model (under horizon).
  23059. */
  23060. protected _useHorizonOcclusion: boolean;
  23061. /**
  23062. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  23063. * too much the area relying on ambient texture to define their ambient occlusion.
  23064. */
  23065. protected _useRadianceOcclusion: boolean;
  23066. /**
  23067. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  23068. */
  23069. protected _useAlphaFromAlbedoTexture: boolean;
  23070. /**
  23071. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  23072. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  23073. */
  23074. protected _useSpecularOverAlpha: boolean;
  23075. /**
  23076. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  23077. */
  23078. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  23079. /**
  23080. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  23081. */
  23082. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  23083. /**
  23084. * Specifies if the metallic texture contains the roughness information in its green channel.
  23085. */
  23086. protected _useRoughnessFromMetallicTextureGreen: boolean;
  23087. /**
  23088. * Specifies if the metallic texture contains the metallness information in its blue channel.
  23089. */
  23090. protected _useMetallnessFromMetallicTextureBlue: boolean;
  23091. /**
  23092. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  23093. */
  23094. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  23095. /**
  23096. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  23097. */
  23098. protected _useAmbientInGrayScale: boolean;
  23099. /**
  23100. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  23101. * The material will try to infer what glossiness each pixel should be.
  23102. */
  23103. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  23104. /**
  23105. * BJS is using an harcoded light falloff based on a manually sets up range.
  23106. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  23107. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  23108. */
  23109. protected _usePhysicalLightFalloff: boolean;
  23110. /**
  23111. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  23112. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  23113. */
  23114. protected _useRadianceOverAlpha: boolean;
  23115. /**
  23116. * Allows using the bump map in parallax mode.
  23117. */
  23118. protected _useParallax: boolean;
  23119. /**
  23120. * Allows using the bump map in parallax occlusion mode.
  23121. */
  23122. protected _useParallaxOcclusion: boolean;
  23123. /**
  23124. * Controls the scale bias of the parallax mode.
  23125. */
  23126. protected _parallaxScaleBias: number;
  23127. /**
  23128. * If sets to true, disables all the lights affecting the material.
  23129. */
  23130. protected _disableLighting: boolean;
  23131. /**
  23132. * Number of Simultaneous lights allowed on the material.
  23133. */
  23134. protected _maxSimultaneousLights: number;
  23135. /**
  23136. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  23137. */
  23138. protected _invertNormalMapX: boolean;
  23139. /**
  23140. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  23141. */
  23142. protected _invertNormalMapY: boolean;
  23143. /**
  23144. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  23145. */
  23146. protected _twoSidedLighting: boolean;
  23147. /**
  23148. * Defines the alpha limits in alpha test mode.
  23149. */
  23150. protected _alphaCutOff: number;
  23151. /**
  23152. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  23153. */
  23154. protected _forceAlphaTest: boolean;
  23155. /**
  23156. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23157. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  23158. */
  23159. protected _useAlphaFresnel: boolean;
  23160. /**
  23161. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23162. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  23163. */
  23164. protected _useLinearAlphaFresnel: boolean;
  23165. /**
  23166. * The transparency mode of the material.
  23167. */
  23168. protected _transparencyMode: Nullable<number>;
  23169. /**
  23170. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  23171. * from cos thetav and roughness:
  23172. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  23173. */
  23174. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  23175. /**
  23176. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  23177. */
  23178. protected _forceIrradianceInFragment: boolean;
  23179. /**
  23180. * Force normal to face away from face.
  23181. */
  23182. protected _forceNormalForward: boolean;
  23183. /**
  23184. * Force metallic workflow.
  23185. */
  23186. protected _forceMetallicWorkflow: boolean;
  23187. /**
  23188. * Default configuration related to image processing available in the PBR Material.
  23189. */
  23190. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23191. /**
  23192. * Keep track of the image processing observer to allow dispose and replace.
  23193. */
  23194. private _imageProcessingObserver;
  23195. /**
  23196. * Attaches a new image processing configuration to the PBR Material.
  23197. * @param configuration
  23198. */
  23199. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23200. private _renderTargets;
  23201. private _globalAmbientColor;
  23202. private _useLogarithmicDepth;
  23203. /**
  23204. * Instantiates a new PBRMaterial instance.
  23205. *
  23206. * @param name The material name
  23207. * @param scene The scene the material will be use in.
  23208. */
  23209. constructor(name: string, scene: Scene);
  23210. getClassName(): string;
  23211. useLogarithmicDepth: boolean;
  23212. /**
  23213. * Gets the current transparency mode.
  23214. */
  23215. /**
  23216. * Sets the transparency mode of the material.
  23217. */
  23218. transparencyMode: Nullable<number>;
  23219. /**
  23220. * Returns true if alpha blending should be disabled.
  23221. */
  23222. private readonly _disableAlphaBlending;
  23223. /**
  23224. * Specifies whether or not this material should be rendered in alpha blend mode.
  23225. */
  23226. needAlphaBlending(): boolean;
  23227. /**
  23228. * Specifies whether or not this material should be rendered in alpha blend mode for the given mesh.
  23229. */
  23230. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23231. /**
  23232. * Specifies whether or not this material should be rendered in alpha test mode.
  23233. */
  23234. needAlphaTesting(): boolean;
  23235. /**
  23236. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  23237. */
  23238. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  23239. getAlphaTestTexture(): BaseTexture;
  23240. private static _scaledReflectivity;
  23241. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23242. buildUniformLayout(): void;
  23243. unbind(): void;
  23244. bindOnlyWorldMatrix(world: Matrix): void;
  23245. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23246. getAnimatables(): IAnimatable[];
  23247. private _getReflectionTexture();
  23248. private _getRefractionTexture();
  23249. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  23250. }
  23251. }
  23252. declare module BABYLON {
  23253. /**
  23254. * The Physically based simple base material of BJS.
  23255. *
  23256. * This enables better naming and convention enforcements on top of the pbrMaterial.
  23257. * It is used as the base class for both the specGloss and metalRough conventions.
  23258. */
  23259. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  23260. /**
  23261. * Number of Simultaneous lights allowed on the material.
  23262. */
  23263. maxSimultaneousLights: number;
  23264. /**
  23265. * If sets to true, disables all the lights affecting the material.
  23266. */
  23267. disableLighting: boolean;
  23268. /**
  23269. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  23270. */
  23271. environmentTexture: BaseTexture;
  23272. /**
  23273. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  23274. */
  23275. invertNormalMapX: boolean;
  23276. /**
  23277. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  23278. */
  23279. invertNormalMapY: boolean;
  23280. /**
  23281. * Normal map used in the model.
  23282. */
  23283. normalTexture: BaseTexture;
  23284. /**
  23285. * Emissivie color used to self-illuminate the model.
  23286. */
  23287. emissiveColor: Color3;
  23288. /**
  23289. * Emissivie texture used to self-illuminate the model.
  23290. */
  23291. emissiveTexture: BaseTexture;
  23292. /**
  23293. * Occlusion Channel Strenght.
  23294. */
  23295. occlusionStrength: number;
  23296. /**
  23297. * Occlusion Texture of the material (adding extra occlusion effects).
  23298. */
  23299. occlusionTexture: BaseTexture;
  23300. /**
  23301. * Defines the alpha limits in alpha test mode.
  23302. */
  23303. alphaCutOff: number;
  23304. /**
  23305. * Gets the current double sided mode.
  23306. */
  23307. /**
  23308. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  23309. */
  23310. doubleSided: boolean;
  23311. lightmapTexture: BaseTexture;
  23312. useLightmapAsShadowmap: boolean;
  23313. /**
  23314. * Return the active textures of the material.
  23315. */
  23316. getActiveTextures(): BaseTexture[];
  23317. hasTexture(texture: BaseTexture): boolean;
  23318. /**
  23319. * Instantiates a new PBRMaterial instance.
  23320. *
  23321. * @param name The material name
  23322. * @param scene The scene the material will be use in.
  23323. */
  23324. constructor(name: string, scene: Scene);
  23325. getClassName(): string;
  23326. }
  23327. }
  23328. declare module BABYLON {
  23329. /**
  23330. * The Physically based material of BJS.
  23331. *
  23332. * This offers the main features of a standard PBR material.
  23333. * For more information, please refer to the documentation :
  23334. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  23335. */
  23336. class PBRMaterial extends PBRBaseMaterial {
  23337. private static _PBRMATERIAL_OPAQUE;
  23338. /**
  23339. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23340. */
  23341. static readonly PBRMATERIAL_OPAQUE: number;
  23342. private static _PBRMATERIAL_ALPHATEST;
  23343. /**
  23344. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23345. */
  23346. static readonly PBRMATERIAL_ALPHATEST: number;
  23347. private static _PBRMATERIAL_ALPHABLEND;
  23348. /**
  23349. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23350. */
  23351. static readonly PBRMATERIAL_ALPHABLEND: number;
  23352. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  23353. /**
  23354. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23355. * They are also discarded below the alpha cutoff threshold to improve performances.
  23356. */
  23357. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  23358. /**
  23359. * Intensity of the direct lights e.g. the four lights available in your scene.
  23360. * This impacts both the direct diffuse and specular highlights.
  23361. */
  23362. directIntensity: number;
  23363. /**
  23364. * Intensity of the emissive part of the material.
  23365. * This helps controlling the emissive effect without modifying the emissive color.
  23366. */
  23367. emissiveIntensity: number;
  23368. /**
  23369. * Intensity of the environment e.g. how much the environment will light the object
  23370. * either through harmonics for rough material or through the refelction for shiny ones.
  23371. */
  23372. environmentIntensity: number;
  23373. /**
  23374. * This is a special control allowing the reduction of the specular highlights coming from the
  23375. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  23376. */
  23377. specularIntensity: number;
  23378. /**
  23379. * Debug Control allowing disabling the bump map on this material.
  23380. */
  23381. disableBumpMap: boolean;
  23382. /**
  23383. * AKA Diffuse Texture in standard nomenclature.
  23384. */
  23385. albedoTexture: BaseTexture;
  23386. /**
  23387. * AKA Occlusion Texture in other nomenclature.
  23388. */
  23389. ambientTexture: BaseTexture;
  23390. /**
  23391. * AKA Occlusion Texture Intensity in other nomenclature.
  23392. */
  23393. ambientTextureStrength: number;
  23394. opacityTexture: BaseTexture;
  23395. reflectionTexture: Nullable<BaseTexture>;
  23396. emissiveTexture: BaseTexture;
  23397. /**
  23398. * AKA Specular texture in other nomenclature.
  23399. */
  23400. reflectivityTexture: BaseTexture;
  23401. /**
  23402. * Used to switch from specular/glossiness to metallic/roughness workflow.
  23403. */
  23404. metallicTexture: BaseTexture;
  23405. /**
  23406. * Specifies the metallic scalar of the metallic/roughness workflow.
  23407. * Can also be used to scale the metalness values of the metallic texture.
  23408. */
  23409. metallic: number;
  23410. /**
  23411. * Specifies the roughness scalar of the metallic/roughness workflow.
  23412. * Can also be used to scale the roughness values of the metallic texture.
  23413. */
  23414. roughness: number;
  23415. /**
  23416. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  23417. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  23418. */
  23419. microSurfaceTexture: BaseTexture;
  23420. bumpTexture: BaseTexture;
  23421. lightmapTexture: BaseTexture;
  23422. refractionTexture: BaseTexture;
  23423. ambientColor: Color3;
  23424. /**
  23425. * AKA Diffuse Color in other nomenclature.
  23426. */
  23427. albedoColor: Color3;
  23428. /**
  23429. * AKA Specular Color in other nomenclature.
  23430. */
  23431. reflectivityColor: Color3;
  23432. reflectionColor: Color3;
  23433. emissiveColor: Color3;
  23434. /**
  23435. * AKA Glossiness in other nomenclature.
  23436. */
  23437. microSurface: number;
  23438. /**
  23439. * source material index of refraction (IOR)' / 'destination material IOR.
  23440. */
  23441. indexOfRefraction: number;
  23442. /**
  23443. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  23444. */
  23445. invertRefractionY: boolean;
  23446. /**
  23447. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  23448. * Materials half opaque for instance using refraction could benefit from this control.
  23449. */
  23450. linkRefractionWithTransparency: boolean;
  23451. useLightmapAsShadowmap: boolean;
  23452. /**
  23453. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  23454. */
  23455. useAlphaFromAlbedoTexture: boolean;
  23456. /**
  23457. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  23458. */
  23459. forceAlphaTest: boolean;
  23460. /**
  23461. * Defines the alpha limits in alpha test mode.
  23462. */
  23463. alphaCutOff: number;
  23464. /**
  23465. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  23466. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  23467. */
  23468. useSpecularOverAlpha: boolean;
  23469. /**
  23470. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  23471. */
  23472. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  23473. /**
  23474. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  23475. */
  23476. useRoughnessFromMetallicTextureAlpha: boolean;
  23477. /**
  23478. * Specifies if the metallic texture contains the roughness information in its green channel.
  23479. */
  23480. useRoughnessFromMetallicTextureGreen: boolean;
  23481. /**
  23482. * Specifies if the metallic texture contains the metallness information in its blue channel.
  23483. */
  23484. useMetallnessFromMetallicTextureBlue: boolean;
  23485. /**
  23486. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  23487. */
  23488. useAmbientOcclusionFromMetallicTextureRed: boolean;
  23489. /**
  23490. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  23491. */
  23492. useAmbientInGrayScale: boolean;
  23493. /**
  23494. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  23495. * The material will try to infer what glossiness each pixel should be.
  23496. */
  23497. useAutoMicroSurfaceFromReflectivityMap: boolean;
  23498. /**
  23499. * BJS is using an harcoded light falloff based on a manually sets up range.
  23500. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  23501. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  23502. */
  23503. usePhysicalLightFalloff: boolean;
  23504. /**
  23505. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  23506. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  23507. */
  23508. useRadianceOverAlpha: boolean;
  23509. /**
  23510. * Allows using the bump map in parallax mode.
  23511. */
  23512. useParallax: boolean;
  23513. /**
  23514. * Allows using the bump map in parallax occlusion mode.
  23515. */
  23516. useParallaxOcclusion: boolean;
  23517. /**
  23518. * Controls the scale bias of the parallax mode.
  23519. */
  23520. parallaxScaleBias: number;
  23521. /**
  23522. * If sets to true, disables all the lights affecting the material.
  23523. */
  23524. disableLighting: boolean;
  23525. /**
  23526. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  23527. */
  23528. forceIrradianceInFragment: boolean;
  23529. /**
  23530. * Number of Simultaneous lights allowed on the material.
  23531. */
  23532. maxSimultaneousLights: number;
  23533. /**
  23534. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  23535. */
  23536. invertNormalMapX: boolean;
  23537. /**
  23538. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  23539. */
  23540. invertNormalMapY: boolean;
  23541. /**
  23542. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  23543. */
  23544. twoSidedLighting: boolean;
  23545. /**
  23546. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23547. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  23548. */
  23549. useAlphaFresnel: boolean;
  23550. /**
  23551. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23552. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  23553. */
  23554. useLinearAlphaFresnel: boolean;
  23555. /**
  23556. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23557. * And/Or occlude the blended part.
  23558. */
  23559. environmentBRDFTexture: Nullable<BaseTexture>;
  23560. /**
  23561. * Force normal to face away from face.
  23562. */
  23563. forceNormalForward: boolean;
  23564. /**
  23565. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  23566. * makes the reflect vector face the model (under horizon).
  23567. */
  23568. useHorizonOcclusion: boolean;
  23569. /**
  23570. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  23571. * too much the area relying on ambient texture to define their ambient occlusion.
  23572. */
  23573. useRadianceOcclusion: boolean;
  23574. /**
  23575. * Gets the image processing configuration used either in this material.
  23576. */
  23577. /**
  23578. * Sets the Default image processing configuration used either in the this material.
  23579. *
  23580. * If sets to null, the scene one is in use.
  23581. */
  23582. imageProcessingConfiguration: ImageProcessingConfiguration;
  23583. /**
  23584. * Gets wether the color curves effect is enabled.
  23585. */
  23586. /**
  23587. * Sets wether the color curves effect is enabled.
  23588. */
  23589. cameraColorCurvesEnabled: boolean;
  23590. /**
  23591. * Gets wether the color grading effect is enabled.
  23592. */
  23593. /**
  23594. * Gets wether the color grading effect is enabled.
  23595. */
  23596. cameraColorGradingEnabled: boolean;
  23597. /**
  23598. * Gets wether tonemapping is enabled or not.
  23599. */
  23600. /**
  23601. * Sets wether tonemapping is enabled or not
  23602. */
  23603. cameraToneMappingEnabled: boolean;
  23604. /**
  23605. * The camera exposure used on this material.
  23606. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23607. * This corresponds to a photographic exposure.
  23608. */
  23609. /**
  23610. * The camera exposure used on this material.
  23611. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23612. * This corresponds to a photographic exposure.
  23613. */
  23614. cameraExposure: number;
  23615. /**
  23616. * Gets The camera contrast used on this material.
  23617. */
  23618. /**
  23619. * Sets The camera contrast used on this material.
  23620. */
  23621. cameraContrast: number;
  23622. /**
  23623. * Gets the Color Grading 2D Lookup Texture.
  23624. */
  23625. /**
  23626. * Sets the Color Grading 2D Lookup Texture.
  23627. */
  23628. cameraColorGradingTexture: Nullable<BaseTexture>;
  23629. /**
  23630. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23631. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23632. * 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;
  23633. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23634. */
  23635. /**
  23636. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23637. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23638. * 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;
  23639. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23640. */
  23641. cameraColorCurves: Nullable<ColorCurves>;
  23642. /**
  23643. * Instantiates a new PBRMaterial instance.
  23644. *
  23645. * @param name The material name
  23646. * @param scene The scene the material will be use in.
  23647. */
  23648. constructor(name: string, scene: Scene);
  23649. getClassName(): string;
  23650. getActiveTextures(): BaseTexture[];
  23651. hasTexture(texture: BaseTexture): boolean;
  23652. clone(name: string): PBRMaterial;
  23653. serialize(): any;
  23654. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  23655. }
  23656. }
  23657. declare module BABYLON {
  23658. /**
  23659. * The PBR material of BJS following the metal roughness convention.
  23660. *
  23661. * This fits to the PBR convention in the GLTF definition:
  23662. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  23663. */
  23664. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  23665. /**
  23666. * The base color has two different interpretations depending on the value of metalness.
  23667. * When the material is a metal, the base color is the specific measured reflectance value
  23668. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  23669. * of the material.
  23670. */
  23671. baseColor: Color3;
  23672. /**
  23673. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  23674. * well as opacity information in the alpha channel.
  23675. */
  23676. baseTexture: BaseTexture;
  23677. /**
  23678. * Specifies the metallic scalar value of the material.
  23679. * Can also be used to scale the metalness values of the metallic texture.
  23680. */
  23681. metallic: number;
  23682. /**
  23683. * Specifies the roughness scalar value of the material.
  23684. * Can also be used to scale the roughness values of the metallic texture.
  23685. */
  23686. roughness: number;
  23687. /**
  23688. * Texture containing both the metallic value in the B channel and the
  23689. * roughness value in the G channel to keep better precision.
  23690. */
  23691. metallicRoughnessTexture: BaseTexture;
  23692. /**
  23693. * Instantiates a new PBRMetalRoughnessMaterial instance.
  23694. *
  23695. * @param name The material name
  23696. * @param scene The scene the material will be use in.
  23697. */
  23698. constructor(name: string, scene: Scene);
  23699. /**
  23700. * Return the currrent class name of the material.
  23701. */
  23702. getClassName(): string;
  23703. /**
  23704. * Return the active textures of the material.
  23705. */
  23706. getActiveTextures(): BaseTexture[];
  23707. hasTexture(texture: BaseTexture): boolean;
  23708. clone(name: string): PBRMetallicRoughnessMaterial;
  23709. /**
  23710. * Serialize the material to a parsable JSON object.
  23711. */
  23712. serialize(): any;
  23713. /**
  23714. * Parses a JSON object correponding to the serialize function.
  23715. */
  23716. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  23717. }
  23718. }
  23719. declare module BABYLON {
  23720. /**
  23721. * The PBR material of BJS following the specular glossiness convention.
  23722. *
  23723. * This fits to the PBR convention in the GLTF definition:
  23724. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  23725. */
  23726. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  23727. /**
  23728. * Specifies the diffuse color of the material.
  23729. */
  23730. diffuseColor: Color3;
  23731. /**
  23732. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  23733. * channel.
  23734. */
  23735. diffuseTexture: BaseTexture;
  23736. /**
  23737. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  23738. */
  23739. specularColor: Color3;
  23740. /**
  23741. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  23742. */
  23743. glossiness: number;
  23744. /**
  23745. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  23746. */
  23747. specularGlossinessTexture: BaseTexture;
  23748. /**
  23749. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  23750. *
  23751. * @param name The material name
  23752. * @param scene The scene the material will be use in.
  23753. */
  23754. constructor(name: string, scene: Scene);
  23755. /**
  23756. * Return the currrent class name of the material.
  23757. */
  23758. getClassName(): string;
  23759. /**
  23760. * Return the active textures of the material.
  23761. */
  23762. getActiveTextures(): BaseTexture[];
  23763. hasTexture(texture: BaseTexture): boolean;
  23764. clone(name: string): PBRSpecularGlossinessMaterial;
  23765. /**
  23766. * Serialize the material to a parsable JSON object.
  23767. */
  23768. serialize(): any;
  23769. /**
  23770. * Parses a JSON object correponding to the serialize function.
  23771. */
  23772. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  23773. }
  23774. }
  23775. declare module BABYLON {
  23776. class BaseTexture {
  23777. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  23778. name: string;
  23779. private _hasAlpha;
  23780. hasAlpha: boolean;
  23781. getAlphaFromRGB: boolean;
  23782. level: number;
  23783. coordinatesIndex: number;
  23784. private _coordinatesMode;
  23785. coordinatesMode: number;
  23786. wrapU: number;
  23787. wrapV: number;
  23788. wrapR: number;
  23789. anisotropicFilteringLevel: number;
  23790. isCube: boolean;
  23791. is3D: boolean;
  23792. gammaSpace: boolean;
  23793. invertZ: boolean;
  23794. lodLevelInAlpha: boolean;
  23795. lodGenerationOffset: number;
  23796. lodGenerationScale: number;
  23797. isRenderTarget: boolean;
  23798. readonly uid: string;
  23799. toString(): string;
  23800. getClassName(): string;
  23801. animations: Animation[];
  23802. /**
  23803. * An event triggered when the texture is disposed.
  23804. * @type {BABYLON.Observable}
  23805. */
  23806. onDisposeObservable: Observable<BaseTexture>;
  23807. private _onDisposeObserver;
  23808. onDispose: () => void;
  23809. delayLoadState: number;
  23810. private _scene;
  23811. _texture: Nullable<InternalTexture>;
  23812. private _uid;
  23813. readonly isBlocking: boolean;
  23814. constructor(scene: Nullable<Scene>);
  23815. getScene(): Nullable<Scene>;
  23816. getTextureMatrix(): Matrix;
  23817. getReflectionTextureMatrix(): Matrix;
  23818. getInternalTexture(): Nullable<InternalTexture>;
  23819. isReadyOrNotBlocking(): boolean;
  23820. isReady(): boolean;
  23821. getSize(): ISize;
  23822. getBaseSize(): ISize;
  23823. scale(ratio: number): void;
  23824. readonly canRescale: boolean;
  23825. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  23826. _rebuild(): void;
  23827. delayLoad(): void;
  23828. clone(): Nullable<BaseTexture>;
  23829. readonly textureType: number;
  23830. readonly textureFormat: number;
  23831. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  23832. releaseInternalTexture(): void;
  23833. sphericalPolynomial: Nullable<SphericalPolynomial>;
  23834. readonly _lodTextureHigh: Nullable<BaseTexture>;
  23835. readonly _lodTextureMid: Nullable<BaseTexture>;
  23836. readonly _lodTextureLow: Nullable<BaseTexture>;
  23837. dispose(): void;
  23838. serialize(): any;
  23839. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  23840. }
  23841. }
  23842. declare module BABYLON {
  23843. /**
  23844. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  23845. * It can help converting any input color in a desired output one. This can then be used to create effects
  23846. * from sepia, black and white to sixties or futuristic rendering...
  23847. *
  23848. * The only supported format is currently 3dl.
  23849. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  23850. */
  23851. class ColorGradingTexture extends BaseTexture {
  23852. /**
  23853. * The current texture matrix. (will always be identity in color grading texture)
  23854. */
  23855. private _textureMatrix;
  23856. /**
  23857. * The texture URL.
  23858. */
  23859. url: string;
  23860. /**
  23861. * Empty line regex stored for GC.
  23862. */
  23863. private static _noneEmptyLineRegex;
  23864. private _engine;
  23865. /**
  23866. * Instantiates a ColorGradingTexture from the following parameters.
  23867. *
  23868. * @param url The location of the color gradind data (currently only supporting 3dl)
  23869. * @param scene The scene the texture will be used in
  23870. */
  23871. constructor(url: string, scene: Scene);
  23872. /**
  23873. * Returns the texture matrix used in most of the material.
  23874. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  23875. */
  23876. getTextureMatrix(): Matrix;
  23877. /**
  23878. * Occurs when the file being loaded is a .3dl LUT file.
  23879. */
  23880. private load3dlTexture();
  23881. /**
  23882. * Starts the loading process of the texture.
  23883. */
  23884. private loadTexture();
  23885. /**
  23886. * Clones the color gradind texture.
  23887. */
  23888. clone(): ColorGradingTexture;
  23889. /**
  23890. * Called during delayed load for textures.
  23891. */
  23892. delayLoad(): void;
  23893. /**
  23894. * Parses a color grading texture serialized by Babylon.
  23895. * @param parsedTexture The texture information being parsedTexture
  23896. * @param scene The scene to load the texture in
  23897. * @param rootUrl The root url of the data assets to load
  23898. * @return A color gradind texture
  23899. */
  23900. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  23901. /**
  23902. * Serializes the LUT texture to json format.
  23903. */
  23904. serialize(): any;
  23905. }
  23906. }
  23907. declare module BABYLON {
  23908. class CubeTexture extends BaseTexture {
  23909. url: string;
  23910. coordinatesMode: number;
  23911. private _noMipmap;
  23912. private _files;
  23913. private _extensions;
  23914. private _textureMatrix;
  23915. private _format;
  23916. private _prefiltered;
  23917. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  23918. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture;
  23919. 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);
  23920. delayLoad(): void;
  23921. getReflectionTextureMatrix(): Matrix;
  23922. setReflectionTextureMatrix(value: Matrix): void;
  23923. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  23924. clone(): CubeTexture;
  23925. }
  23926. }
  23927. declare module BABYLON {
  23928. class DynamicTexture extends Texture {
  23929. private _generateMipMaps;
  23930. private _canvas;
  23931. private _context;
  23932. private _engine;
  23933. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  23934. readonly canRescale: boolean;
  23935. private _recreate(textureSize);
  23936. scale(ratio: number): void;
  23937. scaleTo(width: number, height: number): void;
  23938. getContext(): CanvasRenderingContext2D;
  23939. clear(): void;
  23940. update(invertY?: boolean): void;
  23941. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  23942. clone(): DynamicTexture;
  23943. _rebuild(): void;
  23944. }
  23945. }
  23946. declare module BABYLON {
  23947. /**
  23948. * This represents a texture coming from an HDR input.
  23949. *
  23950. * The only supported format is currently panorama picture stored in RGBE format.
  23951. * Example of such files can be found on HDRLib: http://hdrlib.com/
  23952. */
  23953. class HDRCubeTexture extends BaseTexture {
  23954. private static _facesMapping;
  23955. private _useInGammaSpace;
  23956. private _generateHarmonics;
  23957. private _noMipmap;
  23958. private _textureMatrix;
  23959. private _size;
  23960. private _usePMREMGenerator;
  23961. private _isBABYLONPreprocessed;
  23962. private _onLoad;
  23963. private _onError;
  23964. /**
  23965. * The texture URL.
  23966. */
  23967. url: string;
  23968. /**
  23969. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  23970. */
  23971. coordinatesMode: number;
  23972. /**
  23973. * Specifies wether the texture has been generated through the PMREMGenerator tool.
  23974. * This is usefull at run time to apply the good shader.
  23975. */
  23976. isPMREM: boolean;
  23977. protected _isBlocking: boolean;
  23978. /**
  23979. * Gets wether or not the texture is blocking during loading.
  23980. */
  23981. /**
  23982. * Sets wether or not the texture is blocking during loading.
  23983. */
  23984. isBlocking: boolean;
  23985. /**
  23986. * Instantiates an HDRTexture from the following parameters.
  23987. *
  23988. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  23989. * @param scene The scene the texture will be used in
  23990. * @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.
  23991. * @param noMipmap Forces to not generate the mipmap if true
  23992. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  23993. * @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)
  23994. * @param usePMREMGenerator Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
  23995. */
  23996. 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>);
  23997. /**
  23998. * Occurs when the file is a preprocessed .babylon.hdr file.
  23999. */
  24000. private loadBabylonTexture();
  24001. /**
  24002. * Occurs when the file is raw .hdr file.
  24003. */
  24004. private loadHDRTexture();
  24005. /**
  24006. * Starts the loading process of the texture.
  24007. */
  24008. private loadTexture();
  24009. clone(): HDRCubeTexture;
  24010. delayLoad(): void;
  24011. getReflectionTextureMatrix(): Matrix;
  24012. setReflectionTextureMatrix(value: Matrix): void;
  24013. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  24014. serialize(): any;
  24015. /**
  24016. * Saves as a file the data contained in the texture in a binary format.
  24017. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  24018. * as the spherical used in the lighting.
  24019. * @param url The HDR file url.
  24020. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  24021. * @param onError Method called if any error happens during download.
  24022. * @return The packed binary data.
  24023. */
  24024. static generateBabylonHDROnDisk(url: string, size: number, onError?: Nullable<(() => void)>): void;
  24025. /**
  24026. * Serializes the data contained in the texture in a binary format.
  24027. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  24028. * as the spherical used in the lighting.
  24029. * @param url The HDR file url.
  24030. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  24031. * @param onError Method called if any error happens during download.
  24032. * @return The packed binary data.
  24033. */
  24034. static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer: ArrayBuffer) => void), onError?: Nullable<(() => void)>): void;
  24035. }
  24036. }
  24037. declare module BABYLON {
  24038. /**
  24039. * Class used to store data associated with WebGL texture data for the engine
  24040. * This class should not be used directly
  24041. */
  24042. class InternalTexture implements IInternalTextureTracker {
  24043. /**
  24044. * The source of the texture data is unknown
  24045. */
  24046. static DATASOURCE_UNKNOWN: number;
  24047. /**
  24048. * Texture data comes from an URL
  24049. */
  24050. static DATASOURCE_URL: number;
  24051. /**
  24052. * Texture data is only used for temporary storage
  24053. */
  24054. static DATASOURCE_TEMP: number;
  24055. /**
  24056. * Texture data comes from raw data (ArrayBuffer)
  24057. */
  24058. static DATASOURCE_RAW: number;
  24059. /**
  24060. * Texture content is dynamic (video or dynamic texture)
  24061. */
  24062. static DATASOURCE_DYNAMIC: number;
  24063. /**
  24064. * Texture content is generated by rendering to it
  24065. */
  24066. static DATASOURCE_RENDERTARGET: number;
  24067. /**
  24068. * Texture content is part of a multi render target process
  24069. */
  24070. static DATASOURCE_MULTIRENDERTARGET: number;
  24071. /**
  24072. * Texture data comes from a cube data file
  24073. */
  24074. static DATASOURCE_CUBE: number;
  24075. /**
  24076. * Texture data comes from a raw cube data
  24077. */
  24078. static DATASOURCE_CUBERAW: number;
  24079. /**
  24080. * Texture data come from a prefiltered cube data file
  24081. */
  24082. static DATASOURCE_CUBEPREFILTERED: number;
  24083. /**
  24084. * Texture content is raw 3D data
  24085. */
  24086. static DATASOURCE_RAW3D: number;
  24087. /**
  24088. * Defines if the texture is ready
  24089. */
  24090. isReady: boolean;
  24091. /**
  24092. * Defines if the texture is a cube texture
  24093. */
  24094. isCube: boolean;
  24095. /**
  24096. * Defines if the texture contains 3D data
  24097. */
  24098. is3D: boolean;
  24099. /**
  24100. * Gets the URL used to load this texture
  24101. */
  24102. url: string;
  24103. /**
  24104. * Gets the sampling mode of the texture
  24105. */
  24106. samplingMode: number;
  24107. /**
  24108. * Gets a boolean indicating if the texture needs mipmaps generation
  24109. */
  24110. generateMipMaps: boolean;
  24111. /**
  24112. * Gets the number of samples used by the texture (WebGL2+ only)
  24113. */
  24114. samples: number;
  24115. /**
  24116. * Gets the type of the texture
  24117. */
  24118. type: number;
  24119. /**
  24120. * Gets the format of the texture
  24121. */
  24122. format: number;
  24123. /**
  24124. * Observable called when the texture is loaded
  24125. */
  24126. onLoadedObservable: Observable<InternalTexture>;
  24127. /**
  24128. * Gets the width of the texture
  24129. */
  24130. width: number;
  24131. /**
  24132. * Gets the height of the texture
  24133. */
  24134. height: number;
  24135. /**
  24136. * Gets the depth of the texture
  24137. */
  24138. depth: number;
  24139. /**
  24140. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  24141. */
  24142. baseWidth: number;
  24143. /**
  24144. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  24145. */
  24146. baseHeight: number;
  24147. /**
  24148. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  24149. */
  24150. baseDepth: number;
  24151. /**
  24152. * Gets a boolean indicating if the texture is inverted on Y axis
  24153. */
  24154. invertY: boolean;
  24155. /**
  24156. * Gets or set the previous tracker in the list
  24157. */
  24158. previous: Nullable<IInternalTextureTracker>;
  24159. /**
  24160. * Gets or set the next tracker in the list
  24161. */
  24162. next: Nullable<IInternalTextureTracker>;
  24163. /** @ignore */
  24164. _initialSlot: number;
  24165. /** @ignore */
  24166. _designatedSlot: number;
  24167. /** @ignore */
  24168. _dataSource: number;
  24169. /** @ignore */
  24170. _buffer: Nullable<ArrayBuffer | HTMLImageElement>;
  24171. /** @ignore */
  24172. _bufferView: Nullable<ArrayBufferView>;
  24173. /** @ignore */
  24174. _bufferViewArray: Nullable<ArrayBufferView[]>;
  24175. /** @ignore */
  24176. _size: number;
  24177. /** @ignore */
  24178. _extension: string;
  24179. /** @ignore */
  24180. _files: Nullable<string[]>;
  24181. /** @ignore */
  24182. _workingCanvas: HTMLCanvasElement;
  24183. /** @ignore */
  24184. _workingContext: CanvasRenderingContext2D;
  24185. /** @ignore */
  24186. _framebuffer: Nullable<WebGLFramebuffer>;
  24187. /** @ignore */
  24188. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  24189. /** @ignore */
  24190. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  24191. /** @ignore */
  24192. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  24193. /** @ignore */
  24194. _attachments: Nullable<number[]>;
  24195. /** @ignore */
  24196. _cachedCoordinatesMode: Nullable<number>;
  24197. /** @ignore */
  24198. _cachedWrapU: Nullable<number>;
  24199. /** @ignore */
  24200. _cachedWrapV: Nullable<number>;
  24201. /** @ignore */
  24202. _cachedWrapR: Nullable<number>;
  24203. /** @ignore */
  24204. _cachedAnisotropicFilteringLevel: Nullable<number>;
  24205. /** @ignore */
  24206. _isDisabled: boolean;
  24207. /** @ignore */
  24208. _compression: Nullable<string>;
  24209. /** @ignore */
  24210. _generateStencilBuffer: boolean;
  24211. /** @ignore */
  24212. _generateDepthBuffer: boolean;
  24213. /** @ignore */
  24214. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  24215. /** @ignore */
  24216. _lodGenerationScale: number;
  24217. /** @ignore */
  24218. _lodGenerationOffset: number;
  24219. /** @ignore */
  24220. _lodTextureHigh: BaseTexture;
  24221. /** @ignore */
  24222. _lodTextureMid: BaseTexture;
  24223. /** @ignore */
  24224. _lodTextureLow: BaseTexture;
  24225. /** @ignore */
  24226. _webGLTexture: Nullable<WebGLTexture>;
  24227. /** @ignore */
  24228. _references: number;
  24229. private _engine;
  24230. /**
  24231. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  24232. */
  24233. readonly dataSource: number;
  24234. /**
  24235. * Creates a new InternalTexture
  24236. * @param engine defines the engine to use
  24237. * @param dataSource defines the type of data that will be used
  24238. */
  24239. constructor(engine: Engine, dataSource: number);
  24240. /**
  24241. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  24242. */
  24243. incrementReferences(): void;
  24244. /**
  24245. * Change the size of the texture (not the size of the content)
  24246. * @param width defines the new width
  24247. * @param height defines the new height
  24248. * @param depth defines the new depth (1 by default)
  24249. */
  24250. updateSize(width: int, height: int, depth?: int): void;
  24251. /** @ignore */
  24252. _rebuild(): void;
  24253. private _swapAndDie(target);
  24254. /**
  24255. * Dispose the current allocated resources
  24256. */
  24257. dispose(): void;
  24258. }
  24259. }
  24260. declare module BABYLON {
  24261. /**
  24262. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  24263. */
  24264. interface IInternalTextureTracker {
  24265. /**
  24266. * Gets or set the previous tracker in the list
  24267. */
  24268. previous: Nullable<IInternalTextureTracker>;
  24269. /**
  24270. * Gets or set the next tracker in the list
  24271. */
  24272. next: Nullable<IInternalTextureTracker>;
  24273. }
  24274. /**
  24275. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  24276. */
  24277. class DummyInternalTextureTracker {
  24278. /**
  24279. * Gets or set the previous tracker in the list
  24280. */
  24281. previous: Nullable<IInternalTextureTracker>;
  24282. /**
  24283. * Gets or set the next tracker in the list
  24284. */
  24285. next: Nullable<IInternalTextureTracker>;
  24286. }
  24287. }
  24288. declare module BABYLON {
  24289. class MirrorTexture extends RenderTargetTexture {
  24290. mirrorPlane: Plane;
  24291. private _transformMatrix;
  24292. private _mirrorMatrix;
  24293. private _savedViewMatrix;
  24294. private _blurX;
  24295. private _blurY;
  24296. private _adaptiveBlurKernel;
  24297. private _blurKernelX;
  24298. private _blurKernelY;
  24299. private _blurRatio;
  24300. blurRatio: number;
  24301. adaptiveBlurKernel: number;
  24302. blurKernel: number;
  24303. blurKernelX: number;
  24304. blurKernelY: number;
  24305. private _autoComputeBlurKernel();
  24306. protected _onRatioRescale(): void;
  24307. constructor(name: string, size: number | {
  24308. width: number;
  24309. height: number;
  24310. } | {
  24311. ratio: number;
  24312. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24313. private _preparePostProcesses();
  24314. clone(): MirrorTexture;
  24315. serialize(): any;
  24316. }
  24317. }
  24318. declare module BABYLON {
  24319. interface IMultiRenderTargetOptions {
  24320. generateMipMaps?: boolean;
  24321. types?: number[];
  24322. samplingModes?: number[];
  24323. generateDepthBuffer?: boolean;
  24324. generateStencilBuffer?: boolean;
  24325. generateDepthTexture?: boolean;
  24326. textureCount?: number;
  24327. doNotChangeAspectRatio?: boolean;
  24328. defaultType?: number;
  24329. }
  24330. class MultiRenderTarget extends RenderTargetTexture {
  24331. private _internalTextures;
  24332. private _textures;
  24333. readonly isSupported: boolean;
  24334. private _multiRenderTargetOptions;
  24335. readonly textures: Texture[];
  24336. readonly depthTexture: Texture;
  24337. wrapU: number;
  24338. wrapV: number;
  24339. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24340. _rebuild(): void;
  24341. private _createInternalTextures();
  24342. private _createTextures();
  24343. samples: number;
  24344. resize(size: any): void;
  24345. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24346. dispose(): void;
  24347. releaseInternalTextures(): void;
  24348. }
  24349. }
  24350. declare module BABYLON {
  24351. class RawTexture extends Texture {
  24352. format: number;
  24353. private _engine;
  24354. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  24355. update(data: ArrayBufferView): void;
  24356. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  24357. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  24358. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  24359. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  24360. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  24361. }
  24362. }
  24363. declare module BABYLON {
  24364. /**
  24365. * Creates a refraction texture used by refraction channel of the standard material.
  24366. * @param name the texture name
  24367. * @param size size of the underlying texture
  24368. * @param scene root scene
  24369. */
  24370. class RefractionTexture extends RenderTargetTexture {
  24371. refractionPlane: Plane;
  24372. depth: number;
  24373. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  24374. clone(): RefractionTexture;
  24375. serialize(): any;
  24376. }
  24377. }
  24378. declare module BABYLON {
  24379. class RenderTargetTexture extends Texture {
  24380. isCube: boolean;
  24381. static _REFRESHRATE_RENDER_ONCE: number;
  24382. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24383. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24384. static readonly REFRESHRATE_RENDER_ONCE: number;
  24385. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24386. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24387. /**
  24388. * Use this predicate to dynamically define the list of mesh you want to render.
  24389. * If set, the renderList property will be overwritten.
  24390. */
  24391. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24392. /**
  24393. * Use this list to define the list of mesh you want to render.
  24394. */
  24395. renderList: Nullable<Array<AbstractMesh>>;
  24396. renderParticles: boolean;
  24397. renderSprites: boolean;
  24398. coordinatesMode: number;
  24399. activeCamera: Nullable<Camera>;
  24400. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24401. useCameraPostProcesses: boolean;
  24402. ignoreCameraViewport: boolean;
  24403. private _postProcessManager;
  24404. private _postProcesses;
  24405. private _resizeObserver;
  24406. /**
  24407. * An event triggered when the texture is unbind.
  24408. * @type {BABYLON.Observable}
  24409. */
  24410. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24411. /**
  24412. * An event triggered when the texture is unbind.
  24413. * @type {BABYLON.Observable}
  24414. */
  24415. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24416. private _onAfterUnbindObserver;
  24417. onAfterUnbind: () => void;
  24418. /**
  24419. * An event triggered before rendering the texture
  24420. * @type {BABYLON.Observable}
  24421. */
  24422. onBeforeRenderObservable: Observable<number>;
  24423. private _onBeforeRenderObserver;
  24424. onBeforeRender: (faceIndex: number) => void;
  24425. /**
  24426. * An event triggered after rendering the texture
  24427. * @type {BABYLON.Observable}
  24428. */
  24429. onAfterRenderObservable: Observable<number>;
  24430. private _onAfterRenderObserver;
  24431. onAfterRender: (faceIndex: number) => void;
  24432. /**
  24433. * An event triggered after the texture clear
  24434. * @type {BABYLON.Observable}
  24435. */
  24436. onClearObservable: Observable<Engine>;
  24437. private _onClearObserver;
  24438. onClear: (Engine: Engine) => void;
  24439. clearColor: Color4;
  24440. protected _size: number | {
  24441. width: number;
  24442. height: number;
  24443. };
  24444. protected _initialSizeParameter: number | {
  24445. width: number;
  24446. height: number;
  24447. } | {
  24448. ratio: number;
  24449. };
  24450. protected _sizeRatio: Nullable<number>;
  24451. _generateMipMaps: boolean;
  24452. protected _renderingManager: RenderingManager;
  24453. _waitingRenderList: string[];
  24454. protected _doNotChangeAspectRatio: boolean;
  24455. protected _currentRefreshId: number;
  24456. protected _refreshRate: number;
  24457. protected _textureMatrix: Matrix;
  24458. protected _samples: number;
  24459. protected _renderTargetOptions: RenderTargetCreationOptions;
  24460. readonly renderTargetOptions: RenderTargetCreationOptions;
  24461. protected _engine: Engine;
  24462. protected _onRatioRescale(): void;
  24463. constructor(name: string, size: number | {
  24464. width: number;
  24465. height: number;
  24466. } | {
  24467. ratio: number;
  24468. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  24469. private _processSizeParameter(size);
  24470. samples: number;
  24471. resetRefreshCounter(): void;
  24472. refreshRate: number;
  24473. addPostProcess(postProcess: PostProcess): void;
  24474. clearPostProcesses(dispose?: boolean): void;
  24475. removePostProcess(postProcess: PostProcess): void;
  24476. _shouldRender(): boolean;
  24477. getRenderSize(): number;
  24478. getRenderWidth(): number;
  24479. getRenderHeight(): number;
  24480. readonly canRescale: boolean;
  24481. scale(ratio: number): void;
  24482. getReflectionTextureMatrix(): Matrix;
  24483. resize(size: number | {
  24484. width: number;
  24485. height: number;
  24486. } | {
  24487. ratio: number;
  24488. }): void;
  24489. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24490. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  24491. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24492. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  24493. /**
  24494. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24495. * This allowed control for front to back rendering or reversly depending of the special needs.
  24496. *
  24497. * @param renderingGroupId The rendering group id corresponding to its index
  24498. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24499. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24500. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24501. */
  24502. 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;
  24503. /**
  24504. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24505. *
  24506. * @param renderingGroupId The rendering group id corresponding to its index
  24507. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24508. */
  24509. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24510. clone(): RenderTargetTexture;
  24511. serialize(): any;
  24512. disposeFramebufferObjects(): void;
  24513. dispose(): void;
  24514. _rebuild(): void;
  24515. }
  24516. }
  24517. declare module BABYLON {
  24518. class Texture extends BaseTexture {
  24519. static NEAREST_SAMPLINGMODE: number;
  24520. static NEAREST_NEAREST_MIPLINEAR: number;
  24521. static BILINEAR_SAMPLINGMODE: number;
  24522. static LINEAR_LINEAR_MIPNEAREST: number;
  24523. static TRILINEAR_SAMPLINGMODE: number;
  24524. static LINEAR_LINEAR_MIPLINEAR: number;
  24525. static NEAREST_NEAREST_MIPNEAREST: number;
  24526. static NEAREST_LINEAR_MIPNEAREST: number;
  24527. static NEAREST_LINEAR_MIPLINEAR: number;
  24528. static NEAREST_LINEAR: number;
  24529. static NEAREST_NEAREST: number;
  24530. static LINEAR_NEAREST_MIPNEAREST: number;
  24531. static LINEAR_NEAREST_MIPLINEAR: number;
  24532. static LINEAR_LINEAR: number;
  24533. static LINEAR_NEAREST: number;
  24534. static EXPLICIT_MODE: number;
  24535. static SPHERICAL_MODE: number;
  24536. static PLANAR_MODE: number;
  24537. static CUBIC_MODE: number;
  24538. static PROJECTION_MODE: number;
  24539. static SKYBOX_MODE: number;
  24540. static INVCUBIC_MODE: number;
  24541. static EQUIRECTANGULAR_MODE: number;
  24542. static FIXED_EQUIRECTANGULAR_MODE: number;
  24543. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24544. static CLAMP_ADDRESSMODE: number;
  24545. static WRAP_ADDRESSMODE: number;
  24546. static MIRROR_ADDRESSMODE: number;
  24547. url: Nullable<string>;
  24548. uOffset: number;
  24549. vOffset: number;
  24550. uScale: number;
  24551. vScale: number;
  24552. uAng: number;
  24553. vAng: number;
  24554. wAng: number;
  24555. readonly noMipmap: boolean;
  24556. private _noMipmap;
  24557. _invertY: boolean;
  24558. private _rowGenerationMatrix;
  24559. private _cachedTextureMatrix;
  24560. private _projectionModeMatrix;
  24561. private _t0;
  24562. private _t1;
  24563. private _t2;
  24564. private _cachedUOffset;
  24565. private _cachedVOffset;
  24566. private _cachedUScale;
  24567. private _cachedVScale;
  24568. private _cachedUAng;
  24569. private _cachedVAng;
  24570. private _cachedWAng;
  24571. private _cachedProjectionMatrixId;
  24572. private _cachedCoordinatesMode;
  24573. _samplingMode: number;
  24574. private _buffer;
  24575. private _deleteBuffer;
  24576. protected _format: Nullable<number>;
  24577. private _delayedOnLoad;
  24578. private _delayedOnError;
  24579. private _onLoadObservable;
  24580. protected _isBlocking: boolean;
  24581. isBlocking: boolean;
  24582. readonly samplingMode: number;
  24583. 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);
  24584. updateURL(url: string): void;
  24585. delayLoad(): void;
  24586. updateSamplingMode(samplingMode: number): void;
  24587. private _prepareRowForTextureGeneration(x, y, z, t);
  24588. getTextureMatrix(): Matrix;
  24589. getReflectionTextureMatrix(): Matrix;
  24590. clone(): Texture;
  24591. readonly onLoadObservable: Observable<Texture>;
  24592. serialize(): any;
  24593. getClassName(): string;
  24594. dispose(): void;
  24595. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24596. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24597. 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;
  24598. }
  24599. }
  24600. declare module BABYLON {
  24601. /**
  24602. * Settings for finer control over video usage
  24603. */
  24604. interface VideoTextureSettings {
  24605. /**
  24606. * Applies `autoplay` to video, if specified
  24607. */
  24608. autoPlay?: boolean;
  24609. /**
  24610. * Applies `loop` to video, if specified
  24611. */
  24612. loop?: boolean;
  24613. /**
  24614. * Automatically updates internal texture from video at every frame in the render loop
  24615. */
  24616. autoUpdateTexture: boolean;
  24617. }
  24618. class VideoTexture extends Texture {
  24619. /**
  24620. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  24621. */
  24622. readonly autoUpdateTexture: boolean;
  24623. /**
  24624. * The video instance used by the texture internally
  24625. */
  24626. readonly video: HTMLVideoElement;
  24627. private _generateMipMaps;
  24628. private _engine;
  24629. /**
  24630. * Creates a video texture.
  24631. * Sample : https://doc.babylonjs.com/how_to/video_texture
  24632. * @param {string | null} name optional name, will detect from video source, if not defined
  24633. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  24634. * @param {BABYLON.Scene} scene is obviously the current scene.
  24635. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  24636. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  24637. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  24638. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  24639. */
  24640. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  24641. private _getName(src);
  24642. private _getVideo(src);
  24643. private _createInternalTexture;
  24644. private reset;
  24645. /**
  24646. * Internal method to initiate `update`.
  24647. */
  24648. _rebuild(): void;
  24649. /**
  24650. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  24651. */
  24652. update(): void;
  24653. /**
  24654. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  24655. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  24656. */
  24657. updateTexture(isVisible: boolean): void;
  24658. protected _updateInternalTexture: (e?: Event | undefined) => void;
  24659. /**
  24660. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  24661. * @param url New url.
  24662. */
  24663. updateURL(url: string): void;
  24664. dispose(): void;
  24665. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  24666. minWidth: number;
  24667. maxWidth: number;
  24668. minHeight: number;
  24669. maxHeight: number;
  24670. deviceId: string;
  24671. }): void;
  24672. }
  24673. }
  24674. declare module BABYLON {
  24675. class CannonJSPlugin implements IPhysicsEnginePlugin {
  24676. private _useDeltaForWorldStep;
  24677. world: any;
  24678. name: string;
  24679. private _physicsMaterials;
  24680. private _fixedTimeStep;
  24681. BJSCANNON: any;
  24682. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  24683. setGravity(gravity: Vector3): void;
  24684. setTimeStep(timeStep: number): void;
  24685. getTimeStep(): number;
  24686. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24687. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24688. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24689. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24690. private _processChildMeshes(mainImpostor);
  24691. removePhysicsBody(impostor: PhysicsImpostor): void;
  24692. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  24693. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  24694. private _addMaterial(name, friction, restitution);
  24695. private _checkWithEpsilon(value);
  24696. private _createShape(impostor);
  24697. private _createHeightmap(object, pointDepth?);
  24698. private _minus90X;
  24699. private _plus90X;
  24700. private _tmpPosition;
  24701. private _tmpDeltaPosition;
  24702. private _tmpUnityRotation;
  24703. private _updatePhysicsBodyTransformation(impostor);
  24704. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24705. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24706. isSupported(): boolean;
  24707. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  24708. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  24709. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24710. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24711. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24712. getBodyMass(impostor: PhysicsImpostor): number;
  24713. getBodyFriction(impostor: PhysicsImpostor): number;
  24714. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24715. getBodyRestitution(impostor: PhysicsImpostor): number;
  24716. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24717. sleepBody(impostor: PhysicsImpostor): void;
  24718. wakeUpBody(impostor: PhysicsImpostor): void;
  24719. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24720. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  24721. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  24722. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24723. getRadius(impostor: PhysicsImpostor): number;
  24724. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24725. dispose(): void;
  24726. private _extendNamespace();
  24727. }
  24728. }
  24729. declare module BABYLON {
  24730. class OimoJSPlugin implements IPhysicsEnginePlugin {
  24731. world: any;
  24732. name: string;
  24733. BJSOIMO: any;
  24734. constructor(iterations?: number);
  24735. setGravity(gravity: Vector3): void;
  24736. setTimeStep(timeStep: number): void;
  24737. getTimeStep(): number;
  24738. private _tmpImpostorsArray;
  24739. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24740. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24741. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24742. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24743. private _tmpPositionVector;
  24744. removePhysicsBody(impostor: PhysicsImpostor): void;
  24745. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  24746. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  24747. isSupported(): boolean;
  24748. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24749. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24750. private _getLastShape(body);
  24751. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  24752. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  24753. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24754. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24755. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24756. getBodyMass(impostor: PhysicsImpostor): number;
  24757. getBodyFriction(impostor: PhysicsImpostor): number;
  24758. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24759. getBodyRestitution(impostor: PhysicsImpostor): number;
  24760. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24761. sleepBody(impostor: PhysicsImpostor): void;
  24762. wakeUpBody(impostor: PhysicsImpostor): void;
  24763. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24764. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24765. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24766. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24767. getRadius(impostor: PhysicsImpostor): number;
  24768. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24769. dispose(): void;
  24770. }
  24771. }
  24772. declare module BABYLON {
  24773. /**
  24774. * This represents a set of one or more post processes in Babylon.
  24775. * A post process can be used to apply a shader to a texture after it is rendered.
  24776. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  24777. */
  24778. class PostProcessRenderEffect {
  24779. private _postProcesses;
  24780. private _getPostProcesses;
  24781. private _singleInstance;
  24782. private _cameras;
  24783. private _indicesForCamera;
  24784. /**
  24785. * Name of the effect
  24786. */
  24787. _name: string;
  24788. /**
  24789. * Instantiates a post process render effect.
  24790. * A post process can be used to apply a shader to a texture after it is rendered.
  24791. * @param engine The engine the effect is tied to
  24792. * @param name The name of the effect
  24793. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  24794. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  24795. */
  24796. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  24797. /**
  24798. * Checks if all the post processes in the effect are supported.
  24799. */
  24800. readonly isSupported: boolean;
  24801. /**
  24802. * Updates the current state of the effect
  24803. */
  24804. _update(): void;
  24805. /**
  24806. * Attaches the effect on cameras
  24807. * @param cameras The camera to attach to.
  24808. */
  24809. _attachCameras(cameras: Camera): void;
  24810. /**
  24811. * Attaches the effect on cameras
  24812. * @param cameras The camera to attach to.
  24813. */
  24814. _attachCameras(cameras: Camera[]): void;
  24815. /**
  24816. * Detatches the effect on cameras
  24817. * @param cameras The camera to detatch from.
  24818. */
  24819. _detachCameras(cameras: Camera): void;
  24820. /**
  24821. * Detatches the effect on cameras
  24822. * @param cameras The camera to detatch from.
  24823. */
  24824. _detachCameras(cameras: Camera[]): void;
  24825. /**
  24826. * Enables the effect on given cameras
  24827. * @param cameras The camera to enable.
  24828. */
  24829. _enable(cameras: Camera): void;
  24830. /**
  24831. * Enables the effect on given cameras
  24832. * @param cameras The camera to enable.
  24833. */
  24834. _enable(cameras: Nullable<Camera[]>): void;
  24835. /**
  24836. * Disables the effect on the given cameras
  24837. * @param cameras The camera to disable.
  24838. */
  24839. _disable(cameras: Camera): void;
  24840. /**
  24841. * Disables the effect on the given cameras
  24842. * @param cameras The camera to disable.
  24843. */
  24844. _disable(cameras: Nullable<Camera[]>): void;
  24845. /**
  24846. * Gets a list of the post processes contained in the effect.
  24847. * @param camera The camera to get the post processes on.
  24848. * @returns The list of the post processes in the effect.
  24849. */
  24850. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  24851. }
  24852. }
  24853. declare module BABYLON {
  24854. class PostProcessRenderPipeline {
  24855. private _renderEffects;
  24856. private _renderEffectsForIsolatedPass;
  24857. protected _cameras: Camera[];
  24858. _name: string;
  24859. constructor(engine: Engine, name: string);
  24860. getClassName(): string;
  24861. readonly isSupported: boolean;
  24862. addEffect(renderEffect: PostProcessRenderEffect): void;
  24863. _rebuild(): void;
  24864. _enableEffect(renderEffectName: string, cameras: Camera): void;
  24865. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  24866. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  24867. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  24868. _attachCameras(cameras: Camera, unique: boolean): void;
  24869. _attachCameras(cameras: Camera[], unique: boolean): void;
  24870. _detachCameras(cameras: Camera): void;
  24871. _detachCameras(cameras: Nullable<Camera[]>): void;
  24872. _update(): void;
  24873. _reset(): void;
  24874. dispose(): void;
  24875. }
  24876. }
  24877. declare module BABYLON {
  24878. class PostProcessRenderPipelineManager {
  24879. private _renderPipelines;
  24880. constructor();
  24881. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  24882. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  24883. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  24884. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  24885. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  24886. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  24887. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  24888. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  24889. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  24890. update(): void;
  24891. _rebuild(): void;
  24892. dispose(): void;
  24893. }
  24894. }
  24895. declare module BABYLON {
  24896. /**
  24897. * Helper class dealing with the extraction of spherical polynomial dataArray
  24898. * from a cube map.
  24899. */
  24900. class CubeMapToSphericalPolynomialTools {
  24901. private static FileFaces;
  24902. /**
  24903. * Converts a texture to the according Spherical Polynomial data.
  24904. * This extracts the first 3 orders only as they are the only one used in the lighting.
  24905. *
  24906. * @param texture The texture to extract the information from.
  24907. * @return The Spherical Polynomial data.
  24908. */
  24909. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  24910. /**
  24911. * Converts a cubemap to the according Spherical Polynomial data.
  24912. * This extracts the first 3 orders only as they are the only one used in the lighting.
  24913. *
  24914. * @param cubeInfo The Cube map to extract the information from.
  24915. * @return The Spherical Polynomial data.
  24916. */
  24917. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  24918. }
  24919. }
  24920. declare module BABYLON {
  24921. /**
  24922. * Header information of HDR texture files.
  24923. */
  24924. interface HDRInfo {
  24925. /**
  24926. * The height of the texture in pixels.
  24927. */
  24928. height: number;
  24929. /**
  24930. * The width of the texture in pixels.
  24931. */
  24932. width: number;
  24933. /**
  24934. * The index of the beginning of the data in the binary file.
  24935. */
  24936. dataPosition: number;
  24937. }
  24938. /**
  24939. * This groups tools to convert HDR texture to native colors array.
  24940. */
  24941. class HDRTools {
  24942. private static Ldexp(mantissa, exponent);
  24943. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  24944. private static readStringLine(uint8array, startIndex);
  24945. /**
  24946. * Reads header information from an RGBE texture stored in a native array.
  24947. * More information on this format are available here:
  24948. * https://en.wikipedia.org/wiki/RGBE_image_format
  24949. *
  24950. * @param uint8array The binary file stored in native array.
  24951. * @return The header information.
  24952. */
  24953. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  24954. /**
  24955. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  24956. * This RGBE texture needs to store the information as a panorama.
  24957. *
  24958. * More information on this format are available here:
  24959. * https://en.wikipedia.org/wiki/RGBE_image_format
  24960. *
  24961. * @param buffer The binary file stored in an array buffer.
  24962. * @param size The expected size of the extracted cubemap.
  24963. * @return The Cube Map information.
  24964. */
  24965. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  24966. /**
  24967. * Returns the pixels data extracted from an RGBE texture.
  24968. * This pixels will be stored left to right up to down in the R G B order in one array.
  24969. *
  24970. * More information on this format are available here:
  24971. * https://en.wikipedia.org/wiki/RGBE_image_format
  24972. *
  24973. * @param uint8array The binary file stored in an array buffer.
  24974. * @param hdrInfo The header information of the file.
  24975. * @return The pixels data in RGB right to left up to down order.
  24976. */
  24977. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  24978. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  24979. }
  24980. }
  24981. declare module BABYLON {
  24982. /**
  24983. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  24984. */
  24985. interface CubeMapInfo {
  24986. /**
  24987. * The pixel array for the front face.
  24988. * This is stored in format, left to right, up to down format.
  24989. */
  24990. front: Nullable<ArrayBufferView>;
  24991. /**
  24992. * The pixel array for the back face.
  24993. * This is stored in format, left to right, up to down format.
  24994. */
  24995. back: Nullable<ArrayBufferView>;
  24996. /**
  24997. * The pixel array for the left face.
  24998. * This is stored in format, left to right, up to down format.
  24999. */
  25000. left: Nullable<ArrayBufferView>;
  25001. /**
  25002. * The pixel array for the right face.
  25003. * This is stored in format, left to right, up to down format.
  25004. */
  25005. right: Nullable<ArrayBufferView>;
  25006. /**
  25007. * The pixel array for the up face.
  25008. * This is stored in format, left to right, up to down format.
  25009. */
  25010. up: Nullable<ArrayBufferView>;
  25011. /**
  25012. * The pixel array for the down face.
  25013. * This is stored in format, left to right, up to down format.
  25014. */
  25015. down: Nullable<ArrayBufferView>;
  25016. /**
  25017. * The size of the cubemap stored.
  25018. *
  25019. * Each faces will be size * size pixels.
  25020. */
  25021. size: number;
  25022. /**
  25023. * The format of the texture.
  25024. *
  25025. * RGBA, RGB.
  25026. */
  25027. format: number;
  25028. /**
  25029. * The type of the texture data.
  25030. *
  25031. * UNSIGNED_INT, FLOAT.
  25032. */
  25033. type: number;
  25034. /**
  25035. * Specifies whether the texture is in gamma space.
  25036. */
  25037. gammaSpace: boolean;
  25038. }
  25039. /**
  25040. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  25041. */
  25042. class PanoramaToCubeMapTools {
  25043. private static FACE_FRONT;
  25044. private static FACE_BACK;
  25045. private static FACE_RIGHT;
  25046. private static FACE_LEFT;
  25047. private static FACE_DOWN;
  25048. private static FACE_UP;
  25049. /**
  25050. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  25051. *
  25052. * @param float32Array The source data.
  25053. * @param inputWidth The width of the input panorama.
  25054. * @param inputhHeight The height of the input panorama.
  25055. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  25056. * @return The cubemap data
  25057. */
  25058. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  25059. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  25060. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  25061. }
  25062. }
  25063. declare module BABYLON {
  25064. class CustomProceduralTexture extends ProceduralTexture {
  25065. private _animate;
  25066. private _time;
  25067. private _config;
  25068. private _texturePath;
  25069. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  25070. private loadJson(jsonUrl);
  25071. isReady(): boolean;
  25072. render(useCameraPostProcess?: boolean): void;
  25073. updateTextures(): void;
  25074. updateShaderUniforms(): void;
  25075. animate: boolean;
  25076. }
  25077. }
  25078. declare module BABYLON {
  25079. class ProceduralTexture extends Texture {
  25080. isCube: boolean;
  25081. private _size;
  25082. _generateMipMaps: boolean;
  25083. isEnabled: boolean;
  25084. private _currentRefreshId;
  25085. private _refreshRate;
  25086. onGenerated: () => void;
  25087. private _vertexBuffers;
  25088. private _indexBuffer;
  25089. private _effect;
  25090. private _uniforms;
  25091. private _samplers;
  25092. private _fragment;
  25093. _textures: {
  25094. [key: string]: Texture;
  25095. };
  25096. private _floats;
  25097. private _floatsArrays;
  25098. private _colors3;
  25099. private _colors4;
  25100. private _vectors2;
  25101. private _vectors3;
  25102. private _matrices;
  25103. private _fallbackTexture;
  25104. private _fallbackTextureUsed;
  25105. private _engine;
  25106. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  25107. private _createIndexBuffer();
  25108. _rebuild(): void;
  25109. reset(): void;
  25110. isReady(): boolean;
  25111. resetRefreshCounter(): void;
  25112. setFragment(fragment: any): void;
  25113. refreshRate: number;
  25114. _shouldRender(): boolean;
  25115. getRenderSize(): number;
  25116. resize(size: number, generateMipMaps: boolean): void;
  25117. private _checkUniform(uniformName);
  25118. setTexture(name: string, texture: Texture): ProceduralTexture;
  25119. setFloat(name: string, value: number): ProceduralTexture;
  25120. setFloats(name: string, value: number[]): ProceduralTexture;
  25121. setColor3(name: string, value: Color3): ProceduralTexture;
  25122. setColor4(name: string, value: Color4): ProceduralTexture;
  25123. setVector2(name: string, value: Vector2): ProceduralTexture;
  25124. setVector3(name: string, value: Vector3): ProceduralTexture;
  25125. setMatrix(name: string, value: Matrix): ProceduralTexture;
  25126. render(useCameraPostProcess?: boolean): void;
  25127. clone(): ProceduralTexture;
  25128. dispose(): void;
  25129. }
  25130. }
  25131. declare module BABYLON {
  25132. /**
  25133. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  25134. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  25135. */
  25136. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  25137. private _scene;
  25138. /**
  25139. * ID of the pass post process used for bloom,
  25140. */
  25141. readonly PassPostProcessId: string;
  25142. /**
  25143. * ID of the highlight post process used for bloom,
  25144. */
  25145. readonly HighLightsPostProcessId: string;
  25146. /**
  25147. * ID of the blurX post process used for bloom,
  25148. */
  25149. readonly BlurXPostProcessId: string;
  25150. /**
  25151. * ID of the blurY post process used for bloom,
  25152. */
  25153. readonly BlurYPostProcessId: string;
  25154. /**
  25155. * ID of the copy back post process used for bloom,
  25156. */
  25157. readonly CopyBackPostProcessId: string;
  25158. /**
  25159. * ID of the image processing post process;
  25160. */
  25161. readonly ImageProcessingPostProcessId: string;
  25162. /**
  25163. * ID of the Fast Approximate Anti-Aliasing post process;
  25164. */
  25165. readonly FxaaPostProcessId: string;
  25166. /**
  25167. * ID of the final merge post process;
  25168. */
  25169. readonly FinalMergePostProcessId: string;
  25170. /**
  25171. * First pass of bloom to capture the original image texture for later use.
  25172. */
  25173. pass: PassPostProcess;
  25174. /**
  25175. * Second pass of bloom used to brighten bright portions of the image.
  25176. */
  25177. highlights: HighlightsPostProcess;
  25178. /**
  25179. * BlurX post process used in coordination with blurY to guassian blur the highlighted image.
  25180. */
  25181. blurX: BlurPostProcess;
  25182. /**
  25183. * BlurY post process used in coordination with blurX to guassian blur the highlighted image.
  25184. */
  25185. blurY: BlurPostProcess;
  25186. /**
  25187. * Final pass run for bloom to copy the resulting bloom texture back to screen.
  25188. */
  25189. copyBack: PassPostProcess;
  25190. /**
  25191. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  25192. */
  25193. depthOfField: DepthOfFieldEffect;
  25194. /**
  25195. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  25196. */
  25197. fxaa: FxaaPostProcess;
  25198. /**
  25199. * Image post processing pass used to perform operations such as tone mapping or color grading.
  25200. */
  25201. imageProcessing: ImageProcessingPostProcess;
  25202. /**
  25203. * Final post process to merge results of all previous passes
  25204. */
  25205. finalMerge: PassPostProcess;
  25206. /**
  25207. * Animations which can be used to tweak settings over a period of time
  25208. */
  25209. animations: Animation[];
  25210. private _bloomEnabled;
  25211. private _depthOfFieldEnabled;
  25212. private _fxaaEnabled;
  25213. private _imageProcessingEnabled;
  25214. private _defaultPipelineTextureType;
  25215. private _bloomScale;
  25216. private _buildAllowed;
  25217. /**
  25218. * Specifies the size of the bloom blur kernel, relative to the final output size
  25219. */
  25220. bloomKernel: number;
  25221. /**
  25222. * Specifies the weight of the bloom in the final rendering
  25223. */
  25224. private _bloomWeight;
  25225. private _hdr;
  25226. /**
  25227. * The strength of the bloom.
  25228. */
  25229. bloomWeight: number;
  25230. /**
  25231. * The scale of the bloom, lower value will provide better performance.
  25232. */
  25233. bloomScale: number;
  25234. /**
  25235. * Enable or disable the bloom from the pipeline
  25236. */
  25237. bloomEnabled: boolean;
  25238. /**
  25239. * If the depth of field is enabled.
  25240. */
  25241. depthOfFieldEnabled: boolean;
  25242. /**
  25243. * If the anti aliasing is enabled.
  25244. */
  25245. fxaaEnabled: boolean;
  25246. /**
  25247. * If image processing is enabled.
  25248. */
  25249. imageProcessingEnabled: boolean;
  25250. /**
  25251. * @constructor
  25252. * @param {string} name - The rendering pipeline name
  25253. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  25254. * @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)
  25255. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  25256. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
  25257. */
  25258. constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild?: boolean);
  25259. /**
  25260. * Force the compilation of the entire pipeline.
  25261. */
  25262. prepare(): void;
  25263. private _buildPipeline();
  25264. private _disposePostProcesses();
  25265. /**
  25266. * Dispose of the pipeline and stop all post processes
  25267. */
  25268. dispose(): void;
  25269. /**
  25270. * Serialize the rendering pipeline (Used when exporting)
  25271. * @returns the serialized object
  25272. */
  25273. serialize(): any;
  25274. /**
  25275. * Parse the serialized pipeline
  25276. * @param source Source pipeline.
  25277. * @param scene The scene to load the pipeline to.
  25278. * @param rootUrl The URL of the serialized pipeline.
  25279. * @returns An instantiated pipeline from the serialized object.
  25280. */
  25281. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  25282. }
  25283. }
  25284. declare module BABYLON {
  25285. class LensRenderingPipeline extends PostProcessRenderPipeline {
  25286. /**
  25287. * The chromatic aberration PostProcess id in the pipeline
  25288. * @type {string}
  25289. */
  25290. LensChromaticAberrationEffect: string;
  25291. /**
  25292. * The highlights enhancing PostProcess id in the pipeline
  25293. * @type {string}
  25294. */
  25295. HighlightsEnhancingEffect: string;
  25296. /**
  25297. * The depth-of-field PostProcess id in the pipeline
  25298. * @type {string}
  25299. */
  25300. LensDepthOfFieldEffect: string;
  25301. private _scene;
  25302. private _depthTexture;
  25303. private _grainTexture;
  25304. private _chromaticAberrationPostProcess;
  25305. private _highlightsPostProcess;
  25306. private _depthOfFieldPostProcess;
  25307. private _edgeBlur;
  25308. private _grainAmount;
  25309. private _chromaticAberration;
  25310. private _distortion;
  25311. private _highlightsGain;
  25312. private _highlightsThreshold;
  25313. private _dofDistance;
  25314. private _dofAperture;
  25315. private _dofDarken;
  25316. private _dofPentagon;
  25317. private _blurNoise;
  25318. /**
  25319. * @constructor
  25320. *
  25321. * Effect parameters are as follow:
  25322. * {
  25323. * chromatic_aberration: number; // from 0 to x (1 for realism)
  25324. * edge_blur: number; // from 0 to x (1 for realism)
  25325. * distortion: number; // from 0 to x (1 for realism)
  25326. * grain_amount: number; // from 0 to 1
  25327. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  25328. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  25329. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  25330. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  25331. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  25332. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  25333. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  25334. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  25335. * }
  25336. * Note: if an effect parameter is unset, effect is disabled
  25337. *
  25338. * @param {string} name - The rendering pipeline name
  25339. * @param {object} parameters - An object containing all parameters (see above)
  25340. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  25341. * @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)
  25342. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  25343. */
  25344. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  25345. setEdgeBlur(amount: number): void;
  25346. disableEdgeBlur(): void;
  25347. setGrainAmount(amount: number): void;
  25348. disableGrain(): void;
  25349. setChromaticAberration(amount: number): void;
  25350. disableChromaticAberration(): void;
  25351. setEdgeDistortion(amount: number): void;
  25352. disableEdgeDistortion(): void;
  25353. setFocusDistance(amount: number): void;
  25354. disableDepthOfField(): void;
  25355. setAperture(amount: number): void;
  25356. setDarkenOutOfFocus(amount: number): void;
  25357. enablePentagonBokeh(): void;
  25358. disablePentagonBokeh(): void;
  25359. enableNoiseBlur(): void;
  25360. disableNoiseBlur(): void;
  25361. setHighlightsGain(amount: number): void;
  25362. setHighlightsThreshold(amount: number): void;
  25363. disableHighlights(): void;
  25364. /**
  25365. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  25366. */
  25367. dispose(disableDepthRender?: boolean): void;
  25368. private _createChromaticAberrationPostProcess(ratio);
  25369. private _createHighlightsPostProcess(ratio);
  25370. private _createDepthOfFieldPostProcess(ratio);
  25371. private _createGrainTexture();
  25372. }
  25373. }
  25374. declare module BABYLON {
  25375. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  25376. /**
  25377. * The PassPostProcess id in the pipeline that contains the original scene color
  25378. * @type {string}
  25379. */
  25380. SSAOOriginalSceneColorEffect: string;
  25381. /**
  25382. * The SSAO PostProcess id in the pipeline
  25383. * @type {string}
  25384. */
  25385. SSAORenderEffect: string;
  25386. /**
  25387. * The horizontal blur PostProcess id in the pipeline
  25388. * @type {string}
  25389. */
  25390. SSAOBlurHRenderEffect: string;
  25391. /**
  25392. * The vertical blur PostProcess id in the pipeline
  25393. * @type {string}
  25394. */
  25395. SSAOBlurVRenderEffect: string;
  25396. /**
  25397. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  25398. * @type {string}
  25399. */
  25400. SSAOCombineRenderEffect: string;
  25401. /**
  25402. * The output strength of the SSAO post-process. Default value is 1.0.
  25403. * @type {number}
  25404. */
  25405. totalStrength: number;
  25406. /**
  25407. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  25408. * @type {number}
  25409. */
  25410. maxZ: number;
  25411. /**
  25412. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  25413. * @type {number}
  25414. */
  25415. minZAspect: number;
  25416. /**
  25417. * Number of samples used for the SSAO calculations. Default value is 8
  25418. * @type {number}
  25419. */
  25420. private _samples;
  25421. /**
  25422. * Dynamically generated sphere sampler.
  25423. * @type {number[]}
  25424. */
  25425. private _sampleSphere;
  25426. /**
  25427. * Blur filter offsets
  25428. * @type {number[]}
  25429. */
  25430. private _samplerOffsets;
  25431. samples: number;
  25432. /**
  25433. * Are we using bilateral blur ?
  25434. * @type {boolean}
  25435. */
  25436. private _expensiveBlur;
  25437. expensiveBlur: boolean;
  25438. /**
  25439. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  25440. * @type {number}
  25441. */
  25442. radius: number;
  25443. /**
  25444. * The base color of the SSAO post-process
  25445. * The final result is "base + ssao" between [0, 1]
  25446. * @type {number}
  25447. */
  25448. base: number;
  25449. /**
  25450. * Support test.
  25451. * @type {boolean}
  25452. */
  25453. static readonly IsSupported: boolean;
  25454. private _scene;
  25455. private _depthTexture;
  25456. private _normalTexture;
  25457. private _randomTexture;
  25458. private _originalColorPostProcess;
  25459. private _ssaoPostProcess;
  25460. private _blurHPostProcess;
  25461. private _blurVPostProcess;
  25462. private _ssaoCombinePostProcess;
  25463. private _firstUpdate;
  25464. /**
  25465. * @constructor
  25466. * @param {string} name - The rendering pipeline name
  25467. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  25468. * @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 }
  25469. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  25470. */
  25471. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  25472. /**
  25473. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  25474. */
  25475. dispose(disableGeometryBufferRenderer?: boolean): void;
  25476. private _createBlurPostProcess(ssaoRatio, blurRatio);
  25477. _rebuild(): void;
  25478. private _generateHemisphere();
  25479. private _createSSAOPostProcess(ratio);
  25480. private _createSSAOCombinePostProcess(ratio);
  25481. private _createRandomTexture();
  25482. }
  25483. }
  25484. declare module BABYLON {
  25485. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  25486. /**
  25487. * The PassPostProcess id in the pipeline that contains the original scene color
  25488. * @type {string}
  25489. */
  25490. SSAOOriginalSceneColorEffect: string;
  25491. /**
  25492. * The SSAO PostProcess id in the pipeline
  25493. * @type {string}
  25494. */
  25495. SSAORenderEffect: string;
  25496. /**
  25497. * The horizontal blur PostProcess id in the pipeline
  25498. * @type {string}
  25499. */
  25500. SSAOBlurHRenderEffect: string;
  25501. /**
  25502. * The vertical blur PostProcess id in the pipeline
  25503. * @type {string}
  25504. */
  25505. SSAOBlurVRenderEffect: string;
  25506. /**
  25507. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  25508. * @type {string}
  25509. */
  25510. SSAOCombineRenderEffect: string;
  25511. /**
  25512. * The output strength of the SSAO post-process. Default value is 1.0.
  25513. * @type {number}
  25514. */
  25515. totalStrength: number;
  25516. /**
  25517. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  25518. * @type {number}
  25519. */
  25520. radius: number;
  25521. /**
  25522. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  25523. * Must not be equal to fallOff and superior to fallOff.
  25524. * Default value is 0.975
  25525. * @type {number}
  25526. */
  25527. area: number;
  25528. /**
  25529. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  25530. * Must not be equal to area and inferior to area.
  25531. * Default value is 0.0
  25532. * @type {number}
  25533. */
  25534. fallOff: number;
  25535. /**
  25536. * The base color of the SSAO post-process
  25537. * The final result is "base + ssao" between [0, 1]
  25538. * @type {number}
  25539. */
  25540. base: number;
  25541. private _scene;
  25542. private _depthTexture;
  25543. private _randomTexture;
  25544. private _originalColorPostProcess;
  25545. private _ssaoPostProcess;
  25546. private _blurHPostProcess;
  25547. private _blurVPostProcess;
  25548. private _ssaoCombinePostProcess;
  25549. private _firstUpdate;
  25550. /**
  25551. * @constructor
  25552. * @param {string} name - The rendering pipeline name
  25553. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  25554. * @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 }
  25555. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  25556. */
  25557. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  25558. /**
  25559. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  25560. */
  25561. dispose(disableDepthRender?: boolean): void;
  25562. private _createBlurPostProcess(ratio);
  25563. _rebuild(): void;
  25564. private _createSSAOPostProcess(ratio);
  25565. private _createSSAOCombinePostProcess(ratio);
  25566. private _createRandomTexture();
  25567. }
  25568. }
  25569. declare module BABYLON {
  25570. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  25571. /**
  25572. * Public members
  25573. */
  25574. originalPostProcess: Nullable<PostProcess>;
  25575. downSampleX4PostProcess: Nullable<PostProcess>;
  25576. brightPassPostProcess: Nullable<PostProcess>;
  25577. blurHPostProcesses: PostProcess[];
  25578. blurVPostProcesses: PostProcess[];
  25579. textureAdderPostProcess: Nullable<PostProcess>;
  25580. volumetricLightPostProcess: Nullable<PostProcess>;
  25581. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  25582. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  25583. volumetricLightMergePostProces: Nullable<PostProcess>;
  25584. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  25585. luminancePostProcess: Nullable<PostProcess>;
  25586. luminanceDownSamplePostProcesses: PostProcess[];
  25587. hdrPostProcess: Nullable<PostProcess>;
  25588. textureAdderFinalPostProcess: Nullable<PostProcess>;
  25589. lensFlareFinalPostProcess: Nullable<PostProcess>;
  25590. hdrFinalPostProcess: Nullable<PostProcess>;
  25591. lensFlarePostProcess: Nullable<PostProcess>;
  25592. lensFlareComposePostProcess: Nullable<PostProcess>;
  25593. motionBlurPostProcess: Nullable<PostProcess>;
  25594. depthOfFieldPostProcess: Nullable<PostProcess>;
  25595. brightThreshold: number;
  25596. blurWidth: number;
  25597. horizontalBlur: boolean;
  25598. exposure: number;
  25599. lensTexture: Nullable<Texture>;
  25600. volumetricLightCoefficient: number;
  25601. volumetricLightPower: number;
  25602. volumetricLightBlurScale: number;
  25603. sourceLight: Nullable<SpotLight | DirectionalLight>;
  25604. hdrMinimumLuminance: number;
  25605. hdrDecreaseRate: number;
  25606. hdrIncreaseRate: number;
  25607. lensColorTexture: Nullable<Texture>;
  25608. lensFlareStrength: number;
  25609. lensFlareGhostDispersal: number;
  25610. lensFlareHaloWidth: number;
  25611. lensFlareDistortionStrength: number;
  25612. lensStarTexture: Nullable<Texture>;
  25613. lensFlareDirtTexture: Nullable<Texture>;
  25614. depthOfFieldDistance: number;
  25615. depthOfFieldBlurWidth: number;
  25616. motionStrength: number;
  25617. animations: Animation[];
  25618. /**
  25619. * Private members
  25620. */
  25621. private _scene;
  25622. private _currentDepthOfFieldSource;
  25623. private _basePostProcess;
  25624. private _hdrCurrentLuminance;
  25625. private _floatTextureType;
  25626. private _ratio;
  25627. private _bloomEnabled;
  25628. private _depthOfFieldEnabled;
  25629. private _vlsEnabled;
  25630. private _lensFlareEnabled;
  25631. private _hdrEnabled;
  25632. private _motionBlurEnabled;
  25633. private _motionBlurSamples;
  25634. private _volumetricLightStepsCount;
  25635. BloomEnabled: boolean;
  25636. DepthOfFieldEnabled: boolean;
  25637. LensFlareEnabled: boolean;
  25638. HDREnabled: boolean;
  25639. VLSEnabled: boolean;
  25640. MotionBlurEnabled: boolean;
  25641. volumetricLightStepsCount: number;
  25642. motionBlurSamples: number;
  25643. /**
  25644. * @constructor
  25645. * @param {string} name - The rendering pipeline name
  25646. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  25647. * @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)
  25648. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  25649. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  25650. */
  25651. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  25652. private _buildPipeline();
  25653. private _createDownSampleX4PostProcess(scene, ratio);
  25654. private _createBrightPassPostProcess(scene, ratio);
  25655. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  25656. private _createTextureAdderPostProcess(scene, ratio);
  25657. private _createVolumetricLightPostProcess(scene, ratio);
  25658. private _createLuminancePostProcesses(scene, textureType);
  25659. private _createHdrPostProcess(scene, ratio);
  25660. private _createLensFlarePostProcess(scene, ratio);
  25661. private _createDepthOfFieldPostProcess(scene, ratio);
  25662. private _createMotionBlurPostProcess(scene, ratio);
  25663. private _getDepthTexture();
  25664. private _disposePostProcesses();
  25665. dispose(): void;
  25666. serialize(): any;
  25667. /**
  25668. * Static members
  25669. */
  25670. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  25671. static LuminanceSteps: number;
  25672. }
  25673. }