searchChildInFrustum method
void
searchChildInFrustum(
- Frustum frustum,
- Object3D object
Implementation
void searchChildInFrustum(Frustum frustum, Object3D object ) {
if ( object is Mesh || object is Line || object is Points ) {
if ( object is InstancedMesh ) {
instances[ object.uuid ] = [];
for (int instanceId = 0; instanceId < (object.count ?? 0); instanceId ++ ) {
object.getMatrixAt( instanceId, _matrix );
_matrix.decompose( _center, _quaternion, _scale );
_center.applyMatrix4( object.matrixWorld );
if ( frustum.containsPoint( _center ) ) {
instances[ object.uuid ].add( instanceId );
}
}
}
else {
if ( object.geometry?.boundingSphere == null ) object.geometry?.computeBoundingSphere();
_center.setFrom( object.geometry!.boundingSphere!.center );
_center.applyMatrix4( object.matrixWorld );
if ( frustum.containsPoint( _center ) ) {
collection.add( object );
}
}
}
if ( object.children.isNotEmpty ) {
for (int x = 0; x < object.children.length; x ++ ) {
searchChildInFrustum( frustum, object.children[ x ] );
}
}
}