3DTilesRendererJS icon indicating copy to clipboard operation
3DTilesRendererJS copied to clipboard

tile.__distanceFromCamera is generally Infinity? and tile.__error can be NaN if distance is 0

Open dbuck opened this issue 6 months ago • 4 comments

Description

I was using this as an extra point in the prioritizing, while debugging an issue I'd been seeing I'm noticing that all my tiles have tile.__distanceFromCamera: Infinity

Additionally, if you are inside of a tile, the distance returns 0, it's a divide by 0, ending up with a NaN.

This one comes up a LOT for us, as we're walking inside a tileset, rather than the normal looking down at the earth cases.

Reproduction steps

DistanceFromCamera: Infinity

  1. open: https://nasa-ammos.github.io/3DTilesRendererJS/example/bundle/index.html
  2. open console
  3. [...window.tiles.activeTiles].map(t => t.__distanceFromCamera)

tile.__error: NaN:

  1. open: https://nasa-ammos.github.io/3DTilesRendererJS/example/bundle/index.html
  2. place the camera inside a tile
  3. open console
  4. [...window.tiles.activeTiles].map(t => t.__error)

Image

Code

// code goes here

Live example

Screenshots & Tile Set

No response

Library Version

master

Three.js Version

176

dbuck avatar Jun 17 '25 20:06 dbuck

all my tiles have tile.__distanceFromCamera: Infinity

Do you have a repro of this? I'm seeing that tiles outside the frustum have a "distanceToCamera" of Infinity but are otherwise set correctly. We could change this to always set the distance, though.

Additionally, if you are inside of a tile, the distance returns 0, it's a divide by 0, ending up with a NaN.

Yeah this should be fixed. We can set the error to "Infinity" if the distance is set to 0.

gkjohnson avatar Jun 18 '25 00:06 gkjohnson

Hmm, I didn't do anything odd to repro, I saw it in the demo index.html linked above, just zoomed in slightly.

I'll take a closer look in the morning.

dbuck avatar Jun 18 '25 00:06 dbuck

using: https://nasa-ammos.github.io/3DTilesRendererJS/example/bundle/index.html

Image

DISTANCE colorMode is also always white

dbuck avatar Jun 18 '25 14:06 dbuck

Thanks - looks like this was a variable name that got changed in one place and not the other. Fixed in https://github.com/NASA-AMMOS/3DTilesRendererJS/commit/a0be772f1e526242b98b7267167b9a01819daf19.

gkjohnson avatar Jun 18 '25 14:06 gkjohnson