Tweaking FPS meter

0.1
Rob Hawkes 2013-11-01 11:50:49 +00:00
rodzic 6f93d4120d
commit b22d98ac0d
4 zmienionych plików z 21 dodań i 14 usunięć

Wyświetl plik

@ -23,6 +23,8 @@
}; };
VIZI.Loop.prototype.tick = function() { VIZI.Loop.prototype.tick = function() {
this.publish("fpsTickStart", "Main Loop");
this.publish("update"); this.publish("update");
this.publish("render"); this.publish("render");
@ -31,5 +33,7 @@
// http://stackoverflow.com/questions/6065169/requestanimationframe-with-this-keyword // http://stackoverflow.com/questions/6065169/requestanimationframe-with-this-keyword
window.requestAnimationFrame( this.tick.bind(this) ); window.requestAnimationFrame( this.tick.bind(this) );
} }
this.publish("fpsTickEnd", "Main Loop");
}; };
}()); }());

Wyświetl plik

@ -28,12 +28,18 @@
return container; return container;
}; };
VIZI.FPS.prototype.createDOMElement = function(name) { VIZI.FPS.prototype.createDOMElement = function() {
VIZI.Log("Creating FPS meter DOM element"); VIZI.Log("Creating FPS meter DOM element");
var element = document.createElement("div"); var element = document.createElement("div");
element.style.float = "left"; element.style.float = "left";
this.domContainer.appendChild(element);
return element;
};
VIZI.FPS.prototype.createDOMTitle = function(name) {
var title = document.createElement("p"); var title = document.createElement("p");
// Style copied from FPSMeter // Style copied from FPSMeter
@ -41,18 +47,14 @@
title.style.fontFamily = "sans-serif"; title.style.fontFamily = "sans-serif";
title.style.fontSize = "10px"; title.style.fontSize = "10px";
title.style.fontWeight = "bold"; title.style.fontWeight = "bold";
title.style.margin = "5px 5px 0 5px"; title.style.margin = "0 5px 5px 5px";
title.style.textAlign = "left"; title.style.textAlign = "left";
title.style.textTransform = "uppercase"; title.style.textTransform = "uppercase";
title.innerHTML = name; title.innerHTML = name;
element.appendChild(title); return title;
};
this.domContainer.appendChild(element);
return element;
};
VIZI.FPS.prototype.createMeter = function(name) { VIZI.FPS.prototype.createMeter = function(name) {
VIZI.Log("Creating FPS meter: " + name); VIZI.Log("Creating FPS meter: " + name);
@ -71,6 +73,8 @@
margin: "5px 0 5px 5px" margin: "5px 0 5px 5px"
}); });
domElement.appendChild(this.createDOMTitle(name));
this.meters[name] = meter; this.meters[name] = meter;
return meter; return meter;

Wyświetl plik

@ -7,11 +7,11 @@
_.extend(this, VIZI.Mediator); _.extend(this, VIZI.Mediator);
this.cameraRadius = 6000; this.cameraRadius = 4100;
this.theta = 45; // Horizontal orbit this.theta = 45; // Horizontal orbit
this.onMouseDownTheta = 45; this.onMouseDownTheta = 45;
this.phi = 60; // Vertical oribt this.phi = 80; // Vertical oribt
this.onMouseDownPhi = 60; this.onMouseDownPhi = 80;
this.target = new THREE.Object3D(); this.target = new THREE.Object3D();
@ -20,7 +20,7 @@
this.lookAtTarget(); this.lookAtTarget();
this.publish("addToScene", this.camera); this.publish("addToScene", this.camera);
this.publish("addToDat", this, {name: "Camera", properties: ["theta", "phi", "lookAtTarget", "updatePosition"]}); this.publish("addToDat", this, {name: "Camera", properties: ["cameraRadius", "theta", "phi", "lookAtTarget", "updatePosition"]});
this.subscribe("resize", this.resize); this.subscribe("resize", this.resize);
}; };
@ -72,5 +72,6 @@
VIZI.Camera.prototype.datChange = function() { VIZI.Camera.prototype.datChange = function() {
this.updatePosition(); this.updatePosition();
this.lookAtTarget();
}; };
}()); }());

Wyświetl plik

@ -42,10 +42,8 @@
VIZI.Renderer.prototype.render = function() { VIZI.Renderer.prototype.render = function() {
this.publish("fpsTickStart", "render"); this.publish("fpsTickStart", "render");
this.publish("fpsTickStart", "render2");
this.renderer.render( this.scene, this.camera ); this.renderer.render( this.scene, this.camera );
this.publish("fpsTickEnd", "render"); this.publish("fpsTickEnd", "render");
this.publish("fpsTickEnd", "render2");
}; };
VIZI.Renderer.prototype.resize = function() { VIZI.Renderer.prototype.resize = function() {