Created
April 10, 2017 20:34
-
-
Save msfeldstein/efbb62fd279b11830e1ccbc78c3c93ac to your computer and use it in GitHub Desktop.
Log three instances
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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