Avoid unnecessary allocations
Why Avoid Memory Allocations?
Best Practices for Avoiding Garbage Collection
function update() {
const direction = new Vector3().subVectors(target.position, camera.position);
// ...
}const direction = new Vector3(); // allocate once
function update() {
direction.subVectors(target.position, camera.position);
// ...
}Use Chrome DevTools to Monitor Allocations
Last updated