babylon.inspector.js 161 KB

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