Skip to content

Commit

Permalink
Performance improvement: don't need to re-compute bounding box for ev…
Browse files Browse the repository at this point in the history
…ery object on every frame
  • Loading branch information
brianchirls committed Aug 20, 2015
1 parent e8d1ae0 commit c800afb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build/vr.dev.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/vr.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/vr.js.map

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/vr-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ module.exports = (function () {
return scratchVector2.distanceTo(scratchVector1);
}

geometry.computeBoundingBox();
object.worldToLocal(scratchVector1);
return object.geometry.boundingBox.distanceToPoint(scratchVector1);
}
Expand Down Expand Up @@ -94,6 +93,10 @@ module.exports = (function () {
if (options.receiveShadow !== false) {
object.receiveShadow = true;
}

if (object.geometry) {
object.geometry.computeBoundingBox();
}
}

if (options.name !== undefined) {
Expand All @@ -103,7 +106,6 @@ module.exports = (function () {

if (allObjects.set) {
allObjects.set(object, this);
// allObjects.set(object.id, this);
} else {
allObjects[object.id] = this;
}
Expand Down

0 comments on commit c800afb

Please sign in to comment.