Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions src/core/Object3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,17 @@ class Object3D extends EventDispatcher {
*/
raycast( /* raycaster, intersects */ ) {}

/**
* Abstract method to test whether this 3D object intersects the given frustum.
* Renderable 3D objects such as {@link Mesh}, {@link Line} or {@link Points}
* implement this method in order to use frustum culling.
*
* @abstract
* @param {Frustum|FrustumArray} frustum - The frustum to test.
* @return {boolean|undefined} Whether this 3D object intersects the given frustum or not.
*/
intersectsFrustum( /* frustum */ ) {}

/**
* Executes the callback on this 3D object and all descendants.
*
Expand Down
4 changes: 2 additions & 2 deletions src/math/Matrix4.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class Matrix4 {
}

/**
* Extracts the basis of this matrix into the three axis vectors provided.
* Extracts the basis vectors of this matrix into the three vectors provided.
*
* @param {Vector3} xAxis - The basis's x axis.
* @param {Vector3} yAxis - The basis's y axis.
Expand Down Expand Up @@ -788,7 +788,7 @@ class Matrix4 {
}

/**
* Multiplies the columns of this matrix by the given vector.
* Scales each of the first three columns of this matrix by the corresponding component of the given vector.
*
* @param {Vector3} v - The scale vector.
* @return {Matrix4} A reference to this matrix.
Expand Down
12 changes: 12 additions & 0 deletions src/objects/Line.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@ class Line extends Object3D {

}

/**
* Returns `true` if this line intersects the given frustum.
*
* @param {Frustum|FrustumArray} frustum - The frustum to test.
* @return {boolean} Whether this line intersects the given frustum or not.
*/
intersectsFrustum( frustum ) {

return frustum.intersectsObject( this );

}

/**
* Computes intersection points between a casted ray and this line.
*
Expand Down
12 changes: 12 additions & 0 deletions src/objects/Mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,18 @@ class Mesh extends Object3D {

}

/**
* Returns `true` if this mesh intersects the given frustum.
*
* @param {Frustum|FrustumArray} frustum - The frustum to test.
* @return {boolean} Whether this mesh intersects the given frustum or not.
*/
intersectsFrustum( frustum ) {

return frustum.intersectsObject( this );

}

/**
* Computes intersection points between a casted ray and this line.
*
Expand Down
12 changes: 12 additions & 0 deletions src/objects/Points.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ class Points extends Object3D {

}

/**
* Returns `true` if this point cloud intersects the given frustum.
*
* @param {Frustum|FrustumArray} frustum - The frustum to test.
* @return {boolean} Whether this point cloud intersects the given frustum or not.
*/
intersectsFrustum( frustum ) {

return frustum.intersectsObject( this );

}

/**
* Computes intersection points between a casted ray and this point cloud.
*
Expand Down
12 changes: 12 additions & 0 deletions src/objects/Sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ class Sprite extends Object3D {

}

/**
* Returns `true` if this sprite intersects the given frustum.
*
* @param {Frustum|FrustumArray} frustum - The frustum to test.
* @return {boolean} Whether this sprite intersects the given frustum or not.
*/
intersectsFrustum( frustum ) {

return frustum.intersectsSprite( this );

}

/**
* Computes intersection points between a casted ray and this sprite.
*
Expand Down
4 changes: 2 additions & 2 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ class WebGLRenderer {

} else if ( object.isSprite ) {

if ( ! object.frustumCulled || _frustum.intersectsSprite( object ) ) {
if ( ! object.frustumCulled || object.intersectsFrustum( _frustum ) ) {

if ( sortObjects ) {

Expand All @@ -1890,7 +1890,7 @@ class WebGLRenderer {

} else if ( object.isMesh || object.isLine || object.isPoints ) {

if ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) {
if ( ! object.frustumCulled || object.intersectsFrustum( _frustum ) ) {

const geometry = objects.update( object );
const material = object.material;
Expand Down
4 changes: 2 additions & 2 deletions src/renderers/common/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3159,7 +3159,7 @@ class Renderer {

const frustum = camera.isArrayCamera ? _frustumArray : _frustum;

if ( ! object.frustumCulled || frustum.intersectsSprite( object ) ) {
if ( ! object.frustumCulled || object.intersectsFrustum( frustum ) ) {

if ( this.sortObjects === true ) {

Expand All @@ -3185,7 +3185,7 @@ class Renderer {

const frustum = camera.isArrayCamera ? _frustumArray : _frustum;

if ( ! object.frustumCulled || frustum.intersectsObject( object ) ) {
if ( ! object.frustumCulled || object.intersectsFrustum( frustum ) ) {

const { geometry, material } = object;

Expand Down
2 changes: 1 addition & 1 deletion src/renderers/webgl/WebGLShadowMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ function WebGLShadowMap( renderer, objects, capabilities ) {

if ( visible && ( object.isMesh || object.isLine || object.isPoints ) ) {

if ( ( object.castShadow || ( object.receiveShadow && type === VSMShadowMap ) ) && ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) ) {
if ( ( object.castShadow || ( object.receiveShadow && type === VSMShadowMap ) ) && ( ! object.frustumCulled || object.intersectsFrustum( _frustum ) ) ) {

object.modelViewMatrix.multiplyMatrices( shadowCamera.matrixWorldInverse, object.matrixWorld );

Expand Down
Loading