Frustum.set() is a method in the Three.js library that allows users to define the parameters of a frustum, or the portion of space in 3D that is visible on a 3D screen. This method takes in six parameters: left, right, bottom, top, near, and far, which are used to set the properties of the frustum.
set(left: Number, right: Number, bottom: Number, top: Number, near: Number, far: Number): void
left
- The value of the left plane in the frustum. This value specifies the position of the frustum's left plane in relation to the origin and controls the horizontal view frustum.right
- The value of the right plane in the frustum. This value specifies the position of the frustum's right plane in relation to the origin and controls the horizontal view frustum.bottom
- The value of the bottom plane in the frustum. This value specifies the position of the frustum's bottom plane in relation to the origin and controls the vertical view frustum.top
- The value of the top plane in the frustum. This value specifies the position of the frustum's top plane in relation to the origin and controls the vertical view frustum.near
- The value of the near plane in the frustum. This value specifies the distance between the origin and the frustum's near plane, which controls how close objects can be before they are no longer visible.far
- The value of the far plane in the frustum. This value specifies the distance between the origin and the frustum's far plane, which controls how far away objects can be before they are no longer visible.This method does not return any value.
const frustum = new THREE.Frustum();
const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
// Set the properties of the frustum
frustum.set(-1, 1, -1, 1, camera.near, camera.far);
// Use the frustum to test if an object is inside the camera's view
if (frustum.intersectsObject(object)) {
// Do something
}
In this example, we create a new frustum object and a perspective camera. We then use the set() method to define the properties of the frustum based on the camera's near and far values. Finally, we use the intersectsObject() method to check if an object is inside the frustum and do something with it if it is.