UNPKG

ts-game-engine

Version:

Simple WebGL game/render engine written in TypeScript

24 lines (23 loc) 929 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Plane_1 = require("./Plane"); ; class Frustum { constructor() { this.planes = [new Plane_1.Plane(), new Plane_1.Plane(), new Plane_1.Plane(), new Plane_1.Plane(), new Plane_1.Plane(), new Plane_1.Plane()]; } get Planes() { return this.planes; } CheckBoundsIntersection(bounds) { let result = 0 /* Inside */; for (let p = 0; p < 6; p++) { const positive = bounds.GetPositiveVertexFromPlane(this.planes[p]); const negative = bounds.GetNegativeVertexFromPlane(this.planes[p]); if (this.planes[p].DistanceFromPoint(positive) < 0) return 1 /* Outside */; else if (this.planes[p].DistanceFromPoint(negative) < 0) result = 2 /* Intersect */; } return result; } } exports.Frustum = Frustum;