babylon.inspector.js 214 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014
  1. var INSPECTOR;
  2. (function (INSPECTOR) {
  3. var Inspector = (function () {
  4. /** The inspector is created with the given engine.
  5. * If the parameter 'popup' is false, the inspector is created as a right panel on the main window.
  6. * If the parameter 'popup' is true, the inspector is created in another popup.
  7. */
  8. function Inspector(scene, popup, initialTab, parentElement, newColors) {
  9. var _this = this;
  10. /** True if the inspector is built as a popup tab */
  11. this._popupMode = false;
  12. //Load properties of GUI objects now as BABYLON.GUI has to be declared before
  13. INSPECTOR.loadGUIProperties();
  14. //get Tabbar initialTab
  15. this._initialTab = initialTab;
  16. //get parentElement of our Inspector
  17. this._parentElement = parentElement;
  18. // get canvas parent only if needed.
  19. this._scene = scene;
  20. // Save HTML document and window
  21. Inspector.DOCUMENT = window.document;
  22. Inspector.WINDOW = window;
  23. // POPUP MODE
  24. if (popup) {
  25. // Build the inspector in the given parent
  26. this.openPopup(true); // set to true in order to NOT dispose the inspector (done in openPopup), as it's not existing yet
  27. }
  28. else {
  29. // Get canvas and its DOM parent
  30. var canvas = this._scene.getEngine().getRenderingCanvas();
  31. var canvasParent = canvas.parentElement;
  32. var canvasParentComputedStyle = Inspector.WINDOW.getComputedStyle(canvasParent);
  33. // get canvas style
  34. var canvasComputedStyle = Inspector.WINDOW.getComputedStyle(canvas);
  35. this._canvasStyle = {
  36. width: INSPECTOR.Helpers.Css(canvas, 'width'),
  37. height: INSPECTOR.Helpers.Css(canvas, 'height'),
  38. position: canvasComputedStyle.position,
  39. top: canvasComputedStyle.top,
  40. bottom: canvasComputedStyle.bottom,
  41. left: canvasComputedStyle.left,
  42. right: canvasComputedStyle.right,
  43. padding: canvasComputedStyle.padding,
  44. paddingBottom: canvasComputedStyle.paddingBottom,
  45. paddingLeft: canvasComputedStyle.paddingLeft,
  46. paddingTop: canvasComputedStyle.paddingTop,
  47. paddingRight: canvasComputedStyle.paddingRight,
  48. margin: canvasComputedStyle.margin,
  49. marginBottom: canvasComputedStyle.marginBottom,
  50. marginLeft: canvasComputedStyle.marginLeft,
  51. marginTop: canvasComputedStyle.marginTop,
  52. marginRight: canvasComputedStyle.marginRight
  53. };
  54. if (this._parentElement) {
  55. // Build the inspector wrapper
  56. this._c2diwrapper = INSPECTOR.Helpers.CreateDiv('insp-wrapper', this._parentElement);
  57. this._c2diwrapper.style.width = '100%';
  58. this._c2diwrapper.style.height = '100%';
  59. this._c2diwrapper.style.paddingLeft = '5px';
  60. // add inspector
  61. var inspector = INSPECTOR.Helpers.CreateDiv('insp-right-panel', this._c2diwrapper);
  62. inspector.style.width = '100%';
  63. inspector.style.height = '100%';
  64. // and build it in the popup
  65. this._buildInspector(inspector);
  66. }
  67. else {
  68. // Create c2di wrapper
  69. this._c2diwrapper = INSPECTOR.Helpers.CreateDiv('insp-wrapper');
  70. // copy style from canvas to wrapper
  71. for (var prop in this._canvasStyle) {
  72. this._c2diwrapper.style[prop] = this._canvasStyle[prop];
  73. }
  74. // Convert wrapper size in % (because getComputedStyle returns px only)
  75. var widthPx = parseFloat(canvasComputedStyle.width.substr(0, canvasComputedStyle.width.length - 2)) || 0;
  76. var heightPx = parseFloat(canvasComputedStyle.height.substr(0, canvasComputedStyle.height.length - 2)) || 0;
  77. // If the canvas position is absolute, restrain the wrapper width to the window width + left positionning
  78. if (canvasComputedStyle.position === "absolute" || canvasComputedStyle.position === "relative") {
  79. // compute only left as it takes predominance if right is also specified (and it will be for the wrapper)
  80. var leftPx = parseFloat(canvasComputedStyle.left.substr(0, canvasComputedStyle.left.length - 2)) || 0;
  81. if (widthPx + leftPx >= Inspector.WINDOW.innerWidth) {
  82. this._c2diwrapper.style.maxWidth = widthPx - leftPx + "px";
  83. }
  84. }
  85. // Check if the parent of the canvas is the body page. If yes, the size ratio is computed
  86. var parent_1 = this._getRelativeParent(canvas);
  87. var parentWidthPx = parent_1.clientWidth;
  88. var parentHeightPx = parent_1.clientHeight;
  89. var pWidth = widthPx / parentWidthPx * 100;
  90. var pheight = heightPx / parentHeightPx * 100;
  91. this._c2diwrapper.style.width = pWidth + "%";
  92. this._c2diwrapper.style.height = pheight + "%";
  93. // reset canvas style
  94. canvas.style.position = "static";
  95. canvas.style.width = "100%";
  96. canvas.style.height = "100%";
  97. canvas.style.paddingBottom = "0";
  98. canvas.style.paddingLeft = "0";
  99. canvas.style.paddingTop = "0";
  100. canvas.style.paddingRight = "0";
  101. canvas.style.margin = "0";
  102. canvas.style.marginBottom = "0";
  103. canvas.style.marginLeft = "0";
  104. canvas.style.marginTop = "0";
  105. canvas.style.marginRight = "0";
  106. // Replace canvas with the wrapper...
  107. canvasParent.replaceChild(this._c2diwrapper, canvas);
  108. // ... and add canvas to the wrapper
  109. this._c2diwrapper.appendChild(canvas);
  110. // add inspector
  111. var inspector = INSPECTOR.Helpers.CreateDiv('insp-right-panel', this._c2diwrapper);
  112. // Add split bar
  113. if (!this._parentElement) {
  114. Split([canvas, inspector], {
  115. direction: 'horizontal',
  116. sizes: [75, 25],
  117. onDrag: function () {
  118. INSPECTOR.Helpers.SEND_EVENT('resize');
  119. if (_this._tabbar) {
  120. _this._tabbar.updateWidth();
  121. }
  122. }
  123. });
  124. }
  125. // Build the inspector
  126. this._buildInspector(inspector);
  127. }
  128. // Send resize event to the window
  129. INSPECTOR.Helpers.SEND_EVENT('resize');
  130. this._tabbar.updateWidth();
  131. }
  132. // Refresh the inspector if the browser is not edge
  133. if (!INSPECTOR.Helpers.IsBrowserEdge()) {
  134. this.refresh();
  135. }
  136. // Check custom css colors
  137. if (newColors) {
  138. var bColor = newColors.backgroundColor || '#242424';
  139. var bColorl1 = newColors.backgroundColorLighter || '#2c2c2c';
  140. var bColorl2 = newColors.backgroundColorLighter2 || '#383838';
  141. var bColorl3 = newColors.backgroundColorLighter3 || '#454545';
  142. var color = newColors.color || '#ccc';
  143. var colorTop = newColors.colorTop || '#f29766';
  144. var colorBot = newColors.colorBot || '#5db0d7';
  145. var styles = Inspector.DOCUMENT.querySelectorAll('style');
  146. for (var s = 0; s < styles.length; s++) {
  147. var style = styles[s];
  148. if (style.innerHTML.indexOf('insp-wrapper') != -1) {
  149. styles[s].innerHTML = styles[s].innerHTML
  150. .replace(/#242424/g, bColor) // background color
  151. .replace(/#2c2c2c/g, bColorl1) // background-lighter
  152. .replace(/#383838/g, bColorl2) // background-lighter2
  153. .replace(/#454545/g, bColorl3) // background-lighter3
  154. .replace(/#ccc/g, color) // color
  155. .replace(/#f29766/g, colorTop) // color-top
  156. .replace(/#5db0d7/g, colorBot); // color-bot
  157. }
  158. }
  159. }
  160. }
  161. /**
  162. * If the given element has a position 'asbolute' or 'relative',
  163. * returns the first parent of the given element that has a position 'relative' or 'absolute'.
  164. * If the given element has no position, returns the first parent
  165. *
  166. */
  167. Inspector.prototype._getRelativeParent = function (elem, lookForAbsoluteOrRelative) {
  168. // If the elem has no parent, returns himself
  169. if (!elem.parentElement) {
  170. return elem;
  171. }
  172. var computedStyle = Inspector.WINDOW.getComputedStyle(elem);
  173. // looking for the first element absolute or relative
  174. if (lookForAbsoluteOrRelative) {
  175. // if found, return this one
  176. if (computedStyle.position === "relative" || computedStyle.position === "absolute") {
  177. return elem;
  178. }
  179. else {
  180. // otherwise keep looking
  181. return this._getRelativeParent(elem.parentElement, true);
  182. }
  183. }
  184. else {
  185. if (computedStyle.position == "static") {
  186. return elem.parentElement;
  187. }
  188. else {
  189. // the elem has a position relative or absolute, look for the closest relative/absolute parent
  190. return this._getRelativeParent(elem.parentElement, true);
  191. }
  192. }
  193. };
  194. /** Build the inspector panel in the given HTML element */
  195. Inspector.prototype._buildInspector = function (parent) {
  196. // tabbar
  197. this._tabbar = new INSPECTOR.TabBar(this, this._initialTab);
  198. // Top panel
  199. this._topPanel = INSPECTOR.Helpers.CreateDiv('top-panel', parent);
  200. // Add tabbar
  201. this._topPanel.appendChild(this._tabbar.toHtml());
  202. this._tabbar.updateWidth();
  203. // Tab panel
  204. this._tabPanel = INSPECTOR.Helpers.CreateDiv('tab-panel-content', this._topPanel);
  205. };
  206. Object.defineProperty(Inspector.prototype, "scene", {
  207. get: function () {
  208. return this._scene;
  209. },
  210. enumerable: true,
  211. configurable: true
  212. });
  213. Object.defineProperty(Inspector.prototype, "popupMode", {
  214. get: function () {
  215. return this._popupMode;
  216. },
  217. enumerable: true,
  218. configurable: true
  219. });
  220. /**
  221. * Filter the list of item present in the tree.
  222. * All item returned should have the given filter contained in the item id.
  223. */
  224. Inspector.prototype.filterItem = function (filter) {
  225. this._tabbar.getActiveTab().filter(filter);
  226. };
  227. /** Display the mesh tab on the given object */
  228. Inspector.prototype.displayObjectDetails = function (mesh) {
  229. this._tabbar.switchMeshTab(mesh);
  230. };
  231. /** Clean the whole tree of item and rebuilds it */
  232. Inspector.prototype.refresh = function () {
  233. // Clean top panel
  234. INSPECTOR.Helpers.CleanDiv(this._tabPanel);
  235. // Get the active tab and its items
  236. var activeTab = this._tabbar.getActiveTab();
  237. activeTab.update();
  238. this._tabPanel.appendChild(activeTab.getPanel());
  239. INSPECTOR.Helpers.SEND_EVENT('resize');
  240. };
  241. /** Remove the inspector panel when it's built as a right panel:
  242. * remove the right panel and remove the wrapper
  243. */
  244. Inspector.prototype.dispose = function () {
  245. if (!this._popupMode) {
  246. // Get canvas
  247. var canvas = this._scene.getEngine().getRenderingCanvas();
  248. // restore canvas style
  249. for (var prop in this._canvasStyle) {
  250. canvas.style[prop] = this._canvasStyle[prop];
  251. }
  252. // Get parent of the wrapper
  253. var canvasParent = canvas.parentElement.parentElement;
  254. canvasParent.insertBefore(canvas, this._c2diwrapper);
  255. // Remove wrapper
  256. INSPECTOR.Helpers.CleanDiv(this._c2diwrapper);
  257. this._c2diwrapper.remove();
  258. // Send resize event to the window
  259. INSPECTOR.Helpers.SEND_EVENT('resize');
  260. }
  261. };
  262. /** Open the inspector in a new popup
  263. * Set 'firstTime' to true if there is no inspector created beforehands
  264. */
  265. Inspector.prototype.openPopup = function (firstTime) {
  266. var _this = this;
  267. if (INSPECTOR.Helpers.IsBrowserEdge()) {
  268. console.warn('Inspector - Popup mode is disabled in Edge, as the popup DOM cannot be updated from the main window for security reasons');
  269. }
  270. else {
  271. // Create popup
  272. var popup = window.open('', 'Babylon.js INSPECTOR', 'toolbar=no,resizable=yes,menubar=no,width=750,height=1000');
  273. popup.document.title = 'Babylon.js INSPECTOR';
  274. // Get the inspector style
  275. var styles = Inspector.DOCUMENT.querySelectorAll('style');
  276. for (var s = 0; s < styles.length; s++) {
  277. popup.document.body.appendChild(styles[s].cloneNode(true));
  278. }
  279. var links = document.querySelectorAll('link');
  280. for (var l = 0; l < links.length; l++) {
  281. var link = popup.document.createElement("link");
  282. link.rel = "stylesheet";
  283. link.href = links[l].href;
  284. popup.document.head.appendChild(link);
  285. }
  286. // Dispose the right panel if existing
  287. if (!firstTime) {
  288. this.dispose();
  289. }
  290. // set the mode as popup
  291. this._popupMode = true;
  292. // Save the HTML document
  293. Inspector.DOCUMENT = popup.document;
  294. Inspector.WINDOW = popup;
  295. // Build the inspector wrapper
  296. this._c2diwrapper = INSPECTOR.Helpers.CreateDiv('insp-wrapper', popup.document.body);
  297. // add inspector
  298. var inspector = INSPECTOR.Helpers.CreateDiv('insp-right-panel', this._c2diwrapper);
  299. inspector.classList.add('popupmode');
  300. // and build it in the popup
  301. this._buildInspector(inspector);
  302. // Rebuild it
  303. this.refresh();
  304. popup.addEventListener('resize', function () {
  305. if (_this._tabbar) {
  306. _this._tabbar.updateWidth();
  307. }
  308. });
  309. }
  310. };
  311. return Inspector;
  312. }());
  313. INSPECTOR.Inspector = Inspector;
  314. })(INSPECTOR || (INSPECTOR = {}));
  315. //# sourceMappingURL=Inspector.js.map
  316. var INSPECTOR;
  317. (function (INSPECTOR) {
  318. INSPECTOR.PROPERTIES = {
  319. /** Format the given object :
  320. * If a format function exists, returns the result of this function.
  321. * If this function doesn't exists, return the object type instead */
  322. format: function (obj) {
  323. var type = INSPECTOR.Helpers.GET_TYPE(obj) || 'type_not_defined';
  324. if (INSPECTOR.PROPERTIES[type] && INSPECTOR.PROPERTIES[type].format) {
  325. return INSPECTOR.PROPERTIES[type].format(obj);
  326. }
  327. else {
  328. return INSPECTOR.Helpers.GET_TYPE(obj);
  329. }
  330. },
  331. 'type_not_defined': {
  332. properties: [],
  333. format: function () { return ''; }
  334. },
  335. 'Vector2': {
  336. type: BABYLON.Vector2,
  337. properties: ['x', 'y'],
  338. format: function (vec) { return "x:" + INSPECTOR.Helpers.Trunc(vec.x) + ", y:" + INSPECTOR.Helpers.Trunc(vec.y); }
  339. },
  340. 'Vector3': {
  341. type: BABYLON.Vector3,
  342. properties: ['x', 'y', 'z'],
  343. format: function (vec) { return "x:" + INSPECTOR.Helpers.Trunc(vec.x) + ", y:" + INSPECTOR.Helpers.Trunc(vec.y) + ", z:" + INSPECTOR.Helpers.Trunc(vec.z); }
  344. },
  345. 'Color3': {
  346. type: BABYLON.Color3,
  347. properties: ['r', 'g', 'b'],
  348. format: function (color) { return "R:" + color.r + ", G:" + color.g + ", B:" + color.b; }
  349. },
  350. 'Quaternion': {
  351. type: BABYLON.Quaternion,
  352. properties: ['x', 'y', 'z', 'w']
  353. },
  354. 'Size': {
  355. type: BABYLON.Size,
  356. properties: ['width', 'height'],
  357. format: function (size) { return "Size - w:" + INSPECTOR.Helpers.Trunc(size.width) + ", h:" + INSPECTOR.Helpers.Trunc(size.height); }
  358. },
  359. 'Texture': {
  360. type: BABYLON.Texture,
  361. properties: [
  362. 'hasAlpha',
  363. 'level',
  364. 'name',
  365. 'wrapU',
  366. 'wrapV',
  367. 'uScale',
  368. 'vScale',
  369. 'uAng',
  370. 'vAng',
  371. 'wAng',
  372. 'uOffset',
  373. 'vOffset'
  374. ],
  375. format: function (tex) { return tex.name; }
  376. },
  377. 'MapTexture': {
  378. type: BABYLON.MapTexture
  379. },
  380. 'RenderTargetTexture': {
  381. type: BABYLON.RenderTargetTexture
  382. },
  383. 'DynamicTexture': {
  384. type: BABYLON.DynamicTexture
  385. },
  386. 'BaseTexture': {
  387. type: BABYLON.BaseTexture
  388. },
  389. 'FontTexture': {
  390. type: BABYLON.FontTexture
  391. },
  392. 'Sound': {
  393. type: BABYLON.Sound,
  394. properties: [
  395. 'name',
  396. 'autoplay',
  397. 'loop',
  398. 'useCustomAttenuation',
  399. 'soundTrackId',
  400. 'spatialSound',
  401. 'refDistance',
  402. 'rolloffFactor',
  403. 'maxDistance',
  404. 'distanceModel',
  405. 'isPlaying',
  406. 'isPaused'
  407. ]
  408. },
  409. 'ArcRotateCamera': {
  410. type: BABYLON.ArcRotateCamera,
  411. properties: [
  412. 'position',
  413. 'alpha',
  414. 'beta',
  415. 'radius',
  416. 'angularSensibilityX',
  417. 'angularSensibilityY',
  418. 'target',
  419. 'lowerAlphaLimit',
  420. 'lowerBetaLimit',
  421. 'upperAlphaLimit',
  422. 'upperBetaLimit',
  423. 'lowerRadiusLimit',
  424. 'upperRadiusLimit',
  425. 'pinchPrecision',
  426. 'wheelPrecision',
  427. 'allowUpsideDown',
  428. 'checkCollisions'
  429. ]
  430. },
  431. 'FreeCamera': {
  432. type: BABYLON.FreeCamera,
  433. properties: [
  434. 'position',
  435. 'rotation',
  436. 'rotationQuaternion',
  437. 'cameraDirection',
  438. 'cameraRotation',
  439. 'ellipsoid',
  440. 'applyGravity',
  441. 'angularSensibility',
  442. 'keysUp',
  443. 'keysDown',
  444. 'keysLeft',
  445. 'keysRight',
  446. 'checkCollisions',
  447. 'speed',
  448. 'lockedTarget',
  449. 'noRotationConstraint',
  450. 'fov',
  451. 'inertia',
  452. 'minZ', 'maxZ',
  453. 'layerMask',
  454. 'mode',
  455. 'orthoBottom',
  456. 'orthoTop',
  457. 'orthoLeft',
  458. 'orthoRight'
  459. ]
  460. },
  461. 'Scene': {
  462. type: BABYLON.Scene,
  463. properties: [
  464. 'actionManager',
  465. 'activeCamera',
  466. 'ambientColor',
  467. 'clearColor',
  468. 'forceWireframe',
  469. 'forcePointsCloud',
  470. 'forceShowBoundingBoxes',
  471. 'useRightHandedSystem',
  472. 'hoverCursor',
  473. 'cameraToUseForPointers',
  474. 'fogEnabled',
  475. 'fogColor',
  476. 'fogDensity',
  477. 'fogStart',
  478. 'fogEnd',
  479. 'shadowsEnabled',
  480. 'lightsEnabled',
  481. 'collisionsEnabled',
  482. 'gravity',
  483. 'meshUnderPointer',
  484. 'pointerX',
  485. 'pointerY',
  486. 'uid'
  487. ]
  488. },
  489. 'Mesh': {
  490. type: BABYLON.Mesh,
  491. properties: [
  492. 'name',
  493. 'position',
  494. 'rotation',
  495. 'rotationQuaternion',
  496. 'absolutePosition',
  497. 'material',
  498. 'actionManager',
  499. 'visibility',
  500. 'isVisible',
  501. 'isPickable',
  502. 'renderingGroupId',
  503. 'receiveShadows',
  504. 'renderOutline',
  505. 'outlineColor',
  506. 'outlineWidth',
  507. 'renderOverlay',
  508. 'overlayColor',
  509. 'overlayAlpha',
  510. 'hasVertexAlpha',
  511. 'useVertexColors',
  512. 'layerMask',
  513. 'alwaysSelectAsActiveMesh',
  514. 'ellipsoid',
  515. 'ellipsoidOffset',
  516. 'edgesWidth',
  517. 'edgesColor',
  518. 'checkCollisions',
  519. 'hasLODLevels'
  520. ],
  521. format: function (m) { return m.name; }
  522. },
  523. 'StandardMaterial': {
  524. type: BABYLON.StandardMaterial,
  525. properties: [
  526. 'name',
  527. 'alpha',
  528. 'alphaMode',
  529. 'wireframe',
  530. 'isFrozen',
  531. 'zOffset',
  532. 'ambientColor',
  533. 'emissiveColor',
  534. 'diffuseColor',
  535. 'specularColor',
  536. 'specularPower',
  537. 'useAlphaFromDiffuseTexture',
  538. 'linkEmissiveWithDiffuse',
  539. 'useSpecularOverAlpha',
  540. 'diffuseFresnelParameters',
  541. 'opacityFresnelParameters',
  542. 'reflectionFresnelParameters',
  543. 'refractionFresnelParameters',
  544. 'emissiveFresnelParameters',
  545. 'diffuseTexture',
  546. 'emissiveTexture',
  547. 'specularTexture',
  548. 'ambientTexture',
  549. 'bumpTexture',
  550. 'lightMapTexture',
  551. 'opacityTexture',
  552. 'reflectionTexture',
  553. 'refractionTexture'
  554. ],
  555. format: function (mat) { return mat.name; }
  556. },
  557. 'PrimitiveAlignment': {
  558. type: BABYLON.PrimitiveAlignment,
  559. properties: ['horizontal', 'vertical']
  560. },
  561. 'PrimitiveThickness': {
  562. type: BABYLON.PrimitiveThickness,
  563. properties: ['topPixels', 'leftPixels', 'rightPixels', 'bottomPixels']
  564. },
  565. 'BoundingInfo2D': {
  566. type: BABYLON.BoundingInfo2D,
  567. properties: ['radius', 'center', 'extent']
  568. },
  569. 'SolidColorBrush2D': {
  570. type: BABYLON.SolidColorBrush2D,
  571. properties: ['color']
  572. },
  573. 'GradientColorBrush2D': {
  574. type: BABYLON.GradientColorBrush2D,
  575. properties: ['color1', 'color2', 'translation', 'rotation', 'scale']
  576. },
  577. 'PBRMaterial': {
  578. type: BABYLON.PBRMaterial,
  579. properties: [
  580. 'name',
  581. 'albedoColor',
  582. 'albedoTexture',
  583. 'opacityTexture',
  584. 'reflectionTexture',
  585. 'emissiveTexture',
  586. 'bumpTexture',
  587. 'lightmapTexture',
  588. 'opacityFresnelParameters',
  589. 'emissiveFresnelParameters',
  590. 'linkEmissiveWithAlbedo',
  591. 'useLightmapAsShadowmap',
  592. 'useAlphaFromAlbedoTexture',
  593. 'useSpecularOverAlpha',
  594. 'useAutoMicroSurfaceFromReflectivityMap',
  595. 'useLogarithmicDepth',
  596. 'reflectivityColor',
  597. 'reflectivityTexture',
  598. 'reflectionTexture',
  599. 'reflectionColor',
  600. 'alpha',
  601. 'linkRefractionWithTransparency',
  602. 'indexOfRefraction',
  603. 'microSurface',
  604. 'useMicroSurfaceFromReflectivityMapAlpha',
  605. 'directIntensity',
  606. 'emissiveIntensity',
  607. 'specularIntensity',
  608. 'environmentIntensity',
  609. 'cameraExposure',
  610. 'cameraContrast',
  611. 'cameraColorGradingTexture',
  612. 'cameraColorCurves'
  613. ]
  614. },
  615. 'Canvas2D': {
  616. type: BABYLON.Canvas2D
  617. },
  618. 'Canvas2DEngineBoundData': {
  619. type: BABYLON.Canvas2DEngineBoundData
  620. },
  621. 'Ellipse2D': {
  622. type: BABYLON.Ellipse2D
  623. },
  624. 'Ellipse2DInstanceData': {
  625. type: BABYLON.Ellipse2DInstanceData
  626. },
  627. 'Ellipse2DRenderCache': {
  628. type: BABYLON.Ellipse2DRenderCache
  629. },
  630. 'Group2D': {
  631. type: BABYLON.Group2D
  632. },
  633. 'IntersectInfo2D': {
  634. type: BABYLON.IntersectInfo2D
  635. },
  636. 'Lines2D': {
  637. type: BABYLON.Lines2D
  638. },
  639. 'Lines2DInstanceData': {
  640. type: BABYLON.Lines2DInstanceData
  641. },
  642. 'Lines2DRenderCache': {
  643. type: BABYLON.Lines2DRenderCache
  644. },
  645. 'PrepareRender2DContext': {
  646. type: BABYLON.PrepareRender2DContext
  647. },
  648. 'Prim2DBase': {
  649. type: BABYLON.Prim2DBase
  650. },
  651. 'Prim2DClassInfo': {
  652. type: BABYLON.Prim2DClassInfo
  653. },
  654. 'Prim2DPropInfo': {
  655. type: BABYLON.Prim2DPropInfo
  656. },
  657. 'Rectangle2D': {
  658. type: BABYLON.Rectangle2D
  659. },
  660. 'Rectangle2DInstanceData': {
  661. type: BABYLON.Rectangle2DInstanceData
  662. },
  663. 'Rectangle2DRenderCache': {
  664. type: BABYLON.Rectangle2DRenderCache
  665. },
  666. 'Render2DContext': {
  667. type: BABYLON.Render2DContext
  668. },
  669. 'RenderablePrim2D': {
  670. type: BABYLON.RenderablePrim2D
  671. },
  672. 'ScreenSpaceCanvas2D': {
  673. type: BABYLON.ScreenSpaceCanvas2D
  674. },
  675. 'Shape2D': {
  676. type: BABYLON.Shape2D
  677. },
  678. 'Shape2DInstanceData': {
  679. type: BABYLON.Shape2DInstanceData
  680. },
  681. 'Sprite2D': {
  682. type: BABYLON.Sprite2D
  683. },
  684. 'Sprite2DInstanceData': {
  685. type: BABYLON.Sprite2DInstanceData
  686. },
  687. 'Sprite2DRenderCache': {
  688. type: BABYLON.Sprite2DRenderCache
  689. },
  690. 'Text2D': {
  691. type: BABYLON.Text2D
  692. },
  693. 'Text2DInstanceData': {
  694. type: BABYLON.Text2DInstanceData
  695. },
  696. 'Text2DRenderCache': {
  697. type: BABYLON.Text2DRenderCache
  698. },
  699. 'WorldSpaceCanvas2D': {
  700. type: BABYLON.WorldSpaceCanvas2D
  701. },
  702. 'WorldSpaceCanvas2DNode': {
  703. type: BABYLON.WorldSpaceCanvas2DNode
  704. }
  705. };
  706. })(INSPECTOR || (INSPECTOR = {}));
  707. //# sourceMappingURL=properties.js.map
  708. var INSPECTOR;
  709. (function (INSPECTOR) {
  710. /**
  711. * Function that add gui objects properties to the variable PROPERTIES
  712. */
  713. function loadGUIProperties() {
  714. var PROPERTIES_GUI = {
  715. 'ValueAndUnit': {
  716. type: BABYLON.GUI.ValueAndUnit,
  717. properties: ['_value', 'unit'],
  718. format: function (valueAndUnit) { return valueAndUnit; }
  719. },
  720. 'Control': {
  721. type: BABYLON.GUI.Control,
  722. properties: [
  723. '_alpha',
  724. '_fontFamily',
  725. '_color',
  726. '_scaleX',
  727. '_scaleY',
  728. '_rotation',
  729. '_currentMeasure',
  730. '_width',
  731. '_height',
  732. '_left',
  733. '_top',
  734. '_linkedMesh',
  735. 'isHitTestVisible',
  736. 'isPointerBlocker',
  737. ],
  738. format: function (control) { return control.name; }
  739. },
  740. 'Button': {
  741. type: BABYLON.GUI.Button,
  742. properties: [],
  743. format: function (button) { return button.name; }
  744. },
  745. 'ColorPicker': {
  746. type: BABYLON.GUI.ColorPicker,
  747. properties: ['_value'],
  748. format: function (colorPicker) { return colorPicker.name; }
  749. },
  750. 'Checkbox': {
  751. type: BABYLON.GUI.Checkbox,
  752. properties: ['_isChecked', '_background'],
  753. format: function (checkbox) { return checkbox.name; }
  754. },
  755. 'Ellipse': {
  756. type: BABYLON.GUI.Ellipse,
  757. properties: ['_thickness'],
  758. format: function (ellipse) { return ellipse.name; }
  759. },
  760. 'Image': {
  761. type: BABYLON.GUI.Image,
  762. properties: [
  763. '_imageWidth',
  764. '_imageHeight',
  765. '_loaded',
  766. '_source',
  767. ],
  768. format: function (image) { return image.name; }
  769. },
  770. 'Line': {
  771. type: BABYLON.GUI.Line,
  772. properties: ['_lineWidth',
  773. '_background',
  774. '_x1',
  775. '_y1',
  776. '_x2',
  777. '_y2',
  778. ],
  779. format: function (line) { return line.name; }
  780. },
  781. 'RadioButton': {
  782. type: BABYLON.GUI.RadioButton,
  783. properties: ['_isChecked', '_background'],
  784. format: function (radioButton) { return radioButton.name; }
  785. },
  786. 'Rectangle': {
  787. type: BABYLON.GUI.Rectangle,
  788. properties: ['_thickness', '_cornerRadius'],
  789. format: function (rectangle) { return rectangle.name; }
  790. },
  791. 'Slider': {
  792. type: BABYLON.GUI.Slider,
  793. properties: [
  794. '_minimum',
  795. '_maximum',
  796. '_value',
  797. '_background',
  798. '_borderColor',
  799. ],
  800. format: function (slider) { return slider.name; }
  801. },
  802. 'StackPanel': {
  803. type: BABYLON.GUI.StackPanel,
  804. properties: ['_isVertical'],
  805. format: function (stackPanel) { return stackPanel.name; }
  806. },
  807. 'TextBlock': {
  808. type: BABYLON.GUI.TextBlock,
  809. properties: ['_text', '_textWrapping'],
  810. format: function (textBlock) { return textBlock.name; }
  811. },
  812. 'Container': {
  813. type: BABYLON.GUI.Container,
  814. properties: ['_background'],
  815. format: function (container) { return container.name; }
  816. },
  817. };
  818. for (var prop in PROPERTIES_GUI) {
  819. INSPECTOR.PROPERTIES[prop] = PROPERTIES_GUI[prop];
  820. }
  821. }
  822. INSPECTOR.loadGUIProperties = loadGUIProperties;
  823. })(INSPECTOR || (INSPECTOR = {}));
  824. //# sourceMappingURL=properties_gui.js.map
  825. var INSPECTOR;
  826. (function (INSPECTOR) {
  827. /**
  828. * Represents a html div element.
  829. * The div is built when an instance of BasicElement is created.
  830. */
  831. var BasicElement = (function () {
  832. function BasicElement() {
  833. this._div = INSPECTOR.Helpers.CreateDiv();
  834. }
  835. /**
  836. * Returns the div element
  837. */
  838. BasicElement.prototype.toHtml = function () {
  839. return this._div;
  840. };
  841. /**
  842. * Build the html element
  843. */
  844. BasicElement.prototype._build = function () { };
  845. ;
  846. /** Default dispose method if needed */
  847. BasicElement.prototype.dispose = function () { };
  848. ;
  849. return BasicElement;
  850. }());
  851. INSPECTOR.BasicElement = BasicElement;
  852. })(INSPECTOR || (INSPECTOR = {}));
  853. //# sourceMappingURL=BasicElement.js.map
  854. var INSPECTOR;
  855. (function (INSPECTOR) {
  856. var Adapter = (function () {
  857. function Adapter(obj) {
  858. this._obj = obj;
  859. }
  860. Object.defineProperty(Adapter.prototype, "actualObject", {
  861. /** Returns the actual object behind this adapter */
  862. get: function () {
  863. return this._obj;
  864. },
  865. enumerable: true,
  866. configurable: true
  867. });
  868. /** Returns true if the given object correspond to this */
  869. Adapter.prototype.correspondsTo = function (obj) {
  870. return obj === this._obj;
  871. };
  872. Object.defineProperty(Adapter.prototype, "name", {
  873. /** Returns the adapter unique name */
  874. get: function () {
  875. return Adapter._name;
  876. },
  877. enumerable: true,
  878. configurable: true
  879. });
  880. Object.defineProperty(Adapter.prototype, "object", {
  881. /**
  882. * Returns the actual object used for this adapter
  883. */
  884. get: function () {
  885. return this._obj;
  886. },
  887. enumerable: true,
  888. configurable: true
  889. });
  890. /** Should be overriden in subclasses */
  891. Adapter.prototype.highlight = function (b) { };
  892. ;
  893. return Adapter;
  894. }());
  895. // a unique name for this adapter, to retrieve its own key in the local storage
  896. Adapter._name = BABYLON.Geometry.RandomId();
  897. INSPECTOR.Adapter = Adapter;
  898. })(INSPECTOR || (INSPECTOR = {}));
  899. //# sourceMappingURL=Adapter.js.map
  900. var __extends = (this && this.__extends) || (function () {
  901. var extendStatics = Object.setPrototypeOf ||
  902. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  903. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  904. return function (d, b) {
  905. extendStatics(d, b);
  906. function __() { this.constructor = d; }
  907. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  908. };
  909. })();
  910. var INSPECTOR;
  911. (function (INSPECTOR) {
  912. var CameraAdapter = (function (_super) {
  913. __extends(CameraAdapter, _super);
  914. function CameraAdapter(obj) {
  915. return _super.call(this, obj) || this;
  916. }
  917. /** Returns the name displayed in the tree */
  918. CameraAdapter.prototype.id = function () {
  919. var str = '';
  920. if (this._obj.name) {
  921. str = this._obj.name;
  922. } // otherwise nothing displayed
  923. return str;
  924. };
  925. /** Returns the type of this object - displayed in the tree */
  926. CameraAdapter.prototype.type = function () {
  927. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  928. };
  929. /** Returns the list of properties to be displayed for this adapter */
  930. CameraAdapter.prototype.getProperties = function () {
  931. var propertiesLines = [];
  932. var camToDisplay = [];
  933. // The if is there to work with the min version of babylon
  934. if (this._obj instanceof BABYLON.ArcRotateCamera) {
  935. camToDisplay = INSPECTOR.PROPERTIES['ArcRotateCamera'].properties;
  936. }
  937. else if (this._obj instanceof BABYLON.FreeCamera) {
  938. camToDisplay = INSPECTOR.PROPERTIES['FreeCamera'].properties;
  939. }
  940. for (var _i = 0, camToDisplay_1 = camToDisplay; _i < camToDisplay_1.length; _i++) {
  941. var dirty = camToDisplay_1[_i];
  942. var infos = new INSPECTOR.Property(dirty, this._obj);
  943. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  944. }
  945. return propertiesLines;
  946. };
  947. CameraAdapter.prototype.getTools = function () {
  948. var tools = [];
  949. // tools.push(new Checkbox(this));
  950. tools.push(new INSPECTOR.CameraPOV(this));
  951. return tools;
  952. };
  953. CameraAdapter.prototype.setPOV = function () {
  954. this._obj.getScene().activeCamera = this._obj;
  955. };
  956. return CameraAdapter;
  957. }(INSPECTOR.Adapter));
  958. INSPECTOR.CameraAdapter = CameraAdapter;
  959. })(INSPECTOR || (INSPECTOR = {}));
  960. //# sourceMappingURL=CameraAdapter.js.map
  961. var __extends = (this && this.__extends) || (function () {
  962. var extendStatics = Object.setPrototypeOf ||
  963. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  964. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  965. return function (d, b) {
  966. extendStatics(d, b);
  967. function __() { this.constructor = d; }
  968. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  969. };
  970. })();
  971. var INSPECTOR;
  972. (function (INSPECTOR) {
  973. var GUIAdapter = (function (_super) {
  974. __extends(GUIAdapter, _super);
  975. function GUIAdapter(obj) {
  976. return _super.call(this, obj) || this;
  977. }
  978. /** Returns the name displayed in the tree */
  979. GUIAdapter.prototype.id = function () {
  980. var str = '';
  981. if (this._obj.name) {
  982. str = this._obj.name;
  983. } // otherwise nothing displayed
  984. return str;
  985. };
  986. /** Returns the type of this object - displayed in the tree */
  987. GUIAdapter.prototype.type = function () {
  988. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  989. };
  990. /** Returns the list of properties to be displayed for this adapter */
  991. GUIAdapter.prototype.getProperties = function () {
  992. var propertiesLines = [];
  993. for (var _i = 0, _a = INSPECTOR.PROPERTIES['Control'].properties; _i < _a.length; _i++) {
  994. var dirty = _a[_i];
  995. var infos = new INSPECTOR.Property(dirty, this._obj);
  996. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  997. }
  998. if (this._obj instanceof BABYLON.GUI.Button) {
  999. for (var _b = 0, _c = INSPECTOR.PROPERTIES['Button'].properties; _b < _c.length; _b++) {
  1000. var dirty = _c[_b];
  1001. var infos = new INSPECTOR.Property(dirty, this._obj);
  1002. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  1003. }
  1004. }
  1005. if (this._obj instanceof BABYLON.GUI.ColorPicker) {
  1006. for (var _d = 0, _e = INSPECTOR.PROPERTIES['ColorPicker'].properties; _d < _e.length; _d++) {
  1007. var dirty = _e[_d];
  1008. var infos = new INSPECTOR.Property(dirty, this._obj);
  1009. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  1010. }
  1011. }
  1012. if (this._obj instanceof BABYLON.GUI.Checkbox) {
  1013. for (var _f = 0, _g = INSPECTOR.PROPERTIES['Checkbox'].properties; _f < _g.length; _f++) {
  1014. var dirty = _g[_f];
  1015. var infos = new INSPECTOR.Property(dirty, this._obj);
  1016. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  1017. }
  1018. }
  1019. if (this._obj instanceof BABYLON.GUI.Ellipse) {
  1020. for (var _h = 0, _j = INSPECTOR.PROPERTIES['Ellipse'].properties; _h < _j.length; _h++) {
  1021. var dirty = _j[_h];
  1022. var infos = new INSPECTOR.Property(dirty, this._obj);
  1023. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  1024. }
  1025. }
  1026. if (this._obj instanceof BABYLON.GUI.Image) {
  1027. for (var _k = 0, _l = INSPECTOR.PROPERTIES['Image'].properties; _k < _l.length; _k++) {
  1028. var dirty = _l[_k];
  1029. var infos = new INSPECTOR.Property(dirty, this._obj);
  1030. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  1031. }
  1032. }
  1033. if (this._obj instanceof BABYLON.GUI.Line) {
  1034. for (var _m = 0, _o = INSPECTOR.PROPERTIES['Line'].properties; _m < _o.length; _m++) {
  1035. var dirty = _o[_m];
  1036. var infos = new INSPECTOR.Property(dirty, this._obj);
  1037. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  1038. }
  1039. }
  1040. if (this._obj instanceof BABYLON.GUI.RadioButton) {
  1041. for (var _p = 0, _q = INSPECTOR.PROPERTIES['RadioButton'].properties; _p < _q.length; _p++) {
  1042. var dirty = _q[_p];
  1043. var infos = new INSPECTOR.Property(dirty, this._obj);
  1044. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  1045. }
  1046. }
  1047. if (this._obj instanceof BABYLON.GUI.Rectangle) {
  1048. for (var _r = 0, _s = INSPECTOR.PROPERTIES['Rectangle'].properties; _r < _s.length; _r++) {
  1049. var dirty = _s[_r];
  1050. var infos = new INSPECTOR.Property(dirty, this._obj);
  1051. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  1052. }
  1053. }
  1054. if (this._obj instanceof BABYLON.GUI.Slider) {
  1055. for (var _t = 0, _u = INSPECTOR.PROPERTIES['Slider'].properties; _t < _u.length; _t++) {
  1056. var dirty = _u[_t];
  1057. var infos = new INSPECTOR.Property(dirty, this._obj);
  1058. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  1059. }
  1060. }
  1061. if (this._obj instanceof BABYLON.GUI.StackPanel) {
  1062. for (var _v = 0, _w = INSPECTOR.PROPERTIES['StackPanel'].properties; _v < _w.length; _v++) {
  1063. var dirty = _w[_v];
  1064. var infos = new INSPECTOR.Property(dirty, this._obj);
  1065. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  1066. }
  1067. }
  1068. if (this._obj instanceof BABYLON.GUI.TextBlock) {
  1069. for (var _x = 0, _y = INSPECTOR.PROPERTIES['TextBlock'].properties; _x < _y.length; _x++) {
  1070. var dirty = _y[_x];
  1071. var infos = new INSPECTOR.Property(dirty, this._obj);
  1072. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  1073. }
  1074. }
  1075. if (this._obj instanceof BABYLON.GUI.Container) {
  1076. for (var _z = 0, _0 = INSPECTOR.PROPERTIES['Container'].properties; _z < _0.length; _z++) {
  1077. var dirty = _0[_z];
  1078. var infos = new INSPECTOR.Property(dirty, this._obj);
  1079. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  1080. }
  1081. }
  1082. return propertiesLines;
  1083. };
  1084. GUIAdapter.prototype.getTools = function () {
  1085. var tools = [];
  1086. tools.push(new INSPECTOR.Checkbox(this));
  1087. return tools;
  1088. };
  1089. GUIAdapter.prototype.setVisible = function (b) {
  1090. this._obj.isVisible = b;
  1091. };
  1092. GUIAdapter.prototype.isVisible = function () {
  1093. return this._obj.isVisible;
  1094. };
  1095. return GUIAdapter;
  1096. }(INSPECTOR.Adapter));
  1097. INSPECTOR.GUIAdapter = GUIAdapter;
  1098. })(INSPECTOR || (INSPECTOR = {}));
  1099. //# sourceMappingURL=GUIAdapter.js.map
  1100. var __extends = (this && this.__extends) || (function () {
  1101. var extendStatics = Object.setPrototypeOf ||
  1102. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1103. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1104. return function (d, b) {
  1105. extendStatics(d, b);
  1106. function __() { this.constructor = d; }
  1107. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1108. };
  1109. })();
  1110. var INSPECTOR;
  1111. (function (INSPECTOR) {
  1112. var SoundAdapter = (function (_super) {
  1113. __extends(SoundAdapter, _super);
  1114. function SoundAdapter(obj) {
  1115. return _super.call(this, obj) || this;
  1116. }
  1117. /** Returns the name displayed in the tree */
  1118. SoundAdapter.prototype.id = function () {
  1119. var str = '';
  1120. if (this._obj.name) {
  1121. str = this._obj.name;
  1122. } // otherwise nothing displayed
  1123. return str;
  1124. };
  1125. /** Returns the type of this object - displayed in the tree */
  1126. SoundAdapter.prototype.type = function () {
  1127. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  1128. };
  1129. /** Returns the list of properties to be displayed for this adapter */
  1130. SoundAdapter.prototype.getProperties = function () {
  1131. var propertiesLines = [];
  1132. var camToDisplay = [];
  1133. // The if is there to work with the min version of babylon
  1134. var soundProperties = INSPECTOR.PROPERTIES['Sound'].properties;
  1135. for (var _i = 0, soundProperties_1 = soundProperties; _i < soundProperties_1.length; _i++) {
  1136. var dirty = soundProperties_1[_i];
  1137. var infos = new INSPECTOR.Property(dirty, this._obj);
  1138. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  1139. }
  1140. return propertiesLines;
  1141. };
  1142. SoundAdapter.prototype.getTools = function () {
  1143. var tools = [];
  1144. tools.push(new INSPECTOR.SoundInteractions(this));
  1145. return tools;
  1146. };
  1147. SoundAdapter.prototype.setPlaying = function (callback) {
  1148. if (this._obj.isPlaying) {
  1149. this._obj.pause();
  1150. }
  1151. else {
  1152. this._obj.play();
  1153. }
  1154. this._obj.onended = function () {
  1155. callback();
  1156. };
  1157. };
  1158. return SoundAdapter;
  1159. }(INSPECTOR.Adapter));
  1160. INSPECTOR.SoundAdapter = SoundAdapter;
  1161. })(INSPECTOR || (INSPECTOR = {}));
  1162. //# sourceMappingURL=SoundAdapter.js.map
  1163. var __extends = (this && this.__extends) || (function () {
  1164. var extendStatics = Object.setPrototypeOf ||
  1165. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1166. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1167. return function (d, b) {
  1168. extendStatics(d, b);
  1169. function __() { this.constructor = d; }
  1170. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1171. };
  1172. })();
  1173. var INSPECTOR;
  1174. (function (INSPECTOR) {
  1175. var TextureAdapter = (function (_super) {
  1176. __extends(TextureAdapter, _super);
  1177. function TextureAdapter(obj) {
  1178. return _super.call(this, obj) || this;
  1179. }
  1180. /** Returns the name displayed in the tree */
  1181. TextureAdapter.prototype.id = function () {
  1182. var str = '';
  1183. if (this._obj.name) {
  1184. str = this._obj.name;
  1185. } // otherwise nothing displayed
  1186. return str;
  1187. };
  1188. /** Returns the type of this object - displayed in the tree */
  1189. TextureAdapter.prototype.type = function () {
  1190. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  1191. };
  1192. /** Returns the list of properties to be displayed for this adapter */
  1193. TextureAdapter.prototype.getProperties = function () {
  1194. // Not used in this tab
  1195. return [];
  1196. };
  1197. TextureAdapter.prototype.getTools = function () {
  1198. var tools = [];
  1199. // tools.push(new CameraPOV(this));
  1200. return tools;
  1201. };
  1202. return TextureAdapter;
  1203. }(INSPECTOR.Adapter));
  1204. INSPECTOR.TextureAdapter = TextureAdapter;
  1205. })(INSPECTOR || (INSPECTOR = {}));
  1206. //# sourceMappingURL=TextureAdapter.js.map
  1207. var __extends = (this && this.__extends) || (function () {
  1208. var extendStatics = Object.setPrototypeOf ||
  1209. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1210. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1211. return function (d, b) {
  1212. extendStatics(d, b);
  1213. function __() { this.constructor = d; }
  1214. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1215. };
  1216. })();
  1217. var INSPECTOR;
  1218. (function (INSPECTOR) {
  1219. var LightAdapter = (function (_super) {
  1220. __extends(LightAdapter, _super);
  1221. function LightAdapter(obj) {
  1222. return _super.call(this, obj) || this;
  1223. }
  1224. /** Returns the name displayed in the tree */
  1225. LightAdapter.prototype.id = function () {
  1226. var str = '';
  1227. if (this._obj.name) {
  1228. str = this._obj.name;
  1229. } // otherwise nothing displayed
  1230. return str;
  1231. };
  1232. /** Returns the type of this object - displayed in the tree */
  1233. LightAdapter.prototype.type = function () {
  1234. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  1235. };
  1236. /** Returns the list of properties to be displayed for this adapter */
  1237. LightAdapter.prototype.getProperties = function () {
  1238. var propertiesLines = [];
  1239. for (var _i = 0, _a = LightAdapter._PROPERTIES; _i < _a.length; _i++) {
  1240. var dirty = _a[_i];
  1241. var infos = new INSPECTOR.Property(dirty, this._obj);
  1242. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  1243. }
  1244. return propertiesLines;
  1245. };
  1246. LightAdapter.prototype.getTools = function () {
  1247. var tools = [];
  1248. tools.push(new INSPECTOR.Checkbox(this));
  1249. return tools;
  1250. };
  1251. LightAdapter.prototype.setVisible = function (b) {
  1252. this._obj.setEnabled(b);
  1253. };
  1254. LightAdapter.prototype.isVisible = function () {
  1255. return this._obj.isEnabled();
  1256. };
  1257. /** Returns some information about this mesh */
  1258. // public getInfo() : string {
  1259. // return `${(this._obj as BABYLON.AbstractMesh).getTotalVertices()} vertices`;
  1260. // }
  1261. /** Overrides super.highlight */
  1262. LightAdapter.prototype.highlight = function (b) {
  1263. this.actualObject.renderOutline = b;
  1264. this.actualObject.outlineWidth = 0.25;
  1265. this.actualObject.outlineColor = BABYLON.Color3.Yellow();
  1266. };
  1267. return LightAdapter;
  1268. }(INSPECTOR.Adapter));
  1269. LightAdapter._PROPERTIES = [
  1270. 'position',
  1271. 'diffuse',
  1272. 'intensity',
  1273. 'radius',
  1274. 'range',
  1275. 'specular'
  1276. ];
  1277. INSPECTOR.LightAdapter = LightAdapter;
  1278. })(INSPECTOR || (INSPECTOR = {}));
  1279. //# sourceMappingURL=LightAdapter.js.map
  1280. var __extends = (this && this.__extends) || (function () {
  1281. var extendStatics = Object.setPrototypeOf ||
  1282. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1283. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1284. return function (d, b) {
  1285. extendStatics(d, b);
  1286. function __() { this.constructor = d; }
  1287. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1288. };
  1289. })();
  1290. var INSPECTOR;
  1291. (function (INSPECTOR) {
  1292. var MaterialAdapter = (function (_super) {
  1293. __extends(MaterialAdapter, _super);
  1294. function MaterialAdapter(obj) {
  1295. return _super.call(this, obj) || this;
  1296. }
  1297. /** Returns the name displayed in the tree */
  1298. MaterialAdapter.prototype.id = function () {
  1299. var str = '';
  1300. if (this._obj.name) {
  1301. str = this._obj.name;
  1302. } // otherwise nothing displayed
  1303. return str;
  1304. };
  1305. /** Returns the type of this object - displayed in the tree */
  1306. MaterialAdapter.prototype.type = function () {
  1307. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  1308. };
  1309. /** Returns the list of properties to be displayed for this adapter */
  1310. MaterialAdapter.prototype.getProperties = function () {
  1311. var propertiesLines = [];
  1312. var propToDisplay = [];
  1313. // The if is there to work with the min version of babylon
  1314. if (this._obj instanceof BABYLON.StandardMaterial) {
  1315. propToDisplay = INSPECTOR.PROPERTIES['StandardMaterial'].properties;
  1316. }
  1317. else if (this._obj instanceof BABYLON.PBRMaterial) {
  1318. propToDisplay = INSPECTOR.PROPERTIES['PBRMaterial'].properties;
  1319. }
  1320. for (var _i = 0, propToDisplay_1 = propToDisplay; _i < propToDisplay_1.length; _i++) {
  1321. var dirty = propToDisplay_1[_i];
  1322. var infos = new INSPECTOR.Property(dirty, this._obj);
  1323. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  1324. }
  1325. return propertiesLines;
  1326. };
  1327. /** No tools for a material adapter */
  1328. MaterialAdapter.prototype.getTools = function () {
  1329. return [];
  1330. };
  1331. /** Overrides super.highlight.
  1332. * Highlighting a material outlines all meshes linked to this material
  1333. */
  1334. MaterialAdapter.prototype.highlight = function (b) {
  1335. var material = this.actualObject;
  1336. var meshes = material.getBindedMeshes();
  1337. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  1338. var mesh = meshes_1[_i];
  1339. mesh.renderOutline = b;
  1340. mesh.outlineWidth = 0.25;
  1341. mesh.outlineColor = BABYLON.Color3.Yellow();
  1342. }
  1343. };
  1344. return MaterialAdapter;
  1345. }(INSPECTOR.Adapter));
  1346. INSPECTOR.MaterialAdapter = MaterialAdapter;
  1347. })(INSPECTOR || (INSPECTOR = {}));
  1348. //# sourceMappingURL=MaterialAdapter.js.map
  1349. var __extends = (this && this.__extends) || (function () {
  1350. var extendStatics = Object.setPrototypeOf ||
  1351. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1352. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1353. return function (d, b) {
  1354. extendStatics(d, b);
  1355. function __() { this.constructor = d; }
  1356. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1357. };
  1358. })();
  1359. var INSPECTOR;
  1360. (function (INSPECTOR) {
  1361. var MeshAdapter = (function (_super) {
  1362. __extends(MeshAdapter, _super);
  1363. function MeshAdapter(obj) {
  1364. var _this = _super.call(this, obj) || this;
  1365. /** Keep track of the axis of the actual object */
  1366. _this._axis = [];
  1367. return _this;
  1368. }
  1369. /** Returns the name displayed in the tree */
  1370. MeshAdapter.prototype.id = function () {
  1371. var str = '';
  1372. if (this._obj.name) {
  1373. str = this._obj.name;
  1374. } // otherwise nothing displayed
  1375. return str;
  1376. };
  1377. /** Returns the type of this object - displayed in the tree */
  1378. MeshAdapter.prototype.type = function () {
  1379. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  1380. };
  1381. /** Returns the list of properties to be displayed for this adapter */
  1382. MeshAdapter.prototype.getProperties = function () {
  1383. var propertiesLines = [];
  1384. for (var _i = 0, _a = INSPECTOR.PROPERTIES['Mesh'].properties; _i < _a.length; _i++) {
  1385. var dirty = _a[_i];
  1386. var infos = new INSPECTOR.Property(dirty, this._obj);
  1387. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  1388. }
  1389. return propertiesLines;
  1390. };
  1391. MeshAdapter.prototype.getTools = function () {
  1392. var tools = [];
  1393. tools.push(new INSPECTOR.Checkbox(this));
  1394. tools.push(new INSPECTOR.DebugArea(this));
  1395. if (this._obj.getTotalVertices() > 0) {
  1396. tools.push(new INSPECTOR.BoundingBox(this));
  1397. }
  1398. tools.push(new INSPECTOR.Info(this));
  1399. return tools;
  1400. };
  1401. MeshAdapter.prototype.setVisible = function (b) {
  1402. this._obj.setEnabled(b);
  1403. this._obj.isVisible = b;
  1404. };
  1405. MeshAdapter.prototype.isVisible = function () {
  1406. return this._obj.isEnabled() && this._obj.isVisible;
  1407. };
  1408. MeshAdapter.prototype.isBoxVisible = function () {
  1409. return this._obj.showBoundingBox;
  1410. };
  1411. MeshAdapter.prototype.setBoxVisible = function (b) {
  1412. return this._obj.showBoundingBox = b;
  1413. };
  1414. MeshAdapter.prototype.debug = function (b) {
  1415. // Draw axis the first time
  1416. if (this._axis.length == 0) {
  1417. this._drawAxis();
  1418. }
  1419. // Display or hide axis
  1420. for (var _i = 0, _a = this._axis; _i < _a.length; _i++) {
  1421. var ax = _a[_i];
  1422. ax.setEnabled(b);
  1423. }
  1424. };
  1425. /** Returns some information about this mesh */
  1426. MeshAdapter.prototype.getInfo = function () {
  1427. return this._obj.getTotalVertices() + " vertices";
  1428. };
  1429. /** Overrides super.highlight */
  1430. MeshAdapter.prototype.highlight = function (b) {
  1431. this.actualObject.renderOutline = b;
  1432. this.actualObject.outlineWidth = 0.25;
  1433. this.actualObject.outlineColor = BABYLON.Color3.Yellow();
  1434. };
  1435. /** Draw X, Y and Z axis for the actual object if this adapter.
  1436. * Should be called only one time as it will fill this._axis
  1437. */
  1438. MeshAdapter.prototype._drawAxis = function () {
  1439. var _this = this;
  1440. this._obj.computeWorldMatrix();
  1441. var m = this._obj.getWorldMatrix();
  1442. // Axis
  1443. var x = new BABYLON.Vector3(8, 0, 0);
  1444. var y = new BABYLON.Vector3(0, 8, 0);
  1445. var z = new BABYLON.Vector3(0, 0, 8);
  1446. // Draw an axis of the given color
  1447. var _drawAxis = function (color, start, end) {
  1448. var axis = BABYLON.Mesh.CreateLines("###axis###", [
  1449. start,
  1450. end
  1451. ], _this._obj.getScene());
  1452. axis.color = color;
  1453. axis.renderingGroupId = 1;
  1454. return axis;
  1455. };
  1456. // X axis
  1457. var xAxis = _drawAxis(BABYLON.Color3.Red(), BABYLON.Vector3.Zero(), x);
  1458. xAxis.parent = this._obj;
  1459. this._axis.push(xAxis);
  1460. // Y axis
  1461. var yAxis = _drawAxis(BABYLON.Color3.Green(), BABYLON.Vector3.Zero(), y);
  1462. yAxis.parent = this._obj;
  1463. this._axis.push(yAxis);
  1464. // Z axis
  1465. var zAxis = _drawAxis(BABYLON.Color3.Blue(), BABYLON.Vector3.Zero(), z);
  1466. zAxis.parent = this._obj;
  1467. this._axis.push(zAxis);
  1468. };
  1469. return MeshAdapter;
  1470. }(INSPECTOR.Adapter));
  1471. INSPECTOR.MeshAdapter = MeshAdapter;
  1472. })(INSPECTOR || (INSPECTOR = {}));
  1473. //# sourceMappingURL=MeshAdapter.js.map
  1474. var __extends = (this && this.__extends) || (function () {
  1475. var extendStatics = Object.setPrototypeOf ||
  1476. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1477. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1478. return function (d, b) {
  1479. extendStatics(d, b);
  1480. function __() { this.constructor = d; }
  1481. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1482. };
  1483. })();
  1484. var INSPECTOR;
  1485. (function (INSPECTOR) {
  1486. var DetailPanel = (function (_super) {
  1487. __extends(DetailPanel, _super);
  1488. function DetailPanel(dr) {
  1489. var _this = _super.call(this) || this;
  1490. // Contains all details rows that belongs to the item above
  1491. _this._detailRows = [];
  1492. // Store the sort direction of each header column
  1493. _this._sortDirection = {};
  1494. _this._build();
  1495. if (dr) {
  1496. _this._detailRows = dr;
  1497. _this.update();
  1498. }
  1499. return _this;
  1500. }
  1501. Object.defineProperty(DetailPanel.prototype, "details", {
  1502. set: function (detailsRow) {
  1503. this.clean();
  1504. this._detailRows = detailsRow;
  1505. // Refresh HTML
  1506. this.update();
  1507. },
  1508. enumerable: true,
  1509. configurable: true
  1510. });
  1511. DetailPanel.prototype._build = function () {
  1512. this._div.className = 'insp-details';
  1513. this._div.id = 'insp-details';
  1514. // Create header row
  1515. this._createHeaderRow();
  1516. this._div.appendChild(this._headerRow);
  1517. };
  1518. /** Updates the HTML of the detail panel */
  1519. DetailPanel.prototype.update = function () {
  1520. this._sortDetails('name', 1);
  1521. this._addDetails();
  1522. };
  1523. /** Add all lines in the html div. Does not sort them! */
  1524. DetailPanel.prototype._addDetails = function () {
  1525. var details = INSPECTOR.Helpers.CreateDiv('details', this._div);
  1526. for (var _i = 0, _a = this._detailRows; _i < _a.length; _i++) {
  1527. var row = _a[_i];
  1528. details.appendChild(row.toHtml());
  1529. }
  1530. };
  1531. /**
  1532. * Sort the details row by comparing the given property of each row
  1533. */
  1534. DetailPanel.prototype._sortDetails = function (property, _direction) {
  1535. // Clean header
  1536. var elems = INSPECTOR.Inspector.DOCUMENT.querySelectorAll('.sort-direction');
  1537. for (var e = 0; e < elems.length; e++) {
  1538. elems[e].classList.remove('fa-chevron-up');
  1539. elems[e].classList.remove('fa-chevron-down');
  1540. }
  1541. if (_direction || !this._sortDirection[property]) {
  1542. this._sortDirection[property] = _direction || 1;
  1543. }
  1544. else {
  1545. this._sortDirection[property] *= -1;
  1546. }
  1547. var direction = this._sortDirection[property];
  1548. if (direction == 1) {
  1549. this._headerRow.querySelector("#sort-direction-" + property).classList.remove('fa-chevron-down');
  1550. this._headerRow.querySelector("#sort-direction-" + property).classList.add('fa-chevron-up');
  1551. }
  1552. else {
  1553. this._headerRow.querySelector("#sort-direction-" + property).classList.remove('fa-chevron-up');
  1554. this._headerRow.querySelector("#sort-direction-" + property).classList.add('fa-chevron-down');
  1555. }
  1556. var isString = function (s) {
  1557. return typeof (s) === 'string' || s instanceof String;
  1558. };
  1559. this._detailRows.sort(function (detail1, detail2) {
  1560. var str1 = String(detail1[property]);
  1561. var str2 = String(detail2[property]);
  1562. if (!isString(str1)) {
  1563. str1 = detail1[property].toString();
  1564. }
  1565. if (!isString(str2)) {
  1566. str2 = detail2[property].toString();
  1567. }
  1568. // Compare numbers as numbers and string as string with 'numeric=true'
  1569. return str1.localeCompare(str2, [], { numeric: true }) * direction;
  1570. });
  1571. };
  1572. /**
  1573. * Removes all data in the detail panel but keep the header row
  1574. */
  1575. DetailPanel.prototype.clean = function () {
  1576. // Delete all details row
  1577. for (var _i = 0, _a = this._detailRows; _i < _a.length; _i++) {
  1578. var pline = _a[_i];
  1579. pline.dispose();
  1580. }
  1581. INSPECTOR.Helpers.CleanDiv(this._div);
  1582. // Header row
  1583. this._div.appendChild(this._headerRow);
  1584. };
  1585. /** Overrides basicelement.dispose */
  1586. DetailPanel.prototype.dispose = function () {
  1587. // Delete all details row
  1588. for (var _i = 0, _a = this._detailRows; _i < _a.length; _i++) {
  1589. var pline = _a[_i];
  1590. pline.dispose();
  1591. }
  1592. };
  1593. /**
  1594. * Creates the header row : name, value, id
  1595. */
  1596. DetailPanel.prototype._createHeaderRow = function () {
  1597. var _this = this;
  1598. this._headerRow = INSPECTOR.Helpers.CreateDiv('header-row');
  1599. var createDiv = function (name, cssClass) {
  1600. var div = INSPECTOR.Helpers.CreateDiv(cssClass + ' header-col');
  1601. // Column title - first letter in uppercase
  1602. var spanName = INSPECTOR.Inspector.DOCUMENT.createElement('span');
  1603. spanName.textContent = name.charAt(0).toUpperCase() + name.slice(1);
  1604. // sort direction
  1605. var spanDirection = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  1606. spanDirection.className = 'sort-direction fa';
  1607. spanDirection.id = 'sort-direction-' + name;
  1608. div.appendChild(spanName);
  1609. div.appendChild(spanDirection);
  1610. div.addEventListener('click', function (e) {
  1611. _this._sortDetails(name);
  1612. _this._addDetails();
  1613. });
  1614. return div;
  1615. };
  1616. this._headerRow.appendChild(createDiv('name', 'prop-name'));
  1617. this._headerRow.appendChild(createDiv('value', 'prop-value'));
  1618. };
  1619. return DetailPanel;
  1620. }(INSPECTOR.BasicElement));
  1621. INSPECTOR.DetailPanel = DetailPanel;
  1622. })(INSPECTOR || (INSPECTOR = {}));
  1623. //# sourceMappingURL=DetailPanel.js.map
  1624. var INSPECTOR;
  1625. (function (INSPECTOR) {
  1626. /**
  1627. * A property is a link between a data (string) and an object.
  1628. */
  1629. var Property = (function () {
  1630. function Property(prop, obj) {
  1631. this._property = prop;
  1632. this._obj = obj;
  1633. }
  1634. Object.defineProperty(Property.prototype, "name", {
  1635. get: function () {
  1636. return this._property;
  1637. },
  1638. enumerable: true,
  1639. configurable: true
  1640. });
  1641. Object.defineProperty(Property.prototype, "value", {
  1642. get: function () {
  1643. return this._obj[this._property];
  1644. },
  1645. set: function (newValue) {
  1646. this._obj[this._property] = newValue;
  1647. },
  1648. enumerable: true,
  1649. configurable: true
  1650. });
  1651. Object.defineProperty(Property.prototype, "type", {
  1652. get: function () {
  1653. return INSPECTOR.Helpers.GET_TYPE(this.value);
  1654. },
  1655. enumerable: true,
  1656. configurable: true
  1657. });
  1658. Object.defineProperty(Property.prototype, "obj", {
  1659. get: function () {
  1660. return this._obj;
  1661. },
  1662. set: function (newObj) {
  1663. this._obj = newObj;
  1664. },
  1665. enumerable: true,
  1666. configurable: true
  1667. });
  1668. return Property;
  1669. }());
  1670. INSPECTOR.Property = Property;
  1671. })(INSPECTOR || (INSPECTOR = {}));
  1672. //# sourceMappingURL=Property.js.map
  1673. var INSPECTOR;
  1674. (function (INSPECTOR) {
  1675. var PropertyFormatter = (function () {
  1676. function PropertyFormatter() {
  1677. }
  1678. /**
  1679. * Format the value of the given property of the given object.
  1680. */
  1681. PropertyFormatter.format = function (obj, prop) {
  1682. // Get original value;
  1683. var value = obj[prop];
  1684. // test if type PrimitiveAlignment is available (only included in canvas2d)
  1685. if (BABYLON.PrimitiveAlignment) {
  1686. if (obj instanceof BABYLON.PrimitiveAlignment) {
  1687. if (prop === 'horizontal') {
  1688. switch (value) {
  1689. case BABYLON.PrimitiveAlignment.AlignLeft:
  1690. return 'left';
  1691. case BABYLON.PrimitiveAlignment.AlignRight:
  1692. return 'right';
  1693. case BABYLON.PrimitiveAlignment.AlignCenter:
  1694. return 'center';
  1695. case BABYLON.PrimitiveAlignment.AlignStretch:
  1696. return 'stretch';
  1697. }
  1698. }
  1699. else if (prop === 'vertical') {
  1700. switch (value) {
  1701. case BABYLON.PrimitiveAlignment.AlignTop:
  1702. return 'top';
  1703. case BABYLON.PrimitiveAlignment.AlignBottom:
  1704. return 'bottom';
  1705. case BABYLON.PrimitiveAlignment.AlignCenter:
  1706. return 'center';
  1707. case BABYLON.PrimitiveAlignment.AlignStretch:
  1708. return 'stretch';
  1709. }
  1710. }
  1711. }
  1712. }
  1713. return value;
  1714. };
  1715. return PropertyFormatter;
  1716. }());
  1717. INSPECTOR.PropertyFormatter = PropertyFormatter;
  1718. /**
  1719. * A property line represents a line in the detail panel. This line is composed of :
  1720. * - a name (the property name)
  1721. * - a value if this property is of a type 'simple' : string, number, boolean, color, texture
  1722. * - the type of the value if this property is of a complex type (Vector2, Size, ...)
  1723. * - a ID if defined (otherwise an empty string is displayed)
  1724. * The original object is sent to the value object who will update it at will.
  1725. *
  1726. * A property line can contain OTHER property line objects in the case of a complex type.
  1727. * If this instance has no link to other instances, its type is ALWAYS a simple one (see above).
  1728. *
  1729. */
  1730. var PropertyLine = (function () {
  1731. function PropertyLine(prop, parent, level) {
  1732. if (level === void 0) { level = 0; }
  1733. // If the type is complex, this property will have child to update
  1734. this._children = [];
  1735. /** The list of viewer element displayed at the end of the line (color, texture...) */
  1736. this._elements = [];
  1737. this._property = prop;
  1738. this._level = level;
  1739. this._parent = parent;
  1740. this._div = INSPECTOR.Helpers.CreateDiv('row');
  1741. this._div.style.marginLeft = this._level + "px";
  1742. // Property name
  1743. var propName = INSPECTOR.Helpers.CreateDiv('prop-name', this._div);
  1744. propName.textContent = "" + this.name;
  1745. // Value
  1746. this._valueDiv = INSPECTOR.Helpers.CreateDiv('prop-value', this._div);
  1747. this._valueDiv.textContent = this._displayValueContent() || '-'; // Init value text node
  1748. this._createElements();
  1749. for (var _i = 0, _a = this._elements; _i < _a.length; _i++) {
  1750. var elem = _a[_i];
  1751. this._valueDiv.appendChild(elem.toHtml());
  1752. }
  1753. this._updateValue();
  1754. // If the property type is not simple, add click event to unfold its children
  1755. if (!this._isSimple()) {
  1756. this._valueDiv.classList.add('clickable');
  1757. this._valueDiv.addEventListener('click', this._addDetails.bind(this));
  1758. }
  1759. else {
  1760. this._initInput();
  1761. this._valueDiv.addEventListener('click', this._displayInputHandler);
  1762. this._input.addEventListener('keypress', this._validateInputHandler);
  1763. this._input.addEventListener('keydown', this._escapeInputHandler);
  1764. }
  1765. // Add this property to the scheduler
  1766. INSPECTOR.Scheduler.getInstance().add(this);
  1767. }
  1768. /**
  1769. * Init the input element and al its handler :
  1770. * - a click in the window remove the input and restore the old property value
  1771. * - enters updates the property
  1772. */
  1773. PropertyLine.prototype._initInput = function () {
  1774. // Create the input element
  1775. this._input = document.createElement('input');
  1776. this._input.setAttribute('type', 'text');
  1777. // if the property is 'simple', add an event listener to create an input
  1778. this._displayInputHandler = this._displayInput.bind(this);
  1779. this._validateInputHandler = this._validateInput.bind(this);
  1780. this._escapeInputHandler = this._escapeInput.bind(this);
  1781. };
  1782. /**
  1783. * On enter : validates the new value and removes the input
  1784. * On escape : removes the input
  1785. */
  1786. PropertyLine.prototype._validateInput = function (e) {
  1787. if (e.keyCode == 13) {
  1788. // Enter : validate the new value
  1789. var newValue = this._input.value;
  1790. this.updateObject();
  1791. this._property.value = newValue;
  1792. // Remove input
  1793. this.update();
  1794. // resume scheduler
  1795. INSPECTOR.Scheduler.getInstance().pause = false;
  1796. }
  1797. else if (e.keyCode == 27) {
  1798. // Esc : remove input
  1799. this.update();
  1800. }
  1801. };
  1802. /**
  1803. * On escape : removes the input
  1804. */
  1805. PropertyLine.prototype._escapeInput = function (e) {
  1806. if (e.keyCode == 27) {
  1807. // Esc : remove input
  1808. this.update();
  1809. }
  1810. };
  1811. /** Removes the input without validating the new value */
  1812. PropertyLine.prototype._removeInputWithoutValidating = function () {
  1813. INSPECTOR.Helpers.CleanDiv(this._valueDiv);
  1814. this._valueDiv.textContent = "-";
  1815. // restore elements
  1816. for (var _i = 0, _a = this._elements; _i < _a.length; _i++) {
  1817. var elem = _a[_i];
  1818. this._valueDiv.appendChild(elem.toHtml());
  1819. }
  1820. this._valueDiv.addEventListener('click', this._displayInputHandler);
  1821. };
  1822. /** Replaces the default display with an input */
  1823. PropertyLine.prototype._displayInput = function (e) {
  1824. // Remove the displayInput event listener
  1825. this._valueDiv.removeEventListener('click', this._displayInputHandler);
  1826. // Set input value
  1827. var valueTxt = this._valueDiv.textContent;
  1828. this._valueDiv.textContent = "";
  1829. this._input.value = valueTxt;
  1830. this._valueDiv.appendChild(this._input);
  1831. // Pause the scheduler
  1832. INSPECTOR.Scheduler.getInstance().pause = true;
  1833. };
  1834. /** Retrieve the correct object from its parent.
  1835. * If no parent exists, returns the property value.
  1836. * This method is used at each update in case the property object is removed from the original object
  1837. * (example : mesh.position = new BABYLON.Vector3 ; the original vector3 object is deleted from the mesh).
  1838. */
  1839. PropertyLine.prototype.updateObject = function () {
  1840. if (this._parent) {
  1841. this._property.obj = this._parent.updateObject();
  1842. }
  1843. return this._property.value;
  1844. };
  1845. Object.defineProperty(PropertyLine.prototype, "name", {
  1846. // Returns the property name
  1847. get: function () {
  1848. return this._property.name;
  1849. },
  1850. enumerable: true,
  1851. configurable: true
  1852. });
  1853. Object.defineProperty(PropertyLine.prototype, "value", {
  1854. // Returns the value of the property
  1855. get: function () {
  1856. return PropertyFormatter.format(this._property.obj, this._property.name);
  1857. },
  1858. enumerable: true,
  1859. configurable: true
  1860. });
  1861. Object.defineProperty(PropertyLine.prototype, "type", {
  1862. // Returns the type of the property
  1863. get: function () {
  1864. return this._property.type;
  1865. },
  1866. enumerable: true,
  1867. configurable: true
  1868. });
  1869. /**
  1870. * Creates elements that wil be displayed on a property line, depending on the
  1871. * type of the property.
  1872. */
  1873. PropertyLine.prototype._createElements = function () {
  1874. // Colors
  1875. if (this.type == 'Color3' || this.type == 'Color4') {
  1876. this._elements.push(new INSPECTOR.ColorElement(this.value));
  1877. }
  1878. // Texture
  1879. if (this.type == 'Texture') {
  1880. this._elements.push(new INSPECTOR.TextureElement(this.value));
  1881. }
  1882. // HDR Texture
  1883. if (this.type == 'HDRCubeTexture') {
  1884. this._elements.push(new INSPECTOR.HDRCubeTextureElement(this.value));
  1885. }
  1886. if (this.type == 'CubeTexture') {
  1887. this._elements.push(new INSPECTOR.CubeTextureElement(this.value));
  1888. }
  1889. };
  1890. // Returns the text displayed on the left of the property name :
  1891. // - If the type is simple, display its value
  1892. // - If the type is complex, but instance of Vector2, Size, display the type and its tostring
  1893. // - If the type is another one, display the Type
  1894. PropertyLine.prototype._displayValueContent = function () {
  1895. var value = this.value;
  1896. // If the value is a number, truncate it if needed
  1897. if (typeof value === 'number') {
  1898. return INSPECTOR.Helpers.Trunc(value);
  1899. }
  1900. // If it's a string or a boolean, display its value
  1901. if (typeof value === 'string' || typeof value === 'boolean') {
  1902. return value;
  1903. }
  1904. return INSPECTOR.PROPERTIES.format(value);
  1905. };
  1906. /** Delete properly this property line.
  1907. * Removes itself from the scheduler.
  1908. * Dispose all viewer element (color, texture...)
  1909. */
  1910. PropertyLine.prototype.dispose = function () {
  1911. // console.log('delete properties', this.name);
  1912. INSPECTOR.Scheduler.getInstance().remove(this);
  1913. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  1914. var child = _a[_i];
  1915. // console.log('delete properties', child.name);
  1916. INSPECTOR.Scheduler.getInstance().remove(child);
  1917. }
  1918. for (var _b = 0, _c = this._elements; _b < _c.length; _b++) {
  1919. var elem = _c[_b];
  1920. elem.dispose();
  1921. }
  1922. this._elements = [];
  1923. };
  1924. /** Updates the content of _valueDiv with the value of the property,
  1925. * and all HTML element correpsonding to this type.
  1926. * Elements are updated as well
  1927. */
  1928. PropertyLine.prototype._updateValue = function () {
  1929. // Update the property object first
  1930. this.updateObject();
  1931. // Then update its value
  1932. // this._valueDiv.textContent = " "; // TOFIX this removes the elements after
  1933. this._valueDiv.childNodes[0].nodeValue = this._displayValueContent();
  1934. for (var _i = 0, _a = this._elements; _i < _a.length; _i++) {
  1935. var elem = _a[_i];
  1936. elem.update(this.value);
  1937. }
  1938. };
  1939. /**
  1940. * Update the property division with the new property value.
  1941. * If this property is complex, update its child, otherwise update its text content
  1942. */
  1943. PropertyLine.prototype.update = function () {
  1944. this._removeInputWithoutValidating();
  1945. this._updateValue();
  1946. };
  1947. /**
  1948. * Returns true if the given instance is a simple type
  1949. */
  1950. PropertyLine._IS_TYPE_SIMPLE = function (inst) {
  1951. var type = INSPECTOR.Helpers.GET_TYPE(inst);
  1952. return PropertyLine._SIMPLE_TYPE.indexOf(type) != -1;
  1953. };
  1954. /**
  1955. * Returns true if the type of this property is simple, false otherwise.
  1956. * Returns true if the value is null
  1957. */
  1958. PropertyLine.prototype._isSimple = function () {
  1959. if (this.value != null && this.type !== 'type_not_defined') {
  1960. if (PropertyLine._SIMPLE_TYPE.indexOf(this.type) == -1) {
  1961. // complex type : return the type name
  1962. return false;
  1963. }
  1964. else {
  1965. // simple type : return value
  1966. return true;
  1967. }
  1968. }
  1969. else {
  1970. return true;
  1971. }
  1972. };
  1973. PropertyLine.prototype.toHtml = function () {
  1974. return this._div;
  1975. };
  1976. /**
  1977. * Add sub properties in case of a complex type
  1978. */
  1979. PropertyLine.prototype._addDetails = function () {
  1980. if (this._div.classList.contains('unfolded')) {
  1981. // Remove class unfolded
  1982. this._div.classList.remove('unfolded');
  1983. // remove html children
  1984. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  1985. var child = _a[_i];
  1986. this._div.parentNode.removeChild(child.toHtml());
  1987. }
  1988. }
  1989. else {
  1990. // if children does not exists, generate it
  1991. this._div.classList.toggle('unfolded');
  1992. if (this._children.length == 0) {
  1993. var objToDetail = this.value;
  1994. var propToDisplay = INSPECTOR.PROPERTIES[INSPECTOR.Helpers.GET_TYPE(objToDetail)].properties.reverse();
  1995. var propertyLine = null;
  1996. for (var _b = 0, propToDisplay_1 = propToDisplay; _b < propToDisplay_1.length; _b++) {
  1997. var prop = propToDisplay_1[_b];
  1998. var infos = new INSPECTOR.Property(prop, this._property.value);
  1999. var child = new PropertyLine(infos, this, this._level + PropertyLine._MARGIN_LEFT);
  2000. this._children.push(child);
  2001. }
  2002. }
  2003. // otherwise display it
  2004. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  2005. var child = _d[_c];
  2006. this._div.parentNode.insertBefore(child.toHtml(), this._div.nextSibling);
  2007. }
  2008. }
  2009. };
  2010. return PropertyLine;
  2011. }());
  2012. // Array representing the simple type. All others are considered 'complex'
  2013. PropertyLine._SIMPLE_TYPE = ['number', 'string', 'boolean'];
  2014. // The number of pixel at each children step
  2015. PropertyLine._MARGIN_LEFT = 15;
  2016. INSPECTOR.PropertyLine = PropertyLine;
  2017. })(INSPECTOR || (INSPECTOR = {}));
  2018. //# sourceMappingURL=PropertyLine.js.map
  2019. var __extends = (this && this.__extends) || (function () {
  2020. var extendStatics = Object.setPrototypeOf ||
  2021. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2022. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2023. return function (d, b) {
  2024. extendStatics(d, b);
  2025. function __() { this.constructor = d; }
  2026. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2027. };
  2028. })();
  2029. var INSPECTOR;
  2030. (function (INSPECTOR) {
  2031. /**
  2032. * Display a very small div corresponding to the given color
  2033. */
  2034. var ColorElement = (function (_super) {
  2035. __extends(ColorElement, _super);
  2036. // The color as hexadecimal string
  2037. function ColorElement(color) {
  2038. var _this = _super.call(this) || this;
  2039. _this._div.className = 'color-element';
  2040. _this._div.style.backgroundColor = _this._toRgba(color);
  2041. return _this;
  2042. }
  2043. ColorElement.prototype.update = function (color) {
  2044. if (color) {
  2045. this._div.style.backgroundColor = this._toRgba(color);
  2046. }
  2047. };
  2048. ColorElement.prototype._toRgba = function (color) {
  2049. if (color) {
  2050. var r = (color.r * 255) | 0;
  2051. var g = (color.g * 255) | 0;
  2052. var b = (color.b * 255) | 0;
  2053. var a = 1;
  2054. if (color instanceof BABYLON.Color4) {
  2055. var a_1 = color.a;
  2056. }
  2057. return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
  2058. }
  2059. else {
  2060. return '';
  2061. }
  2062. };
  2063. return ColorElement;
  2064. }(INSPECTOR.BasicElement));
  2065. INSPECTOR.ColorElement = ColorElement;
  2066. })(INSPECTOR || (INSPECTOR = {}));
  2067. //# sourceMappingURL=ColorElement.js.map
  2068. var __extends = (this && this.__extends) || (function () {
  2069. var extendStatics = Object.setPrototypeOf ||
  2070. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2071. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2072. return function (d, b) {
  2073. extendStatics(d, b);
  2074. function __() { this.constructor = d; }
  2075. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2076. };
  2077. })();
  2078. var INSPECTOR;
  2079. (function (INSPECTOR) {
  2080. /**
  2081. * Display a very small div. A new canvas is created, with a new Babylon.js scene, containing only the
  2082. * cube texture in a cube
  2083. */
  2084. var CubeTextureElement = (function (_super) {
  2085. __extends(CubeTextureElement, _super);
  2086. /** The texture given as a parameter should be cube. */
  2087. function CubeTextureElement(tex) {
  2088. var _this = _super.call(this) || this;
  2089. // On pause the engine will not render anything
  2090. _this._pause = false;
  2091. _this._div.className = 'fa fa-search texture-element';
  2092. // Create the texture viewer
  2093. _this._textureDiv = INSPECTOR.Helpers.CreateDiv('texture-viewer', _this._div);
  2094. // canvas
  2095. _this._canvas = INSPECTOR.Helpers.CreateElement('canvas', 'texture-viewer-img', _this._textureDiv);
  2096. if (tex) {
  2097. _this._textureUrl = tex.name;
  2098. }
  2099. _this._div.addEventListener('mouseover', _this._showViewer.bind(_this, 'flex'));
  2100. _this._div.addEventListener('mouseout', _this._showViewer.bind(_this, 'none'));
  2101. return _this;
  2102. }
  2103. CubeTextureElement.prototype.update = function (tex) {
  2104. if (tex && tex.url === this._textureUrl) {
  2105. // Nothing to do, as the old texture is the same as the old one
  2106. }
  2107. else {
  2108. if (tex) {
  2109. this._textureUrl = tex.name;
  2110. }
  2111. if (this._engine) {
  2112. // Dispose old material and cube
  2113. this._cube.material.dispose(true, true);
  2114. this._cube.dispose();
  2115. }
  2116. else {
  2117. this._initEngine();
  2118. }
  2119. // and create it again
  2120. this._populateScene();
  2121. }
  2122. };
  2123. /** Creates the box */
  2124. CubeTextureElement.prototype._populateScene = function () {
  2125. var _this = this;
  2126. // Create the hdr texture
  2127. var hdrTexture = new BABYLON.CubeTexture(this._textureUrl, this._scene);
  2128. hdrTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
  2129. this._cube = BABYLON.Mesh.CreateBox("hdrSkyBox", 10.0, this._scene);
  2130. var hdrSkyboxMaterial = new BABYLON.StandardMaterial("skyBox", this._scene);
  2131. hdrSkyboxMaterial.backFaceCulling = false;
  2132. hdrSkyboxMaterial.reflectionTexture = hdrTexture;
  2133. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
  2134. hdrSkyboxMaterial.disableLighting = true;
  2135. this._cube.material = hdrSkyboxMaterial;
  2136. this._cube.registerBeforeRender(function () {
  2137. _this._cube.rotation.y += 0.01;
  2138. });
  2139. };
  2140. /** Init the babylon engine */
  2141. CubeTextureElement.prototype._initEngine = function () {
  2142. var _this = this;
  2143. this._engine = new BABYLON.Engine(this._canvas);
  2144. this._scene = new BABYLON.Scene(this._engine);
  2145. this._scene.clearColor = new BABYLON.Color4(0, 0, 0, 0);
  2146. var cam = new BABYLON.FreeCamera('cam', new BABYLON.Vector3(0, 0, -20), this._scene);
  2147. var light = new BABYLON.HemisphericLight('', new BABYLON.Vector3(0, 1, 0), this._scene);
  2148. this._engine.runRenderLoop(function () {
  2149. if (!_this._pause) {
  2150. _this._scene.render();
  2151. }
  2152. });
  2153. this._canvas.setAttribute('width', '110');
  2154. this._canvas.setAttribute('height', '110');
  2155. };
  2156. CubeTextureElement.prototype._showViewer = function (mode) {
  2157. // If displaying...
  2158. if (mode != 'none') {
  2159. // ... and the canvas is not initialized
  2160. if (!this._engine) {
  2161. this._initEngine();
  2162. this._populateScene();
  2163. }
  2164. // In every cases, unpause the engine
  2165. this._pause = false;
  2166. }
  2167. else {
  2168. // hide : pause the engine
  2169. this._pause = true;
  2170. }
  2171. this._textureDiv.style.display = mode;
  2172. };
  2173. /** Removes properly the babylon engine */
  2174. CubeTextureElement.prototype.dispose = function () {
  2175. if (this._engine) {
  2176. this._engine.dispose();
  2177. this._engine = null;
  2178. }
  2179. };
  2180. return CubeTextureElement;
  2181. }(INSPECTOR.BasicElement));
  2182. INSPECTOR.CubeTextureElement = CubeTextureElement;
  2183. })(INSPECTOR || (INSPECTOR = {}));
  2184. var __extends = (this && this.__extends) || (function () {
  2185. var extendStatics = Object.setPrototypeOf ||
  2186. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2187. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2188. return function (d, b) {
  2189. extendStatics(d, b);
  2190. function __() { this.constructor = d; }
  2191. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2192. };
  2193. })();
  2194. var INSPECTOR;
  2195. (function (INSPECTOR) {
  2196. /**
  2197. * Display a very small div. A new canvas is created, with a new Babylon.js scene, containing only the
  2198. * cube texture in a cube
  2199. */
  2200. var HDRCubeTextureElement = (function (_super) {
  2201. __extends(HDRCubeTextureElement, _super);
  2202. /** The texture given as a parameter should be cube. */
  2203. function HDRCubeTextureElement(tex) {
  2204. return _super.call(this, tex) || this;
  2205. }
  2206. /** Creates the box */
  2207. HDRCubeTextureElement.prototype._populateScene = function () {
  2208. var _this = this;
  2209. // Create the hdr texture
  2210. var hdrTexture = new BABYLON.HDRCubeTexture(this._textureUrl, this._scene, 512);
  2211. hdrTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
  2212. this._cube = BABYLON.Mesh.CreateBox("hdrSkyBox", 10.0, this._scene);
  2213. var hdrSkyboxMaterial = new BABYLON.PBRMaterial("skyBox", this._scene);
  2214. hdrSkyboxMaterial.backFaceCulling = false;
  2215. hdrSkyboxMaterial.reflectionTexture = hdrTexture;
  2216. hdrSkyboxMaterial.microSurface = 1.0;
  2217. hdrSkyboxMaterial.disableLighting = true;
  2218. this._cube.material = hdrSkyboxMaterial;
  2219. this._cube.registerBeforeRender(function () {
  2220. _this._cube.rotation.y += 0.01;
  2221. });
  2222. };
  2223. return HDRCubeTextureElement;
  2224. }(INSPECTOR.CubeTextureElement));
  2225. INSPECTOR.HDRCubeTextureElement = HDRCubeTextureElement;
  2226. })(INSPECTOR || (INSPECTOR = {}));
  2227. var __extends = (this && this.__extends) || (function () {
  2228. var extendStatics = Object.setPrototypeOf ||
  2229. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2230. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2231. return function (d, b) {
  2232. extendStatics(d, b);
  2233. function __() { this.constructor = d; }
  2234. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2235. };
  2236. })();
  2237. var INSPECTOR;
  2238. (function (INSPECTOR) {
  2239. /**
  2240. * A search bar can be used to filter elements in the tree panel.
  2241. * At each keypress on the input, the treepanel will be filtered.
  2242. */
  2243. var SearchBar = (function (_super) {
  2244. __extends(SearchBar, _super);
  2245. function SearchBar(tab) {
  2246. var _this = _super.call(this) || this;
  2247. _this._tab = tab;
  2248. _this._div.classList.add('searchbar');
  2249. var filter = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  2250. filter.className = 'fa fa-search';
  2251. _this._div.appendChild(filter);
  2252. // Create input
  2253. _this._inputElement = INSPECTOR.Inspector.DOCUMENT.createElement('input');
  2254. _this._inputElement.placeholder = 'Filter by name...';
  2255. _this._div.appendChild(_this._inputElement);
  2256. _this._inputElement.addEventListener('keyup', function (evt) {
  2257. var filter = _this._inputElement.value;
  2258. _this._tab.filter(filter);
  2259. });
  2260. return _this;
  2261. }
  2262. /** Delete all characters typped in the input element */
  2263. SearchBar.prototype.reset = function () {
  2264. this._inputElement.value = '';
  2265. };
  2266. SearchBar.prototype.update = function () {
  2267. // Nothing to update
  2268. };
  2269. return SearchBar;
  2270. }(INSPECTOR.BasicElement));
  2271. INSPECTOR.SearchBar = SearchBar;
  2272. })(INSPECTOR || (INSPECTOR = {}));
  2273. var __extends = (this && this.__extends) || (function () {
  2274. var extendStatics = Object.setPrototypeOf ||
  2275. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2276. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2277. return function (d, b) {
  2278. extendStatics(d, b);
  2279. function __() { this.constructor = d; }
  2280. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2281. };
  2282. })();
  2283. var INSPECTOR;
  2284. (function (INSPECTOR) {
  2285. /**
  2286. * Display a very small div corresponding to the given texture. On mouse over, display the full image
  2287. */
  2288. var TextureElement = (function (_super) {
  2289. __extends(TextureElement, _super);
  2290. function TextureElement(tex) {
  2291. var _this = _super.call(this) || this;
  2292. _this._div.className = 'fa fa-search texture-element';
  2293. // Create the texture viewer
  2294. _this._textureDiv = INSPECTOR.Helpers.CreateDiv('texture-viewer', _this._div);
  2295. // Img
  2296. var imgDiv = INSPECTOR.Helpers.CreateDiv('texture-viewer-img', _this._textureDiv);
  2297. // Texture size
  2298. var sizeDiv = INSPECTOR.Helpers.CreateDiv(null, _this._textureDiv);
  2299. if (tex) {
  2300. sizeDiv.textContent = tex.getBaseSize().width + "px x " + tex.getBaseSize().height + "px";
  2301. imgDiv.style.backgroundImage = "url('" + tex.url + "')";
  2302. imgDiv.style.width = tex.getBaseSize().width + "px";
  2303. imgDiv.style.height = tex.getBaseSize().height + "px";
  2304. }
  2305. _this._div.addEventListener('mouseover', _this._showViewer.bind(_this, 'flex'));
  2306. _this._div.addEventListener('mouseout', _this._showViewer.bind(_this, 'none'));
  2307. return _this;
  2308. }
  2309. TextureElement.prototype.update = function (tex) {
  2310. };
  2311. TextureElement.prototype._showViewer = function (mode) {
  2312. this._textureDiv.style.display = mode;
  2313. };
  2314. return TextureElement;
  2315. }(INSPECTOR.BasicElement));
  2316. INSPECTOR.TextureElement = TextureElement;
  2317. })(INSPECTOR || (INSPECTOR = {}));
  2318. var INSPECTOR;
  2319. (function (INSPECTOR) {
  2320. /**
  2321. * Creates a tooltip for the parent of the given html element
  2322. */
  2323. var Tooltip = (function () {
  2324. function Tooltip(elem, tip, attachTo) {
  2325. var _this = this;
  2326. this._elem = elem;
  2327. if (!attachTo) {
  2328. attachTo = this._elem.parentElement;
  2329. }
  2330. this._infoDiv = INSPECTOR.Helpers.CreateDiv('tooltip', attachTo);
  2331. this._elem.addEventListener('mouseover', function () {
  2332. _this._infoDiv.textContent = tip;
  2333. _this._infoDiv.style.display = 'block';
  2334. });
  2335. this._elem.addEventListener('mouseout', function () { _this._infoDiv.style.display = 'none'; });
  2336. }
  2337. return Tooltip;
  2338. }());
  2339. INSPECTOR.Tooltip = Tooltip;
  2340. })(INSPECTOR || (INSPECTOR = {}));
  2341. var INSPECTOR;
  2342. (function (INSPECTOR) {
  2343. var Helpers = (function () {
  2344. function Helpers() {
  2345. }
  2346. /**
  2347. * Returns the type of the given object. First
  2348. * uses getClassName. If nothing is returned, used the type of the constructor
  2349. */
  2350. Helpers.GET_TYPE = function (obj) {
  2351. if (obj != null && obj != undefined) {
  2352. var classname = BABYLON.Tools.getClassName(obj);
  2353. if (!classname || classname === 'object') {
  2354. classname = obj.constructor.name;
  2355. // classname is undefined in IE11
  2356. if (!classname) {
  2357. classname = this._GetFnName(obj.constructor);
  2358. }
  2359. }
  2360. // If the class name has no matching properties, check every type
  2361. if (!this._CheckIfTypeExists(classname)) {
  2362. return this._GetTypeFor(obj);
  2363. }
  2364. return classname;
  2365. }
  2366. else {
  2367. return 'type_not_defined';
  2368. }
  2369. };
  2370. /**
  2371. * Check if some properties are defined for the given type.
  2372. */
  2373. Helpers._CheckIfTypeExists = function (type) {
  2374. var properties = INSPECTOR.PROPERTIES[type];
  2375. if (properties) {
  2376. return true;
  2377. }
  2378. return false;
  2379. };
  2380. /**
  2381. * Returns true if the user browser is edge.
  2382. */
  2383. Helpers.IsBrowserEdge = function () {
  2384. //Detect if we are running on a faulty buggy OS.
  2385. var regexp = /Edge/;
  2386. return regexp.test(navigator.userAgent);
  2387. };
  2388. /**
  2389. * Returns the name of the type of the given object, where the name
  2390. * is in PROPERTIES constant.
  2391. * Returns 'Undefined' if no type exists for this object
  2392. */
  2393. Helpers._GetTypeFor = function (obj) {
  2394. for (var type in INSPECTOR.PROPERTIES) {
  2395. var typeBlock = INSPECTOR.PROPERTIES[type];
  2396. if (typeBlock.type) {
  2397. if (obj instanceof typeBlock.type) {
  2398. return type;
  2399. }
  2400. }
  2401. }
  2402. return 'type_not_defined';
  2403. };
  2404. /**
  2405. * Returns the name of a function (workaround to get object type for IE11)
  2406. */
  2407. Helpers._GetFnName = function (fn) {
  2408. var f = typeof fn == 'function';
  2409. var s = f && ((fn.name && ['', fn.name]) || fn.toString().match(/function ([^\(]+)/));
  2410. return (!f && 'not a function') || (s && s[1] || 'anonymous');
  2411. };
  2412. /** Send the event which name is given in parameter to the window */
  2413. Helpers.SEND_EVENT = function (eventName) {
  2414. var event;
  2415. if (INSPECTOR.Inspector.DOCUMENT.createEvent) {
  2416. event = INSPECTOR.Inspector.DOCUMENT.createEvent('HTMLEvents');
  2417. event.initEvent(eventName, true, true);
  2418. }
  2419. else {
  2420. event = new Event(eventName);
  2421. }
  2422. window.dispatchEvent(event);
  2423. };
  2424. /** Returns the given number with 2 decimal number max if a decimal part exists */
  2425. Helpers.Trunc = function (nb) {
  2426. if (Math.round(nb) !== nb) {
  2427. return nb.toFixed(2);
  2428. }
  2429. return nb;
  2430. };
  2431. ;
  2432. /**
  2433. * Useful function used to create a div
  2434. */
  2435. Helpers.CreateDiv = function (className, parent) {
  2436. return Helpers.CreateElement('div', className, parent);
  2437. };
  2438. Helpers.CreateElement = function (element, className, parent) {
  2439. var elem = INSPECTOR.Inspector.DOCUMENT.createElement(element);
  2440. if (className) {
  2441. elem.className = className;
  2442. }
  2443. if (parent) {
  2444. parent.appendChild(elem);
  2445. }
  2446. return elem;
  2447. };
  2448. /**
  2449. * Removes all children of the given div.
  2450. */
  2451. Helpers.CleanDiv = function (div) {
  2452. while (div.firstChild) {
  2453. div.removeChild(div.firstChild);
  2454. }
  2455. };
  2456. /**
  2457. * Returns the true value of the given CSS Attribute from the given element (in percentage or in pixel, as it was specified in the css)
  2458. */
  2459. Helpers.Css = function (elem, cssAttribute) {
  2460. var clone = elem.cloneNode(true);
  2461. var div = Helpers.CreateDiv('', INSPECTOR.Inspector.DOCUMENT.body);
  2462. div.style.display = 'none';
  2463. div.appendChild(clone);
  2464. var value = INSPECTOR.Inspector.WINDOW.getComputedStyle(clone)[cssAttribute];
  2465. div.parentNode.removeChild(div);
  2466. return value;
  2467. };
  2468. Helpers.LoadScript = function () {
  2469. BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/highlight.min.js", function (elem) {
  2470. var script = Helpers.CreateElement('script', '', INSPECTOR.Inspector.DOCUMENT.body);
  2471. script.textContent = elem;
  2472. // Load glsl detection
  2473. BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/languages/glsl.min.js", function (elem) {
  2474. var script = Helpers.CreateElement('script', '', INSPECTOR.Inspector.DOCUMENT.body);
  2475. script.textContent = elem;
  2476. // Load css style
  2477. BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/styles/zenburn.min.css", function (elem) {
  2478. var style = Helpers.CreateElement('style', '', INSPECTOR.Inspector.DOCUMENT.body);
  2479. style.textContent = elem;
  2480. });
  2481. }, null, null, null, function () {
  2482. console.log("erreur");
  2483. });
  2484. }, null, null, null, function () {
  2485. console.log("erreur");
  2486. });
  2487. };
  2488. Helpers.IsSystemName = function (name) {
  2489. if (name == null) {
  2490. return false;
  2491. }
  2492. return name.indexOf("###") === 0 && name.lastIndexOf("###") === (name.length - 3);
  2493. };
  2494. return Helpers;
  2495. }());
  2496. INSPECTOR.Helpers = Helpers;
  2497. })(INSPECTOR || (INSPECTOR = {}));
  2498. var INSPECTOR;
  2499. (function (INSPECTOR) {
  2500. var Scheduler = (function () {
  2501. function Scheduler() {
  2502. /** Is this scheduler in pause ? */
  2503. this.pause = false;
  2504. /** The list of data to update */
  2505. this._updatableProperties = [];
  2506. this._timer = setInterval(this._update.bind(this), Scheduler.REFRESH_TIME);
  2507. }
  2508. Scheduler.getInstance = function () {
  2509. if (!Scheduler._instance) {
  2510. Scheduler._instance = new Scheduler();
  2511. }
  2512. return Scheduler._instance;
  2513. };
  2514. /** Add a property line to be updated every X ms */
  2515. Scheduler.prototype.add = function (prop) {
  2516. this._updatableProperties.push(prop);
  2517. };
  2518. /** Removes the given property from the list of properties to update */
  2519. Scheduler.prototype.remove = function (prop) {
  2520. var index = this._updatableProperties.indexOf(prop);
  2521. if (index != -1) {
  2522. this._updatableProperties.splice(index, 1);
  2523. }
  2524. };
  2525. Scheduler.prototype._update = function () {
  2526. // If not in pause, update
  2527. if (!this.pause) {
  2528. for (var _i = 0, _a = this._updatableProperties; _i < _a.length; _i++) {
  2529. var prop = _a[_i];
  2530. prop.update();
  2531. }
  2532. }
  2533. };
  2534. return Scheduler;
  2535. }());
  2536. /** All properties are refreshed every 250ms */
  2537. Scheduler.REFRESH_TIME = 250;
  2538. INSPECTOR.Scheduler = Scheduler;
  2539. })(INSPECTOR || (INSPECTOR = {}));
  2540. var __extends = (this && this.__extends) || (function () {
  2541. var extendStatics = Object.setPrototypeOf ||
  2542. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2543. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2544. return function (d, b) {
  2545. extendStatics(d, b);
  2546. function __() { this.constructor = d; }
  2547. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2548. };
  2549. })();
  2550. var INSPECTOR;
  2551. (function (INSPECTOR) {
  2552. var Tab = (function (_super) {
  2553. __extends(Tab, _super);
  2554. function Tab(tabbar, name) {
  2555. var _this = _super.call(this) || this;
  2556. _this._isActive = false;
  2557. _this._tabbar = tabbar;
  2558. _this.name = name;
  2559. _this._build();
  2560. return _this;
  2561. }
  2562. /** True if the tab is active, false otherwise */
  2563. Tab.prototype.isActive = function () {
  2564. return this._isActive;
  2565. };
  2566. Tab.prototype._build = function () {
  2567. var _this = this;
  2568. this._div.className = 'tab';
  2569. this._div.textContent = this.name;
  2570. this._div.addEventListener('click', function (evt) {
  2571. // Set this tab as active
  2572. _this._tabbar.switchTab(_this);
  2573. });
  2574. };
  2575. /** Set this tab as active or not, depending on the current state */
  2576. Tab.prototype.active = function (b) {
  2577. if (b) {
  2578. this._div.classList.add('active');
  2579. }
  2580. else {
  2581. this._div.classList.remove('active');
  2582. }
  2583. this._isActive = b;
  2584. };
  2585. Tab.prototype.update = function () {
  2586. // Nothing for the moment
  2587. };
  2588. /** Creates the tab panel for this tab. */
  2589. Tab.prototype.getPanel = function () {
  2590. return this._panel;
  2591. };
  2592. /** Add this in the propertytab with the searchbar */
  2593. Tab.prototype.filter = function (str) { };
  2594. ;
  2595. /** Select an item in the tree */
  2596. Tab.prototype.select = function (item) {
  2597. // To define in subclasses if needed
  2598. };
  2599. /** Highlight the given node, and downplay all others */
  2600. Tab.prototype.highlightNode = function (item) {
  2601. // To define in subclasses if needed
  2602. };
  2603. /**
  2604. * Returns the total width in pixel of this tab, 0 by default
  2605. */
  2606. Tab.prototype.getPixelWidth = function () {
  2607. var style = INSPECTOR.Inspector.WINDOW.getComputedStyle(this._div);
  2608. var left = parseFloat(style.marginLeft.substr(0, style.marginLeft.length - 2)) || 0;
  2609. var right = parseFloat(style.marginRight.substr(0, style.marginRight.length - 2)) || 0;
  2610. return (this._div.clientWidth || 0) + left + right;
  2611. };
  2612. return Tab;
  2613. }(INSPECTOR.BasicElement));
  2614. INSPECTOR.Tab = Tab;
  2615. })(INSPECTOR || (INSPECTOR = {}));
  2616. var __extends = (this && this.__extends) || (function () {
  2617. var extendStatics = Object.setPrototypeOf ||
  2618. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2619. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2620. return function (d, b) {
  2621. extendStatics(d, b);
  2622. function __() { this.constructor = d; }
  2623. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2624. };
  2625. })();
  2626. var INSPECTOR;
  2627. (function (INSPECTOR) {
  2628. /**
  2629. * A Property tab can creates two panels:
  2630. * a tree panel and a detail panel,
  2631. * in which properties will be displayed.
  2632. * Both panels are separated by a resize bar
  2633. */
  2634. var PropertyTab = (function (_super) {
  2635. __extends(PropertyTab, _super);
  2636. function PropertyTab(tabbar, name, insp) {
  2637. var _this = _super.call(this, tabbar, name) || this;
  2638. _this._treeItems = [];
  2639. _this._inspector = insp;
  2640. // Build the properties panel : a div that will contains the tree and the detail panel
  2641. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  2642. _this._panel.classList.add('searchable');
  2643. // Search bar
  2644. _this._searchBar = new INSPECTOR.SearchBar(_this);
  2645. // Add searchbar
  2646. _this._panel.appendChild(_this._searchBar.toHtml());
  2647. // Build the treepanel
  2648. _this._treePanel = INSPECTOR.Helpers.CreateDiv('insp-tree', _this._panel);
  2649. // Build the detail panel
  2650. _this._detailsPanel = new INSPECTOR.DetailPanel();
  2651. _this._panel.appendChild(_this._detailsPanel.toHtml());
  2652. Split([_this._treePanel, _this._detailsPanel.toHtml()], {
  2653. blockDrag: _this._inspector.popupMode,
  2654. direction: 'vertical'
  2655. });
  2656. _this.update();
  2657. return _this;
  2658. }
  2659. /** Overrides dispose */
  2660. PropertyTab.prototype.dispose = function () {
  2661. this._detailsPanel.dispose();
  2662. };
  2663. PropertyTab.prototype.update = function (_items) {
  2664. var items;
  2665. if (_items) {
  2666. items = _items;
  2667. }
  2668. else {
  2669. // Rebuild the tree
  2670. this._treeItems = this._getTree();
  2671. items = this._treeItems;
  2672. }
  2673. // Clean the tree
  2674. INSPECTOR.Helpers.CleanDiv(this._treePanel);
  2675. // Clean the detail properties
  2676. this._detailsPanel.clean();
  2677. // Sort items alphabetically
  2678. items.sort(function (item1, item2) {
  2679. return item1.compareTo(item2);
  2680. });
  2681. // Display items
  2682. for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
  2683. var item = items_1[_i];
  2684. this._treePanel.appendChild(item.toHtml());
  2685. }
  2686. };
  2687. /** Display the details of the given item */
  2688. PropertyTab.prototype.displayDetails = function (item) {
  2689. // Remove active state on all items
  2690. this.activateNode(item);
  2691. // Update the detail panel
  2692. this._detailsPanel.details = item.getDetails();
  2693. };
  2694. /** Select an item in the tree */
  2695. PropertyTab.prototype.select = function (item) {
  2696. // Remove the node highlight
  2697. this.highlightNode();
  2698. // Active the node
  2699. this.activateNode(item);
  2700. // Display its details
  2701. this.displayDetails(item);
  2702. };
  2703. /** Highlight the given node, and downplay all others */
  2704. PropertyTab.prototype.highlightNode = function (item) {
  2705. if (this._treeItems) {
  2706. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  2707. var node = _a[_i];
  2708. node.highlight(false);
  2709. }
  2710. }
  2711. if (item) {
  2712. item.highlight(true);
  2713. }
  2714. };
  2715. /** Set the given item as active in the tree */
  2716. PropertyTab.prototype.activateNode = function (item) {
  2717. if (this._treeItems) {
  2718. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  2719. var node = _a[_i];
  2720. node.active(false);
  2721. }
  2722. }
  2723. item.active(true);
  2724. };
  2725. /** Returns the treeitem corersponding to the given obj, null if not found */
  2726. PropertyTab.prototype.getItemFor = function (_obj) {
  2727. var obj = _obj;
  2728. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  2729. var item = _a[_i];
  2730. if (item.correspondsTo(obj)) {
  2731. return item;
  2732. }
  2733. }
  2734. return null;
  2735. };
  2736. PropertyTab.prototype.filter = function (filter) {
  2737. var items = [];
  2738. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  2739. var item = _a[_i];
  2740. if (item.id.toLowerCase().indexOf(filter.toLowerCase()) != -1) {
  2741. items.push(item);
  2742. }
  2743. for (var _b = 0, _c = item.children; _b < _c.length; _b++) {
  2744. var child = _c[_b];
  2745. if (child.id.toLowerCase().indexOf(filter.toLowerCase()) != -1) {
  2746. items.push(item);
  2747. }
  2748. }
  2749. }
  2750. this.update(items);
  2751. };
  2752. return PropertyTab;
  2753. }(INSPECTOR.Tab));
  2754. INSPECTOR.PropertyTab = PropertyTab;
  2755. })(INSPECTOR || (INSPECTOR = {}));
  2756. var __extends = (this && this.__extends) || (function () {
  2757. var extendStatics = Object.setPrototypeOf ||
  2758. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2759. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2760. return function (d, b) {
  2761. extendStatics(d, b);
  2762. function __() { this.constructor = d; }
  2763. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2764. };
  2765. })();
  2766. var INSPECTOR;
  2767. (function (INSPECTOR) {
  2768. var CameraTab = (function (_super) {
  2769. __extends(CameraTab, _super);
  2770. function CameraTab(tabbar, inspector) {
  2771. return _super.call(this, tabbar, 'Camera', inspector) || this;
  2772. }
  2773. /* Overrides super */
  2774. CameraTab.prototype._getTree = function () {
  2775. var arr = [];
  2776. // get all cameras from the first scene
  2777. var instances = this._inspector.scene;
  2778. for (var _i = 0, _a = instances.cameras; _i < _a.length; _i++) {
  2779. var camera = _a[_i];
  2780. arr.push(new INSPECTOR.TreeItem(this, new INSPECTOR.CameraAdapter(camera)));
  2781. }
  2782. return arr;
  2783. };
  2784. return CameraTab;
  2785. }(INSPECTOR.PropertyTab));
  2786. INSPECTOR.CameraTab = CameraTab;
  2787. })(INSPECTOR || (INSPECTOR = {}));
  2788. var __extends = (this && this.__extends) || (function () {
  2789. var extendStatics = Object.setPrototypeOf ||
  2790. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2791. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2792. return function (d, b) {
  2793. extendStatics(d, b);
  2794. function __() { this.constructor = d; }
  2795. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2796. };
  2797. })();
  2798. var INSPECTOR;
  2799. (function (INSPECTOR) {
  2800. var GUITab = (function (_super) {
  2801. __extends(GUITab, _super);
  2802. function GUITab(tabbar, inspector) {
  2803. return _super.call(this, tabbar, 'GUI', inspector) || this;
  2804. }
  2805. /* Overrides super */
  2806. GUITab.prototype._getTree = function () {
  2807. var _this = this;
  2808. var arr = [];
  2809. // Recursive method building the tree panel
  2810. var createNode = function (obj) {
  2811. var descendants = obj.children;
  2812. if (descendants && descendants.length > 0) {
  2813. var node = new INSPECTOR.TreeItem(_this, new INSPECTOR.GUIAdapter(obj));
  2814. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  2815. var child = descendants_1[_i];
  2816. var n = createNode(child);
  2817. node.add(n);
  2818. }
  2819. node.update();
  2820. return node;
  2821. }
  2822. else {
  2823. return new INSPECTOR.TreeItem(_this, new INSPECTOR.GUIAdapter(obj));
  2824. }
  2825. };
  2826. // get all textures from the first scene
  2827. var instances = this._inspector.scene;
  2828. for (var _i = 0, _a = instances.textures; _i < _a.length; _i++) {
  2829. var tex = _a[_i];
  2830. //only get GUI's textures
  2831. if (tex instanceof BABYLON.GUI.AdvancedDynamicTexture) {
  2832. var node = createNode(tex._rootContainer);
  2833. arr.push(node);
  2834. }
  2835. }
  2836. return arr;
  2837. };
  2838. return GUITab;
  2839. }(INSPECTOR.PropertyTab));
  2840. INSPECTOR.GUITab = GUITab;
  2841. })(INSPECTOR || (INSPECTOR = {}));
  2842. var __extends = (this && this.__extends) || (function () {
  2843. var extendStatics = Object.setPrototypeOf ||
  2844. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2845. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2846. return function (d, b) {
  2847. extendStatics(d, b);
  2848. function __() { this.constructor = d; }
  2849. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2850. };
  2851. })();
  2852. var INSPECTOR;
  2853. (function (INSPECTOR) {
  2854. var SoundTab = (function (_super) {
  2855. __extends(SoundTab, _super);
  2856. function SoundTab(tabbar, inspector) {
  2857. return _super.call(this, tabbar, 'Audio', inspector) || this;
  2858. }
  2859. /* Overrides super */
  2860. SoundTab.prototype._getTree = function () {
  2861. var _this = this;
  2862. var arr = [];
  2863. // get all cameras from the first scene
  2864. var instances = this._inspector.scene;
  2865. for (var _i = 0, _a = instances.soundTracks; _i < _a.length; _i++) {
  2866. var sounds = _a[_i];
  2867. var sound = sounds.soundCollection;
  2868. sound.forEach(function (element) {
  2869. arr.push(new INSPECTOR.TreeItem(_this, new INSPECTOR.SoundAdapter(element)));
  2870. });
  2871. }
  2872. return arr;
  2873. };
  2874. return SoundTab;
  2875. }(INSPECTOR.PropertyTab));
  2876. INSPECTOR.SoundTab = SoundTab;
  2877. })(INSPECTOR || (INSPECTOR = {}));
  2878. var __extends = (this && this.__extends) || (function () {
  2879. var extendStatics = Object.setPrototypeOf ||
  2880. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2881. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2882. return function (d, b) {
  2883. extendStatics(d, b);
  2884. function __() { this.constructor = d; }
  2885. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2886. };
  2887. })();
  2888. var INSPECTOR;
  2889. (function (INSPECTOR) {
  2890. var TextureTab = (function (_super) {
  2891. __extends(TextureTab, _super);
  2892. function TextureTab(tabbar, inspector) {
  2893. var _this = _super.call(this, tabbar, 'Textures') || this;
  2894. _this._treeItems = [];
  2895. _this._inspector = inspector;
  2896. // Build the properties panel : a div that will contains the tree and the detail panel
  2897. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  2898. // Build the treepanel
  2899. _this._treePanel = INSPECTOR.Helpers.CreateDiv('insp-tree', _this._panel);
  2900. _this._imagePanel = INSPECTOR.Helpers.CreateDiv('image-panel', _this._panel);
  2901. Split([_this._treePanel, _this._imagePanel], {
  2902. blockDrag: _this._inspector.popupMode,
  2903. direction: 'vertical'
  2904. });
  2905. _this.update();
  2906. return _this;
  2907. }
  2908. TextureTab.prototype.dispose = function () {
  2909. // Nothing to dispose
  2910. };
  2911. TextureTab.prototype.update = function (_items) {
  2912. var items;
  2913. if (_items) {
  2914. items = _items;
  2915. }
  2916. else {
  2917. // Rebuild the tree
  2918. this._treeItems = this._getTree();
  2919. items = this._treeItems;
  2920. }
  2921. // Clean the tree
  2922. INSPECTOR.Helpers.CleanDiv(this._treePanel);
  2923. INSPECTOR.Helpers.CleanDiv(this._imagePanel);
  2924. // Sort items alphabetically
  2925. items.sort(function (item1, item2) {
  2926. return item1.compareTo(item2);
  2927. });
  2928. // Display items
  2929. for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
  2930. var item = items_1[_i];
  2931. this._treePanel.appendChild(item.toHtml());
  2932. }
  2933. };
  2934. /* Overrides super */
  2935. TextureTab.prototype._getTree = function () {
  2936. var arr = [];
  2937. // get all cameras from the first scene
  2938. var instances = this._inspector.scene;
  2939. for (var _i = 0, _a = instances.textures; _i < _a.length; _i++) {
  2940. var tex = _a[_i];
  2941. arr.push(new INSPECTOR.TreeItem(this, new INSPECTOR.TextureAdapter(tex)));
  2942. }
  2943. return arr;
  2944. };
  2945. /** Display the details of the given item */
  2946. TextureTab.prototype.displayDetails = function (item) {
  2947. // Remove active state on all items
  2948. this.activateNode(item);
  2949. INSPECTOR.Helpers.CleanDiv(this._imagePanel);
  2950. // Get the texture object
  2951. var texture = item.adapter.object;
  2952. var img = INSPECTOR.Helpers.CreateElement('img', 'texture-image', this._imagePanel);
  2953. if (texture instanceof BABYLON.MapTexture) {
  2954. // instance of Map texture
  2955. texture.bindTextureForPosSize(new BABYLON.Vector2(0, 0), new BABYLON.Size(texture.getSize().width, texture.getSize().height), false);
  2956. BABYLON.Tools.DumpFramebuffer(texture.getSize().width, texture.getSize().height, this._inspector.scene.getEngine(), function (data) { return img.src = data; });
  2957. texture.unbindTexture();
  2958. }
  2959. else if (texture instanceof BABYLON.RenderTargetTexture) {
  2960. // RenderTarget textures
  2961. BABYLON.Tools.CreateScreenshotUsingRenderTarget(this._inspector.scene.getEngine(), texture.activeCamera, { precision: 1 }, function (data) { return img.src = data; });
  2962. }
  2963. else if (texture.url) {
  2964. // If an url is present, the texture is an image
  2965. img.src = texture.url;
  2966. }
  2967. else if (texture['_canvas']) {
  2968. // Dynamic texture
  2969. var base64Image = texture['_canvas'].toDataURL("image/png");
  2970. img.src = base64Image;
  2971. }
  2972. };
  2973. /** Select an item in the tree */
  2974. TextureTab.prototype.select = function (item) {
  2975. // Remove the node highlight
  2976. this.highlightNode();
  2977. // Active the node
  2978. this.activateNode(item);
  2979. // Display its details
  2980. this.displayDetails(item);
  2981. };
  2982. /** Set the given item as active in the tree */
  2983. TextureTab.prototype.activateNode = function (item) {
  2984. if (this._treeItems) {
  2985. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  2986. var node = _a[_i];
  2987. node.active(false);
  2988. }
  2989. }
  2990. item.active(true);
  2991. };
  2992. /** Highlight the given node, and downplay all others */
  2993. TextureTab.prototype.highlightNode = function (item) {
  2994. if (this._treeItems) {
  2995. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  2996. var node = _a[_i];
  2997. node.highlight(false);
  2998. }
  2999. }
  3000. if (item) {
  3001. item.highlight(true);
  3002. }
  3003. };
  3004. return TextureTab;
  3005. }(INSPECTOR.Tab));
  3006. INSPECTOR.TextureTab = TextureTab;
  3007. })(INSPECTOR || (INSPECTOR = {}));
  3008. var __extends = (this && this.__extends) || (function () {
  3009. var extendStatics = Object.setPrototypeOf ||
  3010. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3011. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3012. return function (d, b) {
  3013. extendStatics(d, b);
  3014. function __() { this.constructor = d; }
  3015. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3016. };
  3017. })();
  3018. var INSPECTOR;
  3019. (function (INSPECTOR) {
  3020. var LightTab = (function (_super) {
  3021. __extends(LightTab, _super);
  3022. function LightTab(tabbar, inspector) {
  3023. return _super.call(this, tabbar, 'Light', inspector) || this;
  3024. }
  3025. /* Overrides super */
  3026. LightTab.prototype._getTree = function () {
  3027. var arr = [];
  3028. // get all lights from the first scene
  3029. var instances = this._inspector.scene;
  3030. for (var _i = 0, _a = instances.lights; _i < _a.length; _i++) {
  3031. var light = _a[_i];
  3032. arr.push(new INSPECTOR.TreeItem(this, new INSPECTOR.LightAdapter(light)));
  3033. }
  3034. return arr;
  3035. };
  3036. return LightTab;
  3037. }(INSPECTOR.PropertyTab));
  3038. INSPECTOR.LightTab = LightTab;
  3039. })(INSPECTOR || (INSPECTOR = {}));
  3040. var __extends = (this && this.__extends) || (function () {
  3041. var extendStatics = Object.setPrototypeOf ||
  3042. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3043. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3044. return function (d, b) {
  3045. extendStatics(d, b);
  3046. function __() { this.constructor = d; }
  3047. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3048. };
  3049. })();
  3050. var INSPECTOR;
  3051. (function (INSPECTOR) {
  3052. var MaterialTab = (function (_super) {
  3053. __extends(MaterialTab, _super);
  3054. function MaterialTab(tabbar, inspector) {
  3055. return _super.call(this, tabbar, 'Material', inspector) || this;
  3056. }
  3057. /* Overrides super */
  3058. MaterialTab.prototype._getTree = function () {
  3059. var arr = [];
  3060. // get all meshes from the first scene
  3061. var instances = this._inspector.scene;
  3062. for (var _i = 0, _a = instances.materials; _i < _a.length; _i++) {
  3063. var mat = _a[_i];
  3064. arr.push(new INSPECTOR.TreeItem(this, new INSPECTOR.MaterialAdapter(mat)));
  3065. }
  3066. return arr;
  3067. };
  3068. return MaterialTab;
  3069. }(INSPECTOR.PropertyTab));
  3070. INSPECTOR.MaterialTab = MaterialTab;
  3071. })(INSPECTOR || (INSPECTOR = {}));
  3072. var __extends = (this && this.__extends) || (function () {
  3073. var extendStatics = Object.setPrototypeOf ||
  3074. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3075. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3076. return function (d, b) {
  3077. extendStatics(d, b);
  3078. function __() { this.constructor = d; }
  3079. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3080. };
  3081. })();
  3082. var INSPECTOR;
  3083. (function (INSPECTOR) {
  3084. var MeshTab = (function (_super) {
  3085. __extends(MeshTab, _super);
  3086. function MeshTab(tabbar, inspector) {
  3087. return _super.call(this, tabbar, 'Mesh', inspector) || this;
  3088. }
  3089. /* Overrides super */
  3090. MeshTab.prototype._getTree = function () {
  3091. var _this = this;
  3092. var arr = [];
  3093. // Tab containign mesh already in results
  3094. var alreadyIn = [];
  3095. // Recursive method building the tree panel
  3096. var createNode = function (obj) {
  3097. var descendants = obj.getDescendants(true);
  3098. if (descendants.length > 0) {
  3099. var node = new INSPECTOR.TreeItem(_this, new INSPECTOR.MeshAdapter(obj));
  3100. alreadyIn.push(node);
  3101. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  3102. var child = descendants_1[_i];
  3103. if (child instanceof BABYLON.AbstractMesh) {
  3104. if (!INSPECTOR.Helpers.IsSystemName(child.name)) {
  3105. var n = createNode(child);
  3106. node.add(n);
  3107. }
  3108. }
  3109. }
  3110. node.update();
  3111. return node;
  3112. }
  3113. else {
  3114. alreadyIn.push(obj);
  3115. return new INSPECTOR.TreeItem(_this, new INSPECTOR.MeshAdapter(obj));
  3116. }
  3117. };
  3118. // get all meshes from the first scene
  3119. var instances = this._inspector.scene;
  3120. for (var _i = 0, _a = instances.meshes; _i < _a.length; _i++) {
  3121. var mesh = _a[_i];
  3122. if (alreadyIn.indexOf(mesh) == -1 && !INSPECTOR.Helpers.IsSystemName(mesh.name)) {
  3123. var node = createNode(mesh);
  3124. arr.push(node);
  3125. }
  3126. }
  3127. return arr;
  3128. };
  3129. return MeshTab;
  3130. }(INSPECTOR.PropertyTab));
  3131. INSPECTOR.MeshTab = MeshTab;
  3132. })(INSPECTOR || (INSPECTOR = {}));
  3133. var __extends = (this && this.__extends) || (function () {
  3134. var extendStatics = Object.setPrototypeOf ||
  3135. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3136. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3137. return function (d, b) {
  3138. extendStatics(d, b);
  3139. function __() { this.constructor = d; }
  3140. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3141. };
  3142. })();
  3143. var INSPECTOR;
  3144. (function (INSPECTOR) {
  3145. var SceneTab = (function (_super) {
  3146. __extends(SceneTab, _super);
  3147. function SceneTab(tabbar, insp) {
  3148. var _this = _super.call(this, tabbar, 'Scene') || this;
  3149. /** The list of skeleton viewer */
  3150. _this._skeletonViewers = [];
  3151. _this._inspector = insp;
  3152. // Build the properties panel : a div that will contains the tree and the detail panel
  3153. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  3154. _this._actions = INSPECTOR.Helpers.CreateDiv('scene-actions', _this._panel);
  3155. _this._detailsPanel = new INSPECTOR.DetailPanel();
  3156. _this._panel.appendChild(_this._detailsPanel.toHtml());
  3157. // build propertiesline
  3158. var details = [];
  3159. for (var _i = 0, _a = INSPECTOR.PROPERTIES['Scene'].properties; _i < _a.length; _i++) {
  3160. var prop = _a[_i];
  3161. details.push(new INSPECTOR.PropertyLine(new INSPECTOR.Property(prop, _this._inspector.scene)));
  3162. }
  3163. _this._detailsPanel.details = details;
  3164. Split([_this._actions, _this._detailsPanel.toHtml()], {
  3165. blockDrag: _this._inspector.popupMode,
  3166. sizes: [50, 50],
  3167. direction: 'vertical'
  3168. });
  3169. // Build actions
  3170. {
  3171. // Rendering mode
  3172. var title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  3173. title.textContent = 'Rendering mode';
  3174. var point = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  3175. var wireframe = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  3176. var solid = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  3177. point.textContent = 'Point';
  3178. wireframe.textContent = 'Wireframe';
  3179. solid.textContent = 'Solid';
  3180. if (_this._inspector.scene.forcePointsCloud) {
  3181. point.classList.add('active');
  3182. }
  3183. else if (_this._inspector.scene.forceWireframe) {
  3184. wireframe.classList.add('active');
  3185. }
  3186. else {
  3187. solid.classList.add('active');
  3188. }
  3189. _this._generateRadioAction([point, wireframe, solid]);
  3190. point.addEventListener('click', function () { _this._inspector.scene.forcePointsCloud = true; _this._inspector.scene.forceWireframe = false; });
  3191. wireframe.addEventListener('click', function () { _this._inspector.scene.forcePointsCloud = false; _this._inspector.scene.forceWireframe = true; });
  3192. solid.addEventListener('click', function () { _this._inspector.scene.forcePointsCloud = false; _this._inspector.scene.forceWireframe = false; });
  3193. // Textures
  3194. title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  3195. title.textContent = 'Textures channels';
  3196. _this._generateActionLine('Diffuse Texture', BABYLON.StandardMaterial.DiffuseTextureEnabled, function (b) { BABYLON.StandardMaterial.DiffuseTextureEnabled = b; });
  3197. _this._generateActionLine('Ambient Texture', BABYLON.StandardMaterial.AmbientTextureEnabled, function (b) { BABYLON.StandardMaterial.AmbientTextureEnabled = b; });
  3198. _this._generateActionLine('Specular Texture', BABYLON.StandardMaterial.SpecularTextureEnabled, function (b) { BABYLON.StandardMaterial.SpecularTextureEnabled = b; });
  3199. _this._generateActionLine('Emissive Texture', BABYLON.StandardMaterial.EmissiveTextureEnabled, function (b) { BABYLON.StandardMaterial.EmissiveTextureEnabled = b; });
  3200. _this._generateActionLine('Bump Texture', BABYLON.StandardMaterial.BumpTextureEnabled, function (b) { BABYLON.StandardMaterial.BumpTextureEnabled = b; });
  3201. _this._generateActionLine('Opacity Texture', BABYLON.StandardMaterial.OpacityTextureEnabled, function (b) { BABYLON.StandardMaterial.OpacityTextureEnabled = b; });
  3202. _this._generateActionLine('Reflection Texture', BABYLON.StandardMaterial.ReflectionTextureEnabled, function (b) { BABYLON.StandardMaterial.ReflectionTextureEnabled = b; });
  3203. _this._generateActionLine('Refraction Texture', BABYLON.StandardMaterial.RefractionTextureEnabled, function (b) { BABYLON.StandardMaterial.RefractionTextureEnabled = b; });
  3204. _this._generateActionLine('ColorGrading', BABYLON.StandardMaterial.ColorGradingTextureEnabled, function (b) { BABYLON.StandardMaterial.ColorGradingTextureEnabled = b; });
  3205. _this._generateActionLine('Lightmap Texture', BABYLON.StandardMaterial.LightmapTextureEnabled, function (b) { BABYLON.StandardMaterial.LightmapTextureEnabled = b; });
  3206. _this._generateActionLine('Fresnel', BABYLON.StandardMaterial.FresnelEnabled, function (b) { BABYLON.StandardMaterial.FresnelEnabled = b; });
  3207. // Options
  3208. title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  3209. title.textContent = 'Options';
  3210. _this._generateActionLine('Animations', _this._inspector.scene.animationsEnabled, function (b) { _this._inspector.scene.animationsEnabled = b; });
  3211. _this._generateActionLine('Collisions', _this._inspector.scene.collisionsEnabled, function (b) { _this._inspector.scene.collisionsEnabled = b; });
  3212. _this._generateActionLine('Fog', _this._inspector.scene.fogEnabled, function (b) { _this._inspector.scene.fogEnabled = b; });
  3213. _this._generateActionLine('Lens flares', _this._inspector.scene.lensFlaresEnabled, function (b) { _this._inspector.scene.lensFlaresEnabled = b; });
  3214. _this._generateActionLine('Lights', _this._inspector.scene.lightsEnabled, function (b) { _this._inspector.scene.lightsEnabled = b; });
  3215. _this._generateActionLine('Particles', _this._inspector.scene.particlesEnabled, function (b) { _this._inspector.scene.particlesEnabled = b; });
  3216. _this._generateActionLine('Post-processes', _this._inspector.scene.postProcessesEnabled, function (b) { _this._inspector.scene.postProcessesEnabled = b; });
  3217. _this._generateActionLine('Probes', _this._inspector.scene.probesEnabled, function (b) { _this._inspector.scene.probesEnabled = b; });
  3218. _this._generateActionLine('Procedural textures', _this._inspector.scene.proceduralTexturesEnabled, function (b) { _this._inspector.scene.proceduralTexturesEnabled = b; });
  3219. _this._generateActionLine('Render targets', _this._inspector.scene.renderTargetsEnabled, function (b) { _this._inspector.scene.renderTargetsEnabled = b; });
  3220. _this._generateActionLine('Shadows', _this._inspector.scene.shadowsEnabled, function (b) { _this._inspector.scene.shadowsEnabled = b; });
  3221. _this._generateActionLine('Skeletons', _this._inspector.scene.skeletonsEnabled, function (b) { _this._inspector.scene.skeletonsEnabled = b; });
  3222. _this._generateActionLine('Sprites', _this._inspector.scene.spritesEnabled, function (b) { _this._inspector.scene.spritesEnabled = b; });
  3223. _this._generateActionLine('Textures', _this._inspector.scene.texturesEnabled, function (b) { _this._inspector.scene.texturesEnabled = b; });
  3224. // Audio
  3225. title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  3226. title.textContent = 'Audio';
  3227. var headphones = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  3228. var normalSpeaker = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  3229. _this._generateActionLine('Disable audio', !_this._inspector.scene.audioEnabled, function (b) { _this._inspector.scene.audioEnabled = !b; });
  3230. headphones.textContent = 'Headphones';
  3231. normalSpeaker.textContent = 'Normal speakers';
  3232. _this._generateRadioAction([headphones, normalSpeaker]);
  3233. if (_this._inspector.scene.headphone) {
  3234. headphones.classList.add('active');
  3235. }
  3236. else {
  3237. normalSpeaker.classList.add('active');
  3238. }
  3239. headphones.addEventListener('click', function () { _this._inspector.scene.headphone = true; });
  3240. normalSpeaker.addEventListener('click', function () { _this._inspector.scene.headphone = false; });
  3241. // Viewers
  3242. title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  3243. title.textContent = 'Viewer';
  3244. _this._generateActionLine('Skeletons', false, function (b) {
  3245. if (b) {
  3246. for (var index = 0; index < _this._inspector.scene.meshes.length; index++) {
  3247. var mesh = _this._inspector.scene.meshes[index];
  3248. if (mesh.skeleton) {
  3249. var found = false;
  3250. for (var sIndex = 0; sIndex < _this._skeletonViewers.length; sIndex++) {
  3251. if (_this._skeletonViewers[sIndex].skeleton === mesh.skeleton) {
  3252. found = true;
  3253. break;
  3254. }
  3255. }
  3256. if (found) {
  3257. continue;
  3258. }
  3259. var viewer = new BABYLON.Debug.SkeletonViewer(mesh.skeleton, mesh, _this._inspector.scene);
  3260. viewer.isEnabled = true;
  3261. _this._skeletonViewers.push(viewer);
  3262. }
  3263. }
  3264. }
  3265. else {
  3266. for (var index = 0; index < _this._skeletonViewers.length; index++) {
  3267. _this._skeletonViewers[index].dispose();
  3268. }
  3269. _this._skeletonViewers = [];
  3270. }
  3271. });
  3272. }
  3273. return _this;
  3274. }
  3275. /** Overrides super.dispose */
  3276. SceneTab.prototype.dispose = function () {
  3277. this._detailsPanel.dispose();
  3278. };
  3279. /** generates a div which correspond to an option that can be activated/deactivated */
  3280. SceneTab.prototype._generateActionLine = function (name, initValue, action) {
  3281. var div = INSPECTOR.Helpers.CreateDiv('scene-actions', this._actions);
  3282. div.textContent = name;
  3283. div.classList.add('action');
  3284. if (initValue) {
  3285. div.classList.add('active');
  3286. }
  3287. div.addEventListener('click', function (e) {
  3288. div.classList.toggle('active');
  3289. var isActivated = div.classList.contains('active');
  3290. action(isActivated);
  3291. });
  3292. };
  3293. /**
  3294. * Add a click action for all given elements :
  3295. * the clicked element is set as active, all others elements are deactivated
  3296. */
  3297. SceneTab.prototype._generateRadioAction = function (arr) {
  3298. var active = function (elem, evt) {
  3299. for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
  3300. var e = arr_1[_i];
  3301. e.classList.remove('active');
  3302. }
  3303. elem.classList.add('active');
  3304. };
  3305. for (var _i = 0, arr_2 = arr; _i < arr_2.length; _i++) {
  3306. var elem = arr_2[_i];
  3307. elem.addEventListener('click', active.bind(this, elem));
  3308. }
  3309. };
  3310. return SceneTab;
  3311. }(INSPECTOR.Tab));
  3312. INSPECTOR.SceneTab = SceneTab;
  3313. })(INSPECTOR || (INSPECTOR = {}));
  3314. var __extends = (this && this.__extends) || (function () {
  3315. var extendStatics = Object.setPrototypeOf ||
  3316. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3317. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3318. return function (d, b) {
  3319. extendStatics(d, b);
  3320. function __() { this.constructor = d; }
  3321. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3322. };
  3323. })();
  3324. var INSPECTOR;
  3325. (function (INSPECTOR) {
  3326. var ShaderTab = (function (_super) {
  3327. __extends(ShaderTab, _super);
  3328. function ShaderTab(tabbar, insp) {
  3329. var _this = _super.call(this, tabbar, 'Shader') || this;
  3330. _this._inspector = insp;
  3331. // Build the shaders panel : a div that will contains the shaders tree and both shaders panels
  3332. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  3333. var shaderPanel = INSPECTOR.Helpers.CreateDiv('shader-tree-panel');
  3334. _this._vertexPanel = INSPECTOR.Helpers.CreateDiv('shader-panel');
  3335. _this._fragmentPanel = INSPECTOR.Helpers.CreateDiv('shader-panel');
  3336. _this._panel.appendChild(shaderPanel);
  3337. _this._panel.appendChild(_this._vertexPanel);
  3338. _this._panel.appendChild(_this._fragmentPanel);
  3339. INSPECTOR.Helpers.LoadScript();
  3340. Split([_this._vertexPanel, _this._fragmentPanel], {
  3341. blockDrag: _this._inspector.popupMode,
  3342. sizes: [50, 50],
  3343. direction: 'vertical'
  3344. });
  3345. var comboBox = INSPECTOR.Helpers.CreateElement('select', '', shaderPanel);
  3346. comboBox.addEventListener('change', _this._selectShader.bind(_this));
  3347. var option = INSPECTOR.Helpers.CreateElement('option', '', comboBox);
  3348. option.textContent = 'Select a shader';
  3349. option.setAttribute('value', "");
  3350. option.setAttribute('disabled', 'true');
  3351. option.setAttribute('selected', 'true');
  3352. // Build shaders combobox
  3353. for (var _i = 0, _a = _this._inspector.scene.materials; _i < _a.length; _i++) {
  3354. var mat = _a[_i];
  3355. if (mat instanceof BABYLON.ShaderMaterial) {
  3356. var option_1 = INSPECTOR.Helpers.CreateElement('option', '', comboBox);
  3357. option_1.setAttribute('value', mat.id);
  3358. option_1.textContent = mat.name + " - " + mat.id;
  3359. }
  3360. }
  3361. return _this;
  3362. }
  3363. ShaderTab.prototype._selectShader = function (event) {
  3364. var id = event.target.value;
  3365. var mat = this._inspector.scene.getMaterialByID(id);
  3366. // Clean shader panel
  3367. INSPECTOR.Helpers.CleanDiv(this._vertexPanel);
  3368. // add the title - vertex shader
  3369. var title = INSPECTOR.Helpers.CreateDiv('shader-panel-title', this._vertexPanel);
  3370. title.textContent = 'Vertex shader';
  3371. // add code
  3372. var code = INSPECTOR.Helpers.CreateElement('code', 'glsl', INSPECTOR.Helpers.CreateElement('pre', '', this._vertexPanel));
  3373. code.textContent = this._beautify(mat.getEffect().getVertexShaderSource());
  3374. INSPECTOR.Helpers.CleanDiv(this._fragmentPanel);
  3375. // add the title - fragment shader
  3376. title = INSPECTOR.Helpers.CreateDiv('shader-panel-title', this._fragmentPanel);
  3377. title.textContent = 'Frgament shader';
  3378. // add code
  3379. code = INSPECTOR.Helpers.CreateElement('code', 'glsl', INSPECTOR.Helpers.CreateElement('pre', '', this._fragmentPanel));
  3380. code.textContent = this._beautify(mat.getEffect().getFragmentShaderSource());
  3381. // Init the syntax highlighting
  3382. var styleInit = INSPECTOR.Helpers.CreateElement('script', '', INSPECTOR.Inspector.DOCUMENT.body);
  3383. styleInit.textContent = 'hljs.initHighlighting();';
  3384. };
  3385. /** Overrides super.dispose */
  3386. ShaderTab.prototype.dispose = function () {
  3387. };
  3388. /** Returns the position of the first { and the corresponding } */
  3389. ShaderTab.prototype._getBracket = function (str) {
  3390. var fb = str.indexOf('{');
  3391. var arr = str.substr(fb + 1).split('');
  3392. var counter = 1;
  3393. var currentPosInString = fb;
  3394. var lastBracketIndex = 0;
  3395. for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
  3396. var char = arr_1[_i];
  3397. currentPosInString++;
  3398. if (char === '{') {
  3399. counter++;
  3400. }
  3401. if (char === '}') {
  3402. counter--;
  3403. }
  3404. if (counter == 0) {
  3405. lastBracketIndex = currentPosInString;
  3406. break;
  3407. }
  3408. }
  3409. return { firstBracket: fb, lastBracket: lastBracketIndex };
  3410. };
  3411. /**
  3412. * Beautify the given string : correct indentation
  3413. */
  3414. ShaderTab.prototype._beautify = function (glsl, level) {
  3415. if (level === void 0) { level = 0; }
  3416. // return condition : no brackets at all
  3417. var brackets = this._getBracket(glsl);
  3418. var firstBracket = brackets.firstBracket;
  3419. var lastBracket = brackets.lastBracket;
  3420. var spaces = "";
  3421. for (var i = 0; i < level; i++) {
  3422. spaces += " "; // 4 spaces
  3423. }
  3424. // If no brackets, return the indented string
  3425. if (firstBracket == -1) {
  3426. glsl = spaces + glsl; // indent first line
  3427. glsl = glsl
  3428. .replace(/;./g, function (x) { return '\n' + x.substr(1); }); // new line after ; except the last one
  3429. glsl = glsl.replace(/=/g, " = "); // space around =
  3430. glsl = glsl.replace(/\n/g, "\n" + spaces); // indentation
  3431. return glsl;
  3432. }
  3433. else {
  3434. // if brackets, beautify the inside
  3435. // let insideWithBrackets = glsl.substr(firstBracket, lastBracket-firstBracket+1);
  3436. var left = glsl.substr(0, firstBracket);
  3437. var right = glsl.substr(lastBracket + 1, glsl.length);
  3438. var inside = glsl.substr(firstBracket + 1, lastBracket - firstBracket - 1);
  3439. inside = this._beautify(inside, level + 1);
  3440. return this._beautify(left, level) + '{\n' + inside + '\n' + spaces + '}\n' + this._beautify(right, level);
  3441. }
  3442. };
  3443. return ShaderTab;
  3444. }(INSPECTOR.Tab));
  3445. INSPECTOR.ShaderTab = ShaderTab;
  3446. })(INSPECTOR || (INSPECTOR = {}));
  3447. var __extends = (this && this.__extends) || (function () {
  3448. var extendStatics = Object.setPrototypeOf ||
  3449. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3450. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3451. return function (d, b) {
  3452. extendStatics(d, b);
  3453. function __() { this.constructor = d; }
  3454. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3455. };
  3456. })();
  3457. var INSPECTOR;
  3458. (function (INSPECTOR) {
  3459. /**
  3460. * The console tab will have two features :
  3461. * - hook all console.log call and display them in this panel (and in the browser console as well)
  3462. * - display all Babylon logs (called with Tools.Log...)
  3463. */
  3464. var ConsoleTab = (function (_super) {
  3465. __extends(ConsoleTab, _super);
  3466. function ConsoleTab(tabbar, insp) {
  3467. var _this = _super.call(this, tabbar, 'Console') || this;
  3468. _this._inspector = insp;
  3469. // Build the shaders panel : a div that will contains the shaders tree and both shaders panels
  3470. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  3471. var consolePanel = INSPECTOR.Helpers.CreateDiv('console-panel');
  3472. var bjsPanel = INSPECTOR.Helpers.CreateDiv('console-panel');
  3473. _this._panel.appendChild(consolePanel);
  3474. _this._panel.appendChild(bjsPanel);
  3475. Split([consolePanel, bjsPanel], {
  3476. blockDrag: _this._inspector.popupMode,
  3477. sizes: [50, 50],
  3478. direction: 'vertical'
  3479. });
  3480. // Titles
  3481. var title = INSPECTOR.Helpers.CreateDiv('console-panel-title', consolePanel);
  3482. title.textContent = 'Console logs';
  3483. title = INSPECTOR.Helpers.CreateDiv('console-panel-title', bjsPanel);
  3484. title.textContent = 'Babylon.js logs';
  3485. // Contents
  3486. _this._consolePanelContent = INSPECTOR.Helpers.CreateDiv('console-panel-content', consolePanel);
  3487. _this._bjsPanelContent = INSPECTOR.Helpers.CreateDiv('console-panel-content', bjsPanel);
  3488. // save old console.log
  3489. _this._oldConsoleLog = console.log;
  3490. _this._oldConsoleWarn = console.warn;
  3491. _this._oldConsoleError = console.error;
  3492. console.log = _this._addConsoleLog.bind(_this);
  3493. console.warn = _this._addConsoleWarn.bind(_this);
  3494. console.error = _this._addConsoleError.bind(_this);
  3495. // Bjs logs
  3496. _this._bjsPanelContent.innerHTML = BABYLON.Tools.LogCache;
  3497. BABYLON.Tools.OnNewCacheEntry = function (entry) {
  3498. _this._bjsPanelContent.innerHTML += entry;
  3499. _this._bjsPanelContent.scrollTop = _this._bjsPanelContent.scrollHeight;
  3500. };
  3501. return _this;
  3502. // Testing
  3503. //console.log("This is a console.log message");
  3504. // console.log("That's right, console.log calls are hooked to be written in this window");
  3505. // console.log("Object are also stringify-ed", {width:10, height:30, shape:'rectangular'});
  3506. // console.warn("This is a console.warn message");
  3507. // console.error("This is a console.error message");
  3508. // BABYLON.Tools.Log("This is a message");
  3509. // BABYLON.Tools.Warn("This is a warning");
  3510. // BABYLON.Tools.Error("This is a error");
  3511. }
  3512. /** Overrides super.dispose */
  3513. ConsoleTab.prototype.dispose = function () {
  3514. console.log = this._oldConsoleLog;
  3515. console.warn = this._oldConsoleWarn;
  3516. console.error = this._oldConsoleError;
  3517. };
  3518. ConsoleTab.prototype._message = function (type, message, caller) {
  3519. var callerLine = INSPECTOR.Helpers.CreateDiv('caller', this._consolePanelContent);
  3520. callerLine.textContent = caller;
  3521. var line = INSPECTOR.Helpers.CreateDiv(type, this._consolePanelContent);
  3522. line.textContent += message;
  3523. this._consolePanelContent.scrollTop = this._consolePanelContent.scrollHeight;
  3524. };
  3525. ConsoleTab.prototype._addConsoleLog = function () {
  3526. var params = [];
  3527. for (var _i = 0; _i < arguments.length; _i++) {
  3528. params[_i] = arguments[_i];
  3529. }
  3530. // Get caller name if not null
  3531. var callerFunc = this._addConsoleLog.caller;
  3532. var caller = callerFunc == null ? "Window" : "Function " + callerFunc['name'] + ": ";
  3533. for (var i = 0; i < params.length; i++) {
  3534. this._message('log', params[i], caller);
  3535. // Write again in console does not work on edge, as the console object
  3536. // is not instantiate if debugger tools is not open
  3537. if (!INSPECTOR.Helpers.IsBrowserEdge()) {
  3538. this._oldConsoleLog(params[i]);
  3539. }
  3540. }
  3541. };
  3542. ConsoleTab.prototype._addConsoleWarn = function () {
  3543. var params = [];
  3544. for (var _i = 0; _i < arguments.length; _i++) {
  3545. params[_i] = arguments[_i];
  3546. }
  3547. // Get caller name if not null
  3548. var callerFunc = this._addConsoleLog.caller;
  3549. var caller = callerFunc == null ? "Window" : callerFunc['name'];
  3550. for (var i = 0; i < params.length; i++) {
  3551. this._message('warn', params[i], caller);
  3552. // Write again in console does not work on edge, as the console object
  3553. // is not instantiate if debugger tools is not open
  3554. if (!INSPECTOR.Helpers.IsBrowserEdge()) {
  3555. this._oldConsoleWarn(params[i]);
  3556. }
  3557. }
  3558. };
  3559. ConsoleTab.prototype._addConsoleError = function () {
  3560. var params = [];
  3561. for (var _i = 0; _i < arguments.length; _i++) {
  3562. params[_i] = arguments[_i];
  3563. }
  3564. // Get caller name if not null
  3565. var callerFunc = this._addConsoleLog.caller;
  3566. var caller = callerFunc == null ? "Window" : callerFunc['name'];
  3567. for (var i = 0; i < params.length; i++) {
  3568. this._message('error', params[i], caller);
  3569. // Write again in console does not work on edge, as the console object
  3570. // is not instantiate if debugger tools is not open
  3571. if (!INSPECTOR.Helpers.IsBrowserEdge()) {
  3572. this._oldConsoleError(params[i]);
  3573. }
  3574. }
  3575. };
  3576. return ConsoleTab;
  3577. }(INSPECTOR.Tab));
  3578. INSPECTOR.ConsoleTab = ConsoleTab;
  3579. })(INSPECTOR || (INSPECTOR = {}));
  3580. var __extends = (this && this.__extends) || (function () {
  3581. var extendStatics = Object.setPrototypeOf ||
  3582. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3583. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3584. return function (d, b) {
  3585. extendStatics(d, b);
  3586. function __() { this.constructor = d; }
  3587. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3588. };
  3589. })();
  3590. var INSPECTOR;
  3591. (function (INSPECTOR) {
  3592. var StatsTab = (function (_super) {
  3593. __extends(StatsTab, _super);
  3594. function StatsTab(tabbar, insp) {
  3595. var _this = _super.call(this, tabbar, 'Stats') || this;
  3596. /**
  3597. * Properties in this array will be updated
  3598. * in a render loop - Mostly stats properties
  3599. */
  3600. _this._updatableProperties = [];
  3601. _this._inspector = insp;
  3602. _this._scene = _this._inspector.scene;
  3603. _this._engine = _this._scene.getEngine();
  3604. _this._glInfo = _this._engine.getGlInfo();
  3605. // Build the stats panel: a div that will contains all stats
  3606. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  3607. _this._panel.classList.add("stats-panel");
  3608. var title = INSPECTOR.Helpers.CreateDiv('stat-title1', _this._panel);
  3609. var fpsSpan = INSPECTOR.Helpers.CreateElement('span', 'stats-fps');
  3610. _this._updatableProperties.push({
  3611. elem: fpsSpan,
  3612. updateFct: function () { return BABYLON.Tools.Format(_this._inspector.scene.getEngine().getFps(), 0) + " fps"; }
  3613. });
  3614. var versionSpan = INSPECTOR.Helpers.CreateElement('span');
  3615. versionSpan.textContent = "Babylon.js v" + BABYLON.Engine.Version + " - ";
  3616. title.appendChild(versionSpan);
  3617. title.appendChild(fpsSpan);
  3618. _this._updateLoopHandler = _this._update.bind(_this);
  3619. // Count block
  3620. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  3621. title.textContent = "Count";
  3622. {
  3623. var elemLabel = _this._createStatLabel("Total meshes", _this._panel);
  3624. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3625. _this._updatableProperties.push({
  3626. elem: elemValue,
  3627. updateFct: function () { return _this._scene.meshes.length.toString(); }
  3628. });
  3629. elemLabel = _this._createStatLabel("Draw calls", _this._panel);
  3630. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3631. _this._updatableProperties.push({
  3632. elem: elemValue,
  3633. updateFct: function () { return _this._engine.drawCalls.toString(); }
  3634. });
  3635. elemLabel = _this._createStatLabel("Total lights", _this._panel);
  3636. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3637. _this._updatableProperties.push({
  3638. elem: elemValue,
  3639. updateFct: function () { return _this._scene.lights.length.toString(); }
  3640. });
  3641. elemLabel = _this._createStatLabel("Total vertices", _this._panel);
  3642. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3643. _this._updatableProperties.push({
  3644. elem: elemValue,
  3645. updateFct: function () { return _this._scene.getTotalVertices().toString(); }
  3646. });
  3647. elemLabel = _this._createStatLabel("Total materials", _this._panel);
  3648. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3649. _this._updatableProperties.push({
  3650. elem: elemValue,
  3651. updateFct: function () { return _this._scene.materials.length.toString(); }
  3652. });
  3653. elemLabel = _this._createStatLabel("Total textures", _this._panel);
  3654. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3655. _this._updatableProperties.push({
  3656. elem: elemValue,
  3657. updateFct: function () { return _this._scene.textures.length.toString(); }
  3658. });
  3659. elemLabel = _this._createStatLabel("Active meshes", _this._panel);
  3660. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3661. _this._updatableProperties.push({
  3662. elem: elemValue,
  3663. updateFct: function () { return _this._scene.getActiveMeshes().length.toString(); }
  3664. });
  3665. elemLabel = _this._createStatLabel("Active indices", _this._panel);
  3666. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3667. _this._updatableProperties.push({
  3668. elem: elemValue,
  3669. updateFct: function () { return _this._scene.getActiveIndices().toString(); }
  3670. });
  3671. elemLabel = _this._createStatLabel("Active bones", _this._panel);
  3672. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3673. _this._updatableProperties.push({
  3674. elem: elemValue,
  3675. updateFct: function () { return _this._scene.getActiveBones().toString(); }
  3676. });
  3677. elemLabel = _this._createStatLabel("Active particles", _this._panel);
  3678. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3679. _this._updatableProperties.push({
  3680. elem: elemValue,
  3681. updateFct: function () { return _this._scene.getActiveParticles().toString(); }
  3682. });
  3683. }
  3684. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  3685. title.textContent = "Duration";
  3686. {
  3687. var elemLabel = _this._createStatLabel("Meshes selection", _this._panel);
  3688. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3689. _this._updatableProperties.push({
  3690. elem: elemValue,
  3691. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getEvaluateActiveMeshesDuration()); }
  3692. });
  3693. elemLabel = _this._createStatLabel("Render targets", _this._panel);
  3694. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3695. _this._updatableProperties.push({
  3696. elem: elemValue,
  3697. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getRenderTargetsDuration()); }
  3698. });
  3699. elemLabel = _this._createStatLabel("Particles", _this._panel);
  3700. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3701. _this._updatableProperties.push({
  3702. elem: elemValue,
  3703. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getParticlesDuration()); }
  3704. });
  3705. elemLabel = _this._createStatLabel("Sprites", _this._panel);
  3706. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3707. _this._updatableProperties.push({
  3708. elem: elemValue,
  3709. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getSpritesDuration()); }
  3710. });
  3711. elemLabel = _this._createStatLabel("Render", _this._panel);
  3712. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3713. _this._updatableProperties.push({
  3714. elem: elemValue,
  3715. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getRenderDuration()); }
  3716. });
  3717. elemLabel = _this._createStatLabel("Frame", _this._panel);
  3718. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3719. _this._updatableProperties.push({
  3720. elem: elemValue,
  3721. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getLastFrameDuration()); }
  3722. });
  3723. elemLabel = _this._createStatLabel("Potential FPS", _this._panel);
  3724. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3725. _this._updatableProperties.push({
  3726. elem: elemValue,
  3727. updateFct: function () { return BABYLON.Tools.Format(1000.0 / _this._scene.getLastFrameDuration(), 0); }
  3728. });
  3729. elemLabel = _this._createStatLabel("Resolution", _this._panel);
  3730. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3731. _this._updatableProperties.push({
  3732. elem: elemValue,
  3733. updateFct: function () { return _this._engine.getRenderWidth() + "x" + _this._engine.getRenderHeight(); }
  3734. });
  3735. }
  3736. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  3737. title.textContent = "Extensions";
  3738. {
  3739. var elemLabel = _this._createStatLabel("Std derivatives", _this._panel);
  3740. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3741. _this._updatableProperties.push({
  3742. elem: elemValue,
  3743. updateFct: function () { return (_this._engine.getCaps().standardDerivatives ? "Yes" : "No"); }
  3744. });
  3745. elemLabel = _this._createStatLabel("Compressed textures", _this._panel);
  3746. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3747. _this._updatableProperties.push({
  3748. elem: elemValue,
  3749. updateFct: function () { return (_this._engine.getCaps().s3tc ? "Yes" : "No"); }
  3750. });
  3751. elemLabel = _this._createStatLabel("Hardware instances", _this._panel);
  3752. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3753. _this._updatableProperties.push({
  3754. elem: elemValue,
  3755. updateFct: function () { return (_this._engine.getCaps().instancedArrays ? "Yes" : "No"); }
  3756. });
  3757. elemLabel = _this._createStatLabel("Texture float", _this._panel);
  3758. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3759. _this._updatableProperties.push({
  3760. elem: elemValue,
  3761. updateFct: function () { return (_this._engine.getCaps().textureFloat ? "Yes" : "No"); }
  3762. });
  3763. elemLabel = _this._createStatLabel("32bits indices", _this._panel);
  3764. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3765. _this._updatableProperties.push({
  3766. elem: elemValue,
  3767. updateFct: function () { return (_this._engine.getCaps().uintIndices ? "Yes" : "No"); }
  3768. });
  3769. elemLabel = _this._createStatLabel("Fragment depth", _this._panel);
  3770. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3771. _this._updatableProperties.push({
  3772. elem: elemValue,
  3773. updateFct: function () { return (_this._engine.getCaps().fragmentDepthSupported ? "Yes" : "No"); }
  3774. });
  3775. elemLabel = _this._createStatLabel("High precision shaders", _this._panel);
  3776. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3777. _this._updatableProperties.push({
  3778. elem: elemValue,
  3779. updateFct: function () { return (_this._engine.getCaps().highPrecisionShaderSupported ? "Yes" : "No"); }
  3780. });
  3781. elemLabel = _this._createStatLabel("Draw buffers", _this._panel);
  3782. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3783. _this._updatableProperties.push({
  3784. elem: elemValue,
  3785. updateFct: function () { return (_this._engine.getCaps().drawBuffersExtension ? "Yes" : "No"); }
  3786. });
  3787. elemLabel = _this._createStatLabel("Vertex array object", _this._panel);
  3788. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3789. _this._updatableProperties.push({
  3790. elem: elemValue,
  3791. updateFct: function () { return (_this._engine.getCaps().vertexArrayObject ? "Yes" : "No"); }
  3792. });
  3793. }
  3794. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  3795. title.textContent = "Caps.";
  3796. {
  3797. var elemLabel = _this._createStatLabel("Stencil", _this._panel);
  3798. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3799. _this._updatableProperties.push({
  3800. elem: elemValue,
  3801. updateFct: function () { return (_this._engine.isStencilEnable ? "Enabled" : "Disabled"); }
  3802. });
  3803. elemLabel = _this._createStatLabel("Max textures units", _this._panel);
  3804. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3805. _this._updatableProperties.push({
  3806. elem: elemValue,
  3807. updateFct: function () { return _this._engine.getCaps().maxTexturesImageUnits.toString(); }
  3808. });
  3809. elemLabel = _this._createStatLabel("Max textures size", _this._panel);
  3810. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3811. _this._updatableProperties.push({
  3812. elem: elemValue,
  3813. updateFct: function () { return _this._engine.getCaps().maxTextureSize.toString(); }
  3814. });
  3815. elemLabel = _this._createStatLabel("Max anisotropy", _this._panel);
  3816. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  3817. _this._updatableProperties.push({
  3818. elem: elemValue,
  3819. updateFct: function () { return _this._engine.getCaps().maxAnisotropy.toString(); }
  3820. });
  3821. }
  3822. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  3823. title.textContent = "Info";
  3824. {
  3825. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-infos', _this._panel);
  3826. _this._updatableProperties.push({
  3827. elem: elemValue,
  3828. updateFct: function () { return "WebGL v" + _this._engine.webGLVersion + " - " + _this._glInfo.version + " - " + _this._glInfo.renderer; }
  3829. });
  3830. }
  3831. // Register the update loop
  3832. _this._scene.registerAfterRender(_this._updateLoopHandler);
  3833. return _this;
  3834. }
  3835. StatsTab.prototype._createStatLabel = function (content, parent) {
  3836. var elem = INSPECTOR.Helpers.CreateDiv('stat-label', parent);
  3837. elem.textContent = content;
  3838. return elem;
  3839. };
  3840. /** Update each properties of the stats panel */
  3841. StatsTab.prototype._update = function () {
  3842. for (var _i = 0, _a = this._updatableProperties; _i < _a.length; _i++) {
  3843. var prop = _a[_i];
  3844. prop.elem.textContent = prop.updateFct();
  3845. }
  3846. };
  3847. StatsTab.prototype.dispose = function () {
  3848. this._scene.unregisterAfterRender(this._updateLoopHandler);
  3849. };
  3850. return StatsTab;
  3851. }(INSPECTOR.Tab));
  3852. INSPECTOR.StatsTab = StatsTab;
  3853. })(INSPECTOR || (INSPECTOR = {}));
  3854. var __extends = (this && this.__extends) || (function () {
  3855. var extendStatics = Object.setPrototypeOf ||
  3856. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3857. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3858. return function (d, b) {
  3859. extendStatics(d, b);
  3860. function __() { this.constructor = d; }
  3861. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3862. };
  3863. })();
  3864. var INSPECTOR;
  3865. (function (INSPECTOR) {
  3866. /**
  3867. * A tab bar will contains each view the inspector can have : Canvas2D, Meshes...
  3868. * The default active tab is the first one of the list.
  3869. */
  3870. var TabBar = (function (_super) {
  3871. __extends(TabBar, _super);
  3872. function TabBar(inspector, initialTab) {
  3873. var _this = _super.call(this) || this;
  3874. // The list of available tabs
  3875. _this._tabs = [];
  3876. /** The list of tab displayed by clicking on the remainingIcon */
  3877. _this._invisibleTabs = [];
  3878. /** The list of tabs visible, displayed in the tab bar */
  3879. _this._visibleTabs = [];
  3880. _this._inspector = inspector;
  3881. _this._tabs.push(new INSPECTOR.SceneTab(_this, _this._inspector));
  3882. _this._tabs.push(new INSPECTOR.ConsoleTab(_this, _this._inspector));
  3883. _this._tabs.push(new INSPECTOR.StatsTab(_this, _this._inspector));
  3884. _this._meshTab = new INSPECTOR.MeshTab(_this, _this._inspector);
  3885. _this._tabs.push(new INSPECTOR.TextureTab(_this, _this._inspector));
  3886. _this._tabs.push(_this._meshTab);
  3887. _this._tabs.push(new INSPECTOR.ShaderTab(_this, _this._inspector));
  3888. _this._tabs.push(new INSPECTOR.LightTab(_this, _this._inspector));
  3889. _this._tabs.push(new INSPECTOR.MaterialTab(_this, _this._inspector));
  3890. _this._tabs.push(new INSPECTOR.GUITab(_this, _this._inspector));
  3891. _this._tabs.push(new INSPECTOR.CameraTab(_this, _this._inspector));
  3892. _this._tabs.push(new INSPECTOR.SoundTab(_this, _this._inspector));
  3893. _this._toolBar = new INSPECTOR.Toolbar(_this._inspector);
  3894. _this._build();
  3895. //Check initialTab is defined and between tabs bounds
  3896. if (!initialTab || initialTab < 0 || initialTab >= _this._tabs.length) {
  3897. initialTab = 0;
  3898. console.warn('');
  3899. }
  3900. _this._tabs[initialTab].active(true);
  3901. // set all tab as visible
  3902. for (var _i = 0, _a = _this._tabs; _i < _a.length; _i++) {
  3903. var tab = _a[_i];
  3904. _this._visibleTabs.push(tab);
  3905. }
  3906. return _this;
  3907. }
  3908. // No update
  3909. TabBar.prototype.update = function () { };
  3910. TabBar.prototype._build = function () {
  3911. var _this = this;
  3912. this._div.className = 'tabbar';
  3913. this._div.appendChild(this._toolBar.toHtml());
  3914. for (var _i = 0, _a = this._tabs; _i < _a.length; _i++) {
  3915. var tab = _a[_i];
  3916. this._div.appendChild(tab.toHtml());
  3917. }
  3918. this._moreTabsIcon = INSPECTOR.Helpers.CreateElement('i', 'fa fa-angle-double-right more-tabs');
  3919. this._moreTabsPanel = INSPECTOR.Helpers.CreateDiv('more-tabs-panel');
  3920. this._moreTabsIcon.addEventListener('click', function () {
  3921. // Hide the 'more-tabs-panel' if already displayed
  3922. if (_this._moreTabsPanel.style.display == 'flex') {
  3923. _this._moreTabsPanel.style.display = 'none';
  3924. }
  3925. else {
  3926. // Attach more-tabs-panel if not attached yet
  3927. var topPanel = _this._div.parentNode;
  3928. if (!topPanel.contains(_this._moreTabsPanel)) {
  3929. topPanel.appendChild(_this._moreTabsPanel);
  3930. }
  3931. // Clean the 'more-tabs-panel'
  3932. INSPECTOR.Helpers.CleanDiv(_this._moreTabsPanel);
  3933. // Add each invisible tabs to this panel
  3934. for (var _i = 0, _a = _this._invisibleTabs; _i < _a.length; _i++) {
  3935. var tab = _a[_i];
  3936. _this._addInvisibleTabToPanel(tab);
  3937. }
  3938. // And display it
  3939. _this._moreTabsPanel.style.display = 'flex';
  3940. }
  3941. });
  3942. };
  3943. /**
  3944. * Add a tab to the 'more-tabs' panel, displayed by clicking on the
  3945. * 'more-tabs' icon
  3946. */
  3947. TabBar.prototype._addInvisibleTabToPanel = function (tab) {
  3948. var _this = this;
  3949. var div = INSPECTOR.Helpers.CreateDiv('invisible-tab', this._moreTabsPanel);
  3950. div.textContent = tab.name;
  3951. div.addEventListener('click', function () {
  3952. _this._moreTabsPanel.style.display = 'none';
  3953. _this.switchTab(tab);
  3954. });
  3955. };
  3956. /** Dispose the current tab, set the given tab as active, and refresh the treeview */
  3957. TabBar.prototype.switchTab = function (tab) {
  3958. // Dispose the active tab
  3959. this.getActiveTab().dispose();
  3960. // Deactivate all tabs
  3961. for (var _i = 0, _a = this._tabs; _i < _a.length; _i++) {
  3962. var t = _a[_i];
  3963. t.active(false);
  3964. }
  3965. // activate the given tab
  3966. tab.active(true);
  3967. // Refresh the inspector
  3968. this._inspector.refresh();
  3969. };
  3970. /** Display the mesh tab.
  3971. * If a parameter is given, the given mesh details are displayed
  3972. */
  3973. TabBar.prototype.switchMeshTab = function (mesh) {
  3974. this.switchTab(this._meshTab);
  3975. if (mesh) {
  3976. var item = this._meshTab.getItemFor(mesh);
  3977. this._meshTab.select(item);
  3978. }
  3979. };
  3980. /** Returns the active tab */
  3981. TabBar.prototype.getActiveTab = function () {
  3982. for (var _i = 0, _a = this._tabs; _i < _a.length; _i++) {
  3983. var tab = _a[_i];
  3984. if (tab.isActive()) {
  3985. return tab;
  3986. }
  3987. }
  3988. };
  3989. Object.defineProperty(TabBar.prototype, "inspector", {
  3990. get: function () {
  3991. return this._inspector;
  3992. },
  3993. enumerable: true,
  3994. configurable: true
  3995. });
  3996. /**
  3997. * Returns the total width in pixel of the tabbar,
  3998. * that corresponds to the sum of the width of each visible tab + toolbar width
  3999. */
  4000. TabBar.prototype.getPixelWidth = function () {
  4001. var sum = 0;
  4002. for (var _i = 0, _a = this._visibleTabs; _i < _a.length; _i++) {
  4003. var tab = _a[_i];
  4004. sum += tab.getPixelWidth();
  4005. }
  4006. sum += this._toolBar.getPixelWidth();
  4007. if (this._div.contains(this._moreTabsIcon)) {
  4008. sum += 30; // $tabbarheight
  4009. }
  4010. return sum;
  4011. };
  4012. /** Display the remaining icon or not depending on the tabbar width.
  4013. * This function should be called each time the inspector width is updated
  4014. */
  4015. TabBar.prototype.updateWidth = function () {
  4016. var parentSize = this._div.parentElement.clientWidth;
  4017. var lastTabWidth = 75;
  4018. var currentSize = this.getPixelWidth();
  4019. // Check if a tab should be removed : if the tab bar width is greater than
  4020. // its parent width
  4021. while (this._visibleTabs.length > 0 && currentSize > parentSize) {
  4022. // Start by the last element
  4023. var tab = this._visibleTabs.pop();
  4024. // set it invisible
  4025. this._invisibleTabs.push(tab);
  4026. // and removes it from the DOM
  4027. this._div.removeChild(tab.toHtml());
  4028. currentSize = this.getPixelWidth() + lastTabWidth;
  4029. }
  4030. // Check if a tab can be added to the tab bar : if the tab bar width
  4031. // + 100 (at least 100px is needed to add a tab) is less than its parent width
  4032. if (this._invisibleTabs.length > 0) {
  4033. if (currentSize + lastTabWidth < parentSize) {
  4034. var lastTab = this._invisibleTabs.pop();
  4035. this._div.appendChild(lastTab.toHtml());
  4036. this._visibleTabs.push(lastTab);
  4037. // Update more-tab icon in last position if needed
  4038. if (this._div.contains(this._moreTabsIcon)) {
  4039. this._div.removeChild(this._moreTabsIcon);
  4040. }
  4041. }
  4042. }
  4043. if (this._invisibleTabs.length > 0 && !this._div.contains(this._moreTabsIcon)) {
  4044. this._div.appendChild(this._moreTabsIcon);
  4045. }
  4046. };
  4047. return TabBar;
  4048. }(INSPECTOR.BasicElement));
  4049. INSPECTOR.TabBar = TabBar;
  4050. })(INSPECTOR || (INSPECTOR = {}));
  4051. var INSPECTOR;
  4052. (function (INSPECTOR) {
  4053. var AbstractTool = (function () {
  4054. function AbstractTool(icon, parent, inspector, tooltip) {
  4055. var _this = this;
  4056. this._inspector = inspector;
  4057. this._elem = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  4058. this._elem.className = "tool fa " + icon;
  4059. parent.appendChild(this._elem);
  4060. this._elem.addEventListener('click', function (e) {
  4061. _this.action();
  4062. });
  4063. new INSPECTOR.Tooltip(this._elem, tooltip);
  4064. }
  4065. AbstractTool.prototype.toHtml = function () {
  4066. return this._elem;
  4067. };
  4068. /**
  4069. * Returns the total width in pixel of this tool, 0 by default
  4070. */
  4071. AbstractTool.prototype.getPixelWidth = function () {
  4072. var style = INSPECTOR.Inspector.WINDOW.getComputedStyle(this._elem);
  4073. var left = parseFloat(style.marginLeft.substr(0, style.marginLeft.length - 2)) || 0;
  4074. var right = parseFloat(style.marginRight.substr(0, style.marginRight.length - 2)) || 0;
  4075. return (this._elem.clientWidth || 0) + left + right;
  4076. };
  4077. /**
  4078. * Updates the icon of this tool with the given string
  4079. */
  4080. AbstractTool.prototype._updateIcon = function (icon) {
  4081. this._elem.className = "tool fa " + icon;
  4082. };
  4083. return AbstractTool;
  4084. }());
  4085. INSPECTOR.AbstractTool = AbstractTool;
  4086. })(INSPECTOR || (INSPECTOR = {}));
  4087. var __extends = (this && this.__extends) || (function () {
  4088. var extendStatics = Object.setPrototypeOf ||
  4089. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4090. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4091. return function (d, b) {
  4092. extendStatics(d, b);
  4093. function __() { this.constructor = d; }
  4094. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4095. };
  4096. })();
  4097. var INSPECTOR;
  4098. (function (INSPECTOR) {
  4099. var PauseScheduleTool = (function (_super) {
  4100. __extends(PauseScheduleTool, _super);
  4101. function PauseScheduleTool(parent, inspector) {
  4102. var _this = _super.call(this, 'fa-pause', parent, inspector, 'Pause the automatic update of properties') || this;
  4103. _this._isPause = false;
  4104. return _this;
  4105. }
  4106. // Action : refresh the whole panel
  4107. PauseScheduleTool.prototype.action = function () {
  4108. if (this._isPause) {
  4109. INSPECTOR.Scheduler.getInstance().pause = false;
  4110. this._updateIcon('fa-pause');
  4111. }
  4112. else {
  4113. INSPECTOR.Scheduler.getInstance().pause = true;
  4114. this._updateIcon('fa-play');
  4115. }
  4116. this._isPause = !this._isPause;
  4117. };
  4118. return PauseScheduleTool;
  4119. }(INSPECTOR.AbstractTool));
  4120. INSPECTOR.PauseScheduleTool = PauseScheduleTool;
  4121. })(INSPECTOR || (INSPECTOR = {}));
  4122. var __extends = (this && this.__extends) || (function () {
  4123. var extendStatics = Object.setPrototypeOf ||
  4124. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4125. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4126. return function (d, b) {
  4127. extendStatics(d, b);
  4128. function __() { this.constructor = d; }
  4129. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4130. };
  4131. })();
  4132. var INSPECTOR;
  4133. (function (INSPECTOR) {
  4134. var PickTool = (function (_super) {
  4135. __extends(PickTool, _super);
  4136. function PickTool(parent, inspector) {
  4137. var _this = _super.call(this, 'fa-mouse-pointer', parent, inspector, 'Select a mesh in the scene') || this;
  4138. _this._isActive = false;
  4139. // Create handler
  4140. _this._pickHandler = _this._pickMesh.bind(_this);
  4141. return _this;
  4142. }
  4143. // Action : find the corresponding tree item in the correct tab and display it
  4144. PickTool.prototype.action = function () {
  4145. if (this._isActive) {
  4146. this._deactivate();
  4147. }
  4148. else {
  4149. this.toHtml().classList.add('active');
  4150. // Add event handler : pick on a mesh in the scene
  4151. this._inspector.scene.getEngine().getRenderingCanvas().addEventListener('click', this._pickHandler);
  4152. this._isActive = true;
  4153. }
  4154. };
  4155. /** Deactivate this tool */
  4156. PickTool.prototype._deactivate = function () {
  4157. this.toHtml().classList.remove('active');
  4158. // Remove event handler
  4159. this._inspector.scene.getEngine().getRenderingCanvas().removeEventListener('click', this._pickHandler);
  4160. this._isActive = false;
  4161. };
  4162. /** Pick a mesh in the scene */
  4163. PickTool.prototype._pickMesh = function (evt) {
  4164. var pos = this._updatePointerPosition(evt);
  4165. var pi = this._inspector.scene.pick(pos.x, pos.y, function (mesh) { return true; });
  4166. if (pi.pickedMesh) {
  4167. console.log(pi.pickedMesh.name);
  4168. this._inspector.displayObjectDetails(pi.pickedMesh);
  4169. }
  4170. this._deactivate();
  4171. };
  4172. PickTool.prototype._updatePointerPosition = function (evt) {
  4173. var canvasRect = this._inspector.scene.getEngine().getRenderingCanvasClientRect();
  4174. var pointerX = evt.clientX - canvasRect.left;
  4175. var pointerY = evt.clientY - canvasRect.top;
  4176. return { x: pointerX, y: pointerY };
  4177. };
  4178. ;
  4179. return PickTool;
  4180. }(INSPECTOR.AbstractTool));
  4181. INSPECTOR.PickTool = PickTool;
  4182. })(INSPECTOR || (INSPECTOR = {}));
  4183. var __extends = (this && this.__extends) || (function () {
  4184. var extendStatics = Object.setPrototypeOf ||
  4185. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4186. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4187. return function (d, b) {
  4188. extendStatics(d, b);
  4189. function __() { this.constructor = d; }
  4190. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4191. };
  4192. })();
  4193. var INSPECTOR;
  4194. (function (INSPECTOR) {
  4195. var PopupTool = (function (_super) {
  4196. __extends(PopupTool, _super);
  4197. function PopupTool(parent, inspector) {
  4198. return _super.call(this, 'fa-external-link', parent, inspector, 'Open the inspector in a popup') || this;
  4199. }
  4200. // Action : refresh the whole panel
  4201. PopupTool.prototype.action = function () {
  4202. this._inspector.openPopup();
  4203. };
  4204. return PopupTool;
  4205. }(INSPECTOR.AbstractTool));
  4206. INSPECTOR.PopupTool = PopupTool;
  4207. })(INSPECTOR || (INSPECTOR = {}));
  4208. var __extends = (this && this.__extends) || (function () {
  4209. var extendStatics = Object.setPrototypeOf ||
  4210. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4211. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4212. return function (d, b) {
  4213. extendStatics(d, b);
  4214. function __() { this.constructor = d; }
  4215. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4216. };
  4217. })();
  4218. var INSPECTOR;
  4219. (function (INSPECTOR) {
  4220. var RefreshTool = (function (_super) {
  4221. __extends(RefreshTool, _super);
  4222. function RefreshTool(parent, inspector) {
  4223. return _super.call(this, 'fa-refresh', parent, inspector, 'Refresh the current tab') || this;
  4224. }
  4225. // Action : refresh the whole panel
  4226. RefreshTool.prototype.action = function () {
  4227. this._inspector.refresh();
  4228. };
  4229. return RefreshTool;
  4230. }(INSPECTOR.AbstractTool));
  4231. INSPECTOR.RefreshTool = RefreshTool;
  4232. })(INSPECTOR || (INSPECTOR = {}));
  4233. var __extends = (this && this.__extends) || (function () {
  4234. var extendStatics = Object.setPrototypeOf ||
  4235. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4236. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4237. return function (d, b) {
  4238. extendStatics(d, b);
  4239. function __() { this.constructor = d; }
  4240. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4241. };
  4242. })();
  4243. var INSPECTOR;
  4244. (function (INSPECTOR) {
  4245. var LabelTool = (function (_super) {
  4246. __extends(LabelTool, _super);
  4247. function LabelTool(parent, inspector) {
  4248. var _this = _super.call(this, 'fa-tags', parent, inspector, 'Display mesh names on the canvas') || this;
  4249. /** True if label are displayed, false otherwise */
  4250. _this._isDisplayed = false;
  4251. _this._canvas = null;
  4252. _this._labelInitialized = false;
  4253. _this._scene = null;
  4254. _this._canvas2DLoaded = false;
  4255. _this._newMeshObserver = null;
  4256. _this._removedMeshObserver = null;
  4257. _this._newLightObserver = null;
  4258. _this._removedLightObserver = null;
  4259. _this._newCameraObserver = null;
  4260. _this._removedCameraObserver = null;
  4261. _this._scene = inspector.scene;
  4262. return _this;
  4263. }
  4264. LabelTool.prototype.dispose = function () {
  4265. if (this._newMeshObserver) {
  4266. this._scene.onNewMeshAddedObservable.remove(this._newMeshObserver);
  4267. this._scene.onMeshRemovedObservable.remove(this._removedMeshObserver);
  4268. this._scene.onNewLightAddedObservable.remove(this._newLightObserver);
  4269. this._scene.onLightRemovedObservable.remove(this._removedLightObserver);
  4270. this._scene.onNewCameraAddedObservable.remove(this._newCameraObserver);
  4271. this._scene.onCameraRemovedObservable.remove(this._removedCameraObserver);
  4272. this._newMeshObserver = this._newLightObserver = this._newCameraObserver = this._removedMeshObserver = this._removedLightObserver = this._removedCameraObserver = null;
  4273. }
  4274. this._canvas.dispose();
  4275. this._canvas = null;
  4276. };
  4277. LabelTool.prototype._checkC2DLoaded = function () {
  4278. if (this._canvas2DLoaded === true) {
  4279. return true;
  4280. }
  4281. if (BABYLON.Canvas2D) {
  4282. this._canvas2DLoaded = true;
  4283. }
  4284. return this._canvas2DLoaded;
  4285. };
  4286. LabelTool.prototype._initializeLabels = function () {
  4287. var _this = this;
  4288. // Check if the label are already initialized and quit if it's the case
  4289. if (this._labelInitialized) {
  4290. return;
  4291. }
  4292. // Can't initialize them if the Canvas2D lib is not loaded yet
  4293. if (!this._checkC2DLoaded()) {
  4294. return;
  4295. }
  4296. // Create the canvas that will be used to display the labels
  4297. this._canvas = new BABYLON.ScreenSpaceCanvas2D(this._scene, { id: "###Label Canvas###" /*, cachingStrategy: BABYLON.Canvas2D.CACHESTRATEGY_TOPLEVELGROUPS*/ });
  4298. // Create label for all the Meshes, Lights and Cameras
  4299. // Those that will be created/removed after this method is called will be taken care by the event handlers added below
  4300. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  4301. var m = _a[_i];
  4302. this._createLabel(m);
  4303. }
  4304. for (var _b = 0, _c = this._scene.lights; _b < _c.length; _b++) {
  4305. var l = _c[_b];
  4306. this._createLabel(l);
  4307. }
  4308. for (var _d = 0, _e = this._scene.cameras; _d < _e.length; _d++) {
  4309. var c = _e[_d];
  4310. this._createLabel(c);
  4311. }
  4312. // Add handlers for new/removed meshes, camera and lights
  4313. this._newMeshObserver = this._scene.onNewMeshAddedObservable.add(function (e, s) {
  4314. _this._createLabel(e);
  4315. });
  4316. this._removedMeshObserver = this._scene.onMeshRemovedObservable.add(function (e, s) {
  4317. _this._removeLabel(e);
  4318. });
  4319. this._newLightObserver = this._scene.onNewLightAddedObservable.add(function (e, s) {
  4320. _this._createLabel(e);
  4321. });
  4322. this._removedLightObserver = this._scene.onLightRemovedObservable.add(function (e, s) {
  4323. _this._removeLabel(e);
  4324. });
  4325. this._newCameraObserver = this._scene.onNewCameraAddedObservable.add(function (e, s) {
  4326. _this._createLabel(e);
  4327. });
  4328. this._removedCameraObserver = this._scene.onCameraRemovedObservable.add(function (e, s) {
  4329. _this._removeLabel(e);
  4330. });
  4331. this._labelInitialized = true;
  4332. };
  4333. LabelTool.prototype._createLabel = function (node) {
  4334. // Don't create label for "system nodes" (starting and ending with ###)
  4335. var name = node.name;
  4336. if (INSPECTOR.Helpers.IsSystemName(name)) {
  4337. return;
  4338. }
  4339. var labelGroup = new BABYLON.Group2D({ parent: this._canvas, id: "Label of " + node.name, trackNode: node, origin: BABYLON.Vector2.Zero(),
  4340. children: [
  4341. new BABYLON.Rectangle2D({ id: "LabelRect", x: 0, y: 0, width: 100, height: 30, origin: BABYLON.Vector2.Zero(), border: "#FFFFFFFF", fill: "#808080B0", children: [
  4342. new BABYLON.Text2D(node.name, { x: 10, y: 4, fontName: "bold 16px Arial", fontSignedDistanceField: true })
  4343. ]
  4344. })
  4345. ] });
  4346. var r = labelGroup.children[0];
  4347. var t = r.children[0];
  4348. var ts = t.textSize.width;
  4349. r.width = ts + 20;
  4350. r.height = t.textSize.height + 12;
  4351. labelGroup.addExternalData("owner", node);
  4352. return labelGroup;
  4353. };
  4354. LabelTool.prototype._removeLabel = function (node) {
  4355. for (var _i = 0, _a = this._canvas.children; _i < _a.length; _i++) {
  4356. var g = _a[_i];
  4357. var ed = g.getExternalData("owner");
  4358. if (ed === node) {
  4359. g.dispose();
  4360. break;
  4361. }
  4362. }
  4363. };
  4364. // Action : Display/hide mesh names on the canvas
  4365. LabelTool.prototype.action = function () {
  4366. // Don't toggle if the script is not loaded
  4367. if (!this._checkC2DLoaded()) {
  4368. return;
  4369. }
  4370. // Toggle the label display state
  4371. this._isDisplayed = !this._isDisplayed;
  4372. // Check if we have to display the labels
  4373. if (this._isDisplayed) {
  4374. this._initializeLabels();
  4375. this._canvas.levelVisible = true;
  4376. }
  4377. else {
  4378. this._canvas.levelVisible = false;
  4379. }
  4380. };
  4381. return LabelTool;
  4382. }(INSPECTOR.AbstractTool));
  4383. INSPECTOR.LabelTool = LabelTool;
  4384. })(INSPECTOR || (INSPECTOR = {}));
  4385. var __extends = (this && this.__extends) || (function () {
  4386. var extendStatics = Object.setPrototypeOf ||
  4387. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4388. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4389. return function (d, b) {
  4390. extendStatics(d, b);
  4391. function __() { this.constructor = d; }
  4392. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4393. };
  4394. })();
  4395. var INSPECTOR;
  4396. (function (INSPECTOR) {
  4397. var Toolbar = (function (_super) {
  4398. __extends(Toolbar, _super);
  4399. function Toolbar(inspector) {
  4400. var _this = _super.call(this) || this;
  4401. _this._tools = [];
  4402. _this._inspector = inspector;
  4403. _this._build();
  4404. _this._addTools();
  4405. return _this;
  4406. }
  4407. // A toolbar cannot be updated
  4408. Toolbar.prototype.update = function () { };
  4409. ;
  4410. Toolbar.prototype._build = function () {
  4411. this._div.className = 'toolbar';
  4412. };
  4413. ;
  4414. Toolbar.prototype._addTools = function () {
  4415. // Refresh
  4416. this._tools.push(new INSPECTOR.RefreshTool(this._div, this._inspector));
  4417. // Display labels
  4418. this._tools.push(new INSPECTOR.LabelTool(this._div, this._inspector));
  4419. // Pick object
  4420. this._tools.push(new INSPECTOR.PickTool(this._div, this._inspector));
  4421. // Add the popup mode only if the inspector is not in popup mode and if the brower is not edge
  4422. // Edge is
  4423. if (!this._inspector.popupMode && !INSPECTOR.Helpers.IsBrowserEdge()) {
  4424. this._tools.push(new INSPECTOR.PopupTool(this._div, this._inspector));
  4425. }
  4426. // Pause schedule
  4427. this._tools.push(new INSPECTOR.PauseScheduleTool(this._div, this._inspector));
  4428. // Pause schedule
  4429. this._tools.push(new INSPECTOR.DisposeTool(this._div, this._inspector));
  4430. };
  4431. /**
  4432. * Returns the total width in pixel of the tabbar,
  4433. * that corresponds to the sum of the width of each tab + toolbar width
  4434. */
  4435. Toolbar.prototype.getPixelWidth = function () {
  4436. var sum = 0;
  4437. for (var _i = 0, _a = this._tools; _i < _a.length; _i++) {
  4438. var tool = _a[_i];
  4439. sum += tool.getPixelWidth();
  4440. }
  4441. return sum;
  4442. };
  4443. return Toolbar;
  4444. }(INSPECTOR.BasicElement));
  4445. INSPECTOR.Toolbar = Toolbar;
  4446. })(INSPECTOR || (INSPECTOR = {}));
  4447. var __extends = (this && this.__extends) || (function () {
  4448. var extendStatics = Object.setPrototypeOf ||
  4449. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4450. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4451. return function (d, b) {
  4452. extendStatics(d, b);
  4453. function __() { this.constructor = d; }
  4454. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4455. };
  4456. })();
  4457. var INSPECTOR;
  4458. (function (INSPECTOR) {
  4459. /**
  4460. * Removes the inspector panel
  4461. */
  4462. var DisposeTool = (function (_super) {
  4463. __extends(DisposeTool, _super);
  4464. function DisposeTool(parent, inspector) {
  4465. return _super.call(this, 'fa-times', parent, inspector, 'Close the inspector panel') || this;
  4466. }
  4467. // Action : refresh the whole panel
  4468. DisposeTool.prototype.action = function () {
  4469. this._inspector.dispose();
  4470. };
  4471. return DisposeTool;
  4472. }(INSPECTOR.AbstractTool));
  4473. INSPECTOR.DisposeTool = DisposeTool;
  4474. })(INSPECTOR || (INSPECTOR = {}));
  4475. var __extends = (this && this.__extends) || (function () {
  4476. var extendStatics = Object.setPrototypeOf ||
  4477. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4478. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4479. return function (d, b) {
  4480. extendStatics(d, b);
  4481. function __() { this.constructor = d; }
  4482. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4483. };
  4484. })();
  4485. var INSPECTOR;
  4486. (function (INSPECTOR) {
  4487. var TreeItem = (function (_super) {
  4488. __extends(TreeItem, _super);
  4489. function TreeItem(tab, obj) {
  4490. var _this = _super.call(this) || this;
  4491. _this.children = [];
  4492. _this._tab = tab;
  4493. _this._adapter = obj;
  4494. _this._tools = _this._adapter.getTools();
  4495. _this._build();
  4496. return _this;
  4497. }
  4498. Object.defineProperty(TreeItem.prototype, "id", {
  4499. /** Returns the item ID == its adapter ID */
  4500. get: function () {
  4501. return this._adapter.id();
  4502. },
  4503. enumerable: true,
  4504. configurable: true
  4505. });
  4506. /** Add the given item as a child of this one */
  4507. TreeItem.prototype.add = function (child) {
  4508. this.children.push(child);
  4509. this.update();
  4510. };
  4511. Object.defineProperty(TreeItem.prototype, "adapter", {
  4512. /**
  4513. * Returns the original adapter
  4514. */
  4515. get: function () {
  4516. return this._adapter;
  4517. },
  4518. enumerable: true,
  4519. configurable: true
  4520. });
  4521. /**
  4522. * Function used to compare this item to another tree item.
  4523. * Returns the alphabetical sort of the adapter ID
  4524. */
  4525. TreeItem.prototype.compareTo = function (item) {
  4526. var str1 = this.id;
  4527. var str2 = item.id;
  4528. return str1.localeCompare(str2, [], { numeric: true });
  4529. };
  4530. /** Returns true if the given obj correspond to the adapter linked to this tree item */
  4531. TreeItem.prototype.correspondsTo = function (obj) {
  4532. return this._adapter.correspondsTo(obj);
  4533. };
  4534. /** hide all children of this item */
  4535. TreeItem.prototype.fold = function () {
  4536. // Do nothing id no children
  4537. if (this.children.length > 0) {
  4538. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  4539. var elem = _a[_i];
  4540. elem.toHtml().style.display = 'none';
  4541. }
  4542. this._div.classList.add('folded');
  4543. this._div.classList.remove('unfolded');
  4544. }
  4545. };
  4546. /** Show all children of this item */
  4547. TreeItem.prototype.unfold = function () {
  4548. // Do nothing id no children
  4549. if (this.children.length > 0) {
  4550. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  4551. var elem = _a[_i];
  4552. elem.toHtml().style.display = 'block';
  4553. }
  4554. this._div.classList.add('unfolded');
  4555. this._div.classList.remove('folded');
  4556. }
  4557. };
  4558. /** Build the HTML of this item */
  4559. TreeItem.prototype._build = function () {
  4560. this._div.className = 'line';
  4561. for (var _i = 0, _a = this._tools; _i < _a.length; _i++) {
  4562. var tool = _a[_i];
  4563. this._div.appendChild(tool.toHtml());
  4564. }
  4565. // Id
  4566. var text = INSPECTOR.Inspector.DOCUMENT.createElement('span');
  4567. text.textContent = this._adapter.id();
  4568. this._div.appendChild(text);
  4569. // Type
  4570. var type = INSPECTOR.Inspector.DOCUMENT.createElement('span');
  4571. type.className = 'property-type';
  4572. if (this._adapter.type() !== 'type_not_defined') {
  4573. type.textContent = ' - ' + this._adapter.type();
  4574. }
  4575. this._div.appendChild(type);
  4576. this._lineContent = INSPECTOR.Helpers.CreateDiv('line-content', this._div);
  4577. this._addEvent();
  4578. };
  4579. /**
  4580. * Returns one HTML element (.details) containing all details of this primitive
  4581. */
  4582. TreeItem.prototype.getDetails = function () {
  4583. return this._adapter.getProperties();
  4584. };
  4585. TreeItem.prototype.update = function () {
  4586. // Clean division holding all children
  4587. INSPECTOR.Helpers.CleanDiv(this._lineContent);
  4588. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  4589. var child = _a[_i];
  4590. var elem = child.toHtml();
  4591. this._lineContent.appendChild(elem);
  4592. }
  4593. if (this.children.length > 0) {
  4594. // Check if folded or not
  4595. if (!this._div.classList.contains('folded') && !this._div.classList.contains('unfolded')) {
  4596. this._div.classList.add('folded');
  4597. }
  4598. }
  4599. this.fold();
  4600. };
  4601. /**
  4602. * Add an event listener on the item :
  4603. * - one click display details
  4604. * - on mouse hover the item is highlighted
  4605. */
  4606. TreeItem.prototype._addEvent = function () {
  4607. var _this = this;
  4608. this._div.addEventListener('click', function (e) {
  4609. _this._tab.select(_this);
  4610. // Fold/unfold the tree
  4611. if (_this._isFolded()) {
  4612. _this.unfold();
  4613. }
  4614. else {
  4615. _this.fold();
  4616. }
  4617. e.stopPropagation();
  4618. });
  4619. // Highlight on mouse over
  4620. this._div.addEventListener('mouseover', function (e) {
  4621. _this._tab.highlightNode(_this);
  4622. e.stopPropagation();
  4623. });
  4624. // Remove highlight on mouse out
  4625. this._div.addEventListener('mouseout', function (e) {
  4626. _this._tab.highlightNode();
  4627. });
  4628. };
  4629. /** Highlight or downplay this node */
  4630. TreeItem.prototype.highlight = function (b) {
  4631. // Remove highlight for all children
  4632. if (!b) {
  4633. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  4634. var child = _a[_i];
  4635. child._adapter.highlight(b);
  4636. }
  4637. }
  4638. // Highlight this node
  4639. this._adapter.highlight(b);
  4640. };
  4641. /** Returns true if the node is folded, false otherwise */
  4642. TreeItem.prototype._isFolded = function () {
  4643. return !this._div.classList.contains('unfolded');
  4644. };
  4645. /** Set this item as active (background lighter) in the tree panel */
  4646. TreeItem.prototype.active = function (b) {
  4647. this._div.classList.remove('active');
  4648. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  4649. var child = _a[_i];
  4650. child.active(false);
  4651. }
  4652. if (b) {
  4653. this._div.classList.add('active');
  4654. }
  4655. };
  4656. return TreeItem;
  4657. }(INSPECTOR.BasicElement));
  4658. INSPECTOR.TreeItem = TreeItem;
  4659. })(INSPECTOR || (INSPECTOR = {}));
  4660. var INSPECTOR;
  4661. (function (INSPECTOR) {
  4662. var AbstractTreeTool = (function () {
  4663. function AbstractTreeTool() {
  4664. /** Is the tool enabled ? */
  4665. this._on = false;
  4666. this._elem = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  4667. this._elem.className = 'treeTool fa';
  4668. this._addEvents();
  4669. }
  4670. AbstractTreeTool.prototype.toHtml = function () {
  4671. return this._elem;
  4672. };
  4673. AbstractTreeTool.prototype._addEvents = function () {
  4674. var _this = this;
  4675. this._elem.addEventListener('click', function (e) {
  4676. _this.action();
  4677. e.stopPropagation();
  4678. });
  4679. };
  4680. /**
  4681. * Action launched when clicked on this element
  4682. * Should be overrided
  4683. */
  4684. AbstractTreeTool.prototype.action = function () {
  4685. this._on = !this._on;
  4686. };
  4687. return AbstractTreeTool;
  4688. }());
  4689. INSPECTOR.AbstractTreeTool = AbstractTreeTool;
  4690. })(INSPECTOR || (INSPECTOR = {}));
  4691. var __extends = (this && this.__extends) || (function () {
  4692. var extendStatics = Object.setPrototypeOf ||
  4693. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4694. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4695. return function (d, b) {
  4696. extendStatics(d, b);
  4697. function __() { this.constructor = d; }
  4698. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4699. };
  4700. })();
  4701. var INSPECTOR;
  4702. (function (INSPECTOR) {
  4703. /**
  4704. * Checkbox to display/hide the primitive
  4705. */
  4706. var BoundingBox = (function (_super) {
  4707. __extends(BoundingBox, _super);
  4708. function BoundingBox(obj) {
  4709. var _this = _super.call(this) || this;
  4710. _this._obj = obj;
  4711. _this._elem.classList.add('fa-square-o');
  4712. _this._on = _this._obj.isBoxVisible();
  4713. _this._check();
  4714. return _this;
  4715. }
  4716. // For a checkbox, set visible/invisible the corresponding prim
  4717. BoundingBox.prototype.action = function () {
  4718. _super.prototype.action.call(this);
  4719. // update object and gui according to the new status
  4720. this._check();
  4721. };
  4722. BoundingBox.prototype._check = function () {
  4723. if (this._on) {
  4724. // set icon eye
  4725. this._elem.classList.add('active');
  4726. }
  4727. else {
  4728. // set icon eye-slash
  4729. this._elem.classList.remove('active');
  4730. }
  4731. this._obj.setBoxVisible(this._on);
  4732. };
  4733. return BoundingBox;
  4734. }(INSPECTOR.AbstractTreeTool));
  4735. INSPECTOR.BoundingBox = BoundingBox;
  4736. })(INSPECTOR || (INSPECTOR = {}));
  4737. var __extends = (this && this.__extends) || (function () {
  4738. var extendStatics = Object.setPrototypeOf ||
  4739. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4740. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4741. return function (d, b) {
  4742. extendStatics(d, b);
  4743. function __() { this.constructor = d; }
  4744. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4745. };
  4746. })();
  4747. var INSPECTOR;
  4748. (function (INSPECTOR) {
  4749. /**
  4750. *
  4751. */
  4752. var CameraPOV = (function (_super) {
  4753. __extends(CameraPOV, _super);
  4754. function CameraPOV(camera) {
  4755. var _this = _super.call(this) || this;
  4756. _this.cameraPOV = camera;
  4757. _this._elem.classList.add('fa-video-camera');
  4758. return _this;
  4759. }
  4760. CameraPOV.prototype.action = function () {
  4761. _super.prototype.action.call(this);
  4762. this._gotoPOV();
  4763. };
  4764. CameraPOV.prototype._gotoPOV = function () {
  4765. var actives = INSPECTOR.Inspector.DOCUMENT.querySelectorAll(".fa-video-camera.active");
  4766. console.log(actives);
  4767. for (var i = 0; i < actives.length; i++) {
  4768. actives[i].classList.remove('active');
  4769. }
  4770. //if (this._on) {
  4771. // set icon camera
  4772. this._elem.classList.add('active');
  4773. //}
  4774. this.cameraPOV.setPOV();
  4775. };
  4776. return CameraPOV;
  4777. }(INSPECTOR.AbstractTreeTool));
  4778. INSPECTOR.CameraPOV = CameraPOV;
  4779. })(INSPECTOR || (INSPECTOR = {}));
  4780. var __extends = (this && this.__extends) || (function () {
  4781. var extendStatics = Object.setPrototypeOf ||
  4782. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4783. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4784. return function (d, b) {
  4785. extendStatics(d, b);
  4786. function __() { this.constructor = d; }
  4787. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4788. };
  4789. })();
  4790. var INSPECTOR;
  4791. (function (INSPECTOR) {
  4792. /**
  4793. *
  4794. */
  4795. var SoundInteractions = (function (_super) {
  4796. __extends(SoundInteractions, _super);
  4797. function SoundInteractions(playSound) {
  4798. var _this = _super.call(this) || this;
  4799. _this.playSound = playSound;
  4800. _this.b = false;
  4801. _this._elem.classList.add('fa-play');
  4802. return _this;
  4803. }
  4804. SoundInteractions.prototype.action = function () {
  4805. _super.prototype.action.call(this);
  4806. this._playSound();
  4807. };
  4808. SoundInteractions.prototype._playSound = function () {
  4809. var _this = this;
  4810. if (this._elem.classList.contains('fa-play')) {
  4811. this._elem.classList.remove('fa-play');
  4812. this._elem.classList.add('fa-pause');
  4813. }
  4814. else {
  4815. this._elem.classList.remove('fa-pause');
  4816. this._elem.classList.add('fa-play');
  4817. }
  4818. this.playSound.setPlaying(function () {
  4819. _this._elem.classList.remove('fa-pause');
  4820. _this._elem.classList.add('fa-play');
  4821. });
  4822. };
  4823. return SoundInteractions;
  4824. }(INSPECTOR.AbstractTreeTool));
  4825. INSPECTOR.SoundInteractions = SoundInteractions;
  4826. })(INSPECTOR || (INSPECTOR = {}));
  4827. var __extends = (this && this.__extends) || (function () {
  4828. var extendStatics = Object.setPrototypeOf ||
  4829. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4830. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4831. return function (d, b) {
  4832. extendStatics(d, b);
  4833. function __() { this.constructor = d; }
  4834. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4835. };
  4836. })();
  4837. var INSPECTOR;
  4838. (function (INSPECTOR) {
  4839. /**
  4840. * Checkbox to display/hide the primitive
  4841. */
  4842. var Checkbox = (function (_super) {
  4843. __extends(Checkbox, _super);
  4844. function Checkbox(obj) {
  4845. var _this = _super.call(this) || this;
  4846. _this._obj = obj;
  4847. _this._elem.classList.add('fa-eye');
  4848. _this._on = _this._obj.isVisible();
  4849. _this._check(true);
  4850. return _this;
  4851. }
  4852. // For a checkbox, set visible/invisible the corresponding prim
  4853. Checkbox.prototype.action = function () {
  4854. _super.prototype.action.call(this);
  4855. // update object and gui according to the new status
  4856. this._check();
  4857. };
  4858. Checkbox.prototype._check = function (dontEnable) {
  4859. if (this._on) {
  4860. // set icon eye
  4861. this._elem.classList.add('fa-eye');
  4862. this._elem.classList.add('active');
  4863. this._elem.classList.remove('fa-eye-slash');
  4864. }
  4865. else {
  4866. // set icon eye-slash
  4867. this._elem.classList.remove('fa-eye');
  4868. this._elem.classList.remove('active');
  4869. this._elem.classList.add('fa-eye-slash');
  4870. }
  4871. if (!dontEnable) {
  4872. this._obj.setVisible(this._on);
  4873. }
  4874. };
  4875. return Checkbox;
  4876. }(INSPECTOR.AbstractTreeTool));
  4877. INSPECTOR.Checkbox = Checkbox;
  4878. })(INSPECTOR || (INSPECTOR = {}));
  4879. var __extends = (this && this.__extends) || (function () {
  4880. var extendStatics = Object.setPrototypeOf ||
  4881. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4882. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4883. return function (d, b) {
  4884. extendStatics(d, b);
  4885. function __() { this.constructor = d; }
  4886. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4887. };
  4888. })();
  4889. var INSPECTOR;
  4890. (function (INSPECTOR) {
  4891. var DebugArea = (function (_super) {
  4892. __extends(DebugArea, _super);
  4893. function DebugArea(obj) {
  4894. var _this = _super.call(this) || this;
  4895. _this._obj = obj;
  4896. _this._elem.classList.add('fa-wrench');
  4897. return _this;
  4898. }
  4899. DebugArea.prototype.action = function () {
  4900. _super.prototype.action.call(this);
  4901. if (this._on) {
  4902. // set icon activated
  4903. this._elem.classList.add('active');
  4904. }
  4905. else {
  4906. // set icon deactivated
  4907. this._elem.classList.remove('active');
  4908. }
  4909. this._obj.debug(this._on);
  4910. };
  4911. return DebugArea;
  4912. }(INSPECTOR.AbstractTreeTool));
  4913. INSPECTOR.DebugArea = DebugArea;
  4914. })(INSPECTOR || (INSPECTOR = {}));
  4915. var __extends = (this && this.__extends) || (function () {
  4916. var extendStatics = Object.setPrototypeOf ||
  4917. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4918. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4919. return function (d, b) {
  4920. extendStatics(d, b);
  4921. function __() { this.constructor = d; }
  4922. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4923. };
  4924. })();
  4925. var INSPECTOR;
  4926. (function (INSPECTOR) {
  4927. /**
  4928. * Checkbox to display/hide the primitive
  4929. */
  4930. var Info = (function (_super) {
  4931. __extends(Info, _super);
  4932. function Info(obj) {
  4933. var _this = _super.call(this) || this;
  4934. _this._obj = obj;
  4935. _this._elem.classList.add('fa-info-circle');
  4936. _this._tooltip = new INSPECTOR.Tooltip(_this._elem, _this._obj.getInfo(), _this._elem);
  4937. return _this;
  4938. }
  4939. // Nothing to do on click
  4940. Info.prototype.action = function () {
  4941. _super.prototype.action.call(this);
  4942. };
  4943. return Info;
  4944. }(INSPECTOR.AbstractTreeTool));
  4945. INSPECTOR.Info = Info;
  4946. })(INSPECTOR || (INSPECTOR = {}));