|
@@ -25,7 +25,7 @@ import { Settings, PowerPreference } from '../core/settings';
|
25
|
25
|
import { Viewport } from '../core/viewport';
|
26
|
26
|
import { Tracker } from '../trackers/tracker';
|
27
|
27
|
import { Source } from '../sources/source';
|
28
|
|
-import { Utils, Nullable } from '../utils/utils';
|
|
28
|
+import { Nullable } from '../utils/utils';
|
29
|
29
|
import AR from '../main';
|
30
|
30
|
|
31
|
31
|
|
|
@@ -39,6 +39,9 @@ const POWER_ICON: { readonly [P in PowerPreference]: string } = Object.freeze({
|
39
|
39
|
'high-performance': '⚡'
|
40
|
40
|
});
|
41
|
41
|
|
|
42
|
+/** Button icons (atlas) */
|
|
43
|
+const BUTTON_ICONS = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAQCAYAAAB3AH1ZAAAAVUlEQVRIS2NkGGDAOMD2M4w6YDQE8IbAfyBgBAJSEipIDy712MzCaTiyQdRwBC4zsDoAmy8ocQQ+vRgOIDUI8UUPMVFIUvySkhaIVTvqgNEQGPAQAABSNiARgz5LggAAAABJRU5ErkJggg==';
|
|
44
|
+
|
42
|
45
|
|
43
|
46
|
|
44
|
47
|
/**
|
|
@@ -151,10 +154,10 @@ export class StatsPanel
|
151
|
154
|
lout.innerText = trackerStats;
|
152
|
155
|
}
|
153
|
156
|
|
154
|
|
- const ldraw = this._label('_ar_draw');
|
155
|
|
- if(ldraw !== null) {
|
|
157
|
+ const lview = this._label('_ar_view');
|
|
158
|
+ if(lview !== null) {
|
156
|
159
|
const size = viewport.virtualSize;
|
157
|
|
- ldraw.innerText = `${size.width}x${size.height} rendering`;
|
|
160
|
+ lview.innerText = `${size.width}x${size.height} rendering`;
|
158
|
161
|
}
|
159
|
162
|
}
|
160
|
163
|
|
|
@@ -209,15 +212,39 @@ export class StatsPanel
|
209
|
212
|
private _createTitle(): HTMLElement
|
210
|
213
|
{
|
211
|
214
|
const title = document.createElement('div');
|
|
215
|
+ const button = document.createElement('button');
|
212
|
216
|
|
|
217
|
+ title.style.display = 'flex';
|
213
|
218
|
title.style.backgroundColor = '#7e56c2';
|
214
|
219
|
title.style.color = 'white';
|
215
|
220
|
title.style.fontFamily = 'monospace';
|
216
|
221
|
title.style.fontSize = '14px';
|
217
|
222
|
title.style.fontWeight = 'bold';
|
218
|
|
- title.style.padding = '2px';
|
|
223
|
+ title.style.paddingRight = '4px';
|
219
|
224
|
title.innerText = 'encantar.js ' + AR.version;
|
220
|
225
|
|
|
226
|
+ button.style.width = '18px';
|
|
227
|
+ button.style.height = '18px';
|
|
228
|
+ button.style.marginRight = '4px';
|
|
229
|
+ button.style.backgroundColor = '#7e56c2';
|
|
230
|
+ button.style.backgroundImage = 'url(' + BUTTON_ICONS + ')';
|
|
231
|
+ button.style.backgroundRepeat = 'no-repeat';
|
|
232
|
+ button.style.backgroundPosition = '0 0';
|
|
233
|
+ button.style.borderWidth = '2px';
|
|
234
|
+ button.style.borderColor = '#b588fb #46346a #46346a #b588fb';
|
|
235
|
+ title.insertBefore(button, title.firstChild);
|
|
236
|
+
|
|
237
|
+ button.addEventListener('click', () => {
|
|
238
|
+ const container = title.parentNode;
|
|
239
|
+ const details = container && container.querySelector<HTMLElement>('._ar_details');
|
|
240
|
+
|
|
241
|
+ if(!details)
|
|
242
|
+ return;
|
|
243
|
+
|
|
244
|
+ details.hidden = !details.hidden;
|
|
245
|
+ button.style.backgroundPosition = details.hidden ? '0 0 ' : '-16px 0';
|
|
246
|
+ });
|
|
247
|
+
|
221
|
248
|
return title;
|
222
|
249
|
}
|
223
|
250
|
|
|
@@ -228,7 +255,7 @@ export class StatsPanel
|
228
|
255
|
private _createContent(): HTMLElement
|
229
|
256
|
{
|
230
|
257
|
const content = document.createElement('div');
|
231
|
|
- const print = (html: string): void => content.insertAdjacentHTML('beforeend', html);
|
|
258
|
+ const details = document.createElement('div');
|
232
|
259
|
|
233
|
260
|
content.style.backgroundColor = 'rgba(0,0,0,0.5)';
|
234
|
261
|
content.style.color = 'white';
|
|
@@ -237,20 +264,22 @@ export class StatsPanel
|
237
|
264
|
content.style.padding = '2px';
|
238
|
265
|
content.style.whiteSpace = 'pre-line';
|
239
|
266
|
|
240
|
|
- // all sanitized
|
241
|
|
- print('FPS: <span class="_ar_fps"></span> | ');
|
242
|
|
- print('GPU: <span class="_ar_gpu"></span> ');
|
243
|
|
- print('<span class="_ar_power"></span>');
|
|
267
|
+ details.classList.add('_ar_details');
|
|
268
|
+ details.hidden = true;
|
244
|
269
|
|
245
|
|
- print('<br>');
|
246
|
|
- print('IN: <span class="_ar_in"></span>');
|
|
270
|
+ // all sanitized
|
|
271
|
+ const append = (div: HTMLDivElement, html: string): void => div.insertAdjacentHTML('beforeend', html);
|
247
|
272
|
|
248
|
|
- print('<br>');
|
249
|
|
- print('OUT: <span class="_ar_out"></span>');
|
|
273
|
+ append(content, 'FPS: <span class="_ar_fps"></span> | ');
|
|
274
|
+ append(content, 'GPU: <span class="_ar_gpu"></span> ');
|
|
275
|
+ append(content, '<span class="_ar_power"></span>');
|
250
|
276
|
|
251
|
|
- print('<br>');
|
252
|
|
- print('VIEW: <span class="_ar_draw"></span>');
|
|
277
|
+ append(details, 'IN: <span class="_ar_in"></span><br>');
|
|
278
|
+ append(details, 'OUT: <span class="_ar_out"></span><br>');
|
|
279
|
+ append(details, 'VIEW: <span class="_ar_view"></span>');
|
253
|
280
|
|
|
281
|
+ // done!
|
|
282
|
+ content.appendChild(details);
|
254
|
283
|
return content;
|
255
|
284
|
}
|
256
|
285
|
}
|