Skip to content

Instantly share code, notes, and snippets.

@msfeldstein
Created April 10, 2017 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msfeldstein/efbb62fd279b11830e1ccbc78c3c93ac to your computer and use it in GitHub Desktop.
Save msfeldstein/efbb62fd279b11830e1ccbc78c3c93ac to your computer and use it in GitHub Desktop.
Log three instances
function logThreeInstances(className) {
threeTypeMap[className] = 0;
const orig = THREE[className];
const tmp = function() {};
tmp.prototype = THREE[className].prototype;
function newConstructor() {
orig.apply(this, arguments)
threeTypeMap[className]++;
}
newConstructor.prototype = new tmp();
newConstructor.prototype.constructor = newConstructor;
THREE[className] = newConstructor;
}
function printInstanceLogs() {
requestAnimationFrame(printInstanceLogs)
for (var key in threeTypeMap) {
if (THREE.LOG)
console.log(key, ":", threeTypeMap[key])
threeTypeMap[key] = 0;
}
}
printInstanceLogs()
logThreeInstances("Vector3");
logThreeInstances("Vector2");
logThreeInstances("Quaternion");
logThreeInstances("Matrix4");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment