Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(3dtiles): apply matrixWorld to boundingVolume.box #788

Merged
merged 1 commit into from
Jul 9, 2018

Conversation

peppsac
Copy link
Contributor

@peppsac peppsac commented Jun 25, 2018

Before this commit we only used the translation part of the transform.
We're now using the full 4x4 matrix to match the wording of the 3dtiles
specification:

The transform property applies to [...] tile.boundingVolume , except
when tile.boundingVolume.region is defined

@peppsac peppsac force-pushed the fix_3dtiles_boundingvolume branch from e8805b9 to ab5d42e Compare June 26, 2018 15:43
@peppsac
Copy link
Contributor Author

peppsac commented Jun 26, 2018

Updated with some unittest. Note that something is broken with the distance computation when using region but I couldn't fix it.

@gchoqueux
Copy link
Contributor

Updated with some unittest. Note that something is broken with the distance computation when using region but I couldn't fix it.

an issue should be opened to specify the problem

@peppsac
Copy link
Contributor Author

peppsac commented Jun 27, 2018

an issue should be opened to specify the problem

I've added 2 unit tests that need to be fixed. That's visible everytime a developer runs the tests so it's good enough:

50 passing (93ms)
2 pending

@gchoqueux gchoqueux self-requested a review June 28, 2018 10:05
Copy link
Contributor

@gchoqueux gchoqueux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this bug statement is clearly not visible, the best location for declaring and looking for bugs is the issues

@peppsac
Copy link
Contributor Author

peppsac commented Jun 29, 2018

this bug statement is clearly not visible, the best location for declaring and looking for bugs is the issues

Done: #796

@peppsac
Copy link
Contributor Author

peppsac commented Jul 2, 2018

@gchoqueux anything else bothering you on this PR or can we move forward and merge it?

function computeNodeSSE(camera, node) {
const boundingVolumeBox = new THREE.Box3();
const boundingVolumeSphere = new THREE.Sphere();
export function computeNodeSSE(camera, node) {
node.distance = 0;
if (node.boundingVolume.region) {
worldPosition.setFromMatrixPosition(node.boundingVolume.region.matrixWorld);
Copy link
Contributor

@gchoqueux gchoqueux Jul 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test works with

    if (node.boundingVolume.region) {
        boundingVolumeBox.copy(node.boundingVolume.region.box3D);
        boundingVolumeBox.applyMatrix4(node.boundingVolume.region.matrixWorld);
        node.distance = boundingVolumeBox.distanceToPoint(camera.camera3D.position);
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed and pushed. Thanks

boundingVolumeSphere.copy(node.boundingVolume.sphere);
boundingVolumeSphere.applyMatrix4(node.matrixWorld);
node.distance = Math.max(0.0,
boundingVolumeSphere.distanceToPoint(camera.camera3D.position));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relying on camera.camera3D.position assumes that the camera's matrix is equal to its matrixWorld (as when the camera is a direct child of the scene). I would rather not have this assumption but if we have, let's write it somewhere.

To be conservative, but correct, I think you should apply node.matrixWorld * camera.matrixWorldInverse instead and measure the distance to the origin.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. As there are other places that make the same assumption I suggest to not fix this in this PR.

I can add a // TODO to not forget about this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would seem wise:

  • to create an issue, to specify the problem and indicate where are the other places that make the same assumption (because apparently, this can be a source of bugs)
  • apply the solution here and propose it also in the same issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apply the solution here and propose it also in the same issue

It's not free performance-wise so I won't sneak this small change in an unrelated PR.

I've opened the following issue to not forget about it: #800

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add a // TODO to not forget about this?

just add the TODO

@peppsac peppsac force-pushed the fix_3dtiles_boundingvolume branch from 60bfc5a to e6986d8 Compare July 9, 2018 08:35
@peppsac
Copy link
Contributor Author

peppsac commented Jul 9, 2018

Squashed and ready to merge.

boundingVolumeSphere.copy(node.boundingVolume.sphere);
boundingVolumeSphere.applyMatrix4(node.matrixWorld);
node.distance = Math.max(0.0,
boundingVolumeSphere.distanceToPoint(camera.camera3D.position));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add a // TODO to not forget about this?

just add the TODO

Before this commit we only used the translation part of the transform.
We're now using the full 4x4 matrix to match the wording of the 3dtiles
specification:
"The transform property applies to [...] tile.boundingVolume , except
when tile.boundingVolume.region is defined"
@peppsac peppsac force-pushed the fix_3dtiles_boundingvolume branch from e6986d8 to e845505 Compare July 9, 2018 16:08
@peppsac peppsac merged commit 7ae39eb into master Jul 9, 2018
@peppsac peppsac deleted the fix_3dtiles_boundingvolume branch July 9, 2018 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants