|
@@ -253,11 +253,13 @@ export class TilesRenderer extends TilesRendererBase {
|
|
|
|
|
|
info.invScale = invScale;
|
|
info.invScale = invScale;
|
|
|
|
|
|
|
|
+ // get frustum in grop root frame
|
|
tempMat.copy( group.matrixWorld );
|
|
tempMat.copy( group.matrixWorld );
|
|
tempMat.premultiply( camera.matrixWorldInverse );
|
|
tempMat.premultiply( camera.matrixWorldInverse );
|
|
tempMat.premultiply( camera.projectionMatrix );
|
|
tempMat.premultiply( camera.projectionMatrix );
|
|
frustum.setFromProjectionMatrix( tempMat );
|
|
frustum.setFromProjectionMatrix( tempMat );
|
|
|
|
|
|
|
|
+ // get transform position in group root frame
|
|
position.set( 0, 0, 0 );
|
|
position.set( 0, 0, 0 );
|
|
position.applyMatrix4( camera.matrixWorld );
|
|
position.applyMatrix4( camera.matrixWorld );
|
|
position.applyMatrix4( tempMat2 );
|
|
position.applyMatrix4( tempMat2 );
|
|
@@ -364,6 +366,7 @@ export class TilesRenderer extends TilesRendererBase {
|
|
loadIndex: 0,
|
|
loadIndex: 0,
|
|
transform,
|
|
transform,
|
|
active: false,
|
|
active: false,
|
|
|
|
+ inFrustum: [],
|
|
|
|
|
|
box,
|
|
box,
|
|
boxTransform,
|
|
boxTransform,
|
|
@@ -597,6 +600,7 @@ export class TilesRenderer extends TilesRendererBase {
|
|
}
|
|
}
|
|
|
|
|
|
const cached = tile.cached;
|
|
const cached = tile.cached;
|
|
|
|
+ const inFrustum = cached.inFrustum;
|
|
const cameras = this.cameras;
|
|
const cameras = this.cameras;
|
|
const cameraInfo = this.cameraInfo;
|
|
const cameraInfo = this.cameraInfo;
|
|
|
|
|
|
@@ -611,10 +615,13 @@ export class TilesRenderer extends TilesRendererBase {
|
|
let minDistance = Infinity;
|
|
let minDistance = Infinity;
|
|
for ( let i = 0, l = cameras.length; i < l; i ++ ) {
|
|
for ( let i = 0, l = cameras.length; i < l; i ++ ) {
|
|
|
|
|
|
- // TODO: move this logic (and the distance scale extraction) into the update preprocess step
|
|
|
|
|
|
+ if ( ! inFrustum[ i ] ) {
|
|
|
|
+
|
|
|
|
+ continue;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
// transform camera position into local frame of the tile bounding box
|
|
// transform camera position into local frame of the tile bounding box
|
|
- // TODO: this should be the cameras world position
|
|
|
|
const camera = cameras[ i ];
|
|
const camera = cameras[ i ];
|
|
const info = cameraInfo[ i ];
|
|
const info = cameraInfo[ i ];
|
|
const invScale = info.invScale;
|
|
const invScale = info.invScale;
|
|
@@ -669,22 +676,32 @@ export class TilesRenderer extends TilesRendererBase {
|
|
// cache the root-space planes
|
|
// cache the root-space planes
|
|
// Use separating axis theorem for frustum and obb
|
|
// Use separating axis theorem for frustum and obb
|
|
|
|
|
|
- const sphere = tile.cached.sphere;
|
|
|
|
|
|
+ const cached = tile.cached;
|
|
|
|
+ const sphere = cached.sphere;
|
|
|
|
+ const inFrustum = cached.inFrustum;
|
|
if ( sphere ) {
|
|
if ( sphere ) {
|
|
|
|
|
|
const cameraInfo = this.cameraInfo;
|
|
const cameraInfo = this.cameraInfo;
|
|
|
|
+ let inView = false;
|
|
for ( let i = 0, l = cameraInfo.length; i < l; i ++ ) {
|
|
for ( let i = 0, l = cameraInfo.length; i < l; i ++ ) {
|
|
|
|
|
|
|
|
+ // Track which camera frustums this tile is in so we can use it
|
|
|
|
+ // to ignore the error calculations for cameras that can't see it
|
|
const frustum = cameraInfo[ i ].frustum;
|
|
const frustum = cameraInfo[ i ].frustum;
|
|
if ( frustum.intersectsSphere( sphere ) ) {
|
|
if ( frustum.intersectsSphere( sphere ) ) {
|
|
|
|
|
|
- return true;
|
|
|
|
|
|
+ inView = true;
|
|
|
|
+ inFrustum[ i ] = true;
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ inFrustum[ i ] = false;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- return false;
|
|
|
|
|
|
+ return inView;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|