Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
fix frustum culling calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
AidanCaruso committed Jun 19, 2024
1 parent abe0e11 commit 873b722
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/spatial/src/transform/systems/TransformSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export const getDistanceSquaredFromTarget = (entity: Entity, targetPosition: Vec
}

const _frustum = new Frustum()
const _worldPos = new Vector3()
const _projScreenMatrix = new Matrix4()

const transformDepths = new Map<Entity, number>()
Expand Down Expand Up @@ -209,7 +210,7 @@ const execute = () => {
)?.box
const cull = boundingBox
? _frustum.intersectsBox(boundingBox)
: _frustum.containsPoint(getComponent(entity, TransformComponent).position)
: _frustum.containsPoint(TransformComponent.getWorldPosition(entity, _worldPos))
FrustumCullCameraComponent.isCulled[entity] = cull ? 0 : 1
}
}
Expand Down

0 comments on commit 873b722

Please sign in to comment.