Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

frustum-intersects

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

frustum-intersects

Determines if camera's frustum intersects with aabb box and sphere

  • 0.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
increased by2586.16%
Maintainers
1
Weekly downloads
 
Created
Source

Frustum-Intersects

NPM Version CircleCI

A zero-dependency lib extracted from THREE.js to determine if camera's frustum intersects with given box or sphere.

Usage

npm

npm i frustum-intersects --save
import { intersectsBox, intersectsSphere } from 'frustum-intersects';

const ret = intersectsBox([
            1, 0, 0, 0,
            0, 1, 0, 0,
            0, 0, 1, 0,
            0, 0, 0, 1],
           [[-1,-1,-1], [1,1,1]]);

const ret2 = intersectsSphere([
            1, 0, 0, 0,
            0, 1, 0, 0,
            0, 0, 1, 0,
            0, 0, 0, 1],
           [[0, 0, 0], 1]);

Browser

<script src="https://cdn.jsdelivr.net/npm/frustum-intersects/dist/frustum-intersects.js"></script>

<script>
const ret = frustum.intersectsBox(matrix, box);
</script>

API

intersectsBox(matrix, box, mask)

  • matrix camera's 4x4 projection view matrix array, compatible with gl-matrix
  • box the aabb box, [[minx, miny, minz], [maxx, maxy, maxz]]
  • mask A 6 chars string mask (e.g. "111111") of frustum planes, plane with mask of 0 will always return true

intersectsSphere(matrix, sphere, mask)

  • matrix camera's 4x4 projection view matrix array, compatible with gl-matrix
  • sphere sphere, [[centerx, centery, centerz], radius]
  • mask A 6 chars string mask (e.g. "111111") of frustum planes, plane with mask of 0 will always return true

the planes' order of mask is {right}{left}{bottom}{top}{z-far}{z-near},

Keywords

FAQs

Package last updated on 25 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc