Skip to content

Commit

Permalink
Merge pull request #13 from oasis-engine/bug/fix-bounds-update
Browse files Browse the repository at this point in the history
fix bounds update
  • Loading branch information
eyworldwide authored Jan 28, 2021
2 parents 09893f3 + b925f92 commit 4446f63
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
3 changes: 3 additions & 0 deletions packages/core/src/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ export abstract class Renderer extends Component {
@ignoreClone
private _normalMatrix: Matrix = new Matrix();

/**
* The bounding volume of the renderer.
*/
get bounds(): BoundingBox {
const changeFlag = this._transformChangeFlag;
if (changeFlag.flag) {
Expand Down
13 changes: 9 additions & 4 deletions packages/core/src/geometry/GeometryRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@ export class GeometryRenderer extends Renderer {
* @override
*/
protected _updateBounds(worldBounds: BoundingBox): void {
const localBounds = this._geometry.bounds;
const worldMatrix = this._entity.transform.worldMatrix;

BoundingBox.transform(localBounds, worldMatrix, worldBounds);
const geometry = this._geometry;
if (geometry) {
const localBounds = geometry.bounds;
const worldMatrix = this._entity.transform.worldMatrix;
BoundingBox.transform(localBounds, worldMatrix, worldBounds);
} else {
worldBounds.min.setValue(0, 0, 0);
worldBounds.max.setValue(0, 0, 0);
}
}
}
2 changes: 1 addition & 1 deletion packages/core/src/particle/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { ParticleRenderer } from "./particleRenderer";
export { ParticleRenderer } from "./ParticleRenderer";

0 comments on commit 4446f63

Please sign in to comment.