Skip to content

Commit

Permalink
fix (3dtiles): fix SSE computation
Browse files Browse the repository at this point in the history
Use distance to bounding volume instead of distance to center of the bounding volume
Issue: #185
  • Loading branch information
NikoSaul authored and autra committed Aug 29, 2017
1 parent e671403 commit e8ce7b7
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/Process/3dTilesProcessing.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as THREE from 'three';

function requestNewTile(view, scheduler, geometryLayer, metadata, parent) {
const command = {
/* mandatory */
Expand Down Expand Up @@ -97,23 +95,27 @@ export function pre3dTilesUpdate(context, layer) {
// Improved zoom geometry
function computeNodeSSE(camera, node) {
if (node.boundingVolume.region) {
const worldCoordinateCenter = new THREE.Vector3();
worldCoordinateCenter.applyMatrix4(node.boundingVolume.region.matrixWorld);
const distance = camera.camera3D.position.distanceTo(worldCoordinateCenter);
const cameraLocalPosition = camera.camera3D.position.clone();
cameraLocalPosition.x -= node.boundingVolume.region.matrixWorld.elements[12];
cameraLocalPosition.y -= node.boundingVolume.region.matrixWorld.elements[13];
cameraLocalPosition.z -= node.boundingVolume.region.matrixWorld.elements[14];
const distance = node.boundingVolume.region.box3D.distanceToPoint(cameraLocalPosition);
return preSSE * (node.geometricError / distance);
}
if (node.boundingVolume.box) {
// TODO: compute proper distance
const worldCoordinateCenter = node.boundingVolume.box.getCenter();
worldCoordinateCenter.applyMatrix4(node.matrixWorld);
const distance = camera.camera3D.position.distanceTo(worldCoordinateCenter);
const cameraLocalPosition = camera.camera3D.position.clone();
cameraLocalPosition.x -= node.matrixWorld.elements[12];
cameraLocalPosition.y -= node.matrixWorld.elements[13];
cameraLocalPosition.z -= node.matrixWorld.elements[14];
const distance = node.boundingVolume.box.distanceToPoint(cameraLocalPosition);
return preSSE * (node.geometricError / distance);
} else if (node.boundingVolume.sphere) {
const worldCoordinateCenter = node.boundingVolume.sphere.center.clone();
worldCoordinateCenter.applyMatrix4(node.matrixWorld);
const distance = Math.max(
0.0,
camera.camera3D.position.distanceTo(worldCoordinateCenter) - node.boundingVolume.sphere.radius);
}
if (node.boundingVolume.sphere) {
const cameraLocalPosition = camera.camera3D.position.clone();
cameraLocalPosition.x -= node.matrixWorld.elements[12];
cameraLocalPosition.y -= node.matrixWorld.elements[13];
cameraLocalPosition.z -= node.matrixWorld.elements[14];
const distance = node.boundingVolume.sphere.distanceToPoint(cameraLocalPosition);
return preSSE * (node.geometricError / distance);
}
return Infinity;
Expand Down Expand Up @@ -177,6 +179,5 @@ export function process3dTilesNode(cullingTest, subdivisionTest) {

export function $3dTilesSubdivisionControl(context, layer, node) {
const sse = computeNodeSSE(context.camera, node);

return sse > 1.0;
}

0 comments on commit e8ce7b7

Please sign in to comment.