babylon.inspector.js 151 KB

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