Skip to content
This repository was archived by the owner on Nov 12, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions src/gfx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
isVec3,
isColor,
isMat4,
testRectRect,
} from "./math";

import {
Expand Down Expand Up @@ -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,
Expand All @@ -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);
}
Expand Down