Socket
Socket
Sign inDemoInstall

frustum-intersects

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    frustum-intersects

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


Version published
Weekly downloads
934
decreased by-18.64%
Maintainers
1
Install size
9.78 kB
Created
Weekly downloads
 

Readme

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

Last updated on 29 Jan 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc