babylon.inspector.js 150 KB

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