diff --git a/src/gfx.ts b/src/gfx.ts index 512815c7c..770f0c795 100644 --- a/src/gfx.ts +++ b/src/gfx.ts @@ -9,7 +9,6 @@ import { isVec3, isColor, isMat4, - testRectRect, } from "./math"; import { @@ -480,20 +479,11 @@ function gfxInit(gl: WebGLRenderingContext, gopt: GfxOpt): Gfx { flush(); } - const objBound = { p1: vec2(Number.MAX_VALUE), p2: vec2(-Number.MAX_VALUE)}; - const screenBound = { p1: vec2(-1), p2: vec2(1) }; - for (const v of verts) { - // WebGL screen space coordinate [-1.0 ~ 1.0] + // normalized world space coordinate [-1.0 ~ 1.0] const pt = toNDC(gfx.transform.multVec2(v.pos.xy())); - // get the bounding rectangle for the polygon - objBound.p1.x = Math.min(objBound.p1.x, pt.x); - objBound.p2.x = Math.max(objBound.p2.x, pt.x); - objBound.p1.y = Math.min(objBound.p1.y, pt.y); - objBound.p2.y = Math.max(objBound.p2.y, pt.y); - gfx.vqueue.push( pt.x, pt.y, v.pos.z, v.uv.x, v.uv.y, @@ -502,13 +492,6 @@ function gfxInit(gl: WebGLRenderingContext, gopt: GfxOpt): Gfx { } - // if the object bound is totally outside, we don't render - if (!testRectRect(objBound, screenBound)) { - const num = verts.length * STRIDE; - gfx.vqueue.splice(gfx.vqueue.length - num, num); - return; - } - for (const i of indices) { gfx.iqueue.push(i + gfx.vqueue.length / STRIDE - verts.length); }