Browse Source

Level3D: Add info button with scene stats

trethaller 6 years ago
parent
commit
a379620c91
3 changed files with 46 additions and 0 deletions
  1. 13 0
      bin/style.css
  2. 15 0
      bin/style.less
  3. 18 0
      hide/view/l3d/Level3D.hx

+ 13 - 0
bin/style.css

@@ -1631,3 +1631,16 @@ div.sp-container input:hover {
   left: 10px;
   bottom: 10px;
 }
+/* Level 3D */
+.overlay-info {
+  background: #000000e0;
+  position: absolute;
+  z-index: 1;
+  left: 0px;
+  bottom: 0px;
+  overflow-y: scroll;
+  overflow-x: hidden;
+  padding: 10px;
+  max-height: 800px;
+  min-width: 600px;
+}

+ 15 - 0
bin/style.less

@@ -1850,3 +1850,18 @@ div.sp-container {
 		}
 	}
 }
+
+
+/* Level 3D */
+.overlay-info {
+	background: #000000e0;
+	position: absolute;
+	z-index: 1;
+	left : 0px;
+	bottom : 0px;
+	overflow-y: scroll;
+	overflow-x: hidden;
+	padding: 10px;
+	max-height: 800px;
+    min-width: 600px;
+}

+ 18 - 0
hide/view/l3d/Level3D.hx

@@ -55,6 +55,8 @@ class CamController extends h3d.scene.CameraController {
 						var se = level3d.sceneEditor;
 						var fromPt = se.screenToWorld(pushX, pushY);
 						var toPt = se.screenToWorld(e.relX, e.relY);
+						if(fromPt == null || toPt == null)
+							return;
 						var delta = toPt.sub(fromPt).toVector();
 						delta.w = 0;
 						targetOffset = targetOffset.sub(delta);
@@ -394,6 +396,22 @@ class Level3D extends FileView {
 		tools.addToggle("th", "Show grid", function(v) { showGrid = v; updateGrid(); }, showGrid);
 		tools.addButton("sun-o", "Bake Lights", () -> bakeLights());
 		tools.addButton("map", "Bake Volumetric Lightmaps", () -> { bakeLights(); bakeVolumetricLightmaps(); });
+		tools.addButton("info-circle", "Scene information", () -> {
+			var memStats = scene.engine.mem.stats();
+			var texs = @:privateAccess scene.engine.mem.textures;
+			var list = [for(t in texs) {
+				n: '${t.width}x${t.height}  ${t.format}  ${t.name}',
+				size: t.width * t.height
+			}];
+			list.sort((a, b) -> Reflect.compare(b.size, a.size));
+			var content = new Element('<div tabindex="1" class="overlay-info"><h2>Scene info</h2><pre></pre></div>');
+			new Element(element[0].ownerDocument.body).append(content);
+			var pre = content.find("pre");
+			pre.text([for(l in list) l.n].join("\n"));
+			content.blur(function(_) {
+				content.remove();
+			});
+		});
 
 		tools.addColor("Background color", function(v) {
 			scene.engine.backgroundColor = v;