babylon.inspector.js 158 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647
  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) {
  9. var _this = this;
  10. /** True if the inspector is built as a popup tab */
  11. this._popupMode = false;
  12. // get canvas parent only if needed.
  13. this._scene = scene;
  14. // Save HTML document and window
  15. Inspector.DOCUMENT = window.document;
  16. Inspector.WINDOW = window;
  17. // POPUP MODE
  18. if (popup) {
  19. // Build the inspector in the given parent
  20. this.openPopup(true); // set to true in order to NOT dispose the inspector (done in openPopup), as it's not existing yet
  21. }
  22. else {
  23. // Get canvas and its DOM parent
  24. var canvas = this._scene.getEngine().getRenderingCanvas();
  25. var canvasParent = canvas.parentElement;
  26. var canvasParentComputedStyle = Inspector.WINDOW.getComputedStyle(canvasParent);
  27. // resize canvas
  28. // canvas.style.width = 'calc(100% - 750px - 12px)';
  29. // get canvas style
  30. var canvasComputedStyle = Inspector.WINDOW.getComputedStyle(canvas);
  31. this._canvasStyle = {
  32. width: canvasComputedStyle.width,
  33. height: canvasComputedStyle.height,
  34. position: canvasComputedStyle.position,
  35. top: canvasComputedStyle.top,
  36. bottom: canvasComputedStyle.bottom,
  37. left: canvasComputedStyle.left,
  38. right: canvasComputedStyle.right,
  39. padding: canvasComputedStyle.padding,
  40. paddingBottom: canvasComputedStyle.paddingBottom,
  41. paddingLeft: canvasComputedStyle.paddingLeft,
  42. paddingTop: canvasComputedStyle.paddingTop,
  43. paddingRight: canvasComputedStyle.paddingRight,
  44. margin: canvasComputedStyle.margin,
  45. marginBottom: canvasComputedStyle.marginBottom,
  46. marginLeft: canvasComputedStyle.marginLeft,
  47. marginTop: canvasComputedStyle.marginTop,
  48. marginRight: canvasComputedStyle.marginRight
  49. };
  50. // Create c2di wrapper
  51. this._c2diwrapper = INSPECTOR.Helpers.CreateDiv('insp-wrapper');
  52. // copy style from canvas to wrapper
  53. for (var prop in this._canvasStyle) {
  54. this._c2diwrapper.style[prop] = this._canvasStyle[prop];
  55. }
  56. // Convert wrapper size in % (because getComputedStyle returns px only)
  57. var widthPx = parseFloat(canvasComputedStyle.width.substr(0, canvasComputedStyle.width.length - 2)) || 0;
  58. var heightPx = parseFloat(canvasComputedStyle.height.substr(0, canvasComputedStyle.height.length - 2)) || 0;
  59. // If the canvas position is absolute, restrain the wrapper width to the window width + left positionning
  60. if (canvasComputedStyle.position === "absolute" || canvasComputedStyle.position === "relative") {
  61. // compute only left as it takes predominance if right is also specified (and it will be for the wrapper)
  62. var leftPx = parseFloat(canvasComputedStyle.left.substr(0, canvasComputedStyle.left.length - 2)) || 0;
  63. if (widthPx + leftPx >= Inspector.WINDOW.innerWidth) {
  64. this._c2diwrapper.style.maxWidth = widthPx - leftPx + "px";
  65. }
  66. }
  67. // Check if the parent of the canvas is the body page. If yes, the size ratio is computed
  68. var parent_1 = this._getRelativeParent(canvas);
  69. var parentWidthPx = parent_1.clientWidth;
  70. var parentHeightPx = parent_1.clientHeight;
  71. var pWidth = widthPx / parentWidthPx * 100;
  72. var pheight = heightPx / parentHeightPx * 100;
  73. this._c2diwrapper.style.width = pWidth + "%";
  74. this._c2diwrapper.style.height = pheight + "%";
  75. // reset canvas style
  76. canvas.style.position = "static";
  77. canvas.style.width = "100%";
  78. canvas.style.height = "100%";
  79. canvas.style.paddingBottom = "0";
  80. canvas.style.paddingLeft = "0";
  81. canvas.style.paddingTop = "0";
  82. canvas.style.paddingRight = "0";
  83. canvas.style.margin = "0";
  84. canvas.style.marginBottom = "0";
  85. canvas.style.marginLeft = "0";
  86. canvas.style.marginTop = "0";
  87. canvas.style.marginRight = "0";
  88. // Replace canvas with the wrapper...
  89. canvasParent.replaceChild(this._c2diwrapper, canvas);
  90. // ... and add canvas to the wrapper
  91. this._c2diwrapper.appendChild(canvas);
  92. // add inspector
  93. var inspector = INSPECTOR.Helpers.CreateDiv('insp-right-panel', this._c2diwrapper);
  94. // Add split bar
  95. Split([canvas, inspector], {
  96. direction: 'horizontal',
  97. sizes: [75, 25],
  98. onDrag: function () {
  99. INSPECTOR.Helpers.SEND_EVENT('resize');
  100. if (_this._tabbar) {
  101. _this._tabbar.updateWidth();
  102. }
  103. }
  104. });
  105. // Build the inspector
  106. this._buildInspector(inspector);
  107. // Send resize event to the window
  108. INSPECTOR.Helpers.SEND_EVENT('resize');
  109. }
  110. // Refresh the inspector if the browser is not edge
  111. if (!INSPECTOR.Helpers.IsBrowserEdge()) {
  112. this.refresh();
  113. }
  114. }
  115. /**
  116. * If the given element has a position 'asbolute' or 'relative',
  117. * returns the first parent of the given element that has a position 'relative' or 'absolute'.
  118. * If the given element has no position, returns the first parent
  119. *
  120. */
  121. Inspector.prototype._getRelativeParent = function (elem, lookForAbsoluteOrRelative) {
  122. // If the elem has no parent, returns himself
  123. if (!elem.parentElement) {
  124. return elem;
  125. }
  126. var computedStyle = Inspector.WINDOW.getComputedStyle(elem);
  127. // looking for the first element absolute or relative
  128. if (lookForAbsoluteOrRelative) {
  129. // if found, return this one
  130. if (computedStyle.position === "relative" || computedStyle.position === "absolute") {
  131. return elem;
  132. }
  133. else {
  134. // otherwise keep looking
  135. return this._getRelativeParent(elem.parentElement, true);
  136. }
  137. }
  138. else {
  139. if (computedStyle.position == "static") {
  140. return elem.parentElement;
  141. }
  142. else {
  143. // the elem has a position relative or absolute, look for the closest relative/absolute parent
  144. return this._getRelativeParent(elem.parentElement, true);
  145. }
  146. }
  147. };
  148. /** Build the inspector panel in the given HTML element */
  149. Inspector.prototype._buildInspector = function (parent) {
  150. // tabbar
  151. this._tabbar = new INSPECTOR.TabBar(this);
  152. // Top panel
  153. this._topPanel = INSPECTOR.Helpers.CreateDiv('top-panel', parent);
  154. // Add tabbar
  155. this._topPanel.appendChild(this._tabbar.toHtml());
  156. this._tabbar.updateWidth();
  157. // Tab panel
  158. this._tabPanel = INSPECTOR.Helpers.CreateDiv('tab-panel-content', this._topPanel);
  159. };
  160. Object.defineProperty(Inspector.prototype, "scene", {
  161. get: function () {
  162. return this._scene;
  163. },
  164. enumerable: true,
  165. configurable: true
  166. });
  167. Object.defineProperty(Inspector.prototype, "popupMode", {
  168. get: function () {
  169. return this._popupMode;
  170. },
  171. enumerable: true,
  172. configurable: true
  173. });
  174. /**
  175. * Filter the list of item present in the tree.
  176. * All item returned should have the given filter contained in the item id.
  177. */
  178. Inspector.prototype.filterItem = function (filter) {
  179. this._tabbar.getActiveTab().filter(filter);
  180. };
  181. /** Display the mesh tab on the given object */
  182. Inspector.prototype.displayObjectDetails = function (mesh) {
  183. this._tabbar.switchMeshTab(mesh);
  184. };
  185. /** Clean the whole tree of item and rebuilds it */
  186. Inspector.prototype.refresh = function () {
  187. // Clean top panel
  188. INSPECTOR.Helpers.CleanDiv(this._tabPanel);
  189. // Get the active tab and its items
  190. var activeTab = this._tabbar.getActiveTab();
  191. activeTab.update();
  192. this._tabPanel.appendChild(activeTab.getPanel());
  193. INSPECTOR.Helpers.SEND_EVENT('resize');
  194. };
  195. /** Remove the inspector panel when it's built as a right panel:
  196. * remove the right panel and remove the wrapper
  197. */
  198. Inspector.prototype.dispose = function () {
  199. if (!this._popupMode) {
  200. // Get canvas
  201. var canvas = this._scene.getEngine().getRenderingCanvas();
  202. // restore canvas style
  203. for (var prop in this._canvasStyle) {
  204. canvas.style[prop] = this._canvasStyle[prop];
  205. }
  206. // Get parent of the wrapper
  207. var canvasParent = canvas.parentElement.parentElement;
  208. canvasParent.appendChild(canvas);
  209. // Remove wrapper
  210. INSPECTOR.Helpers.CleanDiv(this._c2diwrapper);
  211. this._c2diwrapper.remove();
  212. // Send resize event to the window
  213. INSPECTOR.Helpers.SEND_EVENT('resize');
  214. }
  215. };
  216. /** Open the inspector in a new popup
  217. * Set 'firstTime' to true if there is no inspector created beforehands
  218. */
  219. Inspector.prototype.openPopup = function (firstTime) {
  220. if (INSPECTOR.Helpers.IsBrowserEdge()) {
  221. console.warn('Inspector - Popup mode is disabled in Edge, as the popup DOM cannot be updated from the main window for security reasons');
  222. }
  223. else {
  224. // Create popup
  225. var popup = window.open('', 'Babylon.js INSPECTOR', 'toolbar=no,resizable=yes,menubar=no,width=750,height=1000');
  226. popup.document.title = 'Babylon.js INSPECTOR';
  227. // Get the inspector style
  228. var styles = Inspector.DOCUMENT.querySelectorAll('style');
  229. for (var s = 0; s < styles.length; s++) {
  230. popup.document.body.appendChild(styles[s].cloneNode(true));
  231. }
  232. var links = document.querySelectorAll('link');
  233. for (var l = 0; l < links.length; l++) {
  234. var link = popup.document.createElement("link");
  235. link.rel = "stylesheet";
  236. link.href = links[l].href;
  237. popup.document.head.appendChild(link);
  238. }
  239. // Dispose the right panel if existing
  240. if (!firstTime) {
  241. this.dispose();
  242. }
  243. // set the mode as popup
  244. this._popupMode = true;
  245. // Save the HTML document
  246. Inspector.DOCUMENT = popup.document;
  247. Inspector.WINDOW = popup;
  248. // Build the inspector wrapper
  249. this._c2diwrapper = INSPECTOR.Helpers.CreateDiv('insp-wrapper', popup.document.body);
  250. // add inspector
  251. var inspector = INSPECTOR.Helpers.CreateDiv('insp-right-panel', this._c2diwrapper);
  252. // and build it in the popup
  253. this._buildInspector(inspector);
  254. // Rebuild it
  255. this.refresh();
  256. }
  257. };
  258. return Inspector;
  259. }());
  260. INSPECTOR.Inspector = Inspector;
  261. })(INSPECTOR || (INSPECTOR = {}));
  262. //# sourceMappingURL=Inspector.js.map
  263. var INSPECTOR;
  264. (function (INSPECTOR) {
  265. INSPECTOR.PROPERTIES = {
  266. /** Format the given object :
  267. * If a format function exists, returns the result of this function.
  268. * If this function doesn't exists, return the object type instead */
  269. format: function (obj) {
  270. var type = INSPECTOR.Helpers.GET_TYPE(obj) || 'type_not_defined';
  271. if (INSPECTOR.PROPERTIES[type] && INSPECTOR.PROPERTIES[type].format) {
  272. return INSPECTOR.PROPERTIES[type].format(obj);
  273. }
  274. else {
  275. return INSPECTOR.Helpers.GET_TYPE(obj);
  276. }
  277. },
  278. 'type_not_defined': {
  279. properties: [],
  280. format: function () { return ''; }
  281. },
  282. 'Vector2': {
  283. type: BABYLON.Vector2,
  284. properties: ['x', 'y'],
  285. format: function (vec) { return "x:" + INSPECTOR.Helpers.Trunc(vec.x) + ", y:" + INSPECTOR.Helpers.Trunc(vec.y); }
  286. },
  287. 'Vector3': {
  288. type: BABYLON.Vector3,
  289. properties: ['x', 'y', 'z'],
  290. format: function (vec) { return "x:" + INSPECTOR.Helpers.Trunc(vec.x) + ", y:" + INSPECTOR.Helpers.Trunc(vec.y) + ", z:" + INSPECTOR.Helpers.Trunc(vec.z); }
  291. },
  292. 'Color3': {
  293. type: BABYLON.Color3,
  294. properties: ['r', 'g', 'b'],
  295. format: function (color) { return "R:" + color.r + ", G:" + color.g + ", B:" + color.b; }
  296. },
  297. 'Quaternion': {
  298. type: BABYLON.Quaternion,
  299. properties: ['x', 'y', 'z', 'w']
  300. },
  301. 'Size': {
  302. type: BABYLON.Size,
  303. properties: ['width', 'height'],
  304. format: function (size) { return "Size - w:" + INSPECTOR.Helpers.Trunc(size.width) + ", h:" + INSPECTOR.Helpers.Trunc(size.height); }
  305. },
  306. 'Texture': {
  307. type: BABYLON.Texture,
  308. properties: [
  309. 'hasAlpha',
  310. 'level',
  311. 'name',
  312. 'wrapU',
  313. 'wrapV',
  314. 'uScale',
  315. 'vScale',
  316. 'uAng',
  317. 'vAng',
  318. 'wAng',
  319. 'uOffset',
  320. 'vOffset'
  321. ],
  322. },
  323. 'ArcRotateCamera': {
  324. // type: BABYLON.ArcRotateCamera,
  325. properties: ['alpha', 'beta', 'radius']
  326. },
  327. 'Scene': {
  328. type: BABYLON.Scene,
  329. properties: ['actionManager', 'activeCamera', 'ambientColor', 'clearColor']
  330. },
  331. 'Mesh': {
  332. type: BABYLON.Mesh,
  333. properties: [
  334. 'name',
  335. 'position',
  336. 'rotation',
  337. 'rotationQuaternion',
  338. 'absolutePosition',
  339. 'material'
  340. ],
  341. format: function (m) { return m.name; }
  342. },
  343. 'StandardMaterial': {
  344. type: BABYLON.StandardMaterial,
  345. properties: [
  346. 'name',
  347. 'alpha',
  348. 'alphaMode',
  349. 'wireframe',
  350. 'isFrozen',
  351. 'zOffset',
  352. 'ambientColor',
  353. 'emissiveColor',
  354. 'diffuseColor',
  355. 'specularColor',
  356. 'specularPower',
  357. 'useAlphaFromDiffuseTexture',
  358. 'linkEmissiveWithDiffuse',
  359. 'useSpecularOverAlpha',
  360. 'diffuseFresnelParameters',
  361. 'opacityFresnelParameters',
  362. 'reflectionFresnelParameters',
  363. 'refractionFresnelParameters',
  364. 'emissiveFresnelParameters',
  365. 'diffuseTexture',
  366. 'emissiveTexture',
  367. 'specularTexture',
  368. 'ambientTexture',
  369. 'bumpTexture',
  370. 'lightMapTexture',
  371. 'opacityTexture',
  372. 'reflectionTexture',
  373. 'refractionTexture'
  374. ],
  375. format: function (mat) { return mat.name; }
  376. },
  377. 'PrimitiveAlignment': {
  378. type: BABYLON.PrimitiveAlignment,
  379. properties: ['horizontal', 'vertical']
  380. },
  381. 'PrimitiveThickness': {
  382. type: BABYLON.PrimitiveThickness,
  383. properties: ['topPixels', 'leftPixels', 'rightPixels', 'bottomPixels']
  384. },
  385. 'BoundingInfo2D': {
  386. type: BABYLON.BoundingInfo2D,
  387. properties: ['radius', 'center', 'extent']
  388. },
  389. 'SolidColorBrush2D': {
  390. type: BABYLON.SolidColorBrush2D,
  391. properties: ['color']
  392. },
  393. 'GradientColorBrush2D': {
  394. type: BABYLON.GradientColorBrush2D,
  395. properties: ['color1', 'color2', 'translation', 'rotation', 'scale']
  396. },
  397. 'PBRMaterial': {
  398. type: BABYLON.PBRMaterial,
  399. properties: [
  400. 'name',
  401. 'albedoColor',
  402. 'albedoTexture',
  403. 'opacityTexture',
  404. 'reflectionTexture',
  405. 'emissiveTexture',
  406. 'bumpTexture',
  407. 'lightmapTexture',
  408. 'opacityFresnelParameters',
  409. 'emissiveFresnelParameters',
  410. 'linkEmissiveWithAlbedo',
  411. 'useLightmapAsShadowmap',
  412. 'useAlphaFromAlbedoTexture',
  413. 'useSpecularOverAlpha',
  414. 'useAutoMicroSurfaceFromReflectivityMap',
  415. 'useLogarithmicDepth',
  416. 'reflectivityColor',
  417. 'reflectivityTexture',
  418. 'reflectionTexture',
  419. 'reflectionColor',
  420. 'alpha',
  421. 'linkRefractionWithTransparency',
  422. 'indexOfRefraction',
  423. 'microSurface',
  424. 'useMicroSurfaceFromReflectivityMapAlpha',
  425. 'directIntensity',
  426. 'emissiveIntensity',
  427. 'specularIntensity',
  428. 'environmentIntensity',
  429. 'cameraExposure',
  430. 'cameraContrast',
  431. 'cameraColorGradingTexture',
  432. 'cameraColorCurves'
  433. ]
  434. }
  435. };
  436. })(INSPECTOR || (INSPECTOR = {}));
  437. //# sourceMappingURL=properties.js.map
  438. var INSPECTOR;
  439. (function (INSPECTOR) {
  440. /**
  441. * Represents a html div element.
  442. * The div is built when an instance of BasicElement is created.
  443. */
  444. var BasicElement = (function () {
  445. function BasicElement() {
  446. this._div = INSPECTOR.Helpers.CreateDiv();
  447. }
  448. /**
  449. * Returns the div element
  450. */
  451. BasicElement.prototype.toHtml = function () {
  452. return this._div;
  453. };
  454. /**
  455. * Build the html element
  456. */
  457. BasicElement.prototype._build = function () { };
  458. ;
  459. /** Default dispose method if needed */
  460. BasicElement.prototype.dispose = function () { };
  461. ;
  462. return BasicElement;
  463. }());
  464. INSPECTOR.BasicElement = BasicElement;
  465. })(INSPECTOR || (INSPECTOR = {}));
  466. //# sourceMappingURL=BasicElement.js.map
  467. var INSPECTOR;
  468. (function (INSPECTOR) {
  469. var Adapter = (function () {
  470. function Adapter(obj) {
  471. this._obj = obj;
  472. }
  473. Object.defineProperty(Adapter.prototype, "actualObject", {
  474. /** Returns the actual object behind this adapter */
  475. get: function () {
  476. return this._obj;
  477. },
  478. enumerable: true,
  479. configurable: true
  480. });
  481. /** Returns true if the given object correspond to this */
  482. Adapter.prototype.correspondsTo = function (obj) {
  483. return obj === this._obj;
  484. };
  485. Object.defineProperty(Adapter.prototype, "name", {
  486. /** Returns the adapter unique name */
  487. get: function () {
  488. return Adapter._name;
  489. },
  490. enumerable: true,
  491. configurable: true
  492. });
  493. /** Should be overriden in subclasses */
  494. Adapter.prototype.highlight = function (b) { };
  495. ;
  496. return Adapter;
  497. }());
  498. // a unique name for this adapter, to retrieve its own key in the local storage
  499. Adapter._name = BABYLON.Geometry.RandomId();
  500. INSPECTOR.Adapter = Adapter;
  501. })(INSPECTOR || (INSPECTOR = {}));
  502. //# sourceMappingURL=Adapter.js.map
  503. var __extends = (this && this.__extends) || function (d, b) {
  504. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  505. function __() { this.constructor = d; }
  506. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  507. };
  508. var INSPECTOR;
  509. (function (INSPECTOR) {
  510. var Canvas2DAdapter = (function (_super) {
  511. __extends(Canvas2DAdapter, _super);
  512. function Canvas2DAdapter(obj) {
  513. return _super.call(this, obj) || this;
  514. }
  515. /** Returns the name displayed in the tree */
  516. Canvas2DAdapter.prototype.id = function () {
  517. var str = '';
  518. if (this._obj.id) {
  519. str = this._obj.id;
  520. } // otherwise nothing displayed
  521. return str;
  522. };
  523. /** Returns the type of this object - displayed in the tree */
  524. Canvas2DAdapter.prototype.type = function () {
  525. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  526. };
  527. /** Returns the list of properties to be displayed for this adapter */
  528. Canvas2DAdapter.prototype.getProperties = function () {
  529. var _this = this;
  530. var propertiesLines = [];
  531. if (this._obj.propDic) {
  532. var dico = this._obj.propDic;
  533. dico.forEach(function (name, propInfo) {
  534. var property = new INSPECTOR.Property(name, _this.actualObject);
  535. propertiesLines.push(new INSPECTOR.PropertyLine(property));
  536. });
  537. }
  538. // TODO REMOVE THIS WHEN PROPERTIES WILL BE DECORATED
  539. var toAddDirty = [
  540. 'actualZOffset', 'isSizeAuto', 'layoutArea', 'layoutAreaPos', 'contentArea',
  541. 'marginOffset', 'paddingOffset', 'isPickable', 'isContainer', 'boundingInfo',
  542. 'levelBoundingInfo', 'isSizedByContent', 'isPositionAuto', 'actualScale', 'layoutBoundingInfo'
  543. ];
  544. for (var _i = 0, toAddDirty_1 = toAddDirty; _i < toAddDirty_1.length; _i++) {
  545. var dirty = toAddDirty_1[_i];
  546. var infos = new INSPECTOR.Property(dirty, this.actualObject);
  547. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  548. }
  549. return propertiesLines;
  550. };
  551. Canvas2DAdapter.prototype.getTools = function () {
  552. var tools = [];
  553. tools.push(new INSPECTOR.Checkbox(this));
  554. tools.push(new INSPECTOR.DebugArea(this));
  555. return tools;
  556. };
  557. /// TOOLS ///
  558. Canvas2DAdapter.prototype.setVisible = function (b) {
  559. this._obj.levelVisible = b;
  560. };
  561. Canvas2DAdapter.prototype.isVisible = function () {
  562. return this._obj.levelVisible;
  563. };
  564. /** Overrides super */
  565. Canvas2DAdapter.prototype.debug = function (b) {
  566. this._obj["displayDebugAreas"] = b;
  567. };
  568. /** Overrides super.highlight */
  569. Canvas2DAdapter.prototype.highlight = function (b) {
  570. };
  571. return Canvas2DAdapter;
  572. }(INSPECTOR.Adapter));
  573. INSPECTOR.Canvas2DAdapter = Canvas2DAdapter;
  574. })(INSPECTOR || (INSPECTOR = {}));
  575. //# sourceMappingURL=Canvas2DAdapter.js.map
  576. var __extends = (this && this.__extends) || function (d, b) {
  577. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  578. function __() { this.constructor = d; }
  579. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  580. };
  581. var INSPECTOR;
  582. (function (INSPECTOR) {
  583. var LightAdapter = (function (_super) {
  584. __extends(LightAdapter, _super);
  585. function LightAdapter(obj) {
  586. return _super.call(this, obj) || this;
  587. }
  588. /** Returns the name displayed in the tree */
  589. LightAdapter.prototype.id = function () {
  590. var str = '';
  591. if (this._obj.name) {
  592. str = this._obj.name;
  593. } // otherwise nothing displayed
  594. return str;
  595. };
  596. /** Returns the type of this object - displayed in the tree */
  597. LightAdapter.prototype.type = function () {
  598. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  599. };
  600. /** Returns the list of properties to be displayed for this adapter */
  601. LightAdapter.prototype.getProperties = function () {
  602. var propertiesLines = [];
  603. for (var _i = 0, _a = LightAdapter._PROPERTIES; _i < _a.length; _i++) {
  604. var dirty = _a[_i];
  605. var infos = new INSPECTOR.Property(dirty, this._obj);
  606. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  607. }
  608. return propertiesLines;
  609. };
  610. LightAdapter.prototype.getTools = function () {
  611. var tools = [];
  612. tools.push(new INSPECTOR.Checkbox(this));
  613. return tools;
  614. };
  615. LightAdapter.prototype.setVisible = function (b) {
  616. this._obj.setEnabled(b);
  617. };
  618. LightAdapter.prototype.isVisible = function () {
  619. return this._obj.isEnabled();
  620. };
  621. /** Returns some information about this mesh */
  622. // public getInfo() : string {
  623. // return `${(this._obj as BABYLON.AbstractMesh).getTotalVertices()} vertices`;
  624. // }
  625. /** Overrides super.highlight */
  626. LightAdapter.prototype.highlight = function (b) {
  627. this.actualObject.renderOutline = b;
  628. this.actualObject.outlineWidth = 0.25;
  629. this.actualObject.outlineColor = BABYLON.Color3.Yellow();
  630. };
  631. return LightAdapter;
  632. }(INSPECTOR.Adapter));
  633. LightAdapter._PROPERTIES = [
  634. 'position',
  635. 'diffuse',
  636. 'intensity',
  637. 'radius',
  638. 'range',
  639. 'specular'
  640. ];
  641. INSPECTOR.LightAdapter = LightAdapter;
  642. })(INSPECTOR || (INSPECTOR = {}));
  643. //# sourceMappingURL=LightAdapter.js.map
  644. var __extends = (this && this.__extends) || function (d, b) {
  645. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  646. function __() { this.constructor = d; }
  647. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  648. };
  649. var INSPECTOR;
  650. (function (INSPECTOR) {
  651. var MaterialAdapter = (function (_super) {
  652. __extends(MaterialAdapter, _super);
  653. function MaterialAdapter(obj) {
  654. return _super.call(this, obj) || this;
  655. }
  656. /** Returns the name displayed in the tree */
  657. MaterialAdapter.prototype.id = function () {
  658. var str = '';
  659. if (this._obj.name) {
  660. str = this._obj.name;
  661. } // otherwise nothing displayed
  662. return str;
  663. };
  664. /** Returns the type of this object - displayed in the tree */
  665. MaterialAdapter.prototype.type = function () {
  666. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  667. };
  668. /** Returns the list of properties to be displayed for this adapter */
  669. MaterialAdapter.prototype.getProperties = function () {
  670. var propertiesLines = [];
  671. var propToDisplay = [];
  672. // The if is there to work with the min version of babylon
  673. if (this._obj instanceof BABYLON.StandardMaterial) {
  674. propToDisplay = INSPECTOR.PROPERTIES['StandardMaterial'].properties;
  675. }
  676. else if (this._obj instanceof BABYLON.PBRMaterial) {
  677. propToDisplay = INSPECTOR.PROPERTIES['PBRMaterial'].properties;
  678. }
  679. for (var _i = 0, propToDisplay_1 = propToDisplay; _i < propToDisplay_1.length; _i++) {
  680. var dirty = propToDisplay_1[_i];
  681. var infos = new INSPECTOR.Property(dirty, this._obj);
  682. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  683. }
  684. return propertiesLines;
  685. };
  686. /** No tools for a material adapter */
  687. MaterialAdapter.prototype.getTools = function () {
  688. return [];
  689. };
  690. /** Overrides super.highlight.
  691. * Highlighting a material outlines all meshes linked to this material
  692. */
  693. MaterialAdapter.prototype.highlight = function (b) {
  694. var material = this.actualObject;
  695. var meshes = material.getBindedMeshes();
  696. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  697. var mesh = meshes_1[_i];
  698. mesh.renderOutline = b;
  699. mesh.outlineWidth = 0.25;
  700. mesh.outlineColor = BABYLON.Color3.Yellow();
  701. }
  702. };
  703. return MaterialAdapter;
  704. }(INSPECTOR.Adapter));
  705. INSPECTOR.MaterialAdapter = MaterialAdapter;
  706. })(INSPECTOR || (INSPECTOR = {}));
  707. //# sourceMappingURL=MaterialAdapter.js.map
  708. var __extends = (this && this.__extends) || function (d, b) {
  709. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  710. function __() { this.constructor = d; }
  711. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  712. };
  713. var INSPECTOR;
  714. (function (INSPECTOR) {
  715. var MeshAdapter = (function (_super) {
  716. __extends(MeshAdapter, _super);
  717. function MeshAdapter(obj) {
  718. var _this = _super.call(this, obj) || this;
  719. /** Keep track of the axis of the actual object */
  720. _this._axis = [];
  721. return _this;
  722. }
  723. /** Returns the name displayed in the tree */
  724. MeshAdapter.prototype.id = function () {
  725. var str = '';
  726. if (this._obj.name) {
  727. str = this._obj.name;
  728. } // otherwise nothing displayed
  729. return str;
  730. };
  731. /** Returns the type of this object - displayed in the tree */
  732. MeshAdapter.prototype.type = function () {
  733. return INSPECTOR.Helpers.GET_TYPE(this._obj);
  734. };
  735. /** Returns the list of properties to be displayed for this adapter */
  736. MeshAdapter.prototype.getProperties = function () {
  737. var propertiesLines = [];
  738. for (var _i = 0, _a = INSPECTOR.PROPERTIES['Mesh'].properties; _i < _a.length; _i++) {
  739. var dirty = _a[_i];
  740. var infos = new INSPECTOR.Property(dirty, this._obj);
  741. propertiesLines.push(new INSPECTOR.PropertyLine(infos));
  742. }
  743. return propertiesLines;
  744. };
  745. MeshAdapter.prototype.getTools = function () {
  746. var tools = [];
  747. tools.push(new INSPECTOR.Checkbox(this));
  748. tools.push(new INSPECTOR.DebugArea(this));
  749. tools.push(new INSPECTOR.BoundingBox(this));
  750. tools.push(new INSPECTOR.Info(this));
  751. return tools;
  752. };
  753. MeshAdapter.prototype.setVisible = function (b) {
  754. this._obj.setEnabled(b);
  755. this._obj.isVisible = b;
  756. };
  757. MeshAdapter.prototype.isVisible = function () {
  758. return this._obj.isEnabled() && this._obj.isVisible;
  759. };
  760. MeshAdapter.prototype.isBoxVisible = function () {
  761. return this._obj.showBoundingBox;
  762. };
  763. MeshAdapter.prototype.setBoxVisible = function (b) {
  764. return this._obj.showBoundingBox = b;
  765. };
  766. MeshAdapter.prototype.debug = function (b) {
  767. // Draw axis the first time
  768. if (this._axis.length == 0) {
  769. this._drawAxis();
  770. }
  771. // Display or hide axis
  772. for (var _i = 0, _a = this._axis; _i < _a.length; _i++) {
  773. var ax = _a[_i];
  774. ax.setEnabled(b);
  775. }
  776. };
  777. /** Returns some information about this mesh */
  778. MeshAdapter.prototype.getInfo = function () {
  779. return this._obj.getTotalVertices() + " vertices";
  780. };
  781. /** Overrides super.highlight */
  782. MeshAdapter.prototype.highlight = function (b) {
  783. this.actualObject.renderOutline = b;
  784. this.actualObject.outlineWidth = 0.25;
  785. this.actualObject.outlineColor = BABYLON.Color3.Yellow();
  786. };
  787. /** Draw X, Y and Z axis for the actual object if this adapter.
  788. * Should be called only one time as it will fill this._axis
  789. */
  790. MeshAdapter.prototype._drawAxis = function () {
  791. var _this = this;
  792. this._obj.computeWorldMatrix();
  793. var m = this._obj.getWorldMatrix();
  794. // Axis
  795. var x = new BABYLON.Vector3(8, 0, 0);
  796. var y = new BABYLON.Vector3(0, 8, 0);
  797. var z = new BABYLON.Vector3(0, 0, 8);
  798. // Draw an axis of the given color
  799. var _drawAxis = function (color, start, end) {
  800. var axis = BABYLON.Mesh.CreateLines("###axis###", [
  801. start,
  802. end
  803. ], _this._obj.getScene());
  804. axis.color = color;
  805. axis.renderingGroupId = 1;
  806. return axis;
  807. };
  808. // X axis
  809. var xAxis = _drawAxis(BABYLON.Color3.Red(), this._obj.getAbsolutePosition(), BABYLON.Vector3.TransformCoordinates(x, m));
  810. xAxis.position.subtractInPlace(this._obj.position);
  811. xAxis.parent = this._obj;
  812. this._axis.push(xAxis);
  813. // Y axis
  814. var yAxis = _drawAxis(BABYLON.Color3.Green(), this._obj.getAbsolutePosition(), BABYLON.Vector3.TransformCoordinates(y, m));
  815. yAxis.parent = this._obj;
  816. yAxis.position.subtractInPlace(this._obj.position);
  817. this._axis.push(yAxis);
  818. // Z axis
  819. var zAxis = _drawAxis(BABYLON.Color3.Blue(), this._obj.getAbsolutePosition(), BABYLON.Vector3.TransformCoordinates(z, m));
  820. zAxis.parent = this._obj;
  821. zAxis.position.subtractInPlace(this._obj.position);
  822. this._axis.push(zAxis);
  823. };
  824. return MeshAdapter;
  825. }(INSPECTOR.Adapter));
  826. INSPECTOR.MeshAdapter = MeshAdapter;
  827. })(INSPECTOR || (INSPECTOR = {}));
  828. //# sourceMappingURL=MeshAdapter.js.map
  829. var __extends = (this && this.__extends) || function (d, b) {
  830. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  831. function __() { this.constructor = d; }
  832. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  833. };
  834. var INSPECTOR;
  835. (function (INSPECTOR) {
  836. var DetailPanel = (function (_super) {
  837. __extends(DetailPanel, _super);
  838. function DetailPanel(dr) {
  839. var _this = _super.call(this) || this;
  840. // Contains all details rows that belongs to the item above
  841. _this._detailRows = [];
  842. // Store the sort direction of each header column
  843. _this._sortDirection = {};
  844. _this._build();
  845. if (dr) {
  846. _this._detailRows = dr;
  847. _this.update();
  848. }
  849. return _this;
  850. }
  851. Object.defineProperty(DetailPanel.prototype, "details", {
  852. set: function (detailsRow) {
  853. this.clean();
  854. this._detailRows = detailsRow;
  855. // Refresh HTML
  856. this.update();
  857. },
  858. enumerable: true,
  859. configurable: true
  860. });
  861. DetailPanel.prototype._build = function () {
  862. this._div.className = 'insp-details';
  863. this._div.id = 'insp-details';
  864. // Create header row
  865. this._createHeaderRow();
  866. this._div.appendChild(this._headerRow);
  867. };
  868. /** Updates the HTML of the detail panel */
  869. DetailPanel.prototype.update = function () {
  870. this._sortDetails('name', 1);
  871. this._addDetails();
  872. };
  873. /** Add all lines in the html div. Does not sort them! */
  874. DetailPanel.prototype._addDetails = function () {
  875. var details = INSPECTOR.Helpers.CreateDiv('details', this._div);
  876. for (var _i = 0, _a = this._detailRows; _i < _a.length; _i++) {
  877. var row = _a[_i];
  878. details.appendChild(row.toHtml());
  879. }
  880. };
  881. /**
  882. * Sort the details row by comparing the given property of each row
  883. */
  884. DetailPanel.prototype._sortDetails = function (property, _direction) {
  885. // Clean header
  886. var elems = INSPECTOR.Inspector.DOCUMENT.querySelectorAll('.sort-direction');
  887. for (var e = 0; e < elems.length; e++) {
  888. elems[e].classList.remove('fa-chevron-up');
  889. elems[e].classList.remove('fa-chevron-down');
  890. }
  891. if (_direction || !this._sortDirection[property]) {
  892. this._sortDirection[property] = _direction || 1;
  893. }
  894. else {
  895. this._sortDirection[property] *= -1;
  896. }
  897. var direction = this._sortDirection[property];
  898. if (direction == 1) {
  899. this._headerRow.querySelector("#sort-direction-" + property).classList.remove('fa-chevron-down');
  900. this._headerRow.querySelector("#sort-direction-" + property).classList.add('fa-chevron-up');
  901. }
  902. else {
  903. this._headerRow.querySelector("#sort-direction-" + property).classList.remove('fa-chevron-up');
  904. this._headerRow.querySelector("#sort-direction-" + property).classList.add('fa-chevron-down');
  905. }
  906. var isString = function (s) {
  907. return typeof (s) === 'string' || s instanceof String;
  908. };
  909. this._detailRows.sort(function (detail1, detail2) {
  910. var str1 = String(detail1[property]);
  911. var str2 = String(detail2[property]);
  912. if (!isString(str1)) {
  913. str1 = detail1[property].toString();
  914. }
  915. if (!isString(str2)) {
  916. str2 = detail2[property].toString();
  917. }
  918. // Compare numbers as numbers and string as string with 'numeric=true'
  919. return str1.localeCompare(str2, [], { numeric: true }) * direction;
  920. });
  921. };
  922. /**
  923. * Removes all data in the detail panel but keep the header row
  924. */
  925. DetailPanel.prototype.clean = function () {
  926. // Delete all details row
  927. for (var _i = 0, _a = this._detailRows; _i < _a.length; _i++) {
  928. var pline = _a[_i];
  929. pline.dispose();
  930. }
  931. INSPECTOR.Helpers.CleanDiv(this._div);
  932. // Header row
  933. this._div.appendChild(this._headerRow);
  934. };
  935. /** Overrides basicelement.dispose */
  936. DetailPanel.prototype.dispose = function () {
  937. // Delete all details row
  938. for (var _i = 0, _a = this._detailRows; _i < _a.length; _i++) {
  939. var pline = _a[_i];
  940. pline.dispose();
  941. }
  942. };
  943. /**
  944. * Creates the header row : name, value, id
  945. */
  946. DetailPanel.prototype._createHeaderRow = function () {
  947. var _this = this;
  948. this._headerRow = INSPECTOR.Helpers.CreateDiv('header-row');
  949. var createDiv = function (name, cssClass) {
  950. var div = INSPECTOR.Helpers.CreateDiv(cssClass + ' header-col');
  951. // Column title - first letter in uppercase
  952. var spanName = INSPECTOR.Inspector.DOCUMENT.createElement('span');
  953. spanName.textContent = name.charAt(0).toUpperCase() + name.slice(1);
  954. // sort direction
  955. var spanDirection = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  956. spanDirection.className = 'sort-direction fa';
  957. spanDirection.id = 'sort-direction-' + name;
  958. div.appendChild(spanName);
  959. div.appendChild(spanDirection);
  960. div.addEventListener('click', function (e) {
  961. _this._sortDetails(name);
  962. _this._addDetails();
  963. });
  964. return div;
  965. };
  966. this._headerRow.appendChild(createDiv('name', 'prop-name'));
  967. this._headerRow.appendChild(createDiv('value', 'prop-value'));
  968. };
  969. return DetailPanel;
  970. }(INSPECTOR.BasicElement));
  971. INSPECTOR.DetailPanel = DetailPanel;
  972. })(INSPECTOR || (INSPECTOR = {}));
  973. //# sourceMappingURL=DetailPanel.js.map
  974. var INSPECTOR;
  975. (function (INSPECTOR) {
  976. /**
  977. * A property is a link between a data (string) and an object.
  978. */
  979. var Property = (function () {
  980. function Property(prop, obj) {
  981. this._property = prop;
  982. this._obj = obj;
  983. }
  984. Object.defineProperty(Property.prototype, "name", {
  985. get: function () {
  986. return this._property;
  987. },
  988. enumerable: true,
  989. configurable: true
  990. });
  991. Object.defineProperty(Property.prototype, "value", {
  992. get: function () {
  993. return this._obj[this._property];
  994. },
  995. set: function (newValue) {
  996. this._obj[this._property] = newValue;
  997. },
  998. enumerable: true,
  999. configurable: true
  1000. });
  1001. Object.defineProperty(Property.prototype, "type", {
  1002. get: function () {
  1003. return INSPECTOR.Helpers.GET_TYPE(this.value);
  1004. },
  1005. enumerable: true,
  1006. configurable: true
  1007. });
  1008. Object.defineProperty(Property.prototype, "obj", {
  1009. get: function () {
  1010. return this._obj;
  1011. },
  1012. set: function (newObj) {
  1013. this._obj = newObj;
  1014. },
  1015. enumerable: true,
  1016. configurable: true
  1017. });
  1018. return Property;
  1019. }());
  1020. INSPECTOR.Property = Property;
  1021. })(INSPECTOR || (INSPECTOR = {}));
  1022. //# sourceMappingURL=Property.js.map
  1023. var INSPECTOR;
  1024. (function (INSPECTOR) {
  1025. var PropertyFormatter = (function () {
  1026. function PropertyFormatter() {
  1027. }
  1028. /**
  1029. * Format the value of the given property of the given object.
  1030. */
  1031. PropertyFormatter.format = function (obj, prop) {
  1032. // Get original value;
  1033. var value = obj[prop];
  1034. // test if type PrimitiveAlignment is available (only included in canvas2d)
  1035. if (BABYLON.PrimitiveAlignment) {
  1036. if (obj instanceof BABYLON.PrimitiveAlignment) {
  1037. if (prop === 'horizontal') {
  1038. switch (value) {
  1039. case BABYLON.PrimitiveAlignment.AlignLeft:
  1040. return 'left';
  1041. case BABYLON.PrimitiveAlignment.AlignRight:
  1042. return 'right';
  1043. case BABYLON.PrimitiveAlignment.AlignCenter:
  1044. return 'center';
  1045. case BABYLON.PrimitiveAlignment.AlignStretch:
  1046. return 'stretch';
  1047. }
  1048. }
  1049. else if (prop === 'vertical') {
  1050. switch (value) {
  1051. case BABYLON.PrimitiveAlignment.AlignTop:
  1052. return 'top';
  1053. case BABYLON.PrimitiveAlignment.AlignBottom:
  1054. return 'bottom';
  1055. case BABYLON.PrimitiveAlignment.AlignCenter:
  1056. return 'center';
  1057. case BABYLON.PrimitiveAlignment.AlignStretch:
  1058. return 'stretch';
  1059. }
  1060. }
  1061. }
  1062. }
  1063. return value;
  1064. };
  1065. return PropertyFormatter;
  1066. }());
  1067. INSPECTOR.PropertyFormatter = PropertyFormatter;
  1068. /**
  1069. * A property line represents a line in the detail panel. This line is composed of :
  1070. * - a name (the property name)
  1071. * - a value if this property is of a type 'simple' : string, number, boolean, color, texture
  1072. * - the type of the value if this property is of a complex type (Vector2, Size, ...)
  1073. * - a ID if defined (otherwise an empty string is displayed)
  1074. * The original object is sent to the value object who will update it at will.
  1075. *
  1076. * A property line can contain OTHER property line objects in the case of a complex type.
  1077. * If this instance has no link to other instances, its type is ALWAYS a simple one (see above).
  1078. *
  1079. */
  1080. var PropertyLine = (function () {
  1081. function PropertyLine(prop, parent, level) {
  1082. if (level === void 0) { level = 0; }
  1083. // If the type is complex, this property will have child to update
  1084. this._children = [];
  1085. /** The list of viewer element displayed at the end of the line (color, texture...) */
  1086. this._elements = [];
  1087. this._property = prop;
  1088. this._level = level;
  1089. this._parent = parent;
  1090. this._div = INSPECTOR.Helpers.CreateDiv('row');
  1091. this._div.style.marginLeft = this._level + "px";
  1092. // Property name
  1093. var propName = INSPECTOR.Helpers.CreateDiv('prop-name', this._div);
  1094. propName.textContent = "" + this.name;
  1095. // Value
  1096. this._valueDiv = INSPECTOR.Helpers.CreateDiv('prop-value', this._div);
  1097. this._valueDiv.textContent = this._displayValueContent() || '-'; // Init value text node
  1098. this._createElements();
  1099. for (var _i = 0, _a = this._elements; _i < _a.length; _i++) {
  1100. var elem = _a[_i];
  1101. this._valueDiv.appendChild(elem.toHtml());
  1102. }
  1103. this._updateValue();
  1104. // If the property type is not simple, add click event to unfold its children
  1105. if (!this._isSimple()) {
  1106. this._valueDiv.classList.add('clickable');
  1107. this._valueDiv.addEventListener('click', this._addDetails.bind(this));
  1108. }
  1109. else {
  1110. this._initInput();
  1111. this._valueDiv.addEventListener('click', this._displayInputHandler);
  1112. this._input.addEventListener('keypress', this._validateInputHandler);
  1113. }
  1114. // Add this property to the scheduler
  1115. INSPECTOR.Scheduler.getInstance().add(this);
  1116. }
  1117. /**
  1118. * Init the input element and al its handler :
  1119. * - a click in the window remove the input and restore the old property value
  1120. * - enters updates the property
  1121. */
  1122. PropertyLine.prototype._initInput = function () {
  1123. // Create the input element
  1124. this._input = document.createElement('input');
  1125. this._input.setAttribute('type', 'text');
  1126. // if the property is 'simple', add an event listener to create an input
  1127. this._displayInputHandler = this._displayInput.bind(this);
  1128. this._validateInputHandler = this._validateInput.bind(this);
  1129. };
  1130. /**
  1131. * On enter : validates the new value and removes the input
  1132. * On escape : removes the input
  1133. */
  1134. PropertyLine.prototype._validateInput = function (e) {
  1135. if (e.keyCode == 13) {
  1136. // Enter : validate the new value
  1137. var newValue = this._input.value;
  1138. this.updateObject();
  1139. this._property.value = newValue;
  1140. // Remove input
  1141. this.update();
  1142. // resume scheduler
  1143. INSPECTOR.Scheduler.getInstance().pause = false;
  1144. }
  1145. else if (e.keyCode == 27) {
  1146. // Esc : remove input
  1147. this.update();
  1148. }
  1149. };
  1150. /** Removes the input without validating the new value */
  1151. PropertyLine.prototype._removeInputWithoutValidating = function () {
  1152. INSPECTOR.Helpers.CleanDiv(this._valueDiv);
  1153. this._valueDiv.textContent = "-";
  1154. // restore elements
  1155. for (var _i = 0, _a = this._elements; _i < _a.length; _i++) {
  1156. var elem = _a[_i];
  1157. this._valueDiv.appendChild(elem.toHtml());
  1158. }
  1159. this._valueDiv.addEventListener('click', this._displayInputHandler);
  1160. };
  1161. /** Replaces the default display with an input */
  1162. PropertyLine.prototype._displayInput = function (e) {
  1163. // Remove the displayInput event listener
  1164. this._valueDiv.removeEventListener('click', this._displayInputHandler);
  1165. // Set input value
  1166. var valueTxt = this._valueDiv.textContent;
  1167. this._valueDiv.textContent = "";
  1168. this._input.value = valueTxt;
  1169. this._valueDiv.appendChild(this._input);
  1170. // Pause the scheduler
  1171. INSPECTOR.Scheduler.getInstance().pause = true;
  1172. };
  1173. /** Retrieve the correct object from its parent.
  1174. * If no parent exists, returns the property value.
  1175. * This method is used at each update in case the property object is removed from the original object
  1176. * (example : mesh.position = new BABYLON.Vector3 ; the original vector3 object is deleted from the mesh).
  1177. */
  1178. PropertyLine.prototype.updateObject = function () {
  1179. if (!this._parent) {
  1180. return this._property.value;
  1181. }
  1182. else {
  1183. this._property.obj = this._parent.updateObject();
  1184. }
  1185. };
  1186. Object.defineProperty(PropertyLine.prototype, "name", {
  1187. // Returns the property name
  1188. get: function () {
  1189. return this._property.name;
  1190. },
  1191. enumerable: true,
  1192. configurable: true
  1193. });
  1194. Object.defineProperty(PropertyLine.prototype, "value", {
  1195. // Returns the value of the property
  1196. get: function () {
  1197. return PropertyFormatter.format(this._property.obj, this._property.name);
  1198. },
  1199. enumerable: true,
  1200. configurable: true
  1201. });
  1202. Object.defineProperty(PropertyLine.prototype, "type", {
  1203. // Returns the type of the property
  1204. get: function () {
  1205. return this._property.type;
  1206. },
  1207. enumerable: true,
  1208. configurable: true
  1209. });
  1210. /**
  1211. * Creates elements that wil be displayed on a property line, depending on the
  1212. * type of the property.
  1213. */
  1214. PropertyLine.prototype._createElements = function () {
  1215. // Colors
  1216. if (this.type == 'Color3' || this.type == 'Color4') {
  1217. this._elements.push(new INSPECTOR.ColorElement(this.value));
  1218. }
  1219. // Texture
  1220. if (this.type == 'Texture') {
  1221. this._elements.push(new INSPECTOR.TextureElement(this.value));
  1222. }
  1223. // HDR Texture
  1224. if (this.type == 'HDRCubeTexture') {
  1225. this._elements.push(new INSPECTOR.HDRCubeTextureElement(this.value));
  1226. }
  1227. if (this.type == 'CubeTexture') {
  1228. this._elements.push(new INSPECTOR.CubeTextureElement(this.value));
  1229. }
  1230. };
  1231. // Returns the text displayed on the left of the property name :
  1232. // - If the type is simple, display its value
  1233. // - If the type is complex, but instance of Vector2, Size, display the type and its tostring
  1234. // - If the type is another one, display the Type
  1235. PropertyLine.prototype._displayValueContent = function () {
  1236. var value = this.value;
  1237. // If the value is a number, truncate it if needed
  1238. if (typeof value === 'number') {
  1239. return INSPECTOR.Helpers.Trunc(value);
  1240. }
  1241. // If it's a string or a boolean, display its value
  1242. if (typeof value === 'string' || typeof value === 'boolean') {
  1243. return value;
  1244. }
  1245. return INSPECTOR.PROPERTIES.format(value);
  1246. };
  1247. /** Delete properly this property line.
  1248. * Removes itself from the scheduler.
  1249. * Dispose all viewer element (color, texture...)
  1250. */
  1251. PropertyLine.prototype.dispose = function () {
  1252. // console.log('delete properties', this.name);
  1253. INSPECTOR.Scheduler.getInstance().remove(this);
  1254. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  1255. var child = _a[_i];
  1256. // console.log('delete properties', child.name);
  1257. INSPECTOR.Scheduler.getInstance().remove(child);
  1258. }
  1259. for (var _b = 0, _c = this._elements; _b < _c.length; _b++) {
  1260. var elem = _c[_b];
  1261. elem.dispose();
  1262. }
  1263. this._elements = [];
  1264. };
  1265. /** Updates the content of _valueDiv with the value of the property,
  1266. * and all HTML element correpsonding to this type.
  1267. * Elements are updated as well
  1268. */
  1269. PropertyLine.prototype._updateValue = function () {
  1270. // Update the property object first
  1271. this.updateObject();
  1272. // Then update its value
  1273. // this._valueDiv.textContent = " "; // TOFIX this removes the elements after
  1274. this._valueDiv.childNodes[0].nodeValue = this._displayValueContent();
  1275. for (var _i = 0, _a = this._elements; _i < _a.length; _i++) {
  1276. var elem = _a[_i];
  1277. elem.update(this.value);
  1278. }
  1279. };
  1280. /**
  1281. * Update the property division with the new property value.
  1282. * If this property is complex, update its child, otherwise update its text content
  1283. */
  1284. PropertyLine.prototype.update = function () {
  1285. this._removeInputWithoutValidating();
  1286. this._updateValue();
  1287. };
  1288. /**
  1289. * Returns true if the given instance is a simple type
  1290. */
  1291. PropertyLine._IS_TYPE_SIMPLE = function (inst) {
  1292. var type = INSPECTOR.Helpers.GET_TYPE(inst);
  1293. return PropertyLine._SIMPLE_TYPE.indexOf(type) != -1;
  1294. };
  1295. /**
  1296. * Returns true if the type of this property is simple, false otherwise.
  1297. * Returns true if the value is null
  1298. */
  1299. PropertyLine.prototype._isSimple = function () {
  1300. if (this.value != null && this.type !== 'type_not_defined') {
  1301. if (PropertyLine._SIMPLE_TYPE.indexOf(this.type) == -1) {
  1302. // complex type : return the type name
  1303. return false;
  1304. }
  1305. else {
  1306. // simple type : return value
  1307. return true;
  1308. }
  1309. }
  1310. else {
  1311. return true;
  1312. }
  1313. };
  1314. PropertyLine.prototype.toHtml = function () {
  1315. return this._div;
  1316. };
  1317. /**
  1318. * Add sub properties in case of a complex type
  1319. */
  1320. PropertyLine.prototype._addDetails = function () {
  1321. if (this._div.classList.contains('unfolded')) {
  1322. // Remove class unfolded
  1323. this._div.classList.remove('unfolded');
  1324. // remove html children
  1325. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  1326. var child = _a[_i];
  1327. this._div.parentNode.removeChild(child.toHtml());
  1328. }
  1329. }
  1330. else {
  1331. // if children does not exists, generate it
  1332. this._div.classList.toggle('unfolded');
  1333. if (this._children.length == 0) {
  1334. var objToDetail = this.value;
  1335. var propToDisplay = INSPECTOR.PROPERTIES[INSPECTOR.Helpers.GET_TYPE(objToDetail)].properties.reverse();
  1336. var propertyLine = null;
  1337. for (var _b = 0, propToDisplay_1 = propToDisplay; _b < propToDisplay_1.length; _b++) {
  1338. var prop = propToDisplay_1[_b];
  1339. var infos = new INSPECTOR.Property(prop, this._property.value);
  1340. var child = new PropertyLine(infos, this, this._level + PropertyLine._MARGIN_LEFT);
  1341. this._children.push(child);
  1342. }
  1343. }
  1344. // otherwise display it
  1345. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  1346. var child = _d[_c];
  1347. this._div.parentNode.insertBefore(child.toHtml(), this._div.nextSibling);
  1348. }
  1349. }
  1350. };
  1351. return PropertyLine;
  1352. }());
  1353. // Array representing the simple type. All others are considered 'complex'
  1354. PropertyLine._SIMPLE_TYPE = ['number', 'string', 'boolean'];
  1355. // The number of pixel at each children step
  1356. PropertyLine._MARGIN_LEFT = 15;
  1357. INSPECTOR.PropertyLine = PropertyLine;
  1358. })(INSPECTOR || (INSPECTOR = {}));
  1359. //# sourceMappingURL=PropertyLine.js.map
  1360. var __extends = (this && this.__extends) || function (d, b) {
  1361. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1362. function __() { this.constructor = d; }
  1363. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1364. };
  1365. var INSPECTOR;
  1366. (function (INSPECTOR) {
  1367. /**
  1368. * Display a very small div corresponding to the given color
  1369. */
  1370. var ColorElement = (function (_super) {
  1371. __extends(ColorElement, _super);
  1372. // The color as hexadecimal string
  1373. function ColorElement(color) {
  1374. var _this = _super.call(this) || this;
  1375. _this._div.className = 'color-element';
  1376. _this._div.style.backgroundColor = _this._toRgba(color);
  1377. return _this;
  1378. }
  1379. ColorElement.prototype.update = function (color) {
  1380. if (color) {
  1381. this._div.style.backgroundColor = this._toRgba(color);
  1382. }
  1383. };
  1384. ColorElement.prototype._toRgba = function (color) {
  1385. if (color) {
  1386. var r = (color.r * 255) | 0;
  1387. var g = (color.g * 255) | 0;
  1388. var b = (color.b * 255) | 0;
  1389. var a = 1;
  1390. if (color instanceof BABYLON.Color4) {
  1391. var a_1 = color.a;
  1392. }
  1393. return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
  1394. }
  1395. else {
  1396. return '';
  1397. }
  1398. };
  1399. return ColorElement;
  1400. }(INSPECTOR.BasicElement));
  1401. INSPECTOR.ColorElement = ColorElement;
  1402. })(INSPECTOR || (INSPECTOR = {}));
  1403. //# sourceMappingURL=ColorElement.js.map
  1404. var __extends = (this && this.__extends) || function (d, b) {
  1405. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1406. function __() { this.constructor = d; }
  1407. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1408. };
  1409. var INSPECTOR;
  1410. (function (INSPECTOR) {
  1411. /**
  1412. * Display a very small div. A new canvas is created, with a new Babylon.js scene, containing only the
  1413. * cube texture in a cube
  1414. */
  1415. var CubeTextureElement = (function (_super) {
  1416. __extends(CubeTextureElement, _super);
  1417. /** The texture given as a parameter should be cube. */
  1418. function CubeTextureElement(tex) {
  1419. var _this = _super.call(this) || this;
  1420. // On pause the engine will not render anything
  1421. _this._pause = false;
  1422. _this._div.className = 'fa fa-search texture-element';
  1423. // Create the texture viewer
  1424. _this._textureDiv = INSPECTOR.Helpers.CreateDiv('texture-viewer', _this._div);
  1425. // canvas
  1426. _this._canvas = INSPECTOR.Helpers.CreateElement('canvas', 'texture-viewer-img', _this._textureDiv);
  1427. if (tex) {
  1428. _this._textureUrl = tex.name;
  1429. }
  1430. _this._div.addEventListener('mouseover', _this._showViewer.bind(_this, 'flex'));
  1431. _this._div.addEventListener('mouseout', _this._showViewer.bind(_this, 'none'));
  1432. return _this;
  1433. }
  1434. CubeTextureElement.prototype.update = function (tex) {
  1435. if (tex && tex.url === this._textureUrl) {
  1436. }
  1437. else {
  1438. if (tex) {
  1439. this._textureUrl = tex.name;
  1440. }
  1441. if (this._engine) {
  1442. // Dispose old material and cube
  1443. this._cube.material.dispose(true, true);
  1444. this._cube.dispose();
  1445. }
  1446. else {
  1447. this._initEngine();
  1448. }
  1449. // and create it again
  1450. this._populateScene();
  1451. }
  1452. };
  1453. /** Creates the box */
  1454. CubeTextureElement.prototype._populateScene = function () {
  1455. var _this = this;
  1456. // Create the hdr texture
  1457. var hdrTexture = new BABYLON.CubeTexture(this._textureUrl, this._scene);
  1458. hdrTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
  1459. this._cube = BABYLON.Mesh.CreateBox("hdrSkyBox", 10.0, this._scene);
  1460. var hdrSkyboxMaterial = new BABYLON.StandardMaterial("skyBox", this._scene);
  1461. hdrSkyboxMaterial.backFaceCulling = false;
  1462. hdrSkyboxMaterial.reflectionTexture = hdrTexture;
  1463. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
  1464. hdrSkyboxMaterial.disableLighting = true;
  1465. this._cube.material = hdrSkyboxMaterial;
  1466. this._cube.registerBeforeRender(function () {
  1467. _this._cube.rotation.y += 0.01;
  1468. });
  1469. };
  1470. /** Init the babylon engine */
  1471. CubeTextureElement.prototype._initEngine = function () {
  1472. var _this = this;
  1473. this._engine = new BABYLON.Engine(this._canvas);
  1474. this._scene = new BABYLON.Scene(this._engine);
  1475. this._scene.clearColor = new BABYLON.Color4(0, 0, 0, 0);
  1476. var cam = new BABYLON.FreeCamera('cam', new BABYLON.Vector3(0, 0, -20), this._scene);
  1477. var light = new BABYLON.HemisphericLight('', new BABYLON.Vector3(0, 1, 0), this._scene);
  1478. this._engine.runRenderLoop(function () {
  1479. if (!_this._pause) {
  1480. _this._scene.render();
  1481. }
  1482. });
  1483. this._canvas.setAttribute('width', '110');
  1484. this._canvas.setAttribute('height', '110');
  1485. };
  1486. CubeTextureElement.prototype._showViewer = function (mode) {
  1487. // If displaying...
  1488. if (mode != 'none') {
  1489. // ... and the canvas is not initialized
  1490. if (!this._engine) {
  1491. this._initEngine();
  1492. this._populateScene();
  1493. }
  1494. // In every cases, unpause the engine
  1495. this._pause = false;
  1496. }
  1497. else {
  1498. // hide : pause the engine
  1499. this._pause = true;
  1500. }
  1501. this._textureDiv.style.display = mode;
  1502. };
  1503. /** Removes properly the babylon engine */
  1504. CubeTextureElement.prototype.dispose = function () {
  1505. if (this._engine) {
  1506. this._engine.dispose();
  1507. this._engine = null;
  1508. }
  1509. };
  1510. return CubeTextureElement;
  1511. }(INSPECTOR.BasicElement));
  1512. INSPECTOR.CubeTextureElement = CubeTextureElement;
  1513. })(INSPECTOR || (INSPECTOR = {}));
  1514. //# sourceMappingURL=CubeTextureElement.js.map
  1515. var __extends = (this && this.__extends) || function (d, b) {
  1516. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1517. function __() { this.constructor = d; }
  1518. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1519. };
  1520. var INSPECTOR;
  1521. (function (INSPECTOR) {
  1522. /**
  1523. * Display a very small div. A new canvas is created, with a new Babylon.js scene, containing only the
  1524. * cube texture in a cube
  1525. */
  1526. var HDRCubeTextureElement = (function (_super) {
  1527. __extends(HDRCubeTextureElement, _super);
  1528. /** The texture given as a parameter should be cube. */
  1529. function HDRCubeTextureElement(tex) {
  1530. return _super.call(this, tex) || this;
  1531. }
  1532. /** Creates the box */
  1533. HDRCubeTextureElement.prototype._populateScene = function () {
  1534. var _this = this;
  1535. // Create the hdr texture
  1536. var hdrTexture = new BABYLON.HDRCubeTexture(this._textureUrl, this._scene, 512);
  1537. hdrTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
  1538. this._cube = BABYLON.Mesh.CreateBox("hdrSkyBox", 10.0, this._scene);
  1539. var hdrSkyboxMaterial = new BABYLON.PBRMaterial("skyBox", this._scene);
  1540. hdrSkyboxMaterial.backFaceCulling = false;
  1541. hdrSkyboxMaterial.reflectionTexture = hdrTexture;
  1542. hdrSkyboxMaterial.microSurface = 1.0;
  1543. hdrSkyboxMaterial.disableLighting = true;
  1544. this._cube.material = hdrSkyboxMaterial;
  1545. this._cube.registerBeforeRender(function () {
  1546. _this._cube.rotation.y += 0.01;
  1547. });
  1548. };
  1549. return HDRCubeTextureElement;
  1550. }(INSPECTOR.CubeTextureElement));
  1551. INSPECTOR.HDRCubeTextureElement = HDRCubeTextureElement;
  1552. })(INSPECTOR || (INSPECTOR = {}));
  1553. //# sourceMappingURL=HDRCubeTextureElement.js.map
  1554. var __extends = (this && this.__extends) || function (d, b) {
  1555. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1556. function __() { this.constructor = d; }
  1557. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1558. };
  1559. var INSPECTOR;
  1560. (function (INSPECTOR) {
  1561. /**
  1562. * A search bar can be used to filter elements in the tree panel.
  1563. * At each keypress on the input, the treepanel will be filtered.
  1564. */
  1565. var SearchBar = (function (_super) {
  1566. __extends(SearchBar, _super);
  1567. function SearchBar(tab) {
  1568. var _this = _super.call(this) || this;
  1569. _this._tab = tab;
  1570. _this._div.classList.add('searchbar');
  1571. var filter = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  1572. filter.className = 'fa fa-search';
  1573. _this._div.appendChild(filter);
  1574. // Create input
  1575. _this._inputElement = INSPECTOR.Inspector.DOCUMENT.createElement('input');
  1576. _this._inputElement.placeholder = 'Filter by name...';
  1577. _this._div.appendChild(_this._inputElement);
  1578. _this._inputElement.addEventListener('keyup', function (evt) {
  1579. var filter = _this._inputElement.value;
  1580. _this._tab.filter(filter);
  1581. });
  1582. return _this;
  1583. }
  1584. /** Delete all characters typped in the input element */
  1585. SearchBar.prototype.reset = function () {
  1586. this._inputElement.value = '';
  1587. };
  1588. SearchBar.prototype.update = function () {
  1589. // Nothing to update
  1590. };
  1591. return SearchBar;
  1592. }(INSPECTOR.BasicElement));
  1593. INSPECTOR.SearchBar = SearchBar;
  1594. })(INSPECTOR || (INSPECTOR = {}));
  1595. //# sourceMappingURL=SearchBar.js.map
  1596. var __extends = (this && this.__extends) || function (d, b) {
  1597. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1598. function __() { this.constructor = d; }
  1599. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1600. };
  1601. var INSPECTOR;
  1602. (function (INSPECTOR) {
  1603. /**
  1604. * Display a very small div corresponding to the given texture. On mouse over, display the full image
  1605. */
  1606. var TextureElement = (function (_super) {
  1607. __extends(TextureElement, _super);
  1608. function TextureElement(tex) {
  1609. var _this = _super.call(this) || this;
  1610. _this._div.className = 'fa fa-search texture-element';
  1611. // Create the texture viewer
  1612. _this._textureDiv = INSPECTOR.Helpers.CreateDiv('texture-viewer', _this._div);
  1613. // Img
  1614. var imgDiv = INSPECTOR.Helpers.CreateDiv('texture-viewer-img', _this._textureDiv);
  1615. // Texture size
  1616. var sizeDiv = INSPECTOR.Helpers.CreateDiv(null, _this._textureDiv);
  1617. if (tex) {
  1618. sizeDiv.textContent = tex.getBaseSize().width + "px x " + tex.getBaseSize().height + "px";
  1619. imgDiv.style.backgroundImage = "url('" + tex.url + "')";
  1620. imgDiv.style.width = tex.getBaseSize().width + "px";
  1621. imgDiv.style.height = tex.getBaseSize().height + "px";
  1622. }
  1623. _this._div.addEventListener('mouseover', _this._showViewer.bind(_this, 'flex'));
  1624. _this._div.addEventListener('mouseout', _this._showViewer.bind(_this, 'none'));
  1625. return _this;
  1626. }
  1627. TextureElement.prototype.update = function (tex) {
  1628. };
  1629. TextureElement.prototype._showViewer = function (mode) {
  1630. this._textureDiv.style.display = mode;
  1631. };
  1632. return TextureElement;
  1633. }(INSPECTOR.BasicElement));
  1634. INSPECTOR.TextureElement = TextureElement;
  1635. })(INSPECTOR || (INSPECTOR = {}));
  1636. //# sourceMappingURL=TextureElement.js.map
  1637. var INSPECTOR;
  1638. (function (INSPECTOR) {
  1639. /**
  1640. * Creates a tooltip for the parent of the given html element
  1641. */
  1642. var Tooltip = (function () {
  1643. function Tooltip(elem, tip) {
  1644. var _this = this;
  1645. this._elem = elem;
  1646. this._infoDiv = INSPECTOR.Helpers.CreateDiv('tooltip', this._elem.parentElement);
  1647. this._elem.addEventListener('mouseover', function () {
  1648. _this._infoDiv.textContent = tip;
  1649. _this._infoDiv.style.display = 'block';
  1650. });
  1651. this._elem.addEventListener('mouseout', function () { _this._infoDiv.style.display = 'none'; });
  1652. }
  1653. return Tooltip;
  1654. }());
  1655. INSPECTOR.Tooltip = Tooltip;
  1656. })(INSPECTOR || (INSPECTOR = {}));
  1657. var INSPECTOR;
  1658. (function (INSPECTOR) {
  1659. var Helpers = (function () {
  1660. function Helpers() {
  1661. }
  1662. /**
  1663. * Returns the type of the given object. First
  1664. * uses getClassName. If nothing is returned, used the type of the constructor
  1665. */
  1666. Helpers.GET_TYPE = function (obj) {
  1667. if (obj != null && obj != undefined) {
  1668. var classname = BABYLON.Tools.getClassName(obj);
  1669. if (!classname || classname === 'object') {
  1670. classname = obj.constructor.name;
  1671. // classname is undefined in IE11
  1672. if (!classname) {
  1673. classname = this._GetFnName(obj.constructor);
  1674. }
  1675. }
  1676. // If the class name has no matching properties, check every type
  1677. if (!this._CheckIfTypeExists(classname)) {
  1678. return this._GetTypeFor(obj);
  1679. }
  1680. return classname;
  1681. }
  1682. else {
  1683. return 'type_not_defined';
  1684. }
  1685. };
  1686. /**
  1687. * Check if some properties are defined for the given type.
  1688. */
  1689. Helpers._CheckIfTypeExists = function (type) {
  1690. var properties = INSPECTOR.PROPERTIES[type];
  1691. if (properties) {
  1692. return true;
  1693. }
  1694. return false;
  1695. };
  1696. /**
  1697. * Returns true if the user browser is edge.
  1698. */
  1699. Helpers.IsBrowserEdge = function () {
  1700. //Detect if we are running on a faulty buggy OS.
  1701. var regexp = /Edge/;
  1702. return regexp.test(navigator.userAgent);
  1703. };
  1704. /**
  1705. * Returns the name of the type of the given object, where the name
  1706. * is in PROPERTIES constant.
  1707. * Returns 'Undefined' if no type exists for this object
  1708. */
  1709. Helpers._GetTypeFor = function (obj) {
  1710. for (var type in INSPECTOR.PROPERTIES) {
  1711. var typeBlock = INSPECTOR.PROPERTIES[type];
  1712. if (typeBlock.type) {
  1713. if (obj instanceof typeBlock.type) {
  1714. return type;
  1715. }
  1716. }
  1717. }
  1718. return 'type_not_defined';
  1719. };
  1720. /**
  1721. * Returns the name of a function (workaround to get object type for IE11)
  1722. */
  1723. Helpers._GetFnName = function (fn) {
  1724. var f = typeof fn == 'function';
  1725. var s = f && ((fn.name && ['', fn.name]) || fn.toString().match(/function ([^\(]+)/));
  1726. return (!f && 'not a function') || (s && s[1] || 'anonymous');
  1727. };
  1728. /** Send the event which name is given in parameter to the window */
  1729. Helpers.SEND_EVENT = function (eventName) {
  1730. var event;
  1731. if (INSPECTOR.Inspector.DOCUMENT.createEvent) {
  1732. event = INSPECTOR.Inspector.DOCUMENT.createEvent('HTMLEvents');
  1733. event.initEvent(eventName, true, true);
  1734. }
  1735. else {
  1736. event = new Event(eventName);
  1737. }
  1738. window.dispatchEvent(event);
  1739. };
  1740. /** Returns the given number with 2 decimal number max if a decimal part exists */
  1741. Helpers.Trunc = function (nb) {
  1742. if (Math.round(nb) !== nb) {
  1743. return nb.toFixed(2);
  1744. }
  1745. return nb;
  1746. };
  1747. ;
  1748. /**
  1749. * Useful function used to create a div
  1750. */
  1751. Helpers.CreateDiv = function (className, parent) {
  1752. return Helpers.CreateElement('div', className, parent);
  1753. };
  1754. Helpers.CreateElement = function (element, className, parent) {
  1755. var elem = INSPECTOR.Inspector.DOCUMENT.createElement(element);
  1756. if (className) {
  1757. elem.className = className;
  1758. }
  1759. if (parent) {
  1760. parent.appendChild(elem);
  1761. }
  1762. return elem;
  1763. };
  1764. /**
  1765. * Removes all children of the given div.
  1766. */
  1767. Helpers.CleanDiv = function (div) {
  1768. while (div.firstChild) {
  1769. div.removeChild(div.firstChild);
  1770. }
  1771. };
  1772. Helpers.LoadScript = function () {
  1773. BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/highlight.min.js", function (elem) {
  1774. var script = Helpers.CreateElement('script', '', INSPECTOR.Inspector.DOCUMENT.body);
  1775. script.textContent = elem;
  1776. // Load glsl detection
  1777. BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/languages/glsl.min.js", function (elem) {
  1778. var script = Helpers.CreateElement('script', '', INSPECTOR.Inspector.DOCUMENT.body);
  1779. script.textContent = elem;
  1780. // Load css style
  1781. BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/styles/zenburn.min.css", function (elem) {
  1782. var style = Helpers.CreateElement('style', '', INSPECTOR.Inspector.DOCUMENT.body);
  1783. style.textContent = elem;
  1784. });
  1785. }, null, null, null, function () {
  1786. console.log("erreur");
  1787. });
  1788. }, null, null, null, function () {
  1789. console.log("erreur");
  1790. });
  1791. };
  1792. return Helpers;
  1793. }());
  1794. INSPECTOR.Helpers = Helpers;
  1795. })(INSPECTOR || (INSPECTOR = {}));
  1796. var INSPECTOR;
  1797. (function (INSPECTOR) {
  1798. var Scheduler = (function () {
  1799. function Scheduler() {
  1800. /** Is this scheduler in pause ? */
  1801. this.pause = false;
  1802. /** The list of data to update */
  1803. this._updatableProperties = [];
  1804. this._timer = setInterval(this._update.bind(this), Scheduler.REFRESH_TIME);
  1805. }
  1806. Scheduler.getInstance = function () {
  1807. if (!Scheduler._instance) {
  1808. Scheduler._instance = new Scheduler();
  1809. }
  1810. return Scheduler._instance;
  1811. };
  1812. /** Add a property line to be updated every X ms */
  1813. Scheduler.prototype.add = function (prop) {
  1814. this._updatableProperties.push(prop);
  1815. };
  1816. /** Removes the given property from the list of properties to update */
  1817. Scheduler.prototype.remove = function (prop) {
  1818. var index = this._updatableProperties.indexOf(prop);
  1819. if (index != -1) {
  1820. this._updatableProperties.splice(index, 1);
  1821. }
  1822. };
  1823. Scheduler.prototype._update = function () {
  1824. // If not in pause, update
  1825. if (!this.pause) {
  1826. for (var _i = 0, _a = this._updatableProperties; _i < _a.length; _i++) {
  1827. var prop = _a[_i];
  1828. prop.update();
  1829. }
  1830. }
  1831. };
  1832. return Scheduler;
  1833. }());
  1834. /** All properties are refreshed every 250ms */
  1835. Scheduler.REFRESH_TIME = 250;
  1836. INSPECTOR.Scheduler = Scheduler;
  1837. })(INSPECTOR || (INSPECTOR = {}));
  1838. var __extends = (this && this.__extends) || function (d, b) {
  1839. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1840. function __() { this.constructor = d; }
  1841. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1842. };
  1843. var INSPECTOR;
  1844. (function (INSPECTOR) {
  1845. var Tab = (function (_super) {
  1846. __extends(Tab, _super);
  1847. function Tab(tabbar, name) {
  1848. var _this = _super.call(this) || this;
  1849. _this._isActive = false;
  1850. _this._tabbar = tabbar;
  1851. _this.name = name;
  1852. _this._build();
  1853. return _this;
  1854. }
  1855. /** True if the tab is active, false otherwise */
  1856. Tab.prototype.isActive = function () {
  1857. return this._isActive;
  1858. };
  1859. Tab.prototype._build = function () {
  1860. var _this = this;
  1861. this._div.className = 'tab';
  1862. this._div.textContent = this.name;
  1863. this._div.addEventListener('click', function (evt) {
  1864. // Set this tab as active
  1865. _this._tabbar.switchTab(_this);
  1866. });
  1867. };
  1868. /** Set this tab as active or not, depending on the current state */
  1869. Tab.prototype.active = function (b) {
  1870. if (b) {
  1871. this._div.classList.add('active');
  1872. }
  1873. else {
  1874. this._div.classList.remove('active');
  1875. }
  1876. this._isActive = b;
  1877. };
  1878. Tab.prototype.update = function () {
  1879. // Nothing for the moment
  1880. };
  1881. /** Creates the tab panel for this tab. */
  1882. Tab.prototype.getPanel = function () {
  1883. return this._panel;
  1884. };
  1885. /** Add this in the propertytab with the searchbar */
  1886. Tab.prototype.filter = function (str) { };
  1887. ;
  1888. /**
  1889. * Returns the total width in pixel of this tab, 0 by default
  1890. */
  1891. Tab.prototype.getPixelWidth = function () {
  1892. var style = INSPECTOR.Inspector.WINDOW.getComputedStyle(this._div);
  1893. var left = parseFloat(style.marginLeft.substr(0, style.marginLeft.length - 2)) || 0;
  1894. var right = parseFloat(style.marginRight.substr(0, style.marginRight.length - 2)) || 0;
  1895. return (this._div.clientWidth || 0) + left + right;
  1896. };
  1897. return Tab;
  1898. }(INSPECTOR.BasicElement));
  1899. INSPECTOR.Tab = Tab;
  1900. })(INSPECTOR || (INSPECTOR = {}));
  1901. var __extends = (this && this.__extends) || function (d, b) {
  1902. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  1903. function __() { this.constructor = d; }
  1904. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1905. };
  1906. var INSPECTOR;
  1907. (function (INSPECTOR) {
  1908. /**
  1909. * A Property tab can creates two panels:
  1910. * a tree panel and a detail panel,
  1911. * in which properties will be displayed.
  1912. * Both panels are separated by a resize bar
  1913. */
  1914. var PropertyTab = (function (_super) {
  1915. __extends(PropertyTab, _super);
  1916. function PropertyTab(tabbar, name, insp) {
  1917. var _this = _super.call(this, tabbar, name) || this;
  1918. _this._treeItems = [];
  1919. _this._inspector = insp;
  1920. // Build the properties panel : a div that will contains the tree and the detail panel
  1921. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  1922. _this._panel.classList.add('searchable');
  1923. // Search bar
  1924. _this._searchBar = new INSPECTOR.SearchBar(_this);
  1925. // Add searchbar
  1926. _this._panel.appendChild(_this._searchBar.toHtml());
  1927. // Build the treepanel
  1928. _this._treePanel = INSPECTOR.Helpers.CreateDiv('insp-tree', _this._panel);
  1929. // Build the detail panel
  1930. _this._detailsPanel = new INSPECTOR.DetailPanel();
  1931. _this._panel.appendChild(_this._detailsPanel.toHtml());
  1932. Split([_this._treePanel, _this._detailsPanel.toHtml()], {
  1933. blockDrag: _this._inspector.popupMode,
  1934. direction: 'vertical'
  1935. });
  1936. _this.update();
  1937. return _this;
  1938. }
  1939. /** Overrides dispose */
  1940. PropertyTab.prototype.dispose = function () {
  1941. this._detailsPanel.dispose();
  1942. };
  1943. PropertyTab.prototype.update = function (_items) {
  1944. var items;
  1945. if (_items) {
  1946. items = _items;
  1947. }
  1948. else {
  1949. // Rebuild the tree
  1950. this._treeItems = this._getTree();
  1951. items = this._treeItems;
  1952. }
  1953. // Clean the tree
  1954. INSPECTOR.Helpers.CleanDiv(this._treePanel);
  1955. // Clean the detail properties
  1956. this._detailsPanel.clean();
  1957. // Sort items alphabetically
  1958. items.sort(function (item1, item2) {
  1959. return item1.compareTo(item2);
  1960. });
  1961. // Display items
  1962. for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
  1963. var item = items_1[_i];
  1964. this._treePanel.appendChild(item.toHtml());
  1965. }
  1966. };
  1967. /** Display the details of the given item */
  1968. PropertyTab.prototype.displayDetails = function (item) {
  1969. // Remove active state on all items
  1970. this.activateNode(item);
  1971. // Update the detail panel
  1972. this._detailsPanel.details = item.getDetails();
  1973. };
  1974. /** Select an item in the tree */
  1975. PropertyTab.prototype.select = function (item) {
  1976. // Remove the node highlight
  1977. this.highlightNode();
  1978. // Active the node
  1979. this.activateNode(item);
  1980. // Display its details
  1981. this.displayDetails(item);
  1982. };
  1983. /** Highlight the given node, and downplay all others */
  1984. PropertyTab.prototype.highlightNode = function (item) {
  1985. if (this._treeItems) {
  1986. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  1987. var node = _a[_i];
  1988. node.highlight(false);
  1989. }
  1990. }
  1991. if (item) {
  1992. item.highlight(true);
  1993. }
  1994. };
  1995. /** Set the given item as active in the tree */
  1996. PropertyTab.prototype.activateNode = function (item) {
  1997. if (this._treeItems) {
  1998. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  1999. var node = _a[_i];
  2000. node.active(false);
  2001. }
  2002. }
  2003. item.active(true);
  2004. };
  2005. /** Returns the treeitem corersponding to the given obj, null if not found */
  2006. PropertyTab.prototype.getItemFor = function (_obj) {
  2007. var obj = _obj;
  2008. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  2009. var item = _a[_i];
  2010. if (item.correspondsTo(obj)) {
  2011. return item;
  2012. }
  2013. }
  2014. return null;
  2015. };
  2016. PropertyTab.prototype.filter = function (filter) {
  2017. var items = [];
  2018. for (var _i = 0, _a = this._treeItems; _i < _a.length; _i++) {
  2019. var item = _a[_i];
  2020. if (item.id.toLowerCase().indexOf(filter.toLowerCase()) != -1) {
  2021. items.push(item);
  2022. }
  2023. }
  2024. this.update(items);
  2025. };
  2026. return PropertyTab;
  2027. }(INSPECTOR.Tab));
  2028. INSPECTOR.PropertyTab = PropertyTab;
  2029. })(INSPECTOR || (INSPECTOR = {}));
  2030. var __extends = (this && this.__extends) || function (d, b) {
  2031. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  2032. function __() { this.constructor = d; }
  2033. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2034. };
  2035. var INSPECTOR;
  2036. (function (INSPECTOR) {
  2037. var Canvas2DTab = (function (_super) {
  2038. __extends(Canvas2DTab, _super);
  2039. function Canvas2DTab(tabbar, inspector) {
  2040. return _super.call(this, tabbar, 'Canvas2D', inspector) || this;
  2041. }
  2042. /* Overrides */
  2043. Canvas2DTab.prototype._getTree = function () {
  2044. var _this = this;
  2045. var arr = [];
  2046. // get all canvas2D
  2047. var instances = BABYLON.Canvas2D.instances || [];
  2048. // Returns true if the id of the given object starts and ends with '###'
  2049. var shouldExcludeThisPrim = function (obj) {
  2050. return (obj.id && obj.id.indexOf('###') == 0 && obj.id.lastIndexOf('###', 0) === 0);
  2051. };
  2052. // Recursive method building the tree panel
  2053. var createNode = function (obj) {
  2054. if (obj.children && obj.children.length > 0) {
  2055. var node = new INSPECTOR.TreeItem(_this, new INSPECTOR.Canvas2DAdapter(obj));
  2056. for (var _i = 0, _a = obj.children; _i < _a.length; _i++) {
  2057. var child = _a[_i];
  2058. if (!shouldExcludeThisPrim(child)) {
  2059. var n = createNode(child);
  2060. node.add(n);
  2061. }
  2062. }
  2063. node.update();
  2064. return node;
  2065. }
  2066. else {
  2067. return new INSPECTOR.TreeItem(_this, new INSPECTOR.Canvas2DAdapter(obj));
  2068. }
  2069. };
  2070. for (var _i = 0, instances_1 = instances; _i < instances_1.length; _i++) {
  2071. var inst = instances_1[_i];
  2072. var c2d = inst;
  2073. var nodes = createNode(c2d);
  2074. arr.push(nodes);
  2075. }
  2076. return arr;
  2077. };
  2078. return Canvas2DTab;
  2079. }(INSPECTOR.PropertyTab));
  2080. INSPECTOR.Canvas2DTab = Canvas2DTab;
  2081. })(INSPECTOR || (INSPECTOR = {}));
  2082. var __extends = (this && this.__extends) || function (d, b) {
  2083. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  2084. function __() { this.constructor = d; }
  2085. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2086. };
  2087. var INSPECTOR;
  2088. (function (INSPECTOR) {
  2089. var LightTab = (function (_super) {
  2090. __extends(LightTab, _super);
  2091. function LightTab(tabbar, inspector) {
  2092. return _super.call(this, tabbar, 'Light', inspector) || this;
  2093. }
  2094. /* Overrides super */
  2095. LightTab.prototype._getTree = function () {
  2096. var arr = [];
  2097. // get all lights from the first scene
  2098. var instances = this._inspector.scene;
  2099. for (var _i = 0, _a = instances.lights; _i < _a.length; _i++) {
  2100. var light = _a[_i];
  2101. arr.push(new INSPECTOR.TreeItem(this, new INSPECTOR.LightAdapter(light)));
  2102. }
  2103. return arr;
  2104. };
  2105. return LightTab;
  2106. }(INSPECTOR.PropertyTab));
  2107. INSPECTOR.LightTab = LightTab;
  2108. })(INSPECTOR || (INSPECTOR = {}));
  2109. var __extends = (this && this.__extends) || function (d, b) {
  2110. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  2111. function __() { this.constructor = d; }
  2112. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2113. };
  2114. var INSPECTOR;
  2115. (function (INSPECTOR) {
  2116. var MaterialTab = (function (_super) {
  2117. __extends(MaterialTab, _super);
  2118. function MaterialTab(tabbar, inspector) {
  2119. return _super.call(this, tabbar, 'Material', inspector) || this;
  2120. }
  2121. /* Overrides super */
  2122. MaterialTab.prototype._getTree = function () {
  2123. var arr = [];
  2124. // get all meshes from the first scene
  2125. var instances = this._inspector.scene;
  2126. for (var _i = 0, _a = instances.materials; _i < _a.length; _i++) {
  2127. var mat = _a[_i];
  2128. arr.push(new INSPECTOR.TreeItem(this, new INSPECTOR.MaterialAdapter(mat)));
  2129. }
  2130. return arr;
  2131. };
  2132. return MaterialTab;
  2133. }(INSPECTOR.PropertyTab));
  2134. INSPECTOR.MaterialTab = MaterialTab;
  2135. })(INSPECTOR || (INSPECTOR = {}));
  2136. var __extends = (this && this.__extends) || function (d, b) {
  2137. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  2138. function __() { this.constructor = d; }
  2139. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2140. };
  2141. var INSPECTOR;
  2142. (function (INSPECTOR) {
  2143. var MeshTab = (function (_super) {
  2144. __extends(MeshTab, _super);
  2145. function MeshTab(tabbar, inspector) {
  2146. return _super.call(this, tabbar, 'Mesh', inspector) || this;
  2147. }
  2148. /* Overrides super */
  2149. MeshTab.prototype._getTree = function () {
  2150. var arr = [];
  2151. // Returns true if the id of the given object starts and ends with '###'
  2152. var shouldExcludeThisMesh = function (obj) {
  2153. return (obj.name && obj.name.indexOf('###') == 0 && obj.name.lastIndexOf('###', 0) === 0);
  2154. };
  2155. // get all meshes from the first scene
  2156. var instances = this._inspector.scene;
  2157. for (var _i = 0, _a = instances.meshes; _i < _a.length; _i++) {
  2158. var mesh = _a[_i];
  2159. if (!shouldExcludeThisMesh(mesh)) {
  2160. arr.push(new INSPECTOR.TreeItem(this, new INSPECTOR.MeshAdapter(mesh)));
  2161. }
  2162. }
  2163. return arr;
  2164. };
  2165. return MeshTab;
  2166. }(INSPECTOR.PropertyTab));
  2167. INSPECTOR.MeshTab = MeshTab;
  2168. })(INSPECTOR || (INSPECTOR = {}));
  2169. var __extends = (this && this.__extends) || function (d, b) {
  2170. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  2171. function __() { this.constructor = d; }
  2172. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2173. };
  2174. var INSPECTOR;
  2175. (function (INSPECTOR) {
  2176. var SceneTab = (function (_super) {
  2177. __extends(SceneTab, _super);
  2178. function SceneTab(tabbar, insp) {
  2179. var _this = _super.call(this, tabbar, 'Scene') || this;
  2180. /** The list of skeleton viewer */
  2181. _this._skeletonViewers = [];
  2182. _this._inspector = insp;
  2183. // Build the properties panel : a div that will contains the tree and the detail panel
  2184. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  2185. _this._actions = INSPECTOR.Helpers.CreateDiv('scene-actions', _this._panel);
  2186. _this._detailsPanel = new INSPECTOR.DetailPanel();
  2187. _this._panel.appendChild(_this._detailsPanel.toHtml());
  2188. // build propertiesline
  2189. var details = [];
  2190. for (var _i = 0, _a = INSPECTOR.PROPERTIES['Scene'].properties; _i < _a.length; _i++) {
  2191. var prop = _a[_i];
  2192. details.push(new INSPECTOR.PropertyLine(new INSPECTOR.Property(prop, _this._inspector.scene)));
  2193. }
  2194. _this._detailsPanel.details = details;
  2195. Split([_this._actions, _this._detailsPanel.toHtml()], {
  2196. blockDrag: _this._inspector.popupMode,
  2197. sizes: [50, 50],
  2198. direction: 'vertical'
  2199. });
  2200. // Build actions
  2201. {
  2202. // Rendering mode
  2203. var title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  2204. title.textContent = 'Rendering mode';
  2205. var point = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  2206. var wireframe = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  2207. var solid = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  2208. point.textContent = 'Point';
  2209. wireframe.textContent = 'Wireframe';
  2210. solid.textContent = 'Solid';
  2211. if (_this._inspector.scene.forcePointsCloud) {
  2212. point.classList.add('active');
  2213. }
  2214. else if (_this._inspector.scene.forceWireframe) {
  2215. wireframe.classList.add('active');
  2216. }
  2217. else {
  2218. solid.classList.add('active');
  2219. }
  2220. _this._generateRadioAction([point, wireframe, solid]);
  2221. point.addEventListener('click', function () { _this._inspector.scene.forcePointsCloud = true; _this._inspector.scene.forceWireframe = false; });
  2222. wireframe.addEventListener('click', function () { _this._inspector.scene.forcePointsCloud = false; _this._inspector.scene.forceWireframe = true; });
  2223. solid.addEventListener('click', function () { _this._inspector.scene.forcePointsCloud = false; _this._inspector.scene.forceWireframe = false; });
  2224. // Textures
  2225. title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  2226. title.textContent = 'Textures channels';
  2227. _this._generateActionLine('Diffuse Texture', BABYLON.StandardMaterial.DiffuseTextureEnabled, function (b) { BABYLON.StandardMaterial.DiffuseTextureEnabled = b; });
  2228. _this._generateActionLine('Ambient Texture', BABYLON.StandardMaterial.AmbientTextureEnabled, function (b) { BABYLON.StandardMaterial.AmbientTextureEnabled = b; });
  2229. _this._generateActionLine('Specular Texture', BABYLON.StandardMaterial.SpecularTextureEnabled, function (b) { BABYLON.StandardMaterial.SpecularTextureEnabled = b; });
  2230. _this._generateActionLine('Emissive Texture', BABYLON.StandardMaterial.EmissiveTextureEnabled, function (b) { BABYLON.StandardMaterial.EmissiveTextureEnabled = b; });
  2231. _this._generateActionLine('Bump Texture', BABYLON.StandardMaterial.BumpTextureEnabled, function (b) { BABYLON.StandardMaterial.BumpTextureEnabled = b; });
  2232. _this._generateActionLine('Opacity Texture', BABYLON.StandardMaterial.OpacityTextureEnabled, function (b) { BABYLON.StandardMaterial.OpacityTextureEnabled = b; });
  2233. _this._generateActionLine('Reflection Texture', BABYLON.StandardMaterial.ReflectionTextureEnabled, function (b) { BABYLON.StandardMaterial.ReflectionTextureEnabled = b; });
  2234. _this._generateActionLine('Refraction Texture', BABYLON.StandardMaterial.RefractionTextureEnabled, function (b) { BABYLON.StandardMaterial.RefractionTextureEnabled = b; });
  2235. _this._generateActionLine('ColorGrading', BABYLON.StandardMaterial.ColorGradingTextureEnabled, function (b) { BABYLON.StandardMaterial.ColorGradingTextureEnabled = b; });
  2236. _this._generateActionLine('Lightmap Texture', BABYLON.StandardMaterial.LightmapTextureEnabled, function (b) { BABYLON.StandardMaterial.LightmapTextureEnabled = b; });
  2237. _this._generateActionLine('Fresnel', BABYLON.StandardMaterial.FresnelEnabled, function (b) { BABYLON.StandardMaterial.FresnelEnabled = b; });
  2238. // Options
  2239. title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  2240. title.textContent = 'Options';
  2241. _this._generateActionLine('Animations', _this._inspector.scene.animationsEnabled, function (b) { _this._inspector.scene.animationsEnabled = b; });
  2242. _this._generateActionLine('Collisions', _this._inspector.scene.collisionsEnabled, function (b) { _this._inspector.scene.collisionsEnabled = b; });
  2243. _this._generateActionLine('Fog', _this._inspector.scene.fogEnabled, function (b) { _this._inspector.scene.fogEnabled = b; });
  2244. _this._generateActionLine('Lens flares', _this._inspector.scene.lensFlaresEnabled, function (b) { _this._inspector.scene.lensFlaresEnabled = b; });
  2245. _this._generateActionLine('Lights', _this._inspector.scene.lightsEnabled, function (b) { _this._inspector.scene.lightsEnabled = b; });
  2246. _this._generateActionLine('Particles', _this._inspector.scene.particlesEnabled, function (b) { _this._inspector.scene.particlesEnabled = b; });
  2247. _this._generateActionLine('Post-processes', _this._inspector.scene.postProcessesEnabled, function (b) { _this._inspector.scene.postProcessesEnabled = b; });
  2248. _this._generateActionLine('Probes', _this._inspector.scene.probesEnabled, function (b) { _this._inspector.scene.probesEnabled = b; });
  2249. _this._generateActionLine('Procedural textures', _this._inspector.scene.proceduralTexturesEnabled, function (b) { _this._inspector.scene.proceduralTexturesEnabled = b; });
  2250. _this._generateActionLine('Render targets', _this._inspector.scene.renderTargetsEnabled, function (b) { _this._inspector.scene.renderTargetsEnabled = b; });
  2251. _this._generateActionLine('Shadows', _this._inspector.scene.shadowsEnabled, function (b) { _this._inspector.scene.shadowsEnabled = b; });
  2252. _this._generateActionLine('Skeletons', _this._inspector.scene.skeletonsEnabled, function (b) { _this._inspector.scene.skeletonsEnabled = b; });
  2253. _this._generateActionLine('Sprites', _this._inspector.scene.spritesEnabled, function (b) { _this._inspector.scene.spritesEnabled = b; });
  2254. _this._generateActionLine('Textures', _this._inspector.scene.texturesEnabled, function (b) { _this._inspector.scene.texturesEnabled = b; });
  2255. // Audio
  2256. title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  2257. title.textContent = 'Audio';
  2258. var headphones = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  2259. var normalSpeaker = INSPECTOR.Helpers.CreateDiv('action-radio', _this._actions);
  2260. _this._generateActionLine('Disable audio', !_this._inspector.scene.audioEnabled, function (b) { _this._inspector.scene.audioEnabled = !b; });
  2261. headphones.textContent = 'Headphones';
  2262. normalSpeaker.textContent = 'Normal speakers';
  2263. _this._generateRadioAction([headphones, normalSpeaker]);
  2264. if (_this._inspector.scene.headphone) {
  2265. headphones.classList.add('active');
  2266. }
  2267. else {
  2268. normalSpeaker.classList.add('active');
  2269. }
  2270. headphones.addEventListener('click', function () { _this._inspector.scene.headphone = true; });
  2271. normalSpeaker.addEventListener('click', function () { _this._inspector.scene.headphone = false; });
  2272. // Viewers
  2273. title = INSPECTOR.Helpers.CreateDiv('actions-title', _this._actions);
  2274. title.textContent = 'Viewer';
  2275. _this._generateActionLine('Skeletons', false, function (b) {
  2276. if (b) {
  2277. for (var index = 0; index < _this._inspector.scene.meshes.length; index++) {
  2278. var mesh = _this._inspector.scene.meshes[index];
  2279. if (mesh.skeleton) {
  2280. var found = false;
  2281. for (var sIndex = 0; sIndex < _this._skeletonViewers.length; sIndex++) {
  2282. if (_this._skeletonViewers[sIndex].skeleton === mesh.skeleton) {
  2283. found = true;
  2284. break;
  2285. }
  2286. }
  2287. if (found) {
  2288. continue;
  2289. }
  2290. var viewer = new BABYLON.Debug.SkeletonViewer(mesh.skeleton, mesh, _this._inspector.scene);
  2291. viewer.isEnabled = true;
  2292. _this._skeletonViewers.push(viewer);
  2293. }
  2294. }
  2295. }
  2296. else {
  2297. for (var index = 0; index < _this._skeletonViewers.length; index++) {
  2298. _this._skeletonViewers[index].dispose();
  2299. }
  2300. _this._skeletonViewers = [];
  2301. }
  2302. });
  2303. }
  2304. return _this;
  2305. }
  2306. /** Overrides super.dispose */
  2307. SceneTab.prototype.dispose = function () {
  2308. this._detailsPanel.dispose();
  2309. };
  2310. /** generates a div which correspond to an option that can be activated/deactivated */
  2311. SceneTab.prototype._generateActionLine = function (name, initValue, action) {
  2312. var div = INSPECTOR.Helpers.CreateDiv('scene-actions', this._actions);
  2313. div.textContent = name;
  2314. div.classList.add('action');
  2315. if (initValue) {
  2316. div.classList.add('active');
  2317. }
  2318. div.addEventListener('click', function (e) {
  2319. div.classList.toggle('active');
  2320. var isActivated = div.classList.contains('active');
  2321. action(isActivated);
  2322. });
  2323. };
  2324. /**
  2325. * Add a click action for all given elements :
  2326. * the clicked element is set as active, all others elements are deactivated
  2327. */
  2328. SceneTab.prototype._generateRadioAction = function (arr) {
  2329. var active = function (elem, evt) {
  2330. for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
  2331. var e = arr_1[_i];
  2332. e.classList.remove('active');
  2333. }
  2334. elem.classList.add('active');
  2335. };
  2336. for (var _i = 0, arr_2 = arr; _i < arr_2.length; _i++) {
  2337. var elem = arr_2[_i];
  2338. elem.addEventListener('click', active.bind(this, elem));
  2339. }
  2340. };
  2341. return SceneTab;
  2342. }(INSPECTOR.Tab));
  2343. INSPECTOR.SceneTab = SceneTab;
  2344. })(INSPECTOR || (INSPECTOR = {}));
  2345. var __extends = (this && this.__extends) || function (d, b) {
  2346. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  2347. function __() { this.constructor = d; }
  2348. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2349. };
  2350. var INSPECTOR;
  2351. (function (INSPECTOR) {
  2352. var ShaderTab = (function (_super) {
  2353. __extends(ShaderTab, _super);
  2354. function ShaderTab(tabbar, insp) {
  2355. var _this = _super.call(this, tabbar, 'Shader') || this;
  2356. _this._inspector = insp;
  2357. // Build the shaders panel : a div that will contains the shaders tree and both shaders panels
  2358. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  2359. var shaderPanel = INSPECTOR.Helpers.CreateDiv('shader-tree-panel');
  2360. _this._vertexPanel = INSPECTOR.Helpers.CreateDiv('shader-panel');
  2361. _this._fragmentPanel = INSPECTOR.Helpers.CreateDiv('shader-panel');
  2362. _this._panel.appendChild(shaderPanel);
  2363. _this._panel.appendChild(_this._vertexPanel);
  2364. _this._panel.appendChild(_this._fragmentPanel);
  2365. INSPECTOR.Helpers.LoadScript();
  2366. Split([_this._vertexPanel, _this._fragmentPanel], {
  2367. blockDrag: _this._inspector.popupMode,
  2368. sizes: [50, 50],
  2369. direction: 'vertical'
  2370. });
  2371. var comboBox = INSPECTOR.Helpers.CreateElement('select', '', shaderPanel);
  2372. comboBox.addEventListener('change', _this._selectShader.bind(_this));
  2373. var option = INSPECTOR.Helpers.CreateElement('option', '', comboBox);
  2374. option.textContent = 'Select a shader';
  2375. option.setAttribute('value', "");
  2376. option.setAttribute('disabled', 'true');
  2377. option.setAttribute('selected', 'true');
  2378. // Build shaders combobox
  2379. for (var _i = 0, _a = _this._inspector.scene.materials; _i < _a.length; _i++) {
  2380. var mat = _a[_i];
  2381. if (mat instanceof BABYLON.ShaderMaterial) {
  2382. var option_1 = INSPECTOR.Helpers.CreateElement('option', '', comboBox);
  2383. option_1.setAttribute('value', mat.id);
  2384. option_1.textContent = mat.name + " - " + mat.id;
  2385. }
  2386. }
  2387. return _this;
  2388. }
  2389. ShaderTab.prototype._selectShader = function (event) {
  2390. var id = event.target.value;
  2391. var mat = this._inspector.scene.getMaterialByID(id);
  2392. // Clean shader panel
  2393. INSPECTOR.Helpers.CleanDiv(this._vertexPanel);
  2394. // add the title - vertex shader
  2395. var title = INSPECTOR.Helpers.CreateDiv('shader-panel-title', this._vertexPanel);
  2396. title.textContent = 'Vertex shader';
  2397. // add code
  2398. var code = INSPECTOR.Helpers.CreateElement('code', 'glsl', INSPECTOR.Helpers.CreateElement('pre', '', this._vertexPanel));
  2399. code.textContent = this._beautify(mat.getEffect().getVertexShaderSource());
  2400. INSPECTOR.Helpers.CleanDiv(this._fragmentPanel);
  2401. // add the title - fragment shader
  2402. title = INSPECTOR.Helpers.CreateDiv('shader-panel-title', this._fragmentPanel);
  2403. title.textContent = 'Frgament shader';
  2404. // add code
  2405. code = INSPECTOR.Helpers.CreateElement('code', 'glsl', INSPECTOR.Helpers.CreateElement('pre', '', this._fragmentPanel));
  2406. code.textContent = this._beautify(mat.getEffect().getFragmentShaderSource());
  2407. // Init the syntax highlighting
  2408. var styleInit = INSPECTOR.Helpers.CreateElement('script', '', INSPECTOR.Inspector.DOCUMENT.body);
  2409. styleInit.textContent = 'hljs.initHighlighting();';
  2410. };
  2411. /** Overrides super.dispose */
  2412. ShaderTab.prototype.dispose = function () {
  2413. };
  2414. /** Returns the position of the first { and the corresponding } */
  2415. ShaderTab.prototype._getBracket = function (str) {
  2416. var fb = str.indexOf('{');
  2417. var arr = str.substr(fb + 1).split('');
  2418. var counter = 1;
  2419. var currentPosInString = fb;
  2420. var lastBracketIndex = 0;
  2421. for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
  2422. var char = arr_1[_i];
  2423. currentPosInString++;
  2424. if (char === '{') {
  2425. counter++;
  2426. }
  2427. if (char === '}') {
  2428. counter--;
  2429. }
  2430. if (counter == 0) {
  2431. lastBracketIndex = currentPosInString;
  2432. break;
  2433. }
  2434. }
  2435. return { firstBracket: fb, lastBracket: lastBracketIndex };
  2436. };
  2437. /**
  2438. * Beautify the given string : correct indentation
  2439. */
  2440. ShaderTab.prototype._beautify = function (glsl, level) {
  2441. if (level === void 0) { level = 0; }
  2442. // return condition : no brackets at all
  2443. var brackets = this._getBracket(glsl);
  2444. var firstBracket = brackets.firstBracket;
  2445. var lastBracket = brackets.lastBracket;
  2446. var spaces = "";
  2447. for (var i = 0; i < level; i++) {
  2448. spaces += " "; // 4 spaces
  2449. }
  2450. // If no brackets, return the indented string
  2451. if (firstBracket == -1) {
  2452. glsl = spaces + glsl; // indent first line
  2453. glsl = glsl
  2454. .replace(/;./g, function (x) { return '\n' + x.substr(1); }); // new line after ; except the last one
  2455. glsl = glsl.replace(/=/g, " = "); // space around =
  2456. glsl = glsl.replace(/\n/g, "\n" + spaces); // indentation
  2457. return glsl;
  2458. }
  2459. else {
  2460. // if brackets, beautify the inside
  2461. // let insideWithBrackets = glsl.substr(firstBracket, lastBracket-firstBracket+1);
  2462. var left = glsl.substr(0, firstBracket);
  2463. var right = glsl.substr(lastBracket + 1, glsl.length);
  2464. var inside = glsl.substr(firstBracket + 1, lastBracket - firstBracket - 1);
  2465. inside = this._beautify(inside, level + 1);
  2466. return this._beautify(left, level) + '{\n' + inside + '\n' + spaces + '}\n' + this._beautify(right, level);
  2467. }
  2468. // // Replace bracket with @1 and @2 with correct indentation
  2469. // let newInside = "@1\n\t" + inside + "\n@2";
  2470. // newInside = newInside.replace(/;\n/g, ";\n\t");
  2471. // glsl = glsl.replace(insideWithBrackets, newInside);
  2472. // firstBracket = glsl.indexOf('{');
  2473. // lastBracket = glsl.lastIndexOf('}');
  2474. // }
  2475. // console.log(glsl);
  2476. // let regex = /(\{(?:\{??[^\{]*?}))+/gmi;
  2477. // let tmp = glsl;
  2478. // let m;
  2479. // while ((m = regex.exec(tmp)) !== null) {
  2480. // // This is necessary to avoid infinite loops with zero-width matches
  2481. // if (m.index === regex.lastIndex) {
  2482. // regex.lastIndex++;
  2483. // }
  2484. // // The result can be accessed through the `m`-variable.
  2485. // m.forEach((match, groupIndex) => {
  2486. // // Remove the first and the last bracket only
  2487. // let matchWithoutBrackets = match.replace(/{/, "").replace(/}/, "");
  2488. // // Indent the content inside brackets with tabs
  2489. // glsl = glsl.replace(match, `{\n\t${matchWithoutBrackets}\n}\n`);
  2490. // // removes the match from tmp
  2491. // tmp = tmp.replace(match, "");
  2492. // // and continue
  2493. // });
  2494. // }
  2495. // return
  2496. };
  2497. return ShaderTab;
  2498. }(INSPECTOR.Tab));
  2499. INSPECTOR.ShaderTab = ShaderTab;
  2500. })(INSPECTOR || (INSPECTOR = {}));
  2501. var __extends = (this && this.__extends) || function (d, b) {
  2502. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  2503. function __() { this.constructor = d; }
  2504. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2505. };
  2506. var INSPECTOR;
  2507. (function (INSPECTOR) {
  2508. var StatsTab = (function (_super) {
  2509. __extends(StatsTab, _super);
  2510. function StatsTab(tabbar, insp) {
  2511. var _this = _super.call(this, tabbar, 'Stats') || this;
  2512. /**
  2513. * Properties in this array will be updated
  2514. * in a render loop - Mostly stats properties
  2515. */
  2516. _this._updatableProperties = [];
  2517. _this._inspector = insp;
  2518. _this._scene = _this._inspector.scene;
  2519. _this._engine = _this._scene.getEngine();
  2520. _this._glInfo = _this._engine.getGlInfo();
  2521. // Build the stats panel: a div that will contains all stats
  2522. _this._panel = INSPECTOR.Helpers.CreateDiv('tab-panel');
  2523. _this._panel.classList.add("stats-panel");
  2524. var title = INSPECTOR.Helpers.CreateDiv('stat-title1', _this._panel);
  2525. var fpsSpan = INSPECTOR.Helpers.CreateElement('span', 'stats-fps');
  2526. _this._updatableProperties.push({
  2527. elem: fpsSpan,
  2528. updateFct: function () { return BABYLON.Tools.Format(_this._inspector.scene.getEngine().getFps(), 0) + " fps"; }
  2529. });
  2530. var versionSpan = INSPECTOR.Helpers.CreateElement('span');
  2531. versionSpan.textContent = "Babylon.js v" + BABYLON.Engine.Version + " - ";
  2532. title.appendChild(versionSpan);
  2533. title.appendChild(fpsSpan);
  2534. _this._updateLoopHandler = _this._update.bind(_this);
  2535. // Count block
  2536. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  2537. title.textContent = "Count";
  2538. {
  2539. var elemLabel = _this._createStatLabel("Total meshes", _this._panel);
  2540. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2541. _this._updatableProperties.push({
  2542. elem: elemValue,
  2543. updateFct: function () { return _this._scene.meshes.length.toString(); }
  2544. });
  2545. elemLabel = _this._createStatLabel("Draw calls", _this._panel);
  2546. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2547. _this._updatableProperties.push({
  2548. elem: elemValue,
  2549. updateFct: function () { return _this._engine.drawCalls.toString(); }
  2550. });
  2551. elemLabel = _this._createStatLabel("Total lights", _this._panel);
  2552. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2553. _this._updatableProperties.push({
  2554. elem: elemValue,
  2555. updateFct: function () { return _this._scene.lights.length.toString(); }
  2556. });
  2557. elemLabel = _this._createStatLabel("Total lights", _this._panel);
  2558. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2559. _this._updatableProperties.push({
  2560. elem: elemValue,
  2561. updateFct: function () { return _this._scene.lights.length.toString(); }
  2562. });
  2563. elemLabel = _this._createStatLabel("Total vertices", _this._panel);
  2564. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2565. _this._updatableProperties.push({
  2566. elem: elemValue,
  2567. updateFct: function () { return _this._scene.getTotalVertices().toString(); }
  2568. });
  2569. elemLabel = _this._createStatLabel("Total materials", _this._panel);
  2570. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2571. _this._updatableProperties.push({
  2572. elem: elemValue,
  2573. updateFct: function () { return _this._scene.materials.length.toString(); }
  2574. });
  2575. elemLabel = _this._createStatLabel("Total textures", _this._panel);
  2576. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2577. _this._updatableProperties.push({
  2578. elem: elemValue,
  2579. updateFct: function () { return _this._scene.textures.length.toString(); }
  2580. });
  2581. elemLabel = _this._createStatLabel("Active meshes", _this._panel);
  2582. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2583. _this._updatableProperties.push({
  2584. elem: elemValue,
  2585. updateFct: function () { return _this._scene.getActiveMeshes().length.toString(); }
  2586. });
  2587. elemLabel = _this._createStatLabel("Active indices", _this._panel);
  2588. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2589. _this._updatableProperties.push({
  2590. elem: elemValue,
  2591. updateFct: function () { return _this._scene.getActiveIndices().toString(); }
  2592. });
  2593. elemLabel = _this._createStatLabel("Active bones", _this._panel);
  2594. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2595. _this._updatableProperties.push({
  2596. elem: elemValue,
  2597. updateFct: function () { return _this._scene.getActiveBones().toString(); }
  2598. });
  2599. elemLabel = _this._createStatLabel("Active particles", _this._panel);
  2600. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2601. _this._updatableProperties.push({
  2602. elem: elemValue,
  2603. updateFct: function () { return _this._scene.getActiveParticles().toString(); }
  2604. });
  2605. }
  2606. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  2607. title.textContent = "Duration";
  2608. {
  2609. var elemLabel = _this._createStatLabel("Meshes selection", _this._panel);
  2610. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2611. _this._updatableProperties.push({
  2612. elem: elemValue,
  2613. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getEvaluateActiveMeshesDuration()); }
  2614. });
  2615. elemLabel = _this._createStatLabel("Render targets", _this._panel);
  2616. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2617. _this._updatableProperties.push({
  2618. elem: elemValue,
  2619. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getRenderTargetsDuration()); }
  2620. });
  2621. elemLabel = _this._createStatLabel("Particles", _this._panel);
  2622. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2623. _this._updatableProperties.push({
  2624. elem: elemValue,
  2625. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getParticlesDuration()); }
  2626. });
  2627. elemLabel = _this._createStatLabel("Sprites", _this._panel);
  2628. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2629. _this._updatableProperties.push({
  2630. elem: elemValue,
  2631. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getSpritesDuration()); }
  2632. });
  2633. elemLabel = _this._createStatLabel("Render", _this._panel);
  2634. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2635. _this._updatableProperties.push({
  2636. elem: elemValue,
  2637. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getRenderDuration()); }
  2638. });
  2639. elemLabel = _this._createStatLabel("Frame", _this._panel);
  2640. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2641. _this._updatableProperties.push({
  2642. elem: elemValue,
  2643. updateFct: function () { return BABYLON.Tools.Format(_this._scene.getLastFrameDuration()); }
  2644. });
  2645. elemLabel = _this._createStatLabel("Potential FPS", _this._panel);
  2646. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2647. _this._updatableProperties.push({
  2648. elem: elemValue,
  2649. updateFct: function () { return BABYLON.Tools.Format(1000.0 / _this._scene.getLastFrameDuration(), 0); }
  2650. });
  2651. elemLabel = _this._createStatLabel("Resolution", _this._panel);
  2652. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2653. _this._updatableProperties.push({
  2654. elem: elemValue,
  2655. updateFct: function () { return _this._engine.getRenderWidth() + "x" + _this._engine.getRenderHeight(); }
  2656. });
  2657. }
  2658. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  2659. title.textContent = "Extensions";
  2660. {
  2661. var elemLabel = _this._createStatLabel("Std derivatives", _this._panel);
  2662. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2663. _this._updatableProperties.push({
  2664. elem: elemValue,
  2665. updateFct: function () { return (_this._engine.getCaps().standardDerivatives ? "Yes" : "No"); }
  2666. });
  2667. elemLabel = _this._createStatLabel("Compressed textures", _this._panel);
  2668. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2669. _this._updatableProperties.push({
  2670. elem: elemValue,
  2671. updateFct: function () { return (_this._engine.getCaps().s3tc ? "Yes" : "No"); }
  2672. });
  2673. elemLabel = _this._createStatLabel("Hardware instances", _this._panel);
  2674. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2675. _this._updatableProperties.push({
  2676. elem: elemValue,
  2677. updateFct: function () { return (_this._engine.getCaps().instancedArrays ? "Yes" : "No"); }
  2678. });
  2679. elemLabel = _this._createStatLabel("Texture float", _this._panel);
  2680. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2681. _this._updatableProperties.push({
  2682. elem: elemValue,
  2683. updateFct: function () { return (_this._engine.getCaps().textureFloat ? "Yes" : "No"); }
  2684. });
  2685. elemLabel = _this._createStatLabel("32bits indices", _this._panel);
  2686. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2687. _this._updatableProperties.push({
  2688. elem: elemValue,
  2689. updateFct: function () { return (_this._engine.getCaps().uintIndices ? "Yes" : "No"); }
  2690. });
  2691. elemLabel = _this._createStatLabel("Fragment depth", _this._panel);
  2692. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2693. _this._updatableProperties.push({
  2694. elem: elemValue,
  2695. updateFct: function () { return (_this._engine.getCaps().fragmentDepthSupported ? "Yes" : "No"); }
  2696. });
  2697. elemLabel = _this._createStatLabel("High precision shaders", _this._panel);
  2698. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2699. _this._updatableProperties.push({
  2700. elem: elemValue,
  2701. updateFct: function () { return (_this._engine.getCaps().highPrecisionShaderSupported ? "Yes" : "No"); }
  2702. });
  2703. elemLabel = _this._createStatLabel("Draw buffers", _this._panel);
  2704. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2705. _this._updatableProperties.push({
  2706. elem: elemValue,
  2707. updateFct: function () { return (_this._engine.getCaps().drawBuffersExtension ? "Yes" : "No"); }
  2708. });
  2709. }
  2710. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  2711. title.textContent = "Caps.";
  2712. {
  2713. var elemLabel = _this._createStatLabel("Stencil", _this._panel);
  2714. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2715. _this._updatableProperties.push({
  2716. elem: elemValue,
  2717. updateFct: function () { return (_this._engine.isStencilEnable ? "Enabled" : "Disabled"); }
  2718. });
  2719. elemLabel = _this._createStatLabel("Max textures units", _this._panel);
  2720. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2721. _this._updatableProperties.push({
  2722. elem: elemValue,
  2723. updateFct: function () { return _this._engine.getCaps().maxTexturesImageUnits.toString(); }
  2724. });
  2725. elemLabel = _this._createStatLabel("Max textures size", _this._panel);
  2726. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2727. _this._updatableProperties.push({
  2728. elem: elemValue,
  2729. updateFct: function () { return _this._engine.getCaps().maxTextureSize.toString(); }
  2730. });
  2731. elemLabel = _this._createStatLabel("Max anisotropy", _this._panel);
  2732. elemValue = INSPECTOR.Helpers.CreateDiv('stat-value', _this._panel);
  2733. _this._updatableProperties.push({
  2734. elem: elemValue,
  2735. updateFct: function () { return _this._engine.getCaps().maxAnisotropy.toString(); }
  2736. });
  2737. }
  2738. title = INSPECTOR.Helpers.CreateDiv('stat-title2', _this._panel);
  2739. title.textContent = "Info";
  2740. {
  2741. var elemValue = INSPECTOR.Helpers.CreateDiv('stat-infos', _this._panel);
  2742. _this._updatableProperties.push({
  2743. elem: elemValue,
  2744. updateFct: function () { return _this._engine.webGLVersion + " - " + _this._glInfo.version + " - " + _this._glInfo.renderer; }
  2745. });
  2746. }
  2747. // Register the update loop
  2748. _this._scene.registerAfterRender(_this._updateLoopHandler);
  2749. return _this;
  2750. }
  2751. StatsTab.prototype._createStatLabel = function (content, parent) {
  2752. var elem = INSPECTOR.Helpers.CreateDiv('stat-label', parent);
  2753. elem.textContent = content;
  2754. return elem;
  2755. };
  2756. /** Update each properties of the stats panel */
  2757. StatsTab.prototype._update = function () {
  2758. for (var _i = 0, _a = this._updatableProperties; _i < _a.length; _i++) {
  2759. var prop = _a[_i];
  2760. prop.elem.textContent = prop.updateFct();
  2761. }
  2762. };
  2763. StatsTab.prototype.dispose = function () {
  2764. this._scene.unregisterAfterRender(this._updateLoopHandler);
  2765. };
  2766. return StatsTab;
  2767. }(INSPECTOR.Tab));
  2768. INSPECTOR.StatsTab = StatsTab;
  2769. })(INSPECTOR || (INSPECTOR = {}));
  2770. var __extends = (this && this.__extends) || function (d, b) {
  2771. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  2772. function __() { this.constructor = d; }
  2773. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2774. };
  2775. var INSPECTOR;
  2776. (function (INSPECTOR) {
  2777. /**
  2778. * A tab bar will contains each view the inspector can have : Canvas2D, Meshes...
  2779. * The default active tab is the first one of the list.
  2780. */
  2781. var TabBar = (function (_super) {
  2782. __extends(TabBar, _super);
  2783. function TabBar(inspector) {
  2784. var _this = _super.call(this) || this;
  2785. // The list of available tabs
  2786. _this._tabs = [];
  2787. /** The list of tab displayed by clicking on the remainingIcon */
  2788. _this._invisibleTabs = [];
  2789. /** The list of tabs visible, displayed in the tab bar */
  2790. _this._visibleTabs = [];
  2791. _this._inspector = inspector;
  2792. _this._tabs.push(new INSPECTOR.SceneTab(_this, _this._inspector));
  2793. _this._tabs.push(new INSPECTOR.StatsTab(_this, _this._inspector));
  2794. _this._meshTab = new INSPECTOR.MeshTab(_this, _this._inspector);
  2795. _this._tabs.push(_this._meshTab);
  2796. _this._tabs.push(new INSPECTOR.ShaderTab(_this, _this._inspector));
  2797. _this._tabs.push(new INSPECTOR.LightTab(_this, _this._inspector));
  2798. // Add only the tab canvas2D if Canvas2D is defined
  2799. if (BABYLON.Canvas2D) {
  2800. _this._tabs.push(new INSPECTOR.Canvas2DTab(_this, _this._inspector));
  2801. }
  2802. _this._tabs.push(new INSPECTOR.MaterialTab(_this, _this._inspector));
  2803. _this._toolBar = new INSPECTOR.Toolbar(_this._inspector);
  2804. _this._build();
  2805. // Active the first tab
  2806. _this._tabs[0].active(true);
  2807. // set all tab as visible
  2808. for (var _i = 0, _a = _this._tabs; _i < _a.length; _i++) {
  2809. var tab = _a[_i];
  2810. _this._visibleTabs.push(tab);
  2811. }
  2812. return _this;
  2813. }
  2814. // No update
  2815. TabBar.prototype.update = function () { };
  2816. TabBar.prototype._build = function () {
  2817. var _this = this;
  2818. this._div.className = 'tabbar';
  2819. this._div.appendChild(this._toolBar.toHtml());
  2820. for (var _i = 0, _a = this._tabs; _i < _a.length; _i++) {
  2821. var tab = _a[_i];
  2822. this._div.appendChild(tab.toHtml());
  2823. }
  2824. this._moreTabsIcon = INSPECTOR.Helpers.CreateElement('i', 'fa fa-angle-double-right more-tabs');
  2825. this._moreTabsPanel = INSPECTOR.Helpers.CreateDiv('more-tabs-panel');
  2826. this._moreTabsIcon.addEventListener('click', function () {
  2827. // Hide the 'more-tabs-panel' if already displayed
  2828. if (_this._moreTabsPanel.style.display == 'flex') {
  2829. _this._moreTabsPanel.style.display = 'none';
  2830. }
  2831. else {
  2832. // Attach more-tabs-panel if not attached yet
  2833. var topPanel = _this._div.parentNode;
  2834. if (!topPanel.contains(_this._moreTabsPanel)) {
  2835. topPanel.appendChild(_this._moreTabsPanel);
  2836. }
  2837. // Clean the 'more-tabs-panel'
  2838. INSPECTOR.Helpers.CleanDiv(_this._moreTabsPanel);
  2839. // Add each invisible tabs to this panel
  2840. for (var _i = 0, _a = _this._invisibleTabs; _i < _a.length; _i++) {
  2841. var tab = _a[_i];
  2842. _this._addInvisibleTabToPanel(tab);
  2843. }
  2844. // And display it
  2845. _this._moreTabsPanel.style.display = 'flex';
  2846. }
  2847. });
  2848. };
  2849. /**
  2850. * Add a tab to the 'more-tabs' panel, displayed by clicking on the
  2851. * 'more-tabs' icon
  2852. */
  2853. TabBar.prototype._addInvisibleTabToPanel = function (tab) {
  2854. var _this = this;
  2855. var div = INSPECTOR.Helpers.CreateDiv('invisible-tab', this._moreTabsPanel);
  2856. div.textContent = tab.name;
  2857. div.addEventListener('click', function () {
  2858. _this._moreTabsPanel.style.display = 'none';
  2859. _this.switchTab(tab);
  2860. });
  2861. };
  2862. /** Dispose the current tab, set the given tab as active, and refresh the treeview */
  2863. TabBar.prototype.switchTab = function (tab) {
  2864. // Dispose the active tab
  2865. this.getActiveTab().dispose();
  2866. // Deactivate all tabs
  2867. for (var _i = 0, _a = this._tabs; _i < _a.length; _i++) {
  2868. var t = _a[_i];
  2869. t.active(false);
  2870. }
  2871. // activate the given tab
  2872. tab.active(true);
  2873. // Refresh the inspector
  2874. this._inspector.refresh();
  2875. };
  2876. /** Display the mesh tab.
  2877. * If a parameter is given, the given mesh details are displayed
  2878. */
  2879. TabBar.prototype.switchMeshTab = function (mesh) {
  2880. this.switchTab(this._meshTab);
  2881. if (mesh) {
  2882. var item = this._meshTab.getItemFor(mesh);
  2883. this._meshTab.select(item);
  2884. }
  2885. };
  2886. /** Returns the active tab */
  2887. TabBar.prototype.getActiveTab = function () {
  2888. for (var _i = 0, _a = this._tabs; _i < _a.length; _i++) {
  2889. var tab = _a[_i];
  2890. if (tab.isActive()) {
  2891. return tab;
  2892. }
  2893. }
  2894. };
  2895. Object.defineProperty(TabBar.prototype, "inspector", {
  2896. get: function () {
  2897. return this._inspector;
  2898. },
  2899. enumerable: true,
  2900. configurable: true
  2901. });
  2902. /**
  2903. * Returns the total width in pixel of the tabbar,
  2904. * that corresponds to the sum of the width of each visible tab + toolbar width
  2905. */
  2906. TabBar.prototype.getPixelWidth = function () {
  2907. var sum = 0;
  2908. for (var _i = 0, _a = this._visibleTabs; _i < _a.length; _i++) {
  2909. var tab = _a[_i];
  2910. sum += tab.getPixelWidth();
  2911. }
  2912. sum += this._toolBar.getPixelWidth();
  2913. if (this._div.contains(this._moreTabsIcon)) {
  2914. sum += 30; // $tabbarheight
  2915. }
  2916. return sum;
  2917. };
  2918. /** Display the remaining icon or not depending on the tabbar width.
  2919. * This function should be called each time the inspector width is updated
  2920. */
  2921. TabBar.prototype.updateWidth = function () {
  2922. var parentSize = this._div.parentElement.clientWidth;
  2923. var lastTabWidth = 75;
  2924. var currentSize = this.getPixelWidth();
  2925. // Check if a tab should be removed : if the tab bar width is greater than
  2926. // its parent width
  2927. while (this._visibleTabs.length > 0 && currentSize > parentSize) {
  2928. // Start by the last element
  2929. var tab = this._visibleTabs.pop();
  2930. // set it invisible
  2931. this._invisibleTabs.push(tab);
  2932. // and removes it from the DOM
  2933. this._div.removeChild(tab.toHtml());
  2934. currentSize = this.getPixelWidth() + lastTabWidth;
  2935. }
  2936. // Check if a tab can be added to the tab bar : if the tab bar width
  2937. // + 100 (at least 100px is needed to add a tab) is less than its parent width
  2938. if (this._invisibleTabs.length > 0) {
  2939. if (currentSize + lastTabWidth < parentSize) {
  2940. var lastTab = this._invisibleTabs.pop();
  2941. this._div.appendChild(lastTab.toHtml());
  2942. this._visibleTabs.push(lastTab);
  2943. // Update more-tab icon in last position if needed
  2944. if (this._div.contains(this._moreTabsIcon)) {
  2945. this._div.removeChild(this._moreTabsIcon);
  2946. }
  2947. }
  2948. }
  2949. if (this._invisibleTabs.length > 0 && !this._div.contains(this._moreTabsIcon)) {
  2950. this._div.appendChild(this._moreTabsIcon);
  2951. }
  2952. };
  2953. return TabBar;
  2954. }(INSPECTOR.BasicElement));
  2955. INSPECTOR.TabBar = TabBar;
  2956. })(INSPECTOR || (INSPECTOR = {}));
  2957. var INSPECTOR;
  2958. (function (INSPECTOR) {
  2959. var AbstractTool = (function () {
  2960. function AbstractTool(icon, parent, inspector, tooltip) {
  2961. var _this = this;
  2962. this._inspector = inspector;
  2963. this._elem = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  2964. this._elem.className = "tool fa " + icon;
  2965. parent.appendChild(this._elem);
  2966. this._elem.addEventListener('click', function (e) {
  2967. _this.action();
  2968. });
  2969. new INSPECTOR.Tooltip(this._elem, tooltip);
  2970. }
  2971. AbstractTool.prototype.toHtml = function () {
  2972. return this._elem;
  2973. };
  2974. /**
  2975. * Returns the total width in pixel of this tool, 0 by default
  2976. */
  2977. AbstractTool.prototype.getPixelWidth = function () {
  2978. var style = INSPECTOR.Inspector.WINDOW.getComputedStyle(this._elem);
  2979. var left = parseFloat(style.marginLeft.substr(0, style.marginLeft.length - 2)) || 0;
  2980. var right = parseFloat(style.marginRight.substr(0, style.marginRight.length - 2)) || 0;
  2981. return (this._elem.clientWidth || 0) + left + right;
  2982. };
  2983. /**
  2984. * Updates the icon of this tool with the given string
  2985. */
  2986. AbstractTool.prototype._updateIcon = function (icon) {
  2987. this._elem.className = "tool fa " + icon;
  2988. };
  2989. return AbstractTool;
  2990. }());
  2991. INSPECTOR.AbstractTool = AbstractTool;
  2992. })(INSPECTOR || (INSPECTOR = {}));
  2993. var __extends = (this && this.__extends) || function (d, b) {
  2994. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  2995. function __() { this.constructor = d; }
  2996. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2997. };
  2998. var INSPECTOR;
  2999. (function (INSPECTOR) {
  3000. var PauseScheduleTool = (function (_super) {
  3001. __extends(PauseScheduleTool, _super);
  3002. function PauseScheduleTool(parent, inspector) {
  3003. var _this = _super.call(this, 'fa-pause', parent, inspector, 'Pause the automatic update of properties') || this;
  3004. _this._isPause = false;
  3005. return _this;
  3006. }
  3007. // Action : refresh the whole panel
  3008. PauseScheduleTool.prototype.action = function () {
  3009. if (this._isPause) {
  3010. INSPECTOR.Scheduler.getInstance().pause = false;
  3011. this._updateIcon('fa-pause');
  3012. }
  3013. else {
  3014. INSPECTOR.Scheduler.getInstance().pause = true;
  3015. this._updateIcon('fa-play');
  3016. }
  3017. this._isPause = !this._isPause;
  3018. };
  3019. return PauseScheduleTool;
  3020. }(INSPECTOR.AbstractTool));
  3021. INSPECTOR.PauseScheduleTool = PauseScheduleTool;
  3022. })(INSPECTOR || (INSPECTOR = {}));
  3023. var __extends = (this && this.__extends) || function (d, b) {
  3024. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3025. function __() { this.constructor = d; }
  3026. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3027. };
  3028. var INSPECTOR;
  3029. (function (INSPECTOR) {
  3030. var PickTool = (function (_super) {
  3031. __extends(PickTool, _super);
  3032. function PickTool(parent, inspector) {
  3033. var _this = _super.call(this, 'fa-mouse-pointer', parent, inspector, 'Select a mesh in the scene') || this;
  3034. _this._isActive = false;
  3035. // Create handler
  3036. _this._pickHandler = _this._pickMesh.bind(_this);
  3037. return _this;
  3038. }
  3039. // Action : find the corresponding tree item in the correct tab and display it
  3040. PickTool.prototype.action = function () {
  3041. if (this._isActive) {
  3042. this._deactivate();
  3043. }
  3044. else {
  3045. this.toHtml().classList.add('active');
  3046. // Add event handler : pick on a mesh in the scene
  3047. this._inspector.scene.getEngine().getRenderingCanvas().addEventListener('click', this._pickHandler);
  3048. this._isActive = true;
  3049. }
  3050. };
  3051. /** Deactivate this tool */
  3052. PickTool.prototype._deactivate = function () {
  3053. this.toHtml().classList.remove('active');
  3054. // Remove event handler
  3055. this._inspector.scene.getEngine().getRenderingCanvas().removeEventListener('click', this._pickHandler);
  3056. this._isActive = false;
  3057. };
  3058. /** Pick a mesh in the scene */
  3059. PickTool.prototype._pickMesh = function (evt) {
  3060. var pos = this._updatePointerPosition(evt);
  3061. var pi = this._inspector.scene.pick(pos.x, pos.y, function (mesh) { return true; });
  3062. if (pi.pickedMesh) {
  3063. console.log(pi.pickedMesh.name);
  3064. this._inspector.displayObjectDetails(pi.pickedMesh);
  3065. }
  3066. this._deactivate();
  3067. };
  3068. PickTool.prototype._updatePointerPosition = function (evt) {
  3069. var canvasRect = this._inspector.scene.getEngine().getRenderingCanvasClientRect();
  3070. var pointerX = evt.clientX - canvasRect.left;
  3071. var pointerY = evt.clientY - canvasRect.top;
  3072. return { x: pointerX, y: pointerY };
  3073. };
  3074. ;
  3075. return PickTool;
  3076. }(INSPECTOR.AbstractTool));
  3077. INSPECTOR.PickTool = PickTool;
  3078. })(INSPECTOR || (INSPECTOR = {}));
  3079. var __extends = (this && this.__extends) || function (d, b) {
  3080. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3081. function __() { this.constructor = d; }
  3082. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3083. };
  3084. var INSPECTOR;
  3085. (function (INSPECTOR) {
  3086. var PopupTool = (function (_super) {
  3087. __extends(PopupTool, _super);
  3088. function PopupTool(parent, inspector) {
  3089. return _super.call(this, 'fa-external-link', parent, inspector, 'Open the inspector in a popup') || this;
  3090. }
  3091. // Action : refresh the whole panel
  3092. PopupTool.prototype.action = function () {
  3093. this._inspector.openPopup();
  3094. };
  3095. return PopupTool;
  3096. }(INSPECTOR.AbstractTool));
  3097. INSPECTOR.PopupTool = PopupTool;
  3098. })(INSPECTOR || (INSPECTOR = {}));
  3099. var __extends = (this && this.__extends) || function (d, b) {
  3100. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3101. function __() { this.constructor = d; }
  3102. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3103. };
  3104. var INSPECTOR;
  3105. (function (INSPECTOR) {
  3106. var RefreshTool = (function (_super) {
  3107. __extends(RefreshTool, _super);
  3108. function RefreshTool(parent, inspector) {
  3109. return _super.call(this, 'fa-refresh', parent, inspector, 'Refresh the current tab') || this;
  3110. }
  3111. // Action : refresh the whole panel
  3112. RefreshTool.prototype.action = function () {
  3113. this._inspector.refresh();
  3114. };
  3115. return RefreshTool;
  3116. }(INSPECTOR.AbstractTool));
  3117. INSPECTOR.RefreshTool = RefreshTool;
  3118. })(INSPECTOR || (INSPECTOR = {}));
  3119. var __extends = (this && this.__extends) || function (d, b) {
  3120. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3121. function __() { this.constructor = d; }
  3122. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3123. };
  3124. var INSPECTOR;
  3125. (function (INSPECTOR) {
  3126. var LabelTool = (function (_super) {
  3127. __extends(LabelTool, _super);
  3128. function LabelTool(parent, inspector) {
  3129. var _this = _super.call(this, 'fa-tags', parent, inspector, 'Display mesh names on the canvas') || this;
  3130. /** True if label are displayed, false otherwise */
  3131. _this._isDisplayed = false;
  3132. _this._labels = [];
  3133. _this._transformationMatrix = BABYLON.Matrix.Identity();
  3134. return _this;
  3135. }
  3136. // Action : Display/hide mesh names on the canvas
  3137. LabelTool.prototype.action = function () {
  3138. if (this._isDisplayed) {
  3139. }
  3140. };
  3141. LabelTool.prototype._update = function () {
  3142. this._camera = this._inspector.scene.activeCamera;
  3143. var engine = this._inspector.scene.getEngine();
  3144. var viewport = this._camera.viewport;
  3145. var globalViewport = viewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  3146. this._camera.getViewMatrix().multiplyToRef(this._camera.getProjectionMatrix(), this._transformationMatrix);
  3147. // Old method
  3148. // let meshes = this._camera.getActiveMeshes();
  3149. // let projectedPosition: BABYLON.Vector3;
  3150. // for (let index = 0; index < meshes.length; index++) {
  3151. // let mesh = meshes.data[index];
  3152. // let position = mesh.getBoundingInfo().boundingSphere.center;
  3153. // projectedPosition = BABYLON.Vector3.Project(position, mesh.getWorldMatrix(), this._transformationMatrix, globalViewport);
  3154. // this._renderLabel(mesh.name, projectedPosition, 12,
  3155. // () => { mesh.renderOverlay = !mesh.renderOverlay },
  3156. // () => { return mesh.renderOverlay ? 'red' : 'black'; });
  3157. // }
  3158. };
  3159. return LabelTool;
  3160. }(INSPECTOR.AbstractTool));
  3161. INSPECTOR.LabelTool = LabelTool;
  3162. })(INSPECTOR || (INSPECTOR = {}));
  3163. var __extends = (this && this.__extends) || function (d, b) {
  3164. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3165. function __() { this.constructor = d; }
  3166. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3167. };
  3168. var INSPECTOR;
  3169. (function (INSPECTOR) {
  3170. var Toolbar = (function (_super) {
  3171. __extends(Toolbar, _super);
  3172. function Toolbar(inspector) {
  3173. var _this = _super.call(this) || this;
  3174. _this._tools = [];
  3175. _this._inspector = inspector;
  3176. _this._build();
  3177. _this._addTools();
  3178. return _this;
  3179. }
  3180. // A toolbar cannot be updated
  3181. Toolbar.prototype.update = function () { };
  3182. ;
  3183. Toolbar.prototype._build = function () {
  3184. this._div.className = 'toolbar';
  3185. };
  3186. ;
  3187. Toolbar.prototype._addTools = function () {
  3188. // Refresh
  3189. this._tools.push(new INSPECTOR.RefreshTool(this._div, this._inspector));
  3190. // Display labels
  3191. this._tools.push(new INSPECTOR.LabelTool(this._div, this._inspector));
  3192. // Pick object
  3193. this._tools.push(new INSPECTOR.PickTool(this._div, this._inspector));
  3194. // Add the popup mode only if the inspector is not in popup mode and if the brower is not edge
  3195. // Edge is
  3196. if (!this._inspector.popupMode && !INSPECTOR.Helpers.IsBrowserEdge()) {
  3197. this._tools.push(new INSPECTOR.PopupTool(this._div, this._inspector));
  3198. }
  3199. // Pause schedule
  3200. this._tools.push(new INSPECTOR.PauseScheduleTool(this._div, this._inspector));
  3201. // Pause schedule
  3202. this._tools.push(new INSPECTOR.DisposeTool(this._div, this._inspector));
  3203. };
  3204. /**
  3205. * Returns the total width in pixel of the tabbar,
  3206. * that corresponds to the sum of the width of each tab + toolbar width
  3207. */
  3208. Toolbar.prototype.getPixelWidth = function () {
  3209. var sum = 0;
  3210. for (var _i = 0, _a = this._tools; _i < _a.length; _i++) {
  3211. var tool = _a[_i];
  3212. sum += tool.getPixelWidth();
  3213. }
  3214. return sum;
  3215. };
  3216. return Toolbar;
  3217. }(INSPECTOR.BasicElement));
  3218. INSPECTOR.Toolbar = Toolbar;
  3219. })(INSPECTOR || (INSPECTOR = {}));
  3220. var __extends = (this && this.__extends) || function (d, b) {
  3221. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3222. function __() { this.constructor = d; }
  3223. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3224. };
  3225. var INSPECTOR;
  3226. (function (INSPECTOR) {
  3227. /**
  3228. * Removes the inspector panel
  3229. */
  3230. var DisposeTool = (function (_super) {
  3231. __extends(DisposeTool, _super);
  3232. function DisposeTool(parent, inspector) {
  3233. return _super.call(this, 'fa-times', parent, inspector, 'Close the inspector panel') || this;
  3234. }
  3235. // Action : refresh the whole panel
  3236. DisposeTool.prototype.action = function () {
  3237. this._inspector.dispose();
  3238. };
  3239. return DisposeTool;
  3240. }(INSPECTOR.AbstractTool));
  3241. INSPECTOR.DisposeTool = DisposeTool;
  3242. })(INSPECTOR || (INSPECTOR = {}));
  3243. var __extends = (this && this.__extends) || function (d, b) {
  3244. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3245. function __() { this.constructor = d; }
  3246. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3247. };
  3248. var INSPECTOR;
  3249. (function (INSPECTOR) {
  3250. var TreeItem = (function (_super) {
  3251. __extends(TreeItem, _super);
  3252. function TreeItem(tab, obj) {
  3253. var _this = _super.call(this) || this;
  3254. _this._children = [];
  3255. _this._tab = tab;
  3256. _this._adapter = obj;
  3257. _this._tools = _this._adapter.getTools();
  3258. _this._build();
  3259. return _this;
  3260. }
  3261. Object.defineProperty(TreeItem.prototype, "id", {
  3262. /** Returns the item ID == its adapter ID */
  3263. get: function () {
  3264. return this._adapter.id();
  3265. },
  3266. enumerable: true,
  3267. configurable: true
  3268. });
  3269. /** Add the given item as a child of this one */
  3270. TreeItem.prototype.add = function (child) {
  3271. this._children.push(child);
  3272. this.update();
  3273. };
  3274. /**
  3275. * Function used to compare this item to another tree item.
  3276. * Returns the alphabetical sort of the adapter ID
  3277. */
  3278. TreeItem.prototype.compareTo = function (item) {
  3279. var str1 = this.id;
  3280. var str2 = item.id;
  3281. return str1.localeCompare(str2, [], { numeric: true });
  3282. };
  3283. /** Returns true if the given obj correspond to the adapter linked to this tree item */
  3284. TreeItem.prototype.correspondsTo = function (obj) {
  3285. return this._adapter.correspondsTo(obj);
  3286. };
  3287. /** hide all children of this item */
  3288. TreeItem.prototype.fold = function () {
  3289. // Do nothing id no children
  3290. if (this._children.length > 0) {
  3291. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3292. var elem = _a[_i];
  3293. elem.toHtml().style.display = 'none';
  3294. }
  3295. this._div.classList.add('folded');
  3296. this._div.classList.remove('unfolded');
  3297. }
  3298. };
  3299. /** Show all children of this item */
  3300. TreeItem.prototype.unfold = function () {
  3301. // Do nothing id no children
  3302. if (this._children.length > 0) {
  3303. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3304. var elem = _a[_i];
  3305. elem.toHtml().style.display = 'block';
  3306. }
  3307. this._div.classList.add('unfolded');
  3308. this._div.classList.remove('folded');
  3309. }
  3310. };
  3311. /** Build the HTML of this item */
  3312. TreeItem.prototype._build = function () {
  3313. this._div.className = 'line';
  3314. for (var _i = 0, _a = this._tools; _i < _a.length; _i++) {
  3315. var tool = _a[_i];
  3316. this._div.appendChild(tool.toHtml());
  3317. }
  3318. // Id
  3319. var text = INSPECTOR.Inspector.DOCUMENT.createElement('span');
  3320. text.textContent = this._adapter.id();
  3321. this._div.appendChild(text);
  3322. // Type
  3323. var type = INSPECTOR.Inspector.DOCUMENT.createElement('span');
  3324. type.className = 'property-type';
  3325. if (this._adapter.type() !== 'type_not_defined') {
  3326. type.textContent = ' - ' + this._adapter.type();
  3327. }
  3328. this._div.appendChild(type);
  3329. this._lineContent = INSPECTOR.Helpers.CreateDiv('line-content', this._div);
  3330. this._addEvent();
  3331. };
  3332. /**
  3333. * Returns one HTML element (.details) containing all details of this primitive
  3334. */
  3335. TreeItem.prototype.getDetails = function () {
  3336. return this._adapter.getProperties();
  3337. };
  3338. TreeItem.prototype.update = function () {
  3339. // Clean division holding all children
  3340. INSPECTOR.Helpers.CleanDiv(this._lineContent);
  3341. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3342. var child = _a[_i];
  3343. var elem = child.toHtml();
  3344. this._lineContent.appendChild(elem);
  3345. }
  3346. if (this._children.length > 0) {
  3347. // Check if folded or not
  3348. if (!this._div.classList.contains('folded') && !this._div.classList.contains('unfolded')) {
  3349. this._div.classList.add('folded');
  3350. }
  3351. }
  3352. this.fold();
  3353. };
  3354. /**
  3355. * Add an event listener on the item :
  3356. * - one click display details
  3357. * - on mouse hover the item is highlighted
  3358. */
  3359. TreeItem.prototype._addEvent = function () {
  3360. var _this = this;
  3361. this._div.addEventListener('click', function (e) {
  3362. _this._tab.select(_this);
  3363. // Fold/unfold the tree
  3364. if (_this._isFolded()) {
  3365. _this.unfold();
  3366. }
  3367. else {
  3368. _this.fold();
  3369. }
  3370. e.stopPropagation();
  3371. });
  3372. // Highlight on mouse over
  3373. this._div.addEventListener('mouseover', function (e) {
  3374. _this._tab.highlightNode(_this);
  3375. e.stopPropagation();
  3376. });
  3377. // Remove highlight on mouse out
  3378. this._div.addEventListener('mouseout', function (e) {
  3379. _this._tab.highlightNode();
  3380. });
  3381. };
  3382. /** Highlight or downplay this node */
  3383. TreeItem.prototype.highlight = function (b) {
  3384. // Remove highlight for all children
  3385. if (!b) {
  3386. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3387. var child = _a[_i];
  3388. child._adapter.highlight(b);
  3389. }
  3390. }
  3391. // Highlight this node
  3392. this._adapter.highlight(b);
  3393. };
  3394. /** Returns true if the node is folded, false otherwise */
  3395. TreeItem.prototype._isFolded = function () {
  3396. return !this._div.classList.contains('unfolded');
  3397. };
  3398. /** Set this item as active (background lighter) in the tree panel */
  3399. TreeItem.prototype.active = function (b) {
  3400. this._div.classList.remove('active');
  3401. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3402. var child = _a[_i];
  3403. child.active(false);
  3404. }
  3405. if (b) {
  3406. this._div.classList.add('active');
  3407. }
  3408. };
  3409. return TreeItem;
  3410. }(INSPECTOR.BasicElement));
  3411. INSPECTOR.TreeItem = TreeItem;
  3412. })(INSPECTOR || (INSPECTOR = {}));
  3413. var INSPECTOR;
  3414. (function (INSPECTOR) {
  3415. var AbstractTreeTool = (function () {
  3416. function AbstractTreeTool() {
  3417. /** Is the tool enabled ? */
  3418. this._on = false;
  3419. this._elem = INSPECTOR.Inspector.DOCUMENT.createElement('i');
  3420. this._elem.className = 'treeTool fa';
  3421. this._addEvents();
  3422. }
  3423. AbstractTreeTool.prototype.toHtml = function () {
  3424. return this._elem;
  3425. };
  3426. AbstractTreeTool.prototype._addEvents = function () {
  3427. var _this = this;
  3428. this._elem.addEventListener('click', function (e) {
  3429. _this.action();
  3430. e.stopPropagation();
  3431. });
  3432. };
  3433. /**
  3434. * Action launched when clicked on this element
  3435. * Should be overrided
  3436. */
  3437. AbstractTreeTool.prototype.action = function () {
  3438. this._on = !this._on;
  3439. };
  3440. return AbstractTreeTool;
  3441. }());
  3442. INSPECTOR.AbstractTreeTool = AbstractTreeTool;
  3443. })(INSPECTOR || (INSPECTOR = {}));
  3444. var __extends = (this && this.__extends) || function (d, b) {
  3445. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3446. function __() { this.constructor = d; }
  3447. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3448. };
  3449. var INSPECTOR;
  3450. (function (INSPECTOR) {
  3451. /**
  3452. * Checkbox to display/hide the primitive
  3453. */
  3454. var BoundingBox = (function (_super) {
  3455. __extends(BoundingBox, _super);
  3456. function BoundingBox(obj) {
  3457. var _this = _super.call(this) || this;
  3458. _this._obj = obj;
  3459. _this._elem.classList.add('fa-square-o');
  3460. _this._on = _this._obj.isBoxVisible();
  3461. _this._check();
  3462. return _this;
  3463. }
  3464. // For a checkbox, set visible/invisible the corresponding prim
  3465. BoundingBox.prototype.action = function () {
  3466. _super.prototype.action.call(this);
  3467. // update object and gui according to the new status
  3468. this._check();
  3469. };
  3470. BoundingBox.prototype._check = function () {
  3471. if (this._on) {
  3472. // set icon eye
  3473. this._elem.classList.add('active');
  3474. }
  3475. else {
  3476. // set icon eye-slash
  3477. this._elem.classList.remove('active');
  3478. }
  3479. this._obj.setBoxVisible(this._on);
  3480. };
  3481. return BoundingBox;
  3482. }(INSPECTOR.AbstractTreeTool));
  3483. INSPECTOR.BoundingBox = BoundingBox;
  3484. })(INSPECTOR || (INSPECTOR = {}));
  3485. var __extends = (this && this.__extends) || function (d, b) {
  3486. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3487. function __() { this.constructor = d; }
  3488. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3489. };
  3490. var INSPECTOR;
  3491. (function (INSPECTOR) {
  3492. /**
  3493. * Checkbox to display/hide the primitive
  3494. */
  3495. var Checkbox = (function (_super) {
  3496. __extends(Checkbox, _super);
  3497. function Checkbox(obj) {
  3498. var _this = _super.call(this) || this;
  3499. _this._obj = obj;
  3500. _this._elem.classList.add('fa-eye');
  3501. _this._on = _this._obj.isVisible();
  3502. _this._check(true);
  3503. return _this;
  3504. }
  3505. // For a checkbox, set visible/invisible the corresponding prim
  3506. Checkbox.prototype.action = function () {
  3507. _super.prototype.action.call(this);
  3508. // update object and gui according to the new status
  3509. this._check();
  3510. };
  3511. Checkbox.prototype._check = function (dontEnable) {
  3512. if (this._on) {
  3513. // set icon eye
  3514. this._elem.classList.add('fa-eye');
  3515. this._elem.classList.add('active');
  3516. this._elem.classList.remove('fa-eye-slash');
  3517. }
  3518. else {
  3519. // set icon eye-slash
  3520. this._elem.classList.remove('fa-eye');
  3521. this._elem.classList.remove('active');
  3522. this._elem.classList.add('fa-eye-slash');
  3523. }
  3524. if (!dontEnable) {
  3525. this._obj.setVisible(this._on);
  3526. }
  3527. };
  3528. return Checkbox;
  3529. }(INSPECTOR.AbstractTreeTool));
  3530. INSPECTOR.Checkbox = Checkbox;
  3531. })(INSPECTOR || (INSPECTOR = {}));
  3532. var __extends = (this && this.__extends) || function (d, b) {
  3533. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3534. function __() { this.constructor = d; }
  3535. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3536. };
  3537. var INSPECTOR;
  3538. (function (INSPECTOR) {
  3539. var DebugArea = (function (_super) {
  3540. __extends(DebugArea, _super);
  3541. function DebugArea(obj) {
  3542. var _this = _super.call(this) || this;
  3543. _this._obj = obj;
  3544. _this._elem.classList.add('fa-wrench');
  3545. return _this;
  3546. }
  3547. DebugArea.prototype.action = function () {
  3548. _super.prototype.action.call(this);
  3549. if (this._on) {
  3550. // set icon activated
  3551. this._elem.classList.add('active');
  3552. }
  3553. else {
  3554. // set icon deactivated
  3555. this._elem.classList.remove('active');
  3556. }
  3557. this._obj.debug(this._on);
  3558. };
  3559. return DebugArea;
  3560. }(INSPECTOR.AbstractTreeTool));
  3561. INSPECTOR.DebugArea = DebugArea;
  3562. })(INSPECTOR || (INSPECTOR = {}));
  3563. var __extends = (this && this.__extends) || function (d, b) {
  3564. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3565. function __() { this.constructor = d; }
  3566. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3567. };
  3568. var INSPECTOR;
  3569. (function (INSPECTOR) {
  3570. /**
  3571. * Checkbox to display/hide the primitive
  3572. */
  3573. var Info = (function (_super) {
  3574. __extends(Info, _super);
  3575. function Info(obj) {
  3576. var _this = _super.call(this) || this;
  3577. _this._obj = obj;
  3578. _this._elem.classList.add('fa-info-circle');
  3579. _this._tooltip = new INSPECTOR.Tooltip(_this._elem, _this._obj.getInfo());
  3580. return _this;
  3581. }
  3582. // Nothing to do on click
  3583. Info.prototype.action = function () {
  3584. _super.prototype.action.call(this);
  3585. };
  3586. return Info;
  3587. }(INSPECTOR.AbstractTreeTool));
  3588. INSPECTOR.Info = Info;
  3589. })(INSPECTOR || (INSPECTOR = {}));