Skip to content

Commit 2062b62

Browse files
committed
Fixed divide by zero error in Camera projection
1 parent e224faa commit 2062b62

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

v3/src/camera/Camera3D.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ var Camera3D = new Class({
150150
// Transform into clip space
151151
tmpVec4.transformMat4(this.combined);
152152

153+
// Avoid divide by zero when 0x0x0 camera projects to a 0x0x0 vec3
154+
if (tmpVec4.w === 0)
155+
{
156+
tmpVec4.w = 1;
157+
}
158+
153159
// Now into NDC
154160
tmpVec4.x = tmpVec4.x / tmpVec4.w;
155161
tmpVec4.y = tmpVec4.y / tmpVec4.w;

0 commit comments

Comments
 (0)